diff --git a/src/app/search/components/criteria/cone-search-tab.component.ts b/src/app/search/components/criteria/cone-search-tab.component.ts index b54d4f2f745013d52458b14e3ea2ba1043f3ff8a..e4ffba1aff0fa3acaa24c9188b8f0265853acb08 100644 --- a/src/app/search/components/criteria/cone-search-tab.component.ts +++ b/src/app/search/components/criteria/cone-search-tab.component.ts @@ -16,6 +16,10 @@ import { Dataset } from '../../../metamodel/model'; templateUrl: 'cone-search-tab.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search cone search tab component. + */ export class ConeSearchTabComponent { @Input() datasetName: string; @Input() datasetList: Dataset[]; @@ -23,6 +27,11 @@ export class ConeSearchTabComponent { @Input() isValidConeSearch: boolean; @Output() coneSearchAdded: EventEmitter<boolean> = new EventEmitter(); + /** + * Checks if cone search is enabled. + * + * @return boolean + */ coneSearchEnabled(): boolean { const config = this.datasetList.find(d => d.name === this.datasetName).config; if (config !== null && 'cone_search' in config) { diff --git a/src/app/search/components/criteria/criteria-by-family.component.ts b/src/app/search/components/criteria/criteria-by-family.component.ts index 6644466df4843aeeaa68e080f580d2621b14902d..3d6102be3cbb9f7345879ea109112d8288a9129d 100644 --- a/src/app/search/components/criteria/criteria-by-family.component.ts +++ b/src/app/search/components/criteria/criteria-by-family.component.ts @@ -11,12 +11,17 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from import { Criterion } from '../../store/model'; import { Attribute, Option } from '../../../metamodel/model'; +import { sortByDisplay } from '../../../shared/utils'; @Component({ selector: 'app-criteria-by-family', templateUrl: 'criteria-by-family.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search criteria by family component. + */ export class CriteriaByFamilyComponent { @Input() attributeList: Attribute[]; @Input() criteriaList: Criterion[]; @@ -25,26 +30,57 @@ export class CriteriaByFamilyComponent { advancedForm = false; + /** + * Returns attribute list sorted by criteria display. + * + * @return Attribute[] + */ getAttributeListSortedByDisplay(): Attribute[] { return this.attributeList .sort((a, b) => a.criteria_display - b.criteria_display); } + /** + * Returns options for the given attribute ID. + * + * @param {number} idAttribute - The attribute ID. + * + * @return Option[] + */ getOptions(idAttribute: number): Option[] { - return [...this.attributeList - .find(attribute => attribute.id === idAttribute) - .options] - .sort((a, b) => a.display - b.display); + return [...this.attributeList.find(attribute => attribute.id === idAttribute).options] + .sort(sortByDisplay); } + /** + * Returns criterion for the given criterion ID. + * + * @param {number} id - The criterion ID. + * + * @return Criterion + */ getCriterion(id: number): Criterion { return this.criteriaList.find(criterion => criterion.id === id); } + /** + * Emits event to add the given criterion to the criteria list. + * + * @param {Criterion} criterion - The criterion. + * + * @fires EventEmitter<Criterion> + */ emitAdd(criterion: Criterion): void { this.addCriterion.emit(criterion); } + /** + * Emits event to remove the given criterion ID from the criteria list. + * + * @param {number} id - The criterion ID. + * + * @fires EventEmitter<number> + */ emitDelete(id: number): void { this.deleteCriterion.emit(id); } diff --git a/src/app/search/components/criteria/criteria-tabs.component.ts b/src/app/search/components/criteria/criteria-tabs.component.ts index 0cce811ee984a87cdb36083523565d64170f074c..c2d3b339217bbfbe458febb4e6fab912d2fc70ca 100644 --- a/src/app/search/components/criteria/criteria-tabs.component.ts +++ b/src/app/search/components/criteria/criteria-tabs.component.ts @@ -17,6 +17,10 @@ import { Family, Attribute } from '../../../metamodel/model'; templateUrl: 'criteria-tabs.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search criteria tabs component. + */ export class CriteriaTabsComponent { @Input() criteriaFamilyList: Family[]; @Input() attributeList: Attribute[]; @@ -24,15 +28,36 @@ export class CriteriaTabsComponent { @Output() addCriterion: EventEmitter<Criterion> = new EventEmitter(); @Output() deleteCriterion: EventEmitter<number> = new EventEmitter(); + /** + * Returns attribute list for the given criteria family ID. + * + * @param {number} idFamily - The criteria family ID. + * + * @return Attribute[] + */ getAttributeByFamily(idFamily: number): Attribute[] { return this.attributeList .filter(attribute => attribute.id_criteria_family === idFamily); } + /** + * Emits event to add the given criterion to the criteria list. + * + * @param {Criterion} criterion - The criterion. + * + * @fires EventEmitter<Criterion> + */ emitAdd(criterion: Criterion): void { this.addCriterion.emit(criterion); } + /** + * Emits event to remove the given criterion ID to the criteria list. + * + * @param {number} id - The criterion ID. + * + * @fires EventEmitter<number> + */ emitDelete(id: number): void { this.deleteCriterion.emit(id); } diff --git a/src/app/search/components/criteria/search-type/between-date.component.ts b/src/app/search/components/criteria/search-type/between-date.component.ts index 7f9313a6485e26a6661b6d5e9e6e159dcb33b0be..34788697f05fd735665bdb5879f07bcdef021201 100644 --- a/src/app/search/components/criteria/search-type/between-date.component.ts +++ b/src/app/search/components/criteria/search-type/between-date.component.ts @@ -17,10 +17,19 @@ import { Criterion, BetweenCriterion } from '../../../store/model'; templateUrl: 'between-date.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Between date search type component. + */ export class BetweenDateComponent { @Input() id: number; @Input() operator: string; @Input() label: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -30,6 +39,11 @@ export class BetweenDateComponent { field = new FormControl(''); + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<BetweenCriterion> + */ emitAdd(): void { const dateMin = this.getDateString(this.field.value[0]); const dateMax = this.getDateString(this.field.value[1]); @@ -37,10 +51,20 @@ export class BetweenDateComponent { this.addCriterion.emit(fd); } + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ emitDelete(): void { this.deleteCriterion.emit(this.id); } - + + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.field.reset(); @@ -52,6 +76,13 @@ export class BetweenDateComponent { } } + /** + * Stringifies the given date. + * + * @param {Date} date - The date. + * + * @return string + */ getDateString(date: Date): string { const month = ('0' + (date.getMonth() + 1)).slice(-2); const day = ('0' + (date.getDate())).slice(-2); diff --git a/src/app/search/components/criteria/search-type/between.component.ts b/src/app/search/components/criteria/search-type/between.component.ts index 26534f7ddc477bcc7b5bfe9406addb3bcefba16d..13fd8d35992b97bf4c00bcfac452ff29b2657c7d 100644 --- a/src/app/search/components/criteria/search-type/between.component.ts +++ b/src/app/search/components/criteria/search-type/between.component.ts @@ -18,11 +18,20 @@ import { Criterion, BetweenCriterion } from '../../../store/model'; styleUrls: ['operator.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Between search type component. + */ export class BetweenComponent { @Input() id: number; @Input() label: string; @Input() placeholderMin: string; @Input() placeholderMax: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -33,15 +42,30 @@ export class BetweenComponent { fieldMin = new FormControl(''); fieldMax = new FormControl(''); - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<BetweenCriterion> + */ + emitAdd(): void { const fd = {id: this.id, type: 'between', min: this.fieldMin.value, max: this.fieldMax.value}; this.addCriterion.emit(fd); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.fieldMin.reset(); @@ -57,7 +81,12 @@ export class BetweenComponent { } } - getPlaceholderMin() { + /** + * Returns placeholder for the minimum value. + * + * @return string + */ + getPlaceholderMin(): string { if (!this.placeholderMin) { return ''; } else { @@ -65,7 +94,12 @@ export class BetweenComponent { } } - getPlaceholderMax() { + /** + * Returns placeholder for the maximum value. + * + * @return string + */ + getPlaceholderMax(): string { if (!this.placeholderMax) { return ''; } else { diff --git a/src/app/search/components/criteria/search-type/checkbox.component.ts b/src/app/search/components/criteria/search-type/checkbox.component.ts index d8fdf4e5af0d154e0298c6a4d7fefd4212089b54..30705ef4b4a96c25a5ebdb34cb885687fd07cbda 100644 --- a/src/app/search/components/criteria/search-type/checkbox.component.ts +++ b/src/app/search/components/criteria/search-type/checkbox.component.ts @@ -19,10 +19,19 @@ import { Option } from '../../../../metamodel/model'; styleUrls: ['checkbox.component.css', 'operator.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Checkbox search type component. + */ export class CheckboxComponent { @Input() id: number; @Input() label: string; @Input() options: Option[]; + /** + * Calls getDefault function for the given criterion. + * + * @param {SelectMultipleCriterion} criterion - The criterion. + */ @Input() set criterion(criterion: SelectMultipleCriterion) { this.getDefault(criterion); @@ -32,18 +41,33 @@ export class CheckboxComponent { checkboxes: FormArray; - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<SelectMultipleCriterion> + */ + emitAdd(): void { // Filter options to keep only the checked checkboxes and emit the new criterion const selected = this.checkboxes.value; const values = [...this.options.filter((option, index) => selected[index])]; this.addCriterion.emit({id: this.id, type: 'multiple', options: values}); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { // Delete the criterion into the state to reactivate the checkboxes this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {SelectMultipleCriterion} criterion - The criterion. + */ getDefault(criterion: SelectMultipleCriterion): void { // Initialization of checkboxes (1 per option) const formControls: FormControl[] = []; @@ -66,7 +90,12 @@ export class CheckboxComponent { } } - isChecked() { + /** + * Checks if one of the checkboxes is checked. + * + * @return boolean + */ + isChecked(): boolean { // If one of the checkboxes is checked returns true else returns false return this.checkboxes.controls.filter(formControl => formControl.value).length > 0; } diff --git a/src/app/search/components/criteria/search-type/datalist.component.ts b/src/app/search/components/criteria/search-type/datalist.component.ts index 474959e180f6d1671d489ad11ff5b35a874ea089..262e48cc05f8b7c1842cae6157d0b7877eee21df 100644 --- a/src/app/search/components/criteria/search-type/datalist.component.ts +++ b/src/app/search/components/criteria/search-type/datalist.component.ts @@ -18,12 +18,21 @@ import { Option } from '../../../../metamodel/model'; templateUrl: 'datalist.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Datalist search type component. + */ export class DatalistComponent { @Input() id: number; @Input() operator: string; @Input() label: string; @Input() placeholder: string; @Input() options: Option[]; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -35,19 +44,39 @@ export class DatalistComponent { field = new FormControl(''); disabledOperator: boolean; + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const fd = {id: this.id, type: 'field', operator: this.operator, value: this.field.value}; this.addCriterion.emit(fd); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.field.reset(); @@ -61,7 +90,12 @@ export class DatalistComponent { } } - getPlaceholder() { + /** + * Returns placeholder. + * + * @return string + */ + getPlaceholder(): string { if (!this.placeholder) { return ''; } else { @@ -69,7 +103,12 @@ export class DatalistComponent { } } - getDatalistId() { + /** + * Returns string datalist ID. + * + * @return string + */ + getDatalistId(): string { return 'datalist_' + this.id; } } diff --git a/src/app/search/components/criteria/search-type/date.component.ts b/src/app/search/components/criteria/search-type/date.component.ts index 4cb4393822487052bde91e2e4233f3e43a8bc7c6..dffa099d063522ab14dfd2c68f6259fa4ae0b0b8 100644 --- a/src/app/search/components/criteria/search-type/date.component.ts +++ b/src/app/search/components/criteria/search-type/date.component.ts @@ -17,11 +17,20 @@ import { Criterion, FieldCriterion } from '../../../store/model'; templateUrl: 'date.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Date search type component. + */ export class DateComponent { @Input() id: number; @Input() operator: string; @Input() label: string; @Input() placeholder: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -33,19 +42,39 @@ export class DateComponent { field = new FormControl(''); disabledOperator: boolean; + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const fd = {id: this.id, type: 'field', operator: this.operator, value: this.getDateString(this.field.value)}; this.addCriterion.emit(fd); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete():void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.field.reset(); @@ -59,6 +88,11 @@ export class DateComponent { } } + /** + * Returns placeholder. + * + * @return string + */ getPlaceholder(): string { if (!this.placeholder) { return ''; @@ -67,7 +101,14 @@ export class DateComponent { } } - getDateString(date: Date) { + /** + * Stringifies the given date. + * + * @param {Date} date - The date. + * + * @return string + */ + getDateString(date: Date): string { const month = ('0' + (date.getMonth() + 1)).slice(-2); const day = ('0' + (date.getDate())).slice(-2); return date.getFullYear() + '-' + month + '-' + day; diff --git a/src/app/search/components/criteria/search-type/datetime.component.ts b/src/app/search/components/criteria/search-type/datetime.component.ts index 91967ae38e25ff5578f73aea9c3e3f923b5e13be..ef98ecae26c0e8312a40f04a03161b2174f6a9b1 100644 --- a/src/app/search/components/criteria/search-type/datetime.component.ts +++ b/src/app/search/components/criteria/search-type/datetime.component.ts @@ -17,10 +17,19 @@ import { Criterion, FieldCriterion } from '../../../store/model'; templateUrl: 'datetime.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Datetime search type component. + */ export class DatetimeComponent { @Input() id: number; @Input() operator: string; @Input() label: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -29,9 +38,8 @@ export class DatetimeComponent { @Output() addCriterion: EventEmitter<FieldCriterion> = new EventEmitter(); @Output() deleteCriterion: EventEmitter<number> = new EventEmitter(); - hours: string[] = []; - minutes: string[] = []; - + hours: string[] = this.initTime(24); + minutes: string[] = this.initTime(60); date = new FormControl(''); hh = new FormControl(); mm = new FormControl(); @@ -40,16 +48,21 @@ export class DatetimeComponent { disabledOperator: boolean; - constructor() { - this.hours = this.initTime(24); - this.minutes = this.initTime(60); - } - + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const month = ('0' + (this.datetime.getMonth() + 1)).slice(-2); const day = ('0' + (this.datetime.getDate())).slice(-2); const date = this.datetime.getFullYear() + '-' + month + '-' + day; @@ -58,10 +71,20 @@ export class DatetimeComponent { this.addCriterion.emit(fd); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.date.reset(); @@ -87,6 +110,13 @@ export class DatetimeComponent { } } + /** + * Returns string array to represent the given time. + * + * @param {number} time - The number max to represent time. + * + * @return string[] + */ initTime(time: number): string[] { const array: string[] = []; for (let i = 0; i < time; i++) { @@ -96,6 +126,9 @@ export class DatetimeComponent { return array; } + /** + * Reconstructs datetime from form inputs. + */ change(): void { if (!this.date.value || !this.hh.value || !this.mm.value) { this.isValidFields = false; diff --git a/src/app/search/components/criteria/search-type/field.component.ts b/src/app/search/components/criteria/search-type/field.component.ts index 70ea328f2f17316907cf7b77532f5ca0590cab52..34604327abbbd7008279d8cb3115a82ff483da82 100644 --- a/src/app/search/components/criteria/search-type/field.component.ts +++ b/src/app/search/components/criteria/search-type/field.component.ts @@ -17,12 +17,21 @@ import { FieldCriterion, Criterion } from '../../../store/model'; templateUrl: 'field.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) +/** + * @class + * @classdesc Field search type component. + */ export class FieldComponent { @Input() id: number; @Input() operator: string; @Input() label: string; @Input() placeholder: string; @Input() attributeType: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -34,19 +43,39 @@ export class FieldComponent { field = new FormControl(''); disabledOperator: boolean; + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const fd = {id: this.id, type: 'field', operator: this.operator, value: this.field.value}; this.addCriterion.emit(fd); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.field.reset(); @@ -60,6 +89,11 @@ export class FieldComponent { } } + /** + * Return field type. + * + * @return string + */ getType(): string { const numberTypeList = ['smallint', 'integer', 'decimal', 'float']; if (this.operator === 'in' || this.operator === 'nin' || !numberTypeList.includes(this.attributeType)) { @@ -69,6 +103,11 @@ export class FieldComponent { } } + /** + * Return placeholder. + * + * @return string + */ getPlaceholder(): string { if (!this.placeholder) { return ''; diff --git a/src/app/search/components/criteria/search-type/help-like.component.ts b/src/app/search/components/criteria/search-type/help-like.component.ts index f0362caa2bc7d26e80b61487ca92981fd48a4268..3600c6055e3399883bdddbdf05f3947f1b986491 100644 --- a/src/app/search/components/criteria/search-type/help-like.component.ts +++ b/src/app/search/components/criteria/search-type/help-like.component.ts @@ -13,4 +13,8 @@ import { Component } from '@angular/core'; selector: 'app-help-like', templateUrl: 'help-like.component.html' }) +/** + * @class + * @classdesc Help like operator component. + */ export class HelpLikeComponent { } diff --git a/src/app/search/components/criteria/search-type/json.component.ts b/src/app/search/components/criteria/search-type/json.component.ts index cb37b9f59885b7c24a6ae8f82c0107deb540711d..2a656e819742d228781425e4a66ad8b6bed0c981 100644 --- a/src/app/search/components/criteria/search-type/json.component.ts +++ b/src/app/search/components/criteria/search-type/json.component.ts @@ -17,9 +17,18 @@ import { JsonCriterion, Criterion } from '../../../store/model'; templateUrl: 'json.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc JSON search type component. + */ export class JsonComponent { @Input() id: number; @Input() label: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -33,15 +42,30 @@ export class JsonComponent { value: new FormControl() }); - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<JsonCriterion> + */ + emitAdd(): void { const js = {id: this.id, type: 'json', path: this.jsonForm.value.path, operator: this.jsonForm.value.operator, value: this.jsonForm.value.value}; this.addCriterion.emit(js); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.jsonForm.reset(); diff --git a/src/app/search/components/criteria/search-type/list.component.ts b/src/app/search/components/criteria/search-type/list.component.ts index c6c83008f40fec04420599335c2903baece752bb..5edf69c3cf33c0431eca4770020d2f8fd34a0d76 100644 --- a/src/app/search/components/criteria/search-type/list.component.ts +++ b/src/app/search/components/criteria/search-type/list.component.ts @@ -18,10 +18,19 @@ import { ListCriterion, Criterion } from '../../../store/model'; styleUrls: ['operator.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, }) +/** + * @class + * @classdesc List search type component. + */ export class ListComponent { @Input() id: number; @Input() label: string; @Input() placeholder: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -31,6 +40,11 @@ export class ListComponent { list = new FormControl(''); + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.list.reset(); @@ -42,6 +56,11 @@ export class ListComponent { } } + /** + * Returns placeholder. + * + * @return string + */ getPlaceholder(): string { if (!this.placeholder) { return ''; @@ -50,7 +69,12 @@ export class ListComponent { } } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<ListCriterion> + */ + emitAdd(): void { const ls = { id: this.id, type: 'list', values: this.list.value.split('\n') }; this.addCriterion.emit(ls); } diff --git a/src/app/search/components/criteria/search-type/operator.component.ts b/src/app/search/components/criteria/search-type/operator.component.ts index 9a2cb7292dbb283f1cf5c0d4550a72af2e7172f3..b45fb8e3e4ce02f5122ca0409a4355d5598b2ad3 100644 --- a/src/app/search/components/criteria/search-type/operator.component.ts +++ b/src/app/search/components/criteria/search-type/operator.component.ts @@ -15,6 +15,10 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from styleUrls: ['operator.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Operator component. + */ export class OperatorComponent { @Input() operator: string; @Input() searchType: string; @@ -35,11 +39,22 @@ export class OperatorComponent { { value: 'nin', label: 'not in' } ]; - + /** + * Emits event to change operator with the given one. + * + * @fires EventEmitter<string> + */ emitChange(operator: string): void { this.changeOperator.emit(operator); } + /** + * Return form label for the given operator. + * + * @param {operator} operator - The operator. + * + * @return string + */ getLabel(operator: string): string { return this.operators.find(o => o.value === operator).label; } diff --git a/src/app/search/components/criteria/search-type/radio.component.ts b/src/app/search/components/criteria/search-type/radio.component.ts index 945b36a2b07ee9190579d2741c74687b5b953732..c4d1de05b752ad674fed6777cc51b949bc807b40 100644 --- a/src/app/search/components/criteria/search-type/radio.component.ts +++ b/src/app/search/components/criteria/search-type/radio.component.ts @@ -18,11 +18,20 @@ import { Option } from '../../../../metamodel/model'; templateUrl: 'radio.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Radio search type component. + */ export class RadioComponent { @Input() id: number; @Input() operator: string; @Input() label: string; @Input() options: Option[]; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -32,16 +41,31 @@ export class RadioComponent { radio = new FormControl(''); - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const option = this.options.find(o => o.value === this.radio.value); const cb = {id: this.id, type: 'field', operator: this.operator, value: option.value}; this.addCriterion.emit(cb); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.radio.reset(); diff --git a/src/app/search/components/criteria/search-type/select-multiple.component.ts b/src/app/search/components/criteria/search-type/select-multiple.component.ts index 8ea8d1e0448b4d7a5acec53924dd1dfd5430f527..e047b5efc8e43181b04ba5577081415c6c334abd 100644 --- a/src/app/search/components/criteria/search-type/select-multiple.component.ts +++ b/src/app/search/components/criteria/search-type/select-multiple.component.ts @@ -19,10 +19,19 @@ import { Option } from '../../../../metamodel/model'; styleUrls: ['operator.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Select multiple search type component. + */ export class SelectMultipleComponent { @Input() id: number; @Input() label: string; @Input() options: Option[]; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -32,16 +41,31 @@ export class SelectMultipleComponent { ms = new FormControl(); - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<SelectMultipleCriterion> + */ + emitAdd(): void { const options = this.ms.value.map(optionValue => this.options.find(o => o.value === optionValue)); const ms = {id: this.id, type: 'multiple', options}; this.addCriterion.emit(ms); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.ms.reset(); diff --git a/src/app/search/components/criteria/search-type/select.component.ts b/src/app/search/components/criteria/search-type/select.component.ts index 8fc7340c1e42b2d66f09a9443379dfdf9f528897..d54004743921f3d58a1377c0b7c9702711f80501 100644 --- a/src/app/search/components/criteria/search-type/select.component.ts +++ b/src/app/search/components/criteria/search-type/select.component.ts @@ -18,11 +18,20 @@ import { Option } from '../../../../metamodel/model'; templateUrl: 'select.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Select search type component. + */ export class SelectComponent { @Input() id: number; @Input() operator: string; @Input() label: string; @Input() options: Option[]; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -34,20 +43,40 @@ export class SelectComponent { se = new FormControl(); disabledOperator: boolean; + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const option = this.options.find(o => o.value === this.se.value); const se = {id: this.id, type: 'field', operator: this.operator, value: option.value}; this.addCriterion.emit(se); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.se.reset(); diff --git a/src/app/search/components/criteria/search-type/time.component.ts b/src/app/search/components/criteria/search-type/time.component.ts index 7f192affbf678c346e97ea8b0cb61b455dd381bd..fd82b309c46b727f43dedcab3b18141d3eefc20a 100644 --- a/src/app/search/components/criteria/search-type/time.component.ts +++ b/src/app/search/components/criteria/search-type/time.component.ts @@ -17,10 +17,19 @@ import { Criterion, FieldCriterion } from '../../../store/model'; templateUrl: 'time.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Time search type component. + */ export class TimeComponent { @Input() id: number; @Input() operator: string; @Input() label: string; + /** + * Calls getDefault function for the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ @Input() set criterion(criterion: Criterion) { this.getDefault(criterion); @@ -29,32 +38,45 @@ export class TimeComponent { @Output() addCriterion: EventEmitter<FieldCriterion> = new EventEmitter(); @Output() deleteCriterion: EventEmitter<number> = new EventEmitter(); - public hours: string[] = []; - public minutes: string[] = []; - + hours: string[] = this.initTime(24); + minutes: string[] = this.initTime(60); hh = new FormControl(); mm = new FormControl(); - disabledOperator: boolean; - constructor() { - this.hours = this.initTime(24); - this.minutes = this.initTime(60); - } - + /** + * Modifies operator with the given one. + * + * @param {operator} operator - The operator. + */ changeOperator(operator: string): void { this.operator = operator; } - emitAdd() { + /** + * Emits event to add criterion to the criteria list. + * + * @fires EventEmitter<FieldCriterion> + */ + emitAdd(): void { const time = {id: this.id, type: 'field', operator: this.operator, value: this.hh.value + ':' + this.mm.value}; this.addCriterion.emit(time); } - emitDelete() { + /** + * Emits event to remove criterion ID from the criteria list. + * + * @fires EventEmitter<number> + */ + emitDelete(): void { this.deleteCriterion.emit(this.id); } + /** + * Fills form with the given criterion. + * + * @param {Criterion} criterion - The criterion. + */ getDefault(criterion: Criterion): void { if (!criterion) { this.hh.reset(); @@ -72,6 +94,13 @@ export class TimeComponent { } } + /** + * Returns string array to represent the given time. + * + * @param {number} time - The number max to represent time. + * + * @return string[] + */ initTime(time: number): string[] { const array: string[] = []; for (let i = 0; i < time; i++) { diff --git a/src/app/search/components/dataset/dataset-card.component.ts b/src/app/search/components/dataset/dataset-card.component.ts index f6c39b64e5149743511b584d203e54d7d1dedc18..9e2551f59ae85d3aaf19b1f5378f90bf170c26a7 100644 --- a/src/app/search/components/dataset/dataset-card.component.ts +++ b/src/app/search/components/dataset/dataset-card.component.ts @@ -17,6 +17,10 @@ import { Project, Dataset } from '../../../metamodel/model'; styleUrls: [ 'dataset-card.component.css' ], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search dataset card component. + */ export class DatasetCardComponent { @Input() project: Project; @Input() dataset: Dataset; diff --git a/src/app/search/components/dataset/dataset-tabs.component.html b/src/app/search/components/dataset/dataset-tabs.component.html index 42081af94d85c948673f43f29122cd2f490c90e5..a8be64ca6ee53c3208f6f1f8299c9f1cdb85706d 100644 --- a/src/app/search/components/dataset/dataset-tabs.component.html +++ b/src/app/search/components/dataset/dataset-tabs.component.html @@ -1,7 +1,7 @@ <div *ngIf="datasetFamilyList.length === 1"> <div class="border rounded my-2"> - <p *ngIf="getNbDatasetByFamily() === 1" class="border-bottom bg-light text-primary py-4 pl-4">Dataset</p> - <p *ngIf="getNbDatasetByFamily() > 1" class="border-bottom bg-light text-primary py-4 pl-4">List of datasets</p> + <p *ngIf="getNbDatasetByFamily(datasetFamilyList[0].id) === 1" class="border-bottom bg-light text-primary py-4 pl-4">Dataset</p> + <p *ngIf="getNbDatasetByFamily(datasetFamilyList[0].id) > 1" class="border-bottom bg-light text-primary py-4 pl-4">List of datasets</p> <ul class="p-0"> <li *ngFor="let dataset of getDatasetListByFamily(datasetFamilyList[0].id); last as isLast" class="list-unstyled px-3 pt-3 pb-0"> diff --git a/src/app/search/components/dataset/dataset-tabs.component.spec.ts b/src/app/search/components/dataset/dataset-tabs.component.spec.ts index c5e5269f231fae68e128975a3d501d4ee62097f3..8b805b83179af0e886c6ca9d28ce2981e45a44d2 100644 --- a/src/app/search/components/dataset/dataset-tabs.component.spec.ts +++ b/src/app/search/components/dataset/dataset-tabs.component.spec.ts @@ -60,9 +60,8 @@ describe('[Search][Dataset] Component: DatasetTabsComponent', () => { expect(testedComponent).toBeTruthy(); }); - it('#getNbDatasetByFamily() should return the number of dataset for the only one dataset family', () => { - testedComponent.datasetFamilyList = [DATASET_FAMILY_LIST.find(f => f.id === 1)]; - expect(testedComponent.getNbDatasetByFamily()).toBe(1); + it('#getNbDatasetByFamily() should return the number of dataset for the given dataset family', () => { + expect(testedComponent.getNbDatasetByFamily(1)).toBe(1); }); it('#getDatasetListByFamily(idFamily) should filter datasets by idFamily', () => { diff --git a/src/app/search/components/dataset/dataset-tabs.component.ts b/src/app/search/components/dataset/dataset-tabs.component.ts index 35d0f685411b15e92924d2ee08c0412559d2fb25..f95b608d9de087d849df6fef27f1b74a7cc73540 100644 --- a/src/app/search/components/dataset/dataset-tabs.component.ts +++ b/src/app/search/components/dataset/dataset-tabs.component.ts @@ -10,6 +10,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; import { Project, Dataset, Family } from '../../../metamodel/model'; +import { sortByDisplay } from '../../../shared/utils'; @Component({ selector: 'app-dataset-tabs', @@ -17,10 +18,19 @@ import { Project, Dataset, Family } from '../../../metamodel/model'; styleUrls: ['dataset-tabs.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search dataset tabs component. + */ export class DatasetTabsComponent { @Input() projectList: Project[]; @Input() datasetList: Dataset[]; @Input() datasetFamilyList: Family[]; + /** + * Emits event to select automatically dataset if none selected and only one in dataset list. + * + * @param {string} datasetSelected - The selected dataset name. + */ @Input() set datasetSelected(datasetSelected: string) { this.dnameSelected = datasetSelected; @@ -32,16 +42,37 @@ export class DatasetTabsComponent { dnameSelected: string; - getNbDatasetByFamily(): number { - return this.getDatasetListByFamily(this.datasetFamilyList[0].id).length; + /** + * Returns number of datasets for the given dataset family ID. + * + * @param {number} idFamily - The dataset family ID. + * + * @return number + */ + getNbDatasetByFamily(idFamily: number): number { + return this.getDatasetListByFamily(idFamily).length; } + /** + * Returns dataset list sorted by display, for the given dataset family ID. + * + * @param {number} idFamily - The dataset family ID. + * + * @return Dataset[] + */ getDatasetListByFamily(idFamily: number): Dataset[] { return this.datasetList .filter(d => d.id_dataset_family === idFamily) - .sort((a, b) => a.display - b.display); + .sort(sortByDisplay); } + /** + * Returns project for the given dataset. + * + * @param {Dataset} dataset - The dataset. + * + * @return Project + */ getProject(dataset: Dataset): Project { return this.projectList.find(project => project.name === dataset.project_name); } diff --git a/src/app/search/components/output/output-by-category.component.ts b/src/app/search/components/output/output-by-category.component.ts index b3cfd5873fd8f8c193b09bc4293350569088a414..551f272e51484056b39d68b9a7da0357ab9e1535 100644 --- a/src/app/search/components/output/output-by-category.component.ts +++ b/src/app/search/components/output/output-by-category.component.ts @@ -17,6 +17,10 @@ import { Attribute } from '../../../metamodel/model'; styleUrls: ['output-by-category.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search output by category component. + */ export class OutputByCategoryComponent { @Input() categoryLabel: string; @Input() attributeList: Attribute[]; @@ -25,16 +29,34 @@ export class OutputByCategoryComponent { @Input() isAllUnselected: boolean; @Output() change: EventEmitter<number[]> = new EventEmitter(); - - getAttributeListSortedByDisplay() { + /** + * Returns output list sorted by output display. + * + * @return Attribute[] + */ + getAttributeListSortedByDisplay(): Attribute[] { return this.attributeList .sort((a, b) => a.output_display - b.output_display); } - isSelected(id: number) { + /** + * Checks if the given output ID is selected. + * + * @param {number} id - The output ID. + * + * @return boolean + */ + isSelected(id: number): boolean { return this.outputList.filter(i => i === id).length > 0; } + /** + * Toggles output selection for the given attribute ID and emits updated output list. + * + * @param {number} attributeId - The attribute ID. + * + * @fires EventEmitter<number[]> + */ toggleSelection(attributeId: number): void { const clonedOutputList = [...this.outputList]; const index = clonedOutputList.indexOf(attributeId); @@ -46,6 +68,11 @@ export class OutputByCategoryComponent { this.change.emit(clonedOutputList); } + /** + * Selects all attributes and emits updated output list. + * + * @fires EventEmitter<number[]> + */ selectAll(): void { const clonedOutputList = [...this.outputList]; const attributeListId = this.attributeList.map(a => a.id); @@ -55,6 +82,11 @@ export class OutputByCategoryComponent { this.change.emit(clonedOutputList); } + /** + * Unselects all attributes and emits updated output list. + * + * @fires EventEmitter<number[]> + */ unselectAll(): void { const clonedOutputList = [...this.outputList]; const attributeListId = this.attributeList.map(a => a.id); diff --git a/src/app/search/components/output/output-by-family.component.ts b/src/app/search/components/output/output-by-family.component.ts index 0721c97ec3aa16af821f73a1d6e1991d0ff81b9f..cb89e339fc6352abc130df5a516e1015eeec675d 100644 --- a/src/app/search/components/output/output-by-family.component.ts +++ b/src/app/search/components/output/output-by-family.component.ts @@ -17,6 +17,10 @@ import { sortByDisplay } from '../../../shared/utils'; templateUrl: 'output-by-family.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search output by family component. + */ export class OutputByFamilyComponent { @Input() outputFamily: Family; @Input() categoryList: Category[]; @@ -24,29 +28,64 @@ export class OutputByFamilyComponent { @Input() outputList: number[]; @Output() change: EventEmitter<number[]> = new EventEmitter(); + /** + * Returns category list sorted by display, for the given output family ID. + * + * @param {number} idFamily - The output family ID. + * + * @return Category[] + */ getCategoryByFamilySortedByDisplay(idFamily: number): Category[] { return this.categoryList .filter(category => category.id_output_family === idFamily) .sort(sortByDisplay); } + /** + * Returns output list that belongs to the given category ID. + * + * @param {number} idCategory - The output category ID. + * + * @return Attribute[] + */ getAttributeByCategory(idCategory: number): Attribute[] { return this.attributeList .filter(attribute => attribute.id_output_category === idCategory); } + /** + * Checks if all outputs for the given category ID are selected. + * + * @param {number} idCategory - The output category ID. + * + * @return boolean + */ getIsAllSelected(idCategory: number): boolean { const attributeListId = this.getAttributeByCategory(idCategory).map(a => a.id); const filteredOutputList = this.outputList.filter(id => attributeListId.indexOf(id) > -1); return attributeListId.length === filteredOutputList.length; } + /** + * Checks if all outputs for the given category ID are unselected. + * + * @param {number} idCategory - The output category ID. + * + * @return boolean + */ getIsAllUnselected(idCategory: number): boolean { const attributeListId = this.getAttributeByCategory(idCategory).map(a => a.id); const filteredOutputList = this.outputList.filter(id => attributeListId.indexOf(id) > -1); return filteredOutputList.length === 0; } + /** + * Emits update output list event with updated sorted output list given. + * + * @param {number[]} clonedOutputList - The updated output list. + * + * @fires EventEmitter<number[]> + */ emitChange(clonedOutputList: number[]): void { this.change.emit( this.attributeList diff --git a/src/app/search/components/output/output-tabs.component.ts b/src/app/search/components/output/output-tabs.component.ts index e6265bcfcada74fd6fd0ae50728921ed67c125ea..54c87f9583f1e2e928fb53f46063048d0d56bd6a 100644 --- a/src/app/search/components/output/output-tabs.component.ts +++ b/src/app/search/components/output/output-tabs.component.ts @@ -18,12 +18,22 @@ import { Family, Category, Attribute } from '../../../metamodel/model'; templateUrl: 'output-tabs.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search output tab component. + */ export class OutputTabsComponent { @Input() outputFamilyList: Family[]; @Input() categoryList: Category[]; @Input() attributeList: Attribute[]; @Input() outputList: number[]; - @Input() set outputListEmpty(outputListEmpty: boolean) { + /** + * Displays output list empty warning notifications. + * + * @param {boolean} outputListEmpty - Is output list empty. + */ + @Input() + set outputListEmpty(outputListEmpty: boolean) { if (outputListEmpty) { this.toastr.warning('At least 1 output is required!'); } diff --git a/src/app/search/components/progress-bar.component.ts b/src/app/search/components/progress-bar.component.ts index e8c3672a02727f5523ef15ad28929155989f2d37..0429fd53f8e2082208dfc296760f4b4b69b6fe84 100644 --- a/src/app/search/components/progress-bar.component.ts +++ b/src/app/search/components/progress-bar.component.ts @@ -17,6 +17,10 @@ import { SearchQueryParams } from '../store/model'; styleUrls: ['progress-bar.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search progress bar component. + */ export class ProgressBarComponent { @Input() currentStep: string; @Input() datasetName: string; @@ -26,6 +30,11 @@ export class ProgressBarComponent { @Input() queryParams: SearchQueryParams; @Input() outputListEmpty: boolean; + /** + * Returns step class that match to the current step. + * + * @return string + */ getStepClass(): string { switch (this.currentStep) { case 'dataset': diff --git a/src/app/search/components/result/datatable-tab.component.ts b/src/app/search/components/result/datatable-tab.component.ts index 74e880218f34363b4c1db3318548879fffa7f753..81df08a2b1026c463e2fa9fc8754779b84e99aaa 100644 --- a/src/app/search/components/result/datatable-tab.component.ts +++ b/src/app/search/components/result/datatable-tab.component.ts @@ -12,20 +12,29 @@ import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from import { Attribute, Dataset } from '../../../metamodel/model'; import { Pagination, PaginationOrder } from '../../../shared/datatable/model'; - @Component({ selector: 'app-datatable-tab', templateUrl: 'datatable-tab.component.html', styleUrls: ['datatable-tab.component.css'], changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search result datatable tab component. + */ export class DatatableTabComponent { @Input() datasetName: string; @Input() datasetList: Dataset[]; @Input() datasetAttributeList: Attribute[]; @Input() outputList: number[]; @Input() searchData: any[]; - @Input() set dataLengthIsLoaded(dataLengthIsLoaded: boolean) { + /** + * Emits event to get data when result count is loaded. + * + * @param {boolean} dataLengthIsLoaded - Is result count loaded. + */ + @Input() + set dataLengthIsLoaded(dataLengthIsLoaded: boolean) { this._dataLengthIsLoaded = dataLengthIsLoaded; if (dataLengthIsLoaded) { const pagination: Pagination = { @@ -50,6 +59,11 @@ export class DatatableTabComponent { _dataLengthIsLoaded: boolean = false; + /** + * Checks if datatable accordion should be open. + * + * @return boolean + */ isDatatableOpened(): boolean { const config = this.getDataset().config; if (config !== null && 'opened_datatable' in config) { @@ -58,6 +72,11 @@ export class DatatableTabComponent { return false; } + /** + * Returns selected dataset for the search. + * + * @return Dataset + */ getDataset(): Dataset { return this.datasetList.find(dataset => dataset.name === this.datasetName); } diff --git a/src/app/search/components/result/download.component.ts b/src/app/search/components/result/download.component.ts index 2e8c02b20450914c523d01329531be9f19371d20..4e7e52852b28273001fe93e84eee825e49c78390 100644 --- a/src/app/search/components/result/download.component.ts +++ b/src/app/search/components/result/download.component.ts @@ -19,6 +19,12 @@ import { ConeSearch } from '../../../shared/cone-search/store/model'; templateUrl: 'download.component.html', styleUrls: ['download.component.css'] }) +/** + * @class + * @classdesc Search result download component. + * + * @implements OnInit + */ export class DownloadComponent implements OnInit { @Input() datasetName: string; @Input() datasetList: Dataset[]; @@ -34,6 +40,13 @@ export class DownloadComponent implements OnInit { this.getDataLength.emit(); } + /** + * Checks if the download format is allowed by Anis Admin configuration. + * + * @param {string} format - The file format to download. + * + * @return boolean + */ getConfigDownloadResultFormat(format: string): boolean { const dataset = this.datasetList.find(dataset => dataset.name === this.datasetName); if (dataset.config && dataset.config.download_results_format && dataset.config.download_results_format[format]) { @@ -42,6 +55,13 @@ export class DownloadComponent implements OnInit { return false; } + /** + * Returns URL to download file for the given format. + * + * @param {string} format - The file format to download. + * + * @return string + */ getUrl(format: string): string { let query: string = host() + '/search/' + this.datasetName + '?a=' + this.outputList.join(';'); if (this.criteriaList.length > 0) { diff --git a/src/app/search/components/result/reminder.component.ts b/src/app/search/components/result/reminder.component.ts index 9eda4a5085fd624d757a4085a79c90cefeefb141..defb4021a1b452d5d46d9be5c2651c0e79f6ea35 100644 --- a/src/app/search/components/result/reminder.component.ts +++ b/src/app/search/components/result/reminder.component.ts @@ -19,6 +19,10 @@ import { ConeSearch } from '../../../shared/cone-search/store/model'; templateUrl: 'reminder.component.html', styleUrls: ['reminder.component.css'] }) +/** + * @class + * @classdesc Search result reminder component. + */ export class ReminderComponent { @Input() datasetAttributeList: Attribute[]; @Input() dataLengthIsLoaded:boolean; @@ -30,6 +34,11 @@ export class ReminderComponent { @Input() categoryList: Category[]; @Input() outputList: number[]; + /** + * Returns total of added criteria. + * + * @return number + */ nbCriteria(): number { if (this.isConeSearchAdded) { return this.criteriaList.length + 1; @@ -37,33 +46,68 @@ export class ReminderComponent { return this.criteriaList.length; } + /** + * Returns criteria list for the given criteria family ID. + * + * @param {number} idFamily - The criteria family ID. + * + * @return Criterion[] + */ criteriaByFamily(idFamily: number): Criterion[] { const attributeListByFamily: Attribute[] = this.datasetAttributeList .filter(attribute => attribute.id_criteria_family === idFamily); return this.criteriaList - .filter(criterion => attributeListByFamily - .includes(this.datasetAttributeList.find(attribute => attribute.id === criterion.id)) + .filter(criterion => attributeListByFamily.includes( + this.datasetAttributeList.find(attribute => attribute.id === criterion.id)) ); } - + + /** + * Returns attribute for the given attribute ID. + * + * @param {number} id - The attribute ID. + * + * @return Attribute + */ getAttribute(id: number): Attribute { return this.datasetAttributeList.find(attribute => attribute.id === id); } + /** + * Returns criterion pretty printed. + * + * @param {Criterion} criterion - The criterion. + * + * @return string + */ printCriterion(criterion: Criterion): string { return print(criterion); } + /** + * Returns category list for the given criteria family ID. + * + * @param {number} idFamily - The criteria family ID. + * + * @return Category[] + */ categoryListByFamily(idFamily: number): Category[] { return this.categoryList.filter(category => category.id_output_family === idFamily); } + /** + * Returns output list for the given category ID. + * + * @param {number} idCategory - The output category ID. + * + * @return number[] + */ outputListByCategory(idCategory: number): number[] { const attributeListByCategory: Attribute[] = this.datasetAttributeList .filter(attribute => attribute.id_output_category === idCategory); return this.outputList - .filter(output => attributeListByCategory - .includes(this.datasetAttributeList.find(attribute => attribute.id === output)) + .filter(output => attributeListByCategory.includes( + this.datasetAttributeList.find(attribute => attribute.id === output)) ); } } diff --git a/src/app/search/components/result/url-display.component.ts b/src/app/search/components/result/url-display.component.ts index 66fa6dc275e4d1d600c3b8912e522a6eb81eeeb3..10ea089523ad763644d115bc41fbca714e5b386e 100644 --- a/src/app/search/components/result/url-display.component.ts +++ b/src/app/search/components/result/url-display.component.ts @@ -21,6 +21,10 @@ import { ConeSearch } from '../../../shared/cone-search/store/model'; templateUrl: 'url-display.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) +/** + * @class + * @classdesc Search result URL display component. + */ export class UrlDisplaySectionComponent { @Input() datasetList: Dataset[]; @Input() dataLengthIsLoaded: boolean; @@ -32,6 +36,11 @@ export class UrlDisplaySectionComponent { constructor(private toastr: ToastrService) { } + /** + * Checks if URL display is enabled. + * + * @return boolean + */ urlDisplayEnabled(): boolean { const config = this.datasetList.find(d => d.name === this.datasetName).config; if (config !== null && 'results_server_link' in config) { @@ -40,6 +49,11 @@ export class UrlDisplaySectionComponent { return false; } + /** + * Returns API URL to get data with user parameters. + * + * @return string + */ getUrl(): string { let query: string = host() + '/search/' + this.datasetName + '?a=' + this.outputList.join(';'); if (this.criteriaList.length > 0) { @@ -51,6 +65,9 @@ export class UrlDisplaySectionComponent { return query; } + /** + * Copies API URL to user clipboard. + */ copyToClipboard(): void { const selBox = document.createElement('textarea'); selBox.value = this.getUrl(); diff --git a/src/app/search/components/summary.component.ts b/src/app/search/components/summary.component.ts index 75cd49a6f05fa4ce1a29f15573cb0be42b0b7e47..a64e53f1b2d4741eb0456f94d59251cbc4a31d66 100644 --- a/src/app/search/components/summary.component.ts +++ b/src/app/search/components/summary.component.ts @@ -11,7 +11,7 @@ import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@a import { Criterion, SearchQueryParams } from '../store/model'; import { Attribute, Category, Dataset, Family } from '../../metamodel/model'; -import { printCriterion as print } from '../../shared/utils' +import { printCriterion as print, sortByDisplay } from '../../shared/utils' import { ConeSearch } from '../../shared/cone-search/store/model'; @Component({ @@ -21,6 +21,10 @@ import { ConeSearch } from '../../shared/cone-search/store/model'; changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None }) +/** + * @class + * @classdesc Search summary component. + */ export class SummaryComponent { @Input() currentStep: string; @Input() datasetName: string; @@ -38,10 +42,20 @@ export class SummaryComponent { accordionFamilyIsOpen = true; + /** + * Returns dataset selected for the search. + * + * @return Dataset + */ getDataset(): Dataset { return this.datasetList.find(dataset => dataset.name === this.datasetName); } + /** + * Checks if there is no criteria added to the search. + * + * @return boolean + */ noCriteria(): boolean { if (this.isConeSearchAdded || this.criteriaList.length > 0) { return false @@ -49,20 +63,48 @@ export class SummaryComponent { return true; } + /** + * Returns attribute for the given attribute ID. + * + * @param {number} id - The attribute ID. + * + * @return Dataset[] + */ getAttribute(id: number): Attribute { return this.attributeList.find(attribute => attribute.id === id); } - printCriterion(criterion: Criterion) { + /** + * Returns pretty print of the given criterion. + * + * @param {Criterion} criterion - The criterion. + * + * @return string + */ + printCriterion(criterion: Criterion): string { return print(criterion); } + /** + * Returns category list sorted by display, for the given output family ID. + * + * @param {number} idFamily - The family ID. + * + * @return Category[] + */ getCategoryByFamilySortedByDisplay(idFamily: number): Category[] { return this.categoryList .filter(category => category.id_output_family === idFamily) - .sort((a, b) => a.display - b.display); + .sort(sortByDisplay); } + /** + * Returns output list sorted by display, that belongs to the given category ID. + * + * @param {number} idCategory - The category ID. + * + * @return Attribute[] + */ getSelectedOutputByCategory(idCategory: number): Attribute[] { const outputListByCategory = this.attributeList.filter(attribute => attribute.id_output_category === idCategory); return outputListByCategory diff --git a/src/app/search/containers/criteria.component.ts b/src/app/search/containers/criteria.component.ts index 985bd72e0933e5eed933d85d47d8f640d4e3e776..88bca42c36cfa37f5ff7351d20724d882aaa9399 100644 --- a/src/app/search/containers/criteria.component.ts +++ b/src/app/search/containers/criteria.component.ts @@ -24,6 +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 { search: fromSearch.State; metamodel: fromMetamodel.State; @@ -33,6 +38,12 @@ interface StoreState { selector: 'app-criteria', templateUrl: 'criteria.component.html' }) +/** + * @class + * @classdesc Search criteria container. + * + * @implements OnInit + */ export class CriteriaComponent implements OnInit { public criteriaSearchMetaIsLoading: Observable<boolean>; public criteriaSearchMetaIsLoaded: Observable<boolean>; @@ -90,14 +101,29 @@ export class CriteriaComponent implements OnInit { }); } + /** + * Dispatches action to toggle cone search added status. + * + * @param {boolean} coneSearchAdded - Is cone search added. + */ coneSearchAdded(coneSearchAdded: boolean): void { this.store.dispatch(new searchActions.IsConeSearchAddedAction(coneSearchAdded)); } + /** + * Dispatches action to add the given criterion to the search. + * + * @param {Criterion} criterion - The criterion. + */ addCriterion(criterion: Criterion): void { this.store.dispatch(new searchActions.AddCriterionAction(criterion)); } + /** + * Dispatches action to remove the given criterion ID to the search. + * + * @param {number} id - The criterion ID. + */ deleteCriterion(id: number): void { this.store.dispatch(new searchActions.DeleteCriterionAction(id)); } diff --git a/src/app/search/containers/dataset.component.ts b/src/app/search/containers/dataset.component.ts index dd5b5d5210b7b8e710317c8b719b86411bd7706e..725ad2007a26b5a3360d55e03620a264cb70a209 100644 --- a/src/app/search/containers/dataset.component.ts +++ b/src/app/search/containers/dataset.component.ts @@ -27,6 +27,11 @@ import * as metamodelSelector from '../../metamodel/selectors'; import { Project, Family, Dataset, Attribute, Category } from '../../metamodel/model'; import { ScrollTopService } from '../../shared/service/sroll-top.service'; +/** + * Interface for store state. + * + * @interface StoreState + */ interface StoreState { auth: fromAuth.State; metamodel: fromMetamodel.State; @@ -37,6 +42,12 @@ interface StoreState { selector: 'app-dataset', templateUrl: 'dataset.component.html' }) +/** + * @class + * @classdesc Search dataset container. + * + * @implements OnInit + */ export class DatasetComponent implements OnInit { public isUserAuthenticated: Observable<boolean>; public datasetSearchMetaIsLoading: Observable<boolean>; @@ -83,6 +94,15 @@ export class DatasetComponent implements OnInit { this.scrollTopService.setScrollTop(); } + /** + * Dispatches actions to: + * - launch new search with the given dataset name. + * - retrieve dataset attribute list. + * - retrieve criteria metadata. + * - retrieve output metadata. + * + * @param {string} datasetName - The dataset name. + */ selectDataset(datasetName: string): void { // Create a micro tasks that is processed after the current synchronous code // This micro task prevent the expression has changed after it was checked diff --git a/src/app/search/containers/output.component.ts b/src/app/search/containers/output.component.ts index 3c215ba6e011923fa7b30b361bb4f8edb05065ce..57fd1941fd649b5551139a70361038526f963a5e 100644 --- a/src/app/search/containers/output.component.ts +++ b/src/app/search/containers/output.component.ts @@ -24,6 +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 { search: fromSearch.State; metamodel: fromMetamodel.State; @@ -34,6 +39,12 @@ interface StoreState { templateUrl: 'output.component.html', styleUrls: ['output.component.css'] }) +/** + * @class + * @classdesc Search output container. + * + * @implements OnInit + */ export class OutputComponent implements OnInit { public outputSearchMetaIsLoading: Observable<boolean>; public outputSearchMetaIsLoaded: Observable<boolean>; @@ -91,6 +102,11 @@ export class OutputComponent implements OnInit { }); } + /** + * Dispatches action to update output list selection with the given updated output list. + * + * @param {number[]} outputList - The updated output list. + */ updateOutputList(outputList: number[]): void { this.store.dispatch(new searchActions.UpdateOutputListAction(outputList)); } diff --git a/src/app/search/containers/result.component.ts b/src/app/search/containers/result.component.ts index b09d153eed22842c1ce118ee3e34a744808ecedc..be31b07830813ce8679bf2020a9b62fe6e7f8b78 100644 --- a/src/app/search/containers/result.component.ts +++ b/src/app/search/containers/result.component.ts @@ -25,6 +25,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 { search: fromSearch.State; metamodel: fromMetamodel.State; @@ -34,6 +39,13 @@ interface StoreState { selector: 'app-result', templateUrl: 'result.component.html' }) +/** + * @class + * @classdesc Search result container. + * + * @implements OnInit + * @implements OnDestroy + */ export class ResultComponent implements OnInit, OnDestroy { public datasetSearchMetaIsLoading: Observable<boolean>; public datasetSearchMetaIsLoaded: Observable<boolean>; @@ -99,26 +111,52 @@ export class ResultComponent implements OnInit, OnDestroy { }); } + /** + * Dispatches action to retrieve result number. + */ getDataLength(): void { this.store.dispatch(new searchActions.GetDataLengthAction()); } + /** + * Dispatches action to retrieve data with the given pagination. + * + * @param {Pagination} params - The pagination parameters. + */ getSearchData(params: Pagination): void { this.store.dispatch(new searchActions.RetrieveDataAction(params)); } + /** + * Dispatches action to add the given data ID to the selected data. + * + * @param {number | string} data - The data ID to add to the data selection. + */ addSearchData(data: number | string): void { this.store.dispatch(new searchActions.AddSelectedDataAction(data)); } + /** + * Dispatches action to remove the given data ID to the selected data. + * + * @param {number | string} data - The data ID to remove to the data selection. + */ deleteSearchData(data: number | string): void { this.store.dispatch(new searchActions.DeleteSelectedDataAction(data)); } + /** + * Dispatches action to execute the given process. + * + * @param {string} typeProcess - The data ID to add to the data selection. + */ executeProcess(typeProcess: string): void { this.store.dispatch(new searchActions.ExecuteProcessAction(typeProcess)); } + /** + * Dispatches action to destroy search results. + */ ngOnDestroy() { this.store.dispatch(new searchActions.DestroyResultsAction()); } diff --git a/src/app/search/containers/search.component.ts b/src/app/search/containers/search.component.ts index 7d4e7a97400e364ab3819106f7bb588e6ea8b6f7..e9f36fe99a99c862689009d5ca187f9d4e08df19 100644 --- a/src/app/search/containers/search.component.ts +++ b/src/app/search/containers/search.component.ts @@ -22,6 +22,10 @@ import * as coneSearchActions from '../../shared/cone-search/store/cone-search.a selector: 'app-search', templateUrl: 'search.component.html' }) +/** + * @class + * @classdesc Search container. + */ export class SearchComponent { public currentStep: Observable<string>; public datasetName: Observable<string>; diff --git a/src/app/search/store/model/between-criterion.model.ts b/src/app/search/store/model/between-criterion.model.ts index 2f6bfad355d41098a8857f7021b38c544fe3c917..4fc29159ff23c3af4def99b06aae0c3f84eb4043 100644 --- a/src/app/search/store/model/between-criterion.model.ts +++ b/src/app/search/store/model/between-criterion.model.ts @@ -9,6 +9,12 @@ import { Criterion } from './criterion.model'; +/** + * @class + * @classdesc Between criterion class. + * + * @implements Criterion + */ export class BetweenCriterion implements Criterion { id: number; type: string; diff --git a/src/app/search/store/model/criterion.model.ts b/src/app/search/store/model/criterion.model.ts index 3ea27feee04881ca36b5f257989045a72f1ce5df..e074f1896fa7c7209ad9b658a03feac60e0dd49f 100644 --- a/src/app/search/store/model/criterion.model.ts +++ b/src/app/search/store/model/criterion.model.ts @@ -7,6 +7,10 @@ * file that was distributed with this source code. */ +/** + * @class + * @classdesc Criterion class. + */ export interface Criterion { id: number; type: string; diff --git a/src/app/search/store/model/field-criterion.model.ts b/src/app/search/store/model/field-criterion.model.ts index 3779f8154dd62fc52198e84c95c750473886755d..0b9b906ae5571f6a590259762857a5b94c881288 100644 --- a/src/app/search/store/model/field-criterion.model.ts +++ b/src/app/search/store/model/field-criterion.model.ts @@ -9,6 +9,12 @@ import { Criterion } from './criterion.model'; +/** + * @class + * @classdesc Field criterion class. + * + * @implements Criterion + */ export class FieldCriterion implements Criterion { id: number; type: string; diff --git a/src/app/search/store/model/json-criterion.model.ts b/src/app/search/store/model/json-criterion.model.ts index f37a49ac7b7d4bbc61516811c33152a2544a9f94..dde8b00e472da30c3850aad5a4f2a5a01bfb4240 100644 --- a/src/app/search/store/model/json-criterion.model.ts +++ b/src/app/search/store/model/json-criterion.model.ts @@ -9,6 +9,12 @@ import { Criterion } from './criterion.model'; +/** + * @class + * @classdesc JSON criterion class. + * + * @implements Criterion + */ export class JsonCriterion implements Criterion { id: number; type: string; diff --git a/src/app/search/store/model/list-criterion.model.ts b/src/app/search/store/model/list-criterion.model.ts index 088b0e2153fa36ccf9958a9f4d83f7458b9b3c56..471690d14441fffcb0e8a14e3c030da746a77a0c 100644 --- a/src/app/search/store/model/list-criterion.model.ts +++ b/src/app/search/store/model/list-criterion.model.ts @@ -9,6 +9,12 @@ import { Criterion } from './criterion.model'; +/** + * @class + * @classdesc List criterion class. + * + * @implements Criterion + */ export class ListCriterion implements Criterion { id: number; type: string; diff --git a/src/app/search/store/model/search-query-params.model.ts b/src/app/search/store/model/search-query-params.model.ts index 7daf538cbcf45964317e2e3a29f4784194261235..b413a4a4575e79a6bd085c70f117932bb0a6b7bf 100644 --- a/src/app/search/store/model/search-query-params.model.ts +++ b/src/app/search/store/model/search-query-params.model.ts @@ -7,6 +7,11 @@ * file that was distributed with this source code. */ +/** + * Interface for search query parameters. + * + * @interface SearchQueryParams + */ export interface SearchQueryParams { s: string; a: string; diff --git a/src/app/search/store/model/select-multiple-criterion.model.ts b/src/app/search/store/model/select-multiple-criterion.model.ts index a0cc59157f822cca89554e40026e988874213998..a3077e316f2f49bc420b19cea24bde5e46f6ab97 100644 --- a/src/app/search/store/model/select-multiple-criterion.model.ts +++ b/src/app/search/store/model/select-multiple-criterion.model.ts @@ -10,7 +10,13 @@ import { Criterion } from './criterion.model'; import { Option } from '../../../metamodel/model'; -export class SelectMultipleCriterion implements Criterion { +/** + * @class + * @classdesc Select multiple criterion class. + * + * @implements Criterion + */ +export class SelectMultipleCriterion implements Criterion { id: number; type: string; options: Option[]; diff --git a/src/app/search/store/search.action.ts b/src/app/search/store/search.action.ts index 22322d4800a5f3467157f7e1f12497c70ffb285a..ba78624ff8b2f14252dbce4332a2116dc94ccf82 100644 --- a/src/app/search/store/search.action.ts +++ b/src/app/search/store/search.action.ts @@ -12,6 +12,7 @@ import { Action } from '@ngrx/store'; import { Criterion } from './model'; import { Pagination } from '../../shared/datatable/model'; + export const INIT_SEARCH_BY_URL = '[Search] Init Search By Url'; export const CHANGE_STEP = '[Search] Change Search Step'; export const SELECT_DATASET = '[Search] Select Dataset'; @@ -39,157 +40,286 @@ export const EXECUTE_PROCESS_FAIL = '[Search] Execute Process Fail'; export const DESTROY_RESULTS = '[Search] Destroy Results'; export const RESET_SEARCH = '[Search] Reset Search'; - +/** + * @class + * @classdesc InitSearchByUrl action. + * @readonly + */ export class InitSearchByUrl implements Action { readonly type = INIT_SEARCH_BY_URL; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc ChangeStepAction action. + * @readonly + */ export class ChangeStepAction implements Action { readonly type = CHANGE_STEP; constructor(public payload: string) { } } +/** + * @class + * @classdesc SelectDatasetAction action. + * @readonly + */ export class SelectDatasetAction implements Action { readonly type = SELECT_DATASET; constructor(public payload: string) { } } +/** + * @class + * @classdesc NewSearchAction action. + * @readonly + */ export class NewSearchAction implements Action { readonly type = NEW_SEARCH; constructor(public payload: string) { } } +/** + * @class + * @classdesc CriteriaChecked action. + * @readonly + */ export class CriteriaChecked implements Action { readonly type = CRITERIA_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc OutputChecked action. + * @readonly + */ export class OutputChecked implements Action { readonly type = OUTPUT_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc ResultChecked action. + * @readonly + */ export class ResultChecked implements Action { readonly type = RESULT_CHECKED; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc IsConeSearchAddedAction action. + * @readonly + */ export class IsConeSearchAddedAction implements Action { readonly type = IS_CONE_SEARCH_ADDED; constructor(public payload: boolean) { } } +/** + * @class + * @classdesc UpdateCriteriaListAction action. + * @readonly + */ export class UpdateCriteriaListAction implements Action { readonly type = UPDATE_CRITERIA_LIST; constructor(public payload: Criterion[]) { } } +/** + * @class + * @classdesc AddCriterionAction action. + * @readonly + */ export class AddCriterionAction implements Action { readonly type = ADD_CRITERION; constructor(public payload: Criterion) { } } +/** + * @class + * @classdesc DeleteCriterionAction action. + * @readonly + */ export class DeleteCriterionAction implements Action { readonly type = DELETE_CRITERION; constructor(public payload: number) { } } +/** + * @class + * @classdesc UpdateOutputListAction action. + * @readonly + */ export class UpdateOutputListAction implements Action { readonly type = UPDATE_OUTPUT_LIST; constructor(public payload: number[]) { } } +/** + * @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: any[]) { } } +/** + * @class + * @classdesc RetrieveDataFailAction action. + * @readonly + */ export class RetrieveDataFailAction implements Action { readonly type = RETRIEVE_DATA_FAIL; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc GetDataLengthAction action. + * @readonly + */ export class GetDataLengthAction implements Action { readonly type = GET_DATA_LENGTH; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc GetDataLengthSuccessAction action. + * @readonly + */ export class GetDataLengthSuccessAction implements Action { readonly type = GET_DATA_LENGTH_SUCCESS; constructor(public payload: number) { } } +/** + * @class + * @classdesc GetDataLengthFailAction action. + * @readonly + */ export class GetDataLengthFailAction implements Action { readonly type = GET_DATA_LENGTH_FAIL; constructor(public payload: {} = null) { } } +/** + * @class + * @classdesc AddSelectedDataAction action. + * @readonly + */ export class AddSelectedDataAction implements Action { readonly type = ADD_SELECTED_DATA; constructor(public payload: number | string) { } } +/** + * @class + * @classdesc DeleteSelectedDataAction action. + * @readonly + */ export class DeleteSelectedDataAction implements Action { readonly type = DELETE_SELECTED_DATA; constructor(public payload: number | string) { } } +/** + * @class + * @classdesc ExecuteProcessAction action. + * @readonly + */ export class ExecuteProcessAction implements Action { readonly type = EXECUTE_PROCESS; constructor(public payload: string) { } } +/** + * @class + * @classdesc ExecuteProcessWipAction action. + * @readonly + */ export class ExecuteProcessWipAction implements Action { readonly type = EXECUTE_PROCESS_WIP; constructor(public payload: string) { } } +/** + * @class + * @classdesc ExecuteProcessSuccessAction action. + * @readonly + */ export class ExecuteProcessSuccessAction implements Action { readonly type = EXECUTE_PROCESS_SUCCESS; constructor(public payload: any) { } } +/** + * @class + * @classdesc ExecuteProcessFailAction action. + * @readonly + */ export class ExecuteProcessFailAction implements Action { readonly type = EXECUTE_PROCESS_FAIL; constructor(public payload: {} = null) { } } +/** + * @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/store/search.effects.ts b/src/app/search/store/search.effects.ts index e4157218e43ecc030b74c7f2936ef526ffd98f9c..9c34fd835c4b2752315df50b5ced0eedc3c2a2d8 100644 --- a/src/app/search/store/search.effects.ts +++ b/src/app/search/store/search.effects.ts @@ -48,7 +48,10 @@ export class SearchEffects { coneSearch: fromConeSearch.State }> ) { } - + + /** + * Calls actions to fill store with data provided by the URL. + */ @Effect() initSearchByUrlAction$ = this.actions$.pipe( ofType(searchActions.INIT_SEARCH_BY_URL), @@ -78,6 +81,9 @@ export class SearchEffects { }) ); + /** + * Calls actions to reset search. + */ @Effect() newSearchAction$ = this.actions$.pipe( ofType(searchActions.NEW_SEARCH), @@ -87,6 +93,12 @@ export class SearchEffects { ]) ); + /** + * Calls actions when dataset attribute list is loaded to: + * - generate output list. + * - generate criteria list. + * - instantiate cone search. + */ @Effect() loadAttributeListSuccessAction$ = this.actions$.pipe( ofType(attributeActions.LOAD_ATTRIBUTE_LIST_SUCCESS), @@ -201,6 +213,9 @@ export class SearchEffects { }) ); + /** + * Calls actions to retrieve data with the user parameters. + */ @Effect() retrieveDataAction$ = this.actions$.pipe( ofType(searchActions.RETRIEVE_DATA), @@ -223,12 +238,18 @@ export class SearchEffects { }) ); + /** + * Displays retrieve data error notification. + */ @Effect({ dispatch: false }) retrieveDataFailAction$ = this.actions$.pipe( ofType(searchActions.RETRIEVE_DATA_FAIL), tap(_ => this.toastr.error('Loading Failed!', 'The search data loading failed')) ); + /** + * Calls actions to retrieve data count with the user parameters. + */ @Effect() getDataLengthAction$ = this.actions$.pipe( ofType(searchActions.GET_DATA_LENGTH), @@ -248,12 +269,18 @@ export class SearchEffects { }) ); + /** + * Displays retrieve data count error notification. + */ @Effect({ dispatch: false }) getDataLengthFailAction$ = this.actions$.pipe( ofType(searchActions.GET_DATA_LENGTH_FAIL), tap(_ => this.toastr.error('Loading Failed!', 'The data length loading failed')) ); + /** + * Calls actions to execute process with the user parameters. + */ @Effect() executeProcessAction$ = this.actions$.pipe( ofType(searchActions.EXECUTE_PROCESS), @@ -273,6 +300,9 @@ export class SearchEffects { }) ); + /** + * Checks if process execution is done. + */ @Effect() executeProcessWipAction$ = this.actions$.pipe( ofType(searchActions.EXECUTE_PROCESS_WIP), @@ -293,6 +323,9 @@ export class SearchEffects { }) ); + /** + * Displays process execution error notification. + */ @Effect({ dispatch: false }) executeProcessFailAction$ = this.actions$.pipe( ofType(searchActions.EXECUTE_PROCESS_FAIL),