From ffc8b95ff58bc77665316529f395d16dc8cd2da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr> Date: Tue, 13 Jul 2021 22:01:20 +0200 Subject: [PATCH] Edit dataset => WIP --- client/src/app/admin/admin-routing.module.ts | 3 + .../attribute/attribute-list.component.html | 25 ++++-- .../attribute/attribute-list.component.ts | 25 ++++-- .../dataset/edit-dataset.component.html | 44 +++++++++ .../dataset/edit-dataset.component.ts | 89 +++++++++++++++++++ .../dataset/new-dataset.component.html | 6 +- .../dataset/new-dataset.component.ts | 4 +- .../app/shared/pipes/dataset-by-name.pipe.ts | 19 ++++ client/src/app/shared/pipes/index.ts | 4 +- 9 files changed, 200 insertions(+), 19 deletions(-) create mode 100644 client/src/app/admin/containers/dataset/edit-dataset.component.html create mode 100644 client/src/app/admin/containers/dataset/edit-dataset.component.ts create mode 100644 client/src/app/shared/pipes/dataset-by-name.pipe.ts diff --git a/client/src/app/admin/admin-routing.module.ts b/client/src/app/admin/admin-routing.module.ts index 7c82c2aa..6fa41e51 100644 --- a/client/src/app/admin/admin-routing.module.ts +++ b/client/src/app/admin/admin-routing.module.ts @@ -19,6 +19,7 @@ import { GroupListComponent } from './containers/group/group-list.component'; import { NewGroupComponent } from './containers/group/new-group.component'; import { EditGroupComponent } from './containers/group/edit-group.component'; import { NewDatasetComponent } from './containers/dataset/new-dataset.component'; +import { EditDatasetComponent } from './containers/dataset/edit-dataset.component'; import { AttributeListComponent } from './containers/attribute/attribute-list.component'; import { SurveyListComponent } from './containers/survey/survey-list.component'; import { NewSurveyComponent } from './containers/survey/new-survey.component'; @@ -40,6 +41,7 @@ const routes: Routes = [ { path: 'configure-instance/:iname/new-group', component: NewGroupComponent }, { path: 'configure-instance/:iname/edit-group/:id', component: EditGroupComponent }, { path: 'configure-instance/:iname/new-dataset', component: NewDatasetComponent }, + { path: 'configure-instance/:iname/edit-dataset/:dname', component: EditDatasetComponent }, { path: 'configure-instance/:iname/configure-dataset/:dname', component: AttributeListComponent }, { path: 'survey-list', component: SurveyListComponent }, { path: 'new-survey', component: NewSurveyComponent }, @@ -69,6 +71,7 @@ export const routedComponents = [ NewGroupComponent, EditGroupComponent, NewDatasetComponent, + EditDatasetComponent, AttributeListComponent, SurveyListComponent, NewSurveyComponent, diff --git a/client/src/app/admin/containers/attribute/attribute-list.component.html b/client/src/app/admin/containers/attribute/attribute-list.component.html index e9851583..4f05b006 100644 --- a/client/src/app/admin/containers/attribute/attribute-list.component.html +++ b/client/src/app/admin/containers/attribute/attribute-list.component.html @@ -15,9 +15,20 @@ </ol> </nav> - <app-spinner *ngIf="(attributeListIsLoading | async) || (datasetListIsLoading | async)"></app-spinner> + <app-spinner *ngIf="(attributeListIsLoading | async) + || (datasetListIsLoading | async) + || (criteriaFamilyListIsLoading | async) + || (outputFamilyListIsLoading | async) + || (outputCategoryListIsLoading | async) + || (selectOptionListIsLoading | async)"> + </app-spinner> - <div *ngIf="(attributeListIsLoaded | async) && (datasetListIsLoaded | async)" class="row mt-1"> + <div *ngIf="(attributeListIsLoaded | async) + && (datasetListIsLoaded | async) + && (criteriaFamilyListIsLoaded | async) + && (outputFamilyListIsLoaded | async) + && (outputCategoryListIsLoaded | async) + && (selectOptionListIsLoaded | async)" class="row mt-1"> <div class="col-12"> <app-add-attribute [columnList]="columnList | async" @@ -71,7 +82,7 @@ <tr *ngFor="let attribute of (attributeList | async)" design [attribute]="attribute" - [searchFlags]="settingsSelectOptionList | async | optionListBySelect:'search_flag'" + [searchFlags]="selectOptionList | async | optionListBySelect:'search_flag'" (save)="editAttribute($event)" (delete)="deleteAttribute($event)"> </tr> @@ -81,8 +92,8 @@ criteria [attribute]="attribute" [criteriaFamilyList]="criteriaFamilyList | async" - [searchTypeList]="settingsSelectOptionList | async | optionListBySelect:'search_type'" - [operatorList]="settingsSelectOptionList | async | optionListBySelect:'operator'" + [searchTypeList]="selectOptionList | async | optionListBySelect:'search_type'" + [operatorList]="selectOptionList | async | optionListBySelect:'operator'" [attributeDistinctList]="attributeDistinctList | async" [attributeDistinctListIsLoading]="attributeDistinctListIsLoading | async" [attributeDistinctListIsLoaded]="attributeDistinctListIsLoaded | async" @@ -102,7 +113,7 @@ <tr *ngFor="let attribute of (attributeList | async)" result [attribute]="attribute" - [rendererList]="settingsSelectOptionList | async | optionListBySelect:'renderer'" + [rendererList]="selectOptionList | async | optionListBySelect:'renderer'" (save)="editAttribute($event)"> </tr> </app-table-result> @@ -110,7 +121,7 @@ <tr *ngFor="let attribute of (attributeList | async)" detail [attribute]="attribute" - [rendererDetailList]="settingsSelectOptionList | async | optionListBySelect:'renderer_detail'" + [rendererDetailList]="selectOptionList | async | optionListBySelect:'renderer_detail'" (save)="editAttribute($event)"> </tr> </app-table-detail> diff --git a/client/src/app/admin/containers/attribute/attribute-list.component.ts b/client/src/app/admin/containers/attribute/attribute-list.component.ts index efd9fa76..3031acf7 100644 --- a/client/src/app/admin/containers/attribute/attribute-list.component.ts +++ b/client/src/app/admin/containers/attribute/attribute-list.component.ts @@ -14,7 +14,7 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Select, SelectOption, Dataset, Attribute, Column, CriteriaFamily, OutputCategory, OutputFamily } from 'src/app/metamodel/models'; +import { SelectOption, Dataset, Attribute, Column, CriteriaFamily, OutputCategory, OutputFamily } from 'src/app/metamodel/models'; import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector'; import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; @@ -27,7 +27,6 @@ import * as outputFamilySelector from 'src/app/metamodel/selectors/output-family import * as outputCategoryActions from 'src/app/metamodel/actions/output-category.actions'; import * as outputCategorySelector from 'src/app/metamodel/selectors/output-category.selector'; import * as selectActions from 'src/app/metamodel/actions/select.actions'; -import * as selectSelector from 'src/app/metamodel/selectors/select.selector'; import * as optionActions from 'src/app/metamodel/actions/select-option.actions'; import * as optionSelector from 'src/app/metamodel/selectors/select-option.selector'; import * as columnActions from 'src/app/metamodel/actions/column.actions'; @@ -51,16 +50,23 @@ export class AttributeListComponent implements OnInit { public attributeListIsLoading: Observable<boolean>; public attributeListIsLoaded: Observable<boolean>; public criteriaFamilyList: Observable<CriteriaFamily[]>; + public criteriaFamilyListIsLoading: Observable<boolean>; + public criteriaFamilyListIsLoaded: Observable<boolean>; public outputFamilyList: Observable<OutputFamily[]>; + public outputFamilyListIsLoading: Observable<boolean>; + public outputFamilyListIsLoaded: Observable<boolean>; public outputCategoryList: Observable<OutputCategory[]>; + public outputCategoryListIsLoading: Observable<boolean>; + public outputCategoryListIsLoaded: Observable<boolean>; + public selectOptionList: Observable<SelectOption[]>; + public selectOptionListIsLoading: Observable<boolean>; + public selectOptionListIsLoaded: Observable<boolean>; public columnList: Observable<Column[]>; public columnListIsLoading: Observable<boolean>; public columnListIsLoaded: Observable<boolean>; public attributeDistinctList: Observable<string[]>; public attributeDistinctListIsLoading: Observable<boolean>; public attributeDistinctListIsLoaded: Observable<boolean>; - public settingsSelectList: Observable<Select[]>; - public settingsSelectOptionList: Observable<SelectOption[]>; constructor(private store: Store<{ }>, private route: ActivatedRoute) { this.instanceSelected = store.select(instanceSelector.selectInstanceNameByRoute); @@ -72,16 +78,23 @@ export class AttributeListComponent implements OnInit { this.attributeListIsLoading = store.select(attributeSelector.selectAttributeListIsLoading); this.attributeListIsLoaded = store.select(attributeSelector.selectAttributeListIsLoaded); this.criteriaFamilyList = store.select(criteriaFamilySelector.selectAllCriteriaFamilies); + this.criteriaFamilyListIsLoading = store.select(criteriaFamilySelector.selectCriteriaFamilyListIsLoading); + this.criteriaFamilyListIsLoaded = store.select(criteriaFamilySelector.selectCriteriaFamilyListIsLoaded); this.outputFamilyList = store.select(outputFamilySelector.selectAllOutputFamilies); + this.outputFamilyListIsLoading = store.select(outputFamilySelector.selectOutputFamilyListIsLoading); + this.outputFamilyListIsLoaded = store.select(outputFamilySelector.selectOutputFamilyListIsLoaded); this.outputCategoryList = store.select(outputCategorySelector.selectAllOutputCategories); + this.outputCategoryListIsLoading = store.select(outputCategorySelector.selectOutputCategoryListIsLoading); + this.outputCategoryListIsLoaded = store.select(outputCategorySelector.selectOutputCategoryListIsLoaded); + this.selectOptionList = store.select(optionSelector.selectAllSelectOptions); + this.selectOptionListIsLoading = store.select(optionSelector.selectSelectOptionListIsLoading); + this.selectOptionListIsLoaded = store.select(optionSelector.selectSelectOptionListIsLoaded); this.columnList = store.select(columnSelector.selectAllColumns); this.columnListIsLoading = store.select(columnSelector.selectColumnListIsLoading); this.columnListIsLoaded = store.select(columnSelector.selectColumnListIsLoaded); this.attributeDistinctList = store.select(attributeDistinctSelector.selectAllAttributeDistincts); this.attributeDistinctListIsLoading = store.select(attributeDistinctSelector.selectAttributeDistinctListIsLoading); this.attributeDistinctListIsLoaded = store.select(attributeDistinctSelector.selectAttributeDistinctListIsLoaded); - this.settingsSelectList = store.select(selectSelector.selectAllSelects); - this.settingsSelectOptionList = store.select(optionSelector.selectAllSelectOptions); } ngOnInit() { diff --git a/client/src/app/admin/containers/dataset/edit-dataset.component.html b/client/src/app/admin/containers/dataset/edit-dataset.component.html new file mode 100644 index 00000000..200fd641 --- /dev/null +++ b/client/src/app/admin/containers/dataset/edit-dataset.component.html @@ -0,0 +1,44 @@ +<div class="container-fluid"> + <nav aria-label="breadcrumb"> + <ol class="breadcrumb"> + <li class="breadcrumb-item"> + <a routerLink="/admin/instance-list">Instances</a> + </li> + <li class="breadcrumb-item active" aria-current="page"> + <a routerLink="/admin/configure-instance/{{ instanceSelected | async }}"> + Configure instance {{ instanceSelected | async }} + </a> + </li> + <li class="breadcrumb-item active" aria-current="page">Edit dataset {{ datasetSelected | async }}</li> + </ol> + </nav> +</div> + +<div class="container"> + <app-spinner *ngIf="(surveyListIsLoading | async) || (datasetListIsLoading | async) || (datasetFamilyListIsLoading | async)"></app-spinner> + + <div *ngIf="(surveyListIsLoaded | async) && (datasetListIsLoaded | async) && (datasetFamilyListIsLoaded | async)" class="row"> + <div class="col-12"> + <app-dataset-form + [dataset]="datasetList | async | datasetByName:(datasetSelected | async)" + [surveyList]="surveyList | async" + [tableListIsLoading]="tableListIsLoading | async" + [tableListIsLoaded]="tableListIsLoaded | async" + [tableList]="tableList | async" + [datasetFamilyList]="datasetFamilyList | async" + [rootDirectory]="rootDirectory | async" + [rootDirectoryIsLoading]="rootDirectoryIsLoading | async" + [rootDirectoryIsLoaded]="rootDirectoryIsLoaded | async" + (changeSurvey)="loadTableList($event)" + (loadRootDirectory)="loadRootDirectory($event)" + (onSubmit)="editDataset($event)" + #formDataset> + <button [disabled]="!formDataset.form.valid || formDataset.form.pristine" type="submit" class="btn btn-primary"> + <i class="fa fa-database"></i> Update dataset information + </button> + + <a routerLink="/admin/configure-instance/{{instanceSelected | async}}" type="button" class="btn btn-danger">Cancel</a> + </app-dataset-form> + </div> + </div> +</div> diff --git a/client/src/app/admin/containers/dataset/edit-dataset.component.ts b/client/src/app/admin/containers/dataset/edit-dataset.component.ts new file mode 100644 index 00000000..d275bba3 --- /dev/null +++ b/client/src/app/admin/containers/dataset/edit-dataset.component.ts @@ -0,0 +1,89 @@ +/** + * This file is part of Anis Client. + * + * @copyright Laboratoire d'Astrophysique de Marseille / CNRS + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { Observable } from 'rxjs'; +import { Store } from '@ngrx/store'; + +import { Survey, DatasetFamily, Dataset, FileInfo } from 'src/app/metamodel/models'; +import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; +import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; +import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; +import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; +import * as tableActions from 'src/app/metamodel/actions/table.actions'; +import * as tableSelector from 'src/app/metamodel/selectors/table.selector'; +import * as datasetFamilyActions from 'src/app/metamodel/actions/dataset-family.actions'; +import * as datasetFamilySelector from 'src/app/metamodel/selectors/dataset-family.selector'; +import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector'; +import * as rootDirectoryActions from 'src/app/metamodel/actions/root-directory.actions'; +import * as rootDirectorySelector from 'src/app/metamodel/selectors/root-directory.selector'; + +@Component({ + selector: 'app-edit-dataset', + templateUrl: 'edit-dataset.component.html' +}) +export class EditDatasetComponent implements OnInit { + public instanceSelected: Observable<string>; + public datasetSelected: Observable<string>; + public datasetList: Observable<Dataset[]>; + public datasetListIsLoading: Observable<boolean>; + public datasetListIsLoaded: Observable<boolean>; + public surveyListIsLoading: Observable<boolean>; + public surveyListIsLoaded: Observable<boolean>; + public surveyList: Observable<Survey[]>; + public tableListIsLoading: Observable<boolean>; + public tableListIsLoaded: Observable<boolean>; + public tableList: Observable<string[]>; + public datasetFamilyListIsLoading: Observable<boolean>; + public datasetFamilyListIsLoaded: Observable<boolean>; + public datasetFamilyList: Observable<DatasetFamily[]>; + public rootDirectory: Observable<FileInfo[]>; + public rootDirectoryIsLoading: Observable<boolean>; + public rootDirectoryIsLoaded: Observable<boolean>; + + constructor(private store: Store<{ }>, private route: ActivatedRoute) { + this.instanceSelected = store.select(instanceSelector.selectInstanceNameByRoute); + this.datasetSelected = store.select(datasetSelector.selectDatasetNameByRoute); + this.datasetList = store.select(datasetSelector.selectAllDatasets); + this.datasetListIsLoading = store.select(datasetSelector.selectDatasetListIsLoading); + this.datasetListIsLoaded = store.select(datasetSelector.selectDatasetListIsLoaded); + this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); + this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); + this.surveyList = store.select(surveySelector.selectAllSurveys); + this.tableListIsLoading = store.select(tableSelector.selectTableListIsLoading); + this.tableListIsLoaded = store.select(tableSelector.selectTableListIsLoaded); + this.tableList = store.select(tableSelector.selectAllTables); + this.datasetFamilyListIsLoading = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoading); + this.datasetFamilyListIsLoaded = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoaded); + this.datasetFamilyList = store.select(datasetFamilySelector.selectAllDatasetFamilies); + this.rootDirectory = store.select(rootDirectorySelector.selectAllFileInfo); + this.rootDirectoryIsLoading = store.select(rootDirectorySelector.selectRootDirectoryIsLoading); + this.rootDirectoryIsLoaded = store.select(rootDirectorySelector.selectRootDirectoryIsLoaded); + } + + ngOnInit() { + this.store.dispatch(surveyActions.loadSurveyList()); + this.store.dispatch(datasetActions.loadDatasetList()); + this.store.dispatch(datasetFamilyActions.loadDatasetFamilyList()); + } + + loadTableList(idDatabase: number) { + this.store.dispatch(tableActions.loadTableList({ idDatabase })); + } + + loadRootDirectory(path: string) { + this.store.dispatch(rootDirectoryActions.loadRootDirectory({ path })); + } + + editDataset(dataset: Dataset) { + this.store.dispatch(datasetActions.editDataset({ dataset })); + } +} diff --git a/client/src/app/admin/containers/dataset/new-dataset.component.html b/client/src/app/admin/containers/dataset/new-dataset.component.html index 01b7437b..9d43f2a4 100644 --- a/client/src/app/admin/containers/dataset/new-dataset.component.html +++ b/client/src/app/admin/containers/dataset/new-dataset.component.html @@ -5,8 +5,8 @@ <a routerLink="/admin/instance-list">Instances</a> </li> <li class="breadcrumb-item active" aria-current="page"> - <a routerLink="/admin/configure-instance/{{ instanceName | async }}"> - Configure instance {{ instanceName | async }} + <a routerLink="/admin/configure-instance/{{ instanceSelected | async }}"> + Configure instance {{ instanceSelected | async }} </a> </li> <li class="breadcrumb-item active" aria-current="page">New dataset</li> @@ -37,7 +37,7 @@ <i class="fa fa-database"></i> Add new dataset </button> - <a routerLink="/admin/configure-instance/{{instanceName | async}}" type="button" class="btn btn-danger">Cancel</a> + <a routerLink="/admin/configure-instance/{{instanceSelected | async}}" type="button" class="btn btn-danger">Cancel</a> </app-dataset-form> </div> </div> diff --git a/client/src/app/admin/containers/dataset/new-dataset.component.ts b/client/src/app/admin/containers/dataset/new-dataset.component.ts index 90581da4..be5ac5bb 100644 --- a/client/src/app/admin/containers/dataset/new-dataset.component.ts +++ b/client/src/app/admin/containers/dataset/new-dataset.component.ts @@ -31,7 +31,7 @@ import * as rootDirectorySelector from 'src/app/metamodel/selectors/root-directo templateUrl: 'new-dataset.component.html' }) export class NewDatasetComponent implements OnInit { - public instanceName: Observable<string>; + public instanceSelected: Observable<string>; public surveyListIsLoading: Observable<boolean>; public surveyListIsLoaded: Observable<boolean>; public surveyList: Observable<Survey[]>; @@ -47,7 +47,7 @@ export class NewDatasetComponent implements OnInit { public rootDirectoryIsLoaded: Observable<boolean>; constructor(private store: Store<{ }>, private route: ActivatedRoute) { - this.instanceName = store.select(instanceSelector.selectInstanceNameByRoute); + this.instanceSelected = store.select(instanceSelector.selectInstanceNameByRoute); this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); this.surveyList = store.select(surveySelector.selectAllSurveys); diff --git a/client/src/app/shared/pipes/dataset-by-name.pipe.ts b/client/src/app/shared/pipes/dataset-by-name.pipe.ts new file mode 100644 index 00000000..27292944 --- /dev/null +++ b/client/src/app/shared/pipes/dataset-by-name.pipe.ts @@ -0,0 +1,19 @@ +/** + * This file is part of Anis Client. + * + * @copyright Laboratoire d'Astrophysique de Marseille / CNRS + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +import { Pipe, PipeTransform } from '@angular/core'; + +import { Dataset } from 'src/app/metamodel/models'; + +@Pipe({name: 'datasetByName'}) +export class DatasetByNamePipe implements PipeTransform { + transform(datasetList: Dataset[], datasetName: string): Dataset { + return datasetList.find(dataset => dataset.name === datasetName); + } +} diff --git a/client/src/app/shared/pipes/index.ts b/client/src/app/shared/pipes/index.ts index 83ce7906..85f656d9 100644 --- a/client/src/app/shared/pipes/index.ts +++ b/client/src/app/shared/pipes/index.ts @@ -12,11 +12,13 @@ import { AttributeListByFamilyPipe } from './attribute-list-by-family.pipe'; import { SurveyByNamePipe } from './survey-by-name.pipe'; import { OptionListBySelectPipe } from './option-list-by-select.pipe'; import { OutputFamilyById } from './output-family-by-id.pipe'; +import { DatasetByNamePipe } from './dataset-by-name.pipe'; export const sharedPipes = [ DatasetListByFamilyPipe, AttributeListByFamilyPipe, SurveyByNamePipe, OptionListBySelectPipe, - OutputFamilyById + OutputFamilyById, + DatasetByNamePipe ]; -- GitLab