diff --git a/src/app/search-multiple/components/datasets/dataset-list.component.ts b/src/app/search-multiple/components/datasets/dataset-list.component.ts index 117dc47d5a3c95d14a01bc7d17eed18b546efe0c..406bc062a38803942ef73cea562663ca79805788 100644 --- a/src/app/search-multiple/components/datasets/dataset-list.component.ts +++ b/src/app/search-multiple/components/datasets/dataset-list.component.ts @@ -17,6 +17,10 @@ import { sortByDisplay } from '../../../shared/utils'; templateUrl: 'dataset-list.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search multiple dataset list component. + */ export class DatasetListComponent { @Input() projectList: Project[]; @Input() datasetFamilyList: Family[]; @@ -24,9 +28,11 @@ export class DatasetListComponent { @Input() selectedDatasets: string[]; @Output() updateSelectedDatasets: EventEmitter<string[]> = new EventEmitter(); - - // Return dataset families that contains datasets with cone search enabled - // Return dataset families are sorted by display + /** + * Returns dataset family list sorted by display, that contains datasets with cone search enabled. + * + * @return Family[] + */ getDatasetFamilyList(): Family[] { const familyId: number[] = []; this.datasetList.forEach(d => { @@ -39,16 +45,37 @@ export class DatasetListComponent { .sort(sortByDisplay); } + /** + * Returns dataset list that belongs to the given ID family. + * + * @param {number} familyId - The dataset family ID. + * + * @return Dataset[] + */ getDatasetsByFamily(familyId: number): Dataset[] { return this.datasetList.filter(d => d.id_dataset_family === familyId); } + /** + * Checks if all datasets that belongs to the given dataset family ID are selected. + * + * @param {number} familyId - The dataset family ID. + * + * @return boolean + */ getIsAllSelected(familyId: number): boolean { const datasetListName = this.getDatasetsByFamily(familyId).map(d => d.name); const filteredSelectedDatasets = this.selectedDatasets.filter(name => datasetListName.indexOf(name) > -1); return datasetListName.length === filteredSelectedDatasets.length; } + /** + * Checks if none of datasets that belongs to the given dataset family ID are selected. + * + * @param {number} familyId - The dataset family ID. + * + * @return boolean + */ getIsAllUnselected(familyId: number): boolean { const datasetListName = this.getDatasetsByFamily(familyId).map(d => d.name); const filteredSelectedDatasets = this.selectedDatasets.filter(name => datasetListName.indexOf(name) > -1); diff --git a/src/app/search-multiple/components/datasets/datasets-by-family.component.ts b/src/app/search-multiple/components/datasets/datasets-by-family.component.ts index f0619fe1867113f7342197b96fd274ceaf154b9e..49cd0c1b42255109a45bd0364d7effd1628bf43d 100644 --- a/src/app/search-multiple/components/datasets/datasets-by-family.component.ts +++ b/src/app/search-multiple/components/datasets/datasets-by-family.component.ts @@ -19,6 +19,10 @@ import { sortByDisplay } from '../../../shared/utils'; changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }) +/** + * @class + * @classdesc Search multiple datasets by family component. + */ export class DatasetsByFamilyComponent { @Input() datasetFamily: Family; @Input() projectList: Project[]; @@ -28,14 +32,31 @@ export class DatasetsByFamilyComponent { @Input() isAllUnselected: boolean; @Output() updateSelectedDatasets: EventEmitter<string[]> = new EventEmitter(); + /** + * Returns dataset list sorted by display. + * + * @return Dataset[] + */ getDatasetSortedByDisplay(): Dataset[] { return this.datasetList.sort(sortByDisplay); } + /** + * Checks if dataset is selected fot the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return boolean + */ isSelected(dname: string): boolean { return this.selectedDatasets.filter(i => i === dname).length > 0; } + /** + * Emits event to update dataset list selection with the given updated selected dataset name list. + * + * @param {string} dname - The dataset name. + */ toggleSelection(dname: string): void { const clonedSelectedDatasets = [...this.selectedDatasets]; const index = clonedSelectedDatasets.indexOf(dname); @@ -47,6 +68,9 @@ export class DatasetsByFamilyComponent { this.updateSelectedDatasets.emit(clonedSelectedDatasets); } + /** + * Emits event to update dataset list selection with all datasets names. + */ selectAll(): void { const clonedSelectedDatasets = [...this.selectedDatasets]; const datasetListName = this.datasetList.map(d => d.name); @@ -56,6 +80,9 @@ export class DatasetsByFamilyComponent { this.updateSelectedDatasets.emit(clonedSelectedDatasets); } + /** + * Emits event to update dataset list selection with no datasets names. + */ unselectAll(): void { const clonedSelectedDatasets = [...this.selectedDatasets]; const datasetListName = this.datasetList.map(d => d.name); @@ -66,6 +93,13 @@ export class DatasetsByFamilyComponent { this.updateSelectedDatasets.emit(clonedSelectedDatasets); } + /** + * Returns project description of the given project name. + * + * @param {string} projectName - The project name. + * + * @return string + */ getProjectDescription(projectName: string): string { return this.projectList.find(p => p.name === projectName).description; } diff --git a/src/app/search-multiple/components/progress-bar-multiple.component.ts b/src/app/search-multiple/components/progress-bar-multiple.component.ts index ada44c550e43557ff2fc00aff3e2c7165da7e9a6..1d3bd800b91b4c3e9fe56b581fb1b4ab67c40fa0 100644 --- a/src/app/search-multiple/components/progress-bar-multiple.component.ts +++ b/src/app/search-multiple/components/progress-bar-multiple.component.ts @@ -17,6 +17,10 @@ import { SearchMultipleQueryParams } from '../store/model'; styleUrls: ['progress-bar-multiple.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search multiple progress bar component. + */ export class ProgressBarMultipleComponent { @Input() currentStep: string; @Input() positionStepChecked: boolean; @@ -26,6 +30,11 @@ export class ProgressBarMultipleComponent { @Input() noSelectedDatasets: boolean; @Input() queryParams: SearchMultipleQueryParams; + /** + * Returns step class that match to the current step. + * + * @return string + */ getStepClass(): string { switch (this.currentStep) { case 'position': diff --git a/src/app/search-multiple/components/result/datasets-result.component.ts b/src/app/search-multiple/components/result/datasets-result.component.ts index 0e4f0f4aecc430c2724aafba9388f40dd172e917..e913ee0f87b940e3b7cb52556df30813cfdc4961 100644 --- a/src/app/search-multiple/components/result/datasets-result.component.ts +++ b/src/app/search-multiple/components/result/datasets-result.component.ts @@ -22,6 +22,10 @@ import { sortByDisplay } from '../../../shared/utils'; templateUrl: 'datasets-result.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search multiple result datasets component. + */ export class DatasetsResultComponent { @Input() datasetsCountIsLoaded: boolean; @Input() datasetFamilyList: Family[]; @@ -38,6 +42,11 @@ export class DatasetsResultComponent { @Output() retrieveData: EventEmitter<Pagination> = new EventEmitter(); @Output() updateSelectedData: EventEmitter<{ dname: string, data: (string | number)[] }[]> = new EventEmitter(); + /** + * Returns dataset list with result ordered by dataset family display and dataset display. + * + * @return Dataset[] + */ getOrderedDatasetWithResults(): Dataset[] { let datasets: Dataset[] = []; const sortedDatasetFamilyList: Family[] = [...this.datasetFamilyList].sort(sortByDisplay); @@ -55,14 +64,35 @@ export class DatasetsResultComponent { return datasets; } + /** + * Returns results number for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return number + */ getCount(dname: string): number { return this.datasetsCount.find(c => c.dname === dname).count; } + /** + * Checks if attribute list is loaded for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return boolean + */ attributeListIsLoaded(dname: string): boolean { return this.datasetsWithAttributeList.includes(dname) && this.allAttributeList[dname].isLoaded; } + /** + * Returns attribute list for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return Attribute[] + */ getDatasetAttributeList(dname: string): Attribute[] { if (this.attributeListIsLoaded(dname)) { return this.allAttributeList[dname].attributeList; @@ -70,6 +100,13 @@ export class DatasetsResultComponent { return []; } + /** + * Returns output list for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return number[] + */ getOutputList(dname: string): number[] { return this.getDatasetAttributeList(dname) .filter(attribute => attribute.selected && attribute.id_output_category) @@ -77,6 +114,13 @@ export class DatasetsResultComponent { .map(attribute => attribute.id); } + /** + * Returns data for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return any[] + */ getData(dname: string): any[] { if (this.datasetsWithData.includes(dname) && this.allData[dname].isLoaded) { return this.allData[dname].data; @@ -84,6 +128,13 @@ export class DatasetsResultComponent { return []; } + /** + * Returns selected data for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return (string | number)[] + */ getSelectedData(dname: string): (string | number)[] { // if (this.selectedData.find(d => d.dname === dname) === undefined) { return []; @@ -91,6 +142,14 @@ export class DatasetsResultComponent { // return this.selectedData.find(d => d.dname === dname).data; } + /** + * Adds data to selected data and emits updated data selection. + * + * @param {string} dname - The dataset name. + * @param {(string | number)} data - The data ID. + * + * @fires EventEmitter<{ dname: string, data: (string | number)[] }[]> + */ addSelectedData(dname: string, data: string | number): void { const selectedDataByDataset = this.selectedData.find(d => d.dname === dname); let updatedSelection: { dname: string, data: (string | number)[] }[]; @@ -102,6 +161,14 @@ export class DatasetsResultComponent { this.updateSelectedData.emit(updatedSelection); } + /** + * Remove data to selected data and emits updated data selection. + * + * @param {string} dname - The dataset name. + * @param {(string | number)} data - The data ID. + * + * @fires EventEmitter<{ dname: string, data: (string | number)[] }[]> + */ deleteSelectedData(dname: string, data: string | number): void { const selectedDataByDataset = this.selectedData.find(d => d.dname === dname); let updatedSelection: { dname: string, data: (string | number)[] }[]; @@ -116,6 +183,14 @@ export class DatasetsResultComponent { this.updateSelectedData.emit(updatedSelection); } + /** + * When accordion opens, emits retrieve metadata for the + * given dataset name if not already loaded and emits retrieve + * data for the given dataset name otherwise. + * + * @param {boolean} isOpen - If the accordion is open. + * @param {string} dname - The dataset name. + */ loadData(isOpen: boolean, dname: string) : void { if (isOpen && !this.datasetsWithAttributeList.includes(dname)) { this.retrieveMeta.emit(dname); @@ -126,6 +201,11 @@ export class DatasetsResultComponent { } } + /** + * Emits execute process event. + * + * @param {string} typeProcess - The process type. + */ executeProcess(typeProcess: string): void { // console.log('executeProcess: ' + typeProcess); } diff --git a/src/app/search-multiple/components/result/download-section.component.ts b/src/app/search-multiple/components/result/download-section.component.ts index 629215634da564ede46accda54a7cde82b342955..89b302c0b07c1ba8c9388e75f427e6eac60b9918 100644 --- a/src/app/search-multiple/components/result/download-section.component.ts +++ b/src/app/search-multiple/components/result/download-section.component.ts @@ -19,11 +19,22 @@ import { ConeSearch } from '../../../shared/cone-search/store/model'; styleUrls: ['download-section.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search multiple result download component. + */ export class DownloadSectionComponent { @Input() dataset: Dataset; @Input() coneSearch: ConeSearch; @Input() outputList: number[]; + /** + * Checks if configuration allowed downloading for the given format. + * + * @param {string} format - The format. + * + * @return boolean + */ getConfigDownloadResultFormat(format: string): boolean { if (this.dataset.config && this.dataset.config.download_results_format && this.dataset.config.download_results_format[format]) { return this.dataset.config.download_results_format[format]; @@ -31,6 +42,13 @@ export class DownloadSectionComponent { return false; } + /** + * Returns URL to download data in the given format. + * + * @param {string} format - The format. + * + * @return string + */ getUrl(format: string): string { let query: string = host() + '/search/' + this.dataset.name + '?a=' + this.outputList.join(';'); query += '&cs=' + this.coneSearch.ra + ':' + this.coneSearch.dec + ':' + this.coneSearch.radius; diff --git a/src/app/search-multiple/components/result/overview.component.ts b/src/app/search-multiple/components/result/overview.component.ts index d12c1d503a47733ff4d0cb8055fd2021c144fbc0..7caee682c98371e071262d997167c802c7001db0 100644 --- a/src/app/search-multiple/components/result/overview.component.ts +++ b/src/app/search-multiple/components/result/overview.component.ts @@ -18,8 +18,18 @@ import { sortByDisplay } from '../../../shared/utils'; selector: 'app-overview', templateUrl: 'overview.component.html' }) +/** + * @class + * @classdesc Search multiple result overview component. + */ export class OverviewComponent { - @Input() set datasetSearchMetaIsLoaded(datasetSearchMetaIsLoaded: boolean) { + /** + * Emits event to get dataset result number when dataset metadata is loaded. + * + * @param {boolean} datasetSearchMetaIsLoaded - Is dataset metadata loaded. + */ + @Input() + set datasetSearchMetaIsLoaded(datasetSearchMetaIsLoaded: boolean) { if (datasetSearchMetaIsLoaded) { this.getDatasetCount.emit(); } @@ -33,7 +43,11 @@ export class OverviewComponent { @Input() datasetsCount: DatasetCount[]; @Output() getDatasetCount: EventEmitter<null> = new EventEmitter(); - + /** + * Returns total amount of results for all datasets. + * + * @return number + */ getTotalObject(): number { let total: number = 0; this.datasetsCount @@ -42,12 +56,20 @@ export class OverviewComponent { return total; } + /** + * Returns total number of datasets with results. + * + * @return number + */ getTotalDatasets(): number { return this.datasetsCount.filter(c => c.count > 0).length; } - // Return dataset families that contains datasets with cone search enabled - // Returned dataset families are sorted by display + /** + * Returns dataset families sorted by display, that contains selected datasets. + * + * @return Family[] + */ getSortedDatasetFamilyList(): Family[] { let datasetFamiliesWithSelectedDataset: Family[] = []; this.selectedDatasets.forEach(dname => { @@ -60,12 +82,26 @@ export class OverviewComponent { return datasetFamiliesWithSelectedDataset.sort(sortByDisplay); } + /** + * Returns selected dataset list for the given dataset family ID. + * + * @param {number} familyId - The family ID. + * + * @return Dataset[] + */ getSelectedDatasetsByFamily(familyId: number): Dataset[] { return this.datasetList .filter(d => d.id_dataset_family === familyId) .filter(d => this.selectedDatasets.includes(d.name)); } + /** + * Returns the result number for the given dataset name. + * + * @param {string} dname - The dataset name. + * + * @return number + */ getCountByDataset(dname: string): number { return this.datasetsCount.find(c => c.dname === dname).count; } diff --git a/src/app/search-multiple/components/summary-multiple.component.ts b/src/app/search-multiple/components/summary-multiple.component.ts index 4ac672318af0d35fd2e0a88199f79a81dd523d93..e4185824c81c42ebf7ced8e10491db4bc6bd49f6 100644 --- a/src/app/search-multiple/components/summary-multiple.component.ts +++ b/src/app/search-multiple/components/summary-multiple.component.ts @@ -20,6 +20,10 @@ import { sortByDisplay } from '../../shared/utils'; styleUrls: ['summary-multiple.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, }) +/** + * @class + * @classdesc Search multiple summary component. + */ export class SummaryMultipleComponent { @Input() currentStep: string; @Input() isValidConeSearch: boolean; @@ -34,8 +38,11 @@ export class SummaryMultipleComponent { accordionFamilyIsOpen = true; - // Return dataset families that contains datasets with cone search enabled - // Returned dataset families are sorted by display + /** + * Returns dataset families sorted by display, that contains datasets with cone search enabled. + * + * @return Family[] + */ getDatasetFamilyList(): Family[] { const familiesId: number[] = []; this.datasetList.forEach(d => { @@ -48,6 +55,13 @@ export class SummaryMultipleComponent { .sort(sortByDisplay); } + /** + * Returns dataset list for the given dataset family ID. + * + * @param {number} familyId - The family ID. + * + * @return Dataset[] + */ getSelectedDatasetsByFamily(familyId: number): Dataset[] { return this.datasetList .filter(d => d.id_dataset_family === familyId) diff --git a/src/app/search-multiple/containers/datasets.component.ts b/src/app/search-multiple/containers/datasets.component.ts index 5f458f68249f4c53f810689d8976fd1b0adbb383..13aed8a11ddb13bdacf3f2d4c0c87a032aded8fc 100644 --- a/src/app/search-multiple/containers/datasets.component.ts +++ b/src/app/search-multiple/containers/datasets.component.ts @@ -24,7 +24,11 @@ import * as coneSearchSelector from '../../shared/cone-search/store/cone-search. import { ConeSearch } from '../../shared/cone-search/store/model'; import { ScrollTopService } from '../../shared/service/sroll-top.service'; - +/** + * Interface for store state. + * + * @interface StoreState + */ interface StoreState { searchMultiple: fromSearchMultiple.State; metamodel: fromMetamodel.State; @@ -34,6 +38,12 @@ interface StoreState { selector: 'app-datasets', templateUrl: 'datasets.component.html' }) +/** + * @class + * @classdesc Search multiple datasets container. + * + * @implements OnInit + */ export class DatasetsComponent implements OnInit { public datasetSearchMetaIsLoading: Observable<boolean>; public datasetSearchMetaIsLoaded: Observable<boolean>; @@ -70,11 +80,19 @@ export class DatasetsComponent implements OnInit { this.scrollTopService.setScrollTop(); } + /** + * Dispatches action to check datasets step. + */ checkStep(): void { this.store.dispatch(new searchMultipleActions.DatasetsCheckedAction()); } - updateSelectedDatasets(selectedDatasets: string[]) { + /** + * Dispatches action to update dataset list selection with the given updated selected dataset name list. + * + * @param {string[]} selectedDatasets - The updated dataset name list. + */ + updateSelectedDatasets(selectedDatasets: string[]): void { this.store.dispatch(new searchMultipleActions.UpdateSelectedDatasetsAction(selectedDatasets)); } } diff --git a/src/app/search-multiple/containers/position.component.ts b/src/app/search-multiple/containers/position.component.ts index 0e8f35eb9fd0c36fcbb00da4a78bb2a0b4919e1e..fc282d02e540c90eacbf7e767a9066aaadd1d1d7 100644 --- a/src/app/search-multiple/containers/position.component.ts +++ b/src/app/search-multiple/containers/position.component.ts @@ -25,7 +25,11 @@ import * as coneSearchSelector from '../../shared/cone-search/store/cone-search. import { ConeSearch } from '../../shared/cone-search/store/model'; import { ScrollTopService } from '../../shared/service/sroll-top.service'; - +/** + * Interface for store state. + * + * @interface StoreState + */ interface StoreState { searchMultiple: fromSearchMultiple.State; metamodel: fromMetamodel.State; @@ -36,6 +40,12 @@ interface StoreState { templateUrl: 'position.component.html', styleUrls: ['position.component.css'] }) +/** + * @class + * @classdesc Search multiple position container. + * + * @implements OnInit + */ export class PositionComponent implements OnInit { public datasetSearchMetaIsLoading: Observable<boolean>; public datasetSearchMetaIsLoaded: Observable<boolean>; @@ -70,10 +80,16 @@ export class PositionComponent implements OnInit { this.scrollTopService.setScrollTop(); } + /** + * Dispatches action to check position step. + */ checkStep(): void { this.store.dispatch(new searchMultipleActions.PositionCheckedAction()); } + /** + * Dispatches action to reset cone search. + */ resetConeSearch(): void { this.store.dispatch(new coneSearchActions.DeleteConeSearchAction()); } diff --git a/src/app/search-multiple/containers/result-multiple.component.ts b/src/app/search-multiple/containers/result-multiple.component.ts index fd5c60f970e4228bccdd6ddbd7ba74f417a63534..64b5ed34853a6e95a67995bcd8ff36b808ccc136 100644 --- a/src/app/search-multiple/containers/result-multiple.component.ts +++ b/src/app/search-multiple/containers/result-multiple.component.ts @@ -27,7 +27,11 @@ import { ConeSearch } from '../../shared/cone-search/store/model'; import { Pagination } from '../../shared/datatable/model'; import { ScrollTopService } from '../../shared/service/sroll-top.service'; - +/** + * Interface for store state. + * + * @interface StoreState + */ interface StoreState { searchMultiple: fromSearchMultiple.State; metamodel: fromMetamodel.State; @@ -37,6 +41,13 @@ interface StoreState { selector: 'app-result-multiple', templateUrl: 'result-multiple.component.html' }) +/** + * @class + * @classdesc Search multiple result container. + * + * @implements OnInit + * @implements OnDestroy + */ export class ResultMultipleComponent implements OnInit, OnDestroy { public datasetSearchMetaIsLoading: Observable<boolean>; public datasetSearchMetaIsLoaded: Observable<boolean>; @@ -84,18 +95,36 @@ export class ResultMultipleComponent implements OnInit, OnDestroy { this.scrollTopService.setScrollTop(); } + /** + * Dispatches action to retrieve dataset result number. + */ getDatasetsCount(): void { this.store.dispatch(new searchMultipleActions.RetrieveDatasetsCountAction()); } + /** + * Dispatches action to retrieve metadata of a given dataset name. + * + * @param {string} dname - The dataset name. + */ retrieveMeta(dname: string): void { this.store.dispatch(new attributeActions.LoadAttributeListAction(dname)); } + /** + * Dispatches action to retrieve data with the given pagination parameters. + * + * @param {Pagination} params - The pagination parameters. + */ retrieveData(params: Pagination): void { this.store.dispatch(new searchMultipleActions.RetrieveDataAction(params)); } + /** + * Dispatches action to update data selection with the given updated selected data. + * + * @param {{ dname: string, data: (string | number)[] }[]} data - The updated selected data. + */ updateSelectedData(data: { dname: string, data: (string | number)[] }[]): void { this.store.dispatch(new searchMultipleActions.UpdateSelectedDataAction(data)); } @@ -104,6 +133,9 @@ export class ResultMultipleComponent implements OnInit, OnDestroy { // this.store.dispatch(new searchActions.ExecuteProcessAction(typeProcess)); // } + /** + * Dispatches action to destroy search multiple results. + */ ngOnDestroy() { this.store.dispatch(new searchMultipleActions.DestroyResultsAction()); } diff --git a/src/app/search-multiple/containers/search-multiple.component.ts b/src/app/search-multiple/containers/search-multiple.component.ts index d8bec8534ba3d8345642fc9b0374682b766bc072..99605bc61a9f75ea72fb70b5ec77d5cc0917d0fa 100644 --- a/src/app/search-multiple/containers/search-multiple.component.ts +++ b/src/app/search-multiple/containers/search-multiple.component.ts @@ -23,6 +23,10 @@ import * as coneSearchActions from '../../shared/cone-search/store/cone-search.a selector: 'app-search-multiple', templateUrl: 'search-multiple.component.html' }) +/** + * @class + * @classdesc Search multiple container. + */ export class SearchMultipleComponent { public currentStep: Observable<string>; public positionStepChecked: Observable<boolean>; diff --git a/src/app/search-multiple/search-multiple-routing.module.ts b/src/app/search-multiple/search-multiple-routing.module.ts index 7ce430e9bd796310dbaaa570dda1d956e3b9f264..a305d8bb45719f88356ab19825f024727c69d4c9 100644 --- a/src/app/search-multiple/search-multiple-routing.module.ts +++ b/src/app/search-multiple/search-multiple-routing.module.ts @@ -30,6 +30,10 @@ const routes: Routes = [ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) +/** + * @class + * @classdesc Search multiple routing module. + */ export class SearchMultipleRoutingModule { } export const routedComponents = [ diff --git a/src/app/search-multiple/search-multiple.module.ts b/src/app/search-multiple/search-multiple.module.ts index 439b32a87ec5746b571ab203b57e28403223212d..78e2669139198569f550f844706c8dcc43def852 100644 --- a/src/app/search-multiple/search-multiple.module.ts +++ b/src/app/search-multiple/search-multiple.module.ts @@ -34,4 +34,8 @@ import { reducer } from './store/search-multiple.reducer'; ], providers: [SearchMultipleService] }) +/** + * @class + * @classdesc Search multiple module. + */ export class SearchMultipleModule { } diff --git a/src/app/search-multiple/store/model/data-by-dataset.model.ts b/src/app/search-multiple/store/model/data-by-dataset.model.ts index 38f76aa143e620666c3620b0698839c1a4ac7717..85167bd5d313a43b1e59e2d3f111c0fc36f38855 100644 --- a/src/app/search-multiple/store/model/data-by-dataset.model.ts +++ b/src/app/search-multiple/store/model/data-by-dataset.model.ts @@ -7,6 +7,11 @@ * file that was distributed with this source code. */ +/** + * Interface for search multiple data by dataset. + * + * @interface DataByDataset + */ export interface DataByDataset { datasetName: string; isLoading: boolean; diff --git a/src/app/search-multiple/store/model/dataset-count.model.ts b/src/app/search-multiple/store/model/dataset-count.model.ts index 4874968155ff13bbedcf4d57b7997dd51009d59a..6219acbe5e5a7f30ffb50d4a24780c796b599e07 100644 --- a/src/app/search-multiple/store/model/dataset-count.model.ts +++ b/src/app/search-multiple/store/model/dataset-count.model.ts @@ -7,6 +7,11 @@ * file that was distributed with this source code. */ +/** + * Interface for search multiple dataset count. + * + * @interface DatasetCount + */ export interface DatasetCount { dname: string; count: number; diff --git a/src/app/search-multiple/store/model/search-multiple-query-params.model.ts b/src/app/search-multiple/store/model/search-multiple-query-params.model.ts index 15dd22746d62496d1e9fecbfd16da21a9bbe8617..9e4cd67b1047b0288bf8fcfabe5c895f41a1713a 100644 --- a/src/app/search-multiple/store/model/search-multiple-query-params.model.ts +++ b/src/app/search-multiple/store/model/search-multiple-query-params.model.ts @@ -7,6 +7,11 @@ * file that was distributed with this source code. */ +/** + * Interface for search multiple query parameters. + * + * @interface SearchMultipleQueryParams + */ export interface SearchMultipleQueryParams { cs?: string; d?: string; diff --git a/src/app/search-multiple/store/search-multiple.action.ts b/src/app/search-multiple/store/search-multiple.action.ts index bd7908a58b91a76b0ce982a700665d98d9b6b1e5..c97e8045dc7fada826dab8d5c76642a4fb2d0b3a 100644 --- a/src/app/search-multiple/store/search-multiple.action.ts +++ b/src/app/search-multiple/store/search-multiple.action.ts @@ -30,97 +30,176 @@ export const UPDATE_SELECTED_DATA = '[SearchMultiple] Update Selected Data'; export const DESTROY_RESULTS = '[SearchMultiple] Destroy Results'; export const RESET_SEARCH = '[SearchMultiple] Reset Search'; - +/** + * @class + * @classdesc InitSearchByUrlAction action. + * @readonly + */ export class InitSearchByUrlAction implements Action { readonly type = INIT_SEARCH_BY_URL; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc InitSelectedDatasetsAction action. + * @readonly + */ export class InitSelectedDatasetsAction implements Action { readonly type = INIT_SELECTED_DATASETS; constructor(public payload: string[]) { } } +/** + * @class + * @classdesc ChangeStepAction action. + * @readonly + */ export class ChangeStepAction implements Action { readonly type = CHANGE_STEP; constructor(public payload: string) { } } +/** + * @class + * @classdesc PositionCheckedAction action. + * @readonly + */ export class PositionCheckedAction implements Action { readonly type = POSITION_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc DatasetsCheckedAction action. + * @readonly + */ export class DatasetsCheckedAction implements Action { readonly type = DATASETS_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc ResultsCheckedAction action. + * @readonly + */ export class ResultsCheckedAction implements Action { readonly type = RESULTS_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc UpdateSelectedDatasetsAction action. + * @readonly + */ export class UpdateSelectedDatasetsAction implements Action { readonly type = UPDATE_SELECTED_DATASETS; constructor(public payload: string[]) { } } +/** + * @class + * @classdesc RetrieveDatasetsCountAction action. + * @readonly + */ export class RetrieveDatasetsCountAction implements Action { readonly type = RETRIEVE_DATASETS_COUNT; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc RetrieveDatasetsCountSuccessAction action. + * @readonly + */ export class RetrieveDatasetsCountSuccessAction implements Action { readonly type = RETRIEVE_DATASETS_COUNT_SUCCESS; constructor(public payload: DatasetCount[]) { } } +/** + * @class + * @classdesc RetrieveDatasetsCountFailAction action. + * @readonly + */ export class RetrieveDatasetsCountFailAction implements Action { readonly type = RETRIEVE_DATASETS_COUNT_FAIL; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc RetrieveDataAction action. + * @readonly + */ export class RetrieveDataAction implements Action { readonly type = RETRIEVE_DATA; constructor(public payload: Pagination) { } } +/** + * @class + * @classdesc RetrieveDataSuccessAction action. + * @readonly + */ export class RetrieveDataSuccessAction implements Action { readonly type = RETRIEVE_DATA_SUCCESS; constructor(public payload: { datasetName: string, data: any[] }) { } } +/** + * @class + * @classdesc RetrieveDataFailAction action. + * @readonly + */ export class RetrieveDataFailAction implements Action { readonly type = RETRIEVE_DATA_FAIL; constructor(public payload: string) { } } +/** + * @class + * @classdesc UpdateSelectedDataAction action. + * @readonly + */ export class UpdateSelectedDataAction implements Action { readonly type = UPDATE_SELECTED_DATA; constructor(public payload: { dname: string, data: (string | number)[] }[]) { } } +/** + * @class + * @classdesc DestroyResultsAction action. + * @readonly + */ export class DestroyResultsAction implements Action { readonly type = DESTROY_RESULTS; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc ResetSearchAction action. + * @readonly + */ export class ResetSearchAction implements Action { readonly type = RESET_SEARCH; diff --git a/src/app/search-multiple/store/search-multiple.effects.ts b/src/app/search-multiple/store/search-multiple.effects.ts index f079d3e5dbe8143fe1aaed98174a786b490af383..6ff23ceffacade44bd860a9d497a68d601bb1dfe 100644 --- a/src/app/search-multiple/store/search-multiple.effects.ts +++ b/src/app/search-multiple/store/search-multiple.effects.ts @@ -30,6 +30,10 @@ import { Pagination, PaginationOrder } from '../../shared/datatable/model'; import * as utils from '../../shared/utils'; @Injectable() +/** + * @class + * @classdesc Search multiple effects. + */ export class SearchMultipleEffects { constructor( private actions$: Actions, @@ -43,6 +47,9 @@ export class SearchMultipleEffects { }> ) { } + /** + * Calls actions to fill store with data provided by the URL. + */ @Effect() initSearchByUrlAction$ = this.actions$.pipe( ofType(searchMultipleActions.INIT_SEARCH_BY_URL), @@ -71,6 +78,9 @@ export class SearchMultipleEffects { }) ); + /** + * Fills selectedDatasets with all returned datasets if configured as this in Anis Admin. + */ @Effect() loadDatasetSearchMetaSuccessAction$ = this.actions$.pipe( ofType(datasetActions.LOAD_DATASET_SEARCH_META_SUCCESS), @@ -89,6 +99,9 @@ export class SearchMultipleEffects { }) ); + /** + * Calls multiple requests to get result count for each datasets. + */ @Effect() retrieveDatasetsCountAction$ = this.actions$.pipe( ofType(searchMultipleActions.RETRIEVE_DATASETS_COUNT), @@ -126,12 +139,18 @@ export class SearchMultipleEffects { }) ); + /** + * Displays datasets count error notification. + */ @Effect({ dispatch: false }) retrieveDatasetsCountFailAction$ = this.actions$.pipe( ofType(searchMultipleActions.RETRIEVE_DATASETS_COUNT_FAIL), tap(_ => this.toastr.error('Loading Failed!', 'The data count of datasets loading failed')) ); + /** + * Calls RetrieveDataAction when attributeList is Loaded. + */ @Effect() loadAttributeListSuccessAction$ = this.actions$.pipe( ofType(attributeActions.LOAD_ATTRIBUTE_LIST_SUCCESS), @@ -149,6 +168,9 @@ export class SearchMultipleEffects { }) ); + /** + * Calls RetrieveDataAction to get data for the given dataset and parameters. + */ @Effect() retrieveDataAction$ = this.actions$.pipe( ofType(searchMultipleActions.RETRIEVE_DATA), @@ -173,6 +195,9 @@ export class SearchMultipleEffects { }) ); + /** + * Displays retrieve data error notification. + */ @Effect({ dispatch: false }) retrieveDataFailAction$ = this.actions$.pipe( ofType(searchMultipleActions.RETRIEVE_DATA_FAIL), diff --git a/src/app/search-multiple/store/search-multiple.reducer.ts b/src/app/search-multiple/store/search-multiple.reducer.ts index 963592d47fe54f3c1c36478ac6ae128ceb679ab5..ebfc9c20358e6e594dfdd145c73cdc4cdf84eb84 100644 --- a/src/app/search-multiple/store/search-multiple.reducer.ts +++ b/src/app/search-multiple/store/search-multiple.reducer.ts @@ -12,7 +12,12 @@ import { createEntityAdapter, EntityAdapter, EntityState, Update } from '@ngrx/e import * as actions from './search-multiple.action'; import { DataByDataset, DatasetCount } from './model'; - +/** + * Interface for search multiple state. + * + * @interface State + * @extends EntityState<DataByDataset> + */ export interface State extends EntityState<DataByDataset> { pristine: boolean; currentStep: string; @@ -26,6 +31,13 @@ export interface State extends EntityState<DataByDataset> { selectedData: { dname: string, data: (string | number)[] }[]; } +/** + * Returns datasetName from DataByDataset object. + * + * @param {DataByDataset} d - The data by dataset. + * + * @return string + */ export function selectDataByDatasetId(d: DataByDataset): string { return d.datasetName; } @@ -47,6 +59,14 @@ export const initialState: State = adapter.getInitialState({ selectedData: [] }); +/** + * Reduces state. + * + * @param {State} state - The state. + * @param {actions} action - The action. + * + * @return State + */ export function reducer(state: State = initialState, action: actions.Actions): State { switch (action.type) { case actions.INIT_SELECTED_DATASETS: @@ -81,12 +101,6 @@ export function reducer(state: State = initialState, action: actions.Actions): S resultStepChecked: true }; - // case actions.UPDATE_SELECTED_DATASETS: - // return { - // ...state, - // selectedDatasets: action.payload - // }; - case actions.RETRIEVE_DATASETS_COUNT: return { ...state, @@ -154,6 +168,7 @@ export function reducer(state: State = initialState, action: actions.Actions): S return state; } } + export const { selectAll, selectEntities, diff --git a/src/app/search-multiple/store/search-multiple.service.ts b/src/app/search-multiple/store/search-multiple.service.ts index e1506744dd3f20afdcd7b11bd880fb11d60aea27..f0fe12cac4964ca77381c9b4d9ce292a9e6d8bd6 100644 --- a/src/app/search-multiple/store/search-multiple.service.ts +++ b/src/app/search-multiple/store/search-multiple.service.ts @@ -16,14 +16,25 @@ import { map } from 'rxjs/operators'; import { environment } from '../../../environments/environment'; import { DatasetCount } from './model'; - @Injectable() +/** + * @class + * @classdesc Search multiple service. + */ export class SearchMultipleService { API_PATH: string = environment.apiUrl; instanceName: string = environment.instanceName; constructor(private http: HttpClient) { } + /** + * Retrieves number of results for the given dataset and parameters. + * + * @param {string} dname - The dataset name. + * @param {string} query - The query. + * + * @return Observable<DatasetCount> + */ getCount(dname: string, query: string): Observable<DatasetCount> { return this.http.get<{ nb: number }[]>(this.API_PATH + '/search/' + query).pipe( map(res => { @@ -32,6 +43,14 @@ export class SearchMultipleService { ); } + /** + * Retrieves data for the given dataset and parameters. + * + * @param {string} dname - The dataset name. + * @param {string} query - The query. + * + * @return Observable<{ datasetName: string, data: any[] }> + */ retrieveData(dname: string, query: string): Observable<{ datasetName: string, data: any[] }> { return this.http.get<any[]>(this.API_PATH + '/search/' + query).pipe( map(res => { diff --git a/src/app/shared/cone-search/conainers/cone-search.component.ts b/src/app/shared/cone-search/conainers/cone-search.component.ts index 77611c8cd8e1e3de6fb47497612b4fc2ac652e36..7348c902124fa63c5f33cc606d6ceda0fba58f0d 100644 --- a/src/app/shared/cone-search/conainers/cone-search.component.ts +++ b/src/app/shared/cone-search/conainers/cone-search.component.ts @@ -31,7 +31,7 @@ interface StoreState { }) /** * @class - * @classdesc Cone search component. + * @classdesc Cone search container. */ export class ConeSearchComponent { @Input() disabled: boolean = false; diff --git a/src/app/shared/cone-search/store/cone-search.effects.ts b/src/app/shared/cone-search/store/cone-search.effects.ts index 550621120464e0dda4beccc64c2fa88765bfbab3..e78ab5e7f34b92544ce6a61b0b4220cfc5b1532e 100644 --- a/src/app/shared/cone-search/store/cone-search.effects.ts +++ b/src/app/shared/cone-search/store/cone-search.effects.ts @@ -41,10 +41,10 @@ export class ConeSearchEffects { }> ) { } - @Effect() /** * Calls retrieveCoordinates function and raises success or fail action depending on request result. */ + @Effect() retrieveCoordinatesAction$ = this.actions$.pipe( ofType(coneSearchActions.RETRIEVE_COORDINATES), withLatestFrom(this.store$), @@ -68,10 +68,10 @@ export class ConeSearchEffects { }) ); - @Effect() /** * Fills store cone search. */ + @Effect() retrieveCoordinatesSuccessAction$ = this.actions$.pipe( ofType(coneSearchActions.RETRIEVE_COORDINATES_SUCCESS), withLatestFrom(this.store$), @@ -86,10 +86,10 @@ export class ConeSearchEffects { }) ); - @Effect({ dispatch: false }) /** * Displays a retrieve coordinates error notification. */ + @Effect({ dispatch: false }) retrieveCoordinatesFailAction$ = this.actions$.pipe( ofType(coneSearchActions.RETRIEVE_COORDINATES_FAIL), tap(action => { @@ -102,10 +102,10 @@ export class ConeSearchEffects { }) ); - @Effect() /** * Fills store cone search form url or a not valid notification. */ + @Effect() addConeSearchFromUrlAction$ = this.actions$.pipe( ofType(coneSearchActions.ADD_CONE_SEARCH_FROM_URL), switchMap(action => {