Commit acd2b3ee authored by Tifenn Guillas's avatar Tifenn Guillas

Add comments for search multiple module => DONE

parent 840368f6
......@@ -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);
......
......@@ -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;
}
......
......@@ -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':
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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));
}
}
......@@ -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());
}
......
......@@ -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();
}