From e6e535396d4f6c9d67f2b32fa08a4e3583f8c5a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Agneray?= <francois.agneray@lam.fr> Date: Thu, 14 Apr 2022 15:20:03 +0200 Subject: [PATCH] Delete survey entity --- client/src/app/admin/admin-routing.module.ts | 1 - client/src/app/admin/admin.component.ts | 3 - .../components/database-table.component.html | 3 - .../components/database-table.component.ts | 11 +- .../containers/database-list.component.html | 7 +- .../containers/database-list.component.ts | 9 +- .../dataset/dataset-form.component.html | 6 +- .../dataset/dataset-form.component.ts | 16 +- .../containers/edit-dataset.component.html | 16 +- .../containers/edit-dataset.component.ts | 17 +- .../containers/new-dataset.component.html | 8 +- .../containers/new-dataset.component.ts | 16 +- .../src/app/admin/survey/components/index.ts | 16 - .../components/survey-form.component.html | 45 --- .../components/survey-form.component.ts | 49 --- .../components/survey-table.component.html | 41 --- .../components/survey-table.component.ts | 27 -- .../containers/edit-survey.component.html | 24 -- .../containers/edit-survey.component.ts | 43 --- .../containers/new-survey.component.html | 24 -- .../survey/containers/new-survey.component.ts | 36 --- .../containers/survey-list.component.html | 29 -- .../containers/survey-list.component.ts | 43 --- .../app/admin/survey/survey-routing.module.ts | 37 --- client/src/app/admin/survey/survey.module.ts | 33 -- .../dataset-by-family.component.html | 2 - .../components/dataset-by-family.component.ts | 3 +- .../dataset-card-doc.component.html | 11 - .../components/dataset-card-doc.component.ts | 3 +- .../containers/dataset-list.component.html | 7 +- .../containers/dataset-list.component.ts | 9 +- client/src/app/instance/instance.component.ts | 2 - .../datasets/dataset-list.component.html | 1 - .../datasets/dataset-list.component.ts | 3 +- .../datasets-by-family.component.html | 2 - .../datasets/datasets-by-family.component.ts | 14 +- .../containers/datasets.component.html | 5 +- .../containers/datasets.component.ts | 16 - .../dataset/dataset-card.component.ts | 3 +- .../dataset/dataset-tabs.component.html | 1 - .../dataset/dataset-tabs.component.ts | 3 +- .../search/containers/dataset.component.html | 7 +- .../search/containers/dataset.component.ts | 9 +- .../app/metamodel/actions/survey.actions.ts | 25 -- client/src/app/metamodel/effects/index.ts | 2 - .../metamodel/effects/survey.effects.spec.ts | 298 ------------------ .../app/metamodel/effects/survey.effects.ts | 160 ---------- client/src/app/metamodel/metamodel.reducer.ts | 3 - .../src/app/metamodel/models/dataset.model.ts | 2 +- client/src/app/metamodel/models/index.ts | 1 - .../src/app/metamodel/models/survey.model.ts | 23 -- .../metamodel/reducers/survey.reducer.spec.ts | 107 ------- .../app/metamodel/reducers/survey.reducer.ts | 84 ----- .../selectors/survey.selector.spec.ts | 54 ---- .../metamodel/selectors/survey.selector.ts | 54 ---- client/src/app/metamodel/services/index.ts | 2 - .../metamodel/services/survey.service.spec.ts | 102 ------ .../app/metamodel/services/survey.service.ts | 67 ---- client/src/app/shared/pipes/index.ts | 2 - .../shared/pipes/survey-by-name.pipe.spec.ts | 10 - .../app/shared/pipes/survey-by-name.pipe.ts | 27 -- conf-dev/create-db.sh | 15 +- server/app/routes.php | 2 - .../doctrine-proxy/__CG__AppEntityDataset.php | 21 +- server/src/Action/DatasetListAction.php | 22 +- server/src/Action/SearchAction.php | 2 +- server/src/Action/SurveyAction.php | 117 ------- server/src/Action/SurveyListAction.php | 103 ------ server/src/Entity/Dataset.php | 18 +- server/src/Entity/Survey.php | 153 --------- 70 files changed, 101 insertions(+), 2036 deletions(-) delete mode 100644 client/src/app/admin/survey/components/index.ts delete mode 100644 client/src/app/admin/survey/components/survey-form.component.html delete mode 100644 client/src/app/admin/survey/components/survey-form.component.ts delete mode 100644 client/src/app/admin/survey/components/survey-table.component.html delete mode 100644 client/src/app/admin/survey/components/survey-table.component.ts delete mode 100644 client/src/app/admin/survey/containers/edit-survey.component.html delete mode 100644 client/src/app/admin/survey/containers/edit-survey.component.ts delete mode 100644 client/src/app/admin/survey/containers/new-survey.component.html delete mode 100644 client/src/app/admin/survey/containers/new-survey.component.ts delete mode 100644 client/src/app/admin/survey/containers/survey-list.component.html delete mode 100644 client/src/app/admin/survey/containers/survey-list.component.ts delete mode 100644 client/src/app/admin/survey/survey-routing.module.ts delete mode 100644 client/src/app/admin/survey/survey.module.ts delete mode 100644 client/src/app/metamodel/actions/survey.actions.ts delete mode 100644 client/src/app/metamodel/effects/survey.effects.spec.ts delete mode 100644 client/src/app/metamodel/effects/survey.effects.ts delete mode 100644 client/src/app/metamodel/models/survey.model.ts delete mode 100644 client/src/app/metamodel/reducers/survey.reducer.spec.ts delete mode 100644 client/src/app/metamodel/reducers/survey.reducer.ts delete mode 100644 client/src/app/metamodel/selectors/survey.selector.spec.ts delete mode 100644 client/src/app/metamodel/selectors/survey.selector.ts delete mode 100644 client/src/app/metamodel/services/survey.service.spec.ts delete mode 100644 client/src/app/metamodel/services/survey.service.ts delete mode 100644 client/src/app/shared/pipes/survey-by-name.pipe.spec.ts delete mode 100644 client/src/app/shared/pipes/survey-by-name.pipe.ts delete mode 100644 server/src/Action/SurveyAction.php delete mode 100644 server/src/Action/SurveyListAction.php delete mode 100644 server/src/Entity/Survey.php diff --git a/client/src/app/admin/admin-routing.module.ts b/client/src/app/admin/admin-routing.module.ts index 192e2c5b..62959a4a 100644 --- a/client/src/app/admin/admin-routing.module.ts +++ b/client/src/app/admin/admin-routing.module.ts @@ -18,7 +18,6 @@ const routes: Routes = [ path: '', component: AdminComponent, canActivate: [AdminAuthGuard], children: [ { path: '', redirectTo: 'instance/instance-list', pathMatch: 'full' }, { path: 'instance', loadChildren: () => import('./instance/instance.module').then(m => m.InstanceModule) }, - { path: 'survey', loadChildren: () => import('./survey/survey.module').then(m => m.SurveyModule) }, { path: 'database', loadChildren: () => import('./database/database.module').then(m => m.DatabaseModule) }, { path: 'settings', loadChildren: () => import('./settings/settings.module').then(m => m.SettingsModule) } ] diff --git a/client/src/app/admin/admin.component.ts b/client/src/app/admin/admin.component.ts index b31b8d79..4eaacb1e 100644 --- a/client/src/app/admin/admin.component.ts +++ b/client/src/app/admin/admin.component.ts @@ -16,7 +16,6 @@ import * as fromRouter from '@ngrx/router-store'; import { UserProfile } from 'src/app/auth/user-profile.model'; import * as authActions from 'src/app/auth/auth.actions'; import * as authSelector from 'src/app/auth/auth.selector'; -import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; import * as databaseActions from 'src/app/metamodel/actions/database.actions'; import * as selectActions from 'src/app/metamodel/actions/select.actions'; import * as optionActions from 'src/app/metamodel/actions/select-option.actions'; @@ -39,7 +38,6 @@ export class AdminComponent implements OnInit { public body: HTMLBodyElement = document.querySelector('body'); public links = [ { label: 'Instances', icon: 'fas fa-object-group', routerLink: 'instance/instance-list' }, - { label: 'Surveys', icon: 'fas fa-table', routerLink: 'survey/survey-list'}, { label: 'Databases', icon: 'fas fa-database', routerLink: 'database/database-list'}, { label: 'Settings', icon: 'fas fa-wrench', routerLink: 'settings'} ]; @@ -59,7 +57,6 @@ export class AdminComponent implements OnInit { this.favIcon.href = 'favicon.ico'; this.title.innerHTML = 'ANIS - Admin'; this.body.style.backgroundColor = 'white'; - Promise.resolve(null).then(() => this.store.dispatch(surveyActions.loadSurveyList())); Promise.resolve(null).then(() => this.store.dispatch(databaseActions.loadDatabaseList())); Promise.resolve(null).then(() => this.store.dispatch(selectActions.loadSelectList())); Promise.resolve(null).then(() => this.store.dispatch(optionActions.loadSelectOptionList())); diff --git a/client/src/app/admin/database/components/database-table.component.html b/client/src/app/admin/database/components/database-table.component.html index e44c48b3..bd22043b 100644 --- a/client/src/app/admin/database/components/database-table.component.html +++ b/client/src/app/admin/database/components/database-table.component.html @@ -10,7 +10,6 @@ <th scope="col">Port</th> <th scope="col">Login</th> <th scope="col">Password</th> - <th scope="col">Nb surveys</th> <th scope="col">Edit</th> <th scope="col">Delete</th> </tr> @@ -25,7 +24,6 @@ <td class="align-middle">{{ database.dbport }}</td> <td class="align-middle">{{ database.dblogin }}</td> <td class="align-middle">*******</td> - <td class="align-middle">{{ getNbSurveyByDatabase(database.id) }}</td> <td class="align-middle"> <a title="Edit this database" routerLink="/admin/database/edit-database/{{database.id}}" class="btn btn-outline-primary"> <span class="fas fa-edit"></span> @@ -33,7 +31,6 @@ </td> <td class="align-middle"> <app-delete-btn - [disabled]="!isNoSurveyAttachedToDatabase(database.id)" [type]="'database'" [label]="database.label" (confirm)="deleteDatabase.emit(database)"> diff --git a/client/src/app/admin/database/components/database-table.component.ts b/client/src/app/admin/database/components/database-table.component.ts index 9785f73e..6d852fec 100644 --- a/client/src/app/admin/database/components/database-table.component.ts +++ b/client/src/app/admin/database/components/database-table.component.ts @@ -9,7 +9,7 @@ import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter } from '@angular/core'; -import { Database, Survey } from 'src/app/metamodel/models'; +import { Database } from 'src/app/metamodel/models'; @Component({ selector: 'app-database-table', @@ -18,14 +18,5 @@ import { Database, Survey } from 'src/app/metamodel/models'; }) export class DatabaseTableComponent { @Input() databaseList: Database[]; - @Input() surveyList: Survey[]; @Output() deleteDatabase: EventEmitter<Database> = new EventEmitter(); - - isNoSurveyAttachedToDatabase(idDatabase: number): boolean { - return this.getNbSurveyByDatabase(idDatabase) === 0; - } - - getNbSurveyByDatabase(idDatabase: number): number { - return this.surveyList.filter(p => p.id_database === idDatabase).length - } } diff --git a/client/src/app/admin/database/containers/database-list.component.html b/client/src/app/admin/database/containers/database-list.component.html index e5409f65..2a3ea884 100644 --- a/client/src/app/admin/database/containers/database-list.component.html +++ b/client/src/app/admin/database/containers/database-list.component.html @@ -5,9 +5,9 @@ </ol> </nav> - <app-spinner *ngIf="(surveyListIsLoading | async) || (databaseListIsLoading | async)"></app-spinner> + <app-spinner *ngIf="(databaseListIsLoading | async)"></app-spinner> - <ng-container *ngIf="(surveyListIsLoaded | async) && (databaseListIsLoaded | async)"> + <ng-container *ngIf="(databaseListIsLoaded | async)"> <div class="row"> <div class="col-12"> <button title="Add a new database" class="btn btn-outline-success float-right" routerLink="/admin/database/new-database"> @@ -19,8 +19,7 @@ <div class="row mt-1"> <div class="col-12"> <app-database-table - [databaseList]="databaseList | async" - [surveyList]="surveyList | async" + [databaseList]="databaseList | async" (deleteDatabase)="deleteDatabase($event)"> </app-database-table> </div> diff --git a/client/src/app/admin/database/containers/database-list.component.ts b/client/src/app/admin/database/containers/database-list.component.ts index f5ad27f6..23261180 100644 --- a/client/src/app/admin/database/containers/database-list.component.ts +++ b/client/src/app/admin/database/containers/database-list.component.ts @@ -11,10 +11,9 @@ import { Component } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; -import { Database, Survey } from 'src/app/metamodel/models'; +import { Database } from 'src/app/metamodel/models'; import * as databaseActions from 'src/app/metamodel/actions/database.actions'; import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; @Component({ selector: 'app-database-list', @@ -24,17 +23,11 @@ export class DatabaseListComponent { public databaseListIsLoading: Observable<boolean>; public databaseListIsLoaded: Observable<boolean>; public databaseList: Observable<Database[]>; - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; constructor(private store: Store<{ }>) { this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); this.databaseList = store.select(databaseSelector.selectAllDatabases); - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); } deleteDatabase(database: Database) { diff --git a/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.html b/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.html index 4c129724..e709998b 100644 --- a/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.html +++ b/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.html @@ -10,10 +10,10 @@ <input type="text" class="form-control" id="label" name="label" formControlName="label"> </div> <div class="form-group"> - <label for="survey_name">Survey</label> - <select class="form-control" id="survey_name" name="survey_name" formControlName="survey_name" (change)="onChangeSurvey()"> + <label for="id_database">Database</label> + <select class="form-control" id="id_database" name="id_database" formControlName="id_database" (change)="onChangeDatabase()"> <option></option> - <option *ngFor="let survey of surveyList" [ngValue]="survey.name">{{ survey.label }}</option> + <option *ngFor="let database of databaseList" [ngValue]="database.id">{{ database.label }}</option> </select> </div> <div class="form-group"> diff --git a/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.ts b/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.ts index f9883295..83bcb3d3 100644 --- a/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.ts +++ b/client/src/app/admin/instance/dataset/components/dataset/dataset-form.component.ts @@ -10,7 +10,7 @@ import { Component, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core'; import { FormGroup, FormControl, Validators } from '@angular/forms'; -import { Instance, Dataset, Survey, DatasetFamily, Attribute, Image } from 'src/app/metamodel/models'; +import { Instance, Dataset, DatasetFamily, Database } from 'src/app/metamodel/models'; import { FileInfo } from 'src/app/admin/store/models'; @Component({ @@ -20,7 +20,7 @@ import { FileInfo } from 'src/app/admin/store/models'; export class DatasetFormComponent implements OnInit, OnChanges { @Input() instance: Instance; @Input() dataset: Dataset; - @Input() surveyList: Survey[]; + @Input() databaseList: Database[]; @Input() tableListIsLoading: boolean; @Input() tableListIsLoaded: boolean; @Input() tableList: string[]; @@ -29,7 +29,7 @@ export class DatasetFormComponent implements OnInit, OnChanges { @Input() files: FileInfo[]; @Input() filesIsLoading: boolean; @Input() filesIsLoaded: boolean; - @Output() changeSurvey: EventEmitter<number> = new EventEmitter(); + @Output() changeDatabase: EventEmitter<number> = new EventEmitter(); @Output() loadRootDirectory: EventEmitter<string> = new EventEmitter(); @Output() onSubmit: EventEmitter<Dataset> = new EventEmitter(); @@ -43,7 +43,7 @@ export class DatasetFormComponent implements OnInit, OnChanges { display: new FormControl('', [Validators.required]), data_path: new FormControl(''), public: new FormControl('', [Validators.required]), - survey_name: new FormControl('', [Validators.required]), + id_database: new FormControl('', [Validators.required]), id_dataset_family: new FormControl('', [Validators.required]), download_enabled: new FormControl(true), download_json: new FormControl(true), @@ -88,12 +88,12 @@ export class DatasetFormComponent implements OnInit, OnChanges { } } - onChangeSurvey() { - const surveyName = this.form.controls.survey_name.value; - if (!surveyName) { + onChangeDatabase() { + const idDatabase = this.form.controls.id_database.value; + if (!idDatabase) { this.form.controls.table_ref.disable(); } else { - this.changeSurvey.emit(this.surveyList.find(survey => survey.name === surveyName).id_database); + this.changeDatabase.emit(idDatabase); } } diff --git a/client/src/app/admin/instance/dataset/containers/edit-dataset.component.html b/client/src/app/admin/instance/dataset/containers/edit-dataset.component.html index 91826a28..b168f3aa 100644 --- a/client/src/app/admin/instance/dataset/containers/edit-dataset.component.html +++ b/client/src/app/admin/instance/dataset/containers/edit-dataset.component.html @@ -15,18 +15,18 @@ </div> <div class="container"> - <app-spinner *ngIf="(surveyListIsLoading | async) - || (datasetListIsLoading | async) - || (datasetFamilyListIsLoading | async)"></app-spinner> + <app-spinner *ngIf="(datasetListIsLoading | async) + || (datasetFamilyListIsLoading | async) + || (databaseListIsLoading | async)"></app-spinner> - <div *ngIf="(surveyListIsLoaded | async) - && (datasetListIsLoaded | async) - && (datasetFamilyListIsLoaded | async)" class="row"> + <div *ngIf="(datasetListIsLoaded | async) + && (datasetFamilyListIsLoaded | async) + && (databaseListIsLoaded | async)" class="row"> <div class="col-12"> <app-dataset-form [instance]="instance | async" [dataset]="datasetList | async | datasetByName:(datasetSelected | async)" - [surveyList]="surveyList | async" + [databaseList]="databaseList | async" [tableListIsLoading]="tableListIsLoading | async" [tableListIsLoaded]="tableListIsLoaded | async" [tableList]="tableList | async" @@ -34,7 +34,7 @@ [files]="files | async" [filesIsLoading]="filesIsLoading | async" [filesIsLoaded]="filesIsLoaded | async" - (changeSurvey)="loadTableList($event)" + (changeDatabase)="loadTableList($event)" (loadRootDirectory)="loadRootDirectory($event)" (onSubmit)="editDataset($event)" #formDataset> diff --git a/client/src/app/admin/instance/dataset/containers/edit-dataset.component.ts b/client/src/app/admin/instance/dataset/containers/edit-dataset.component.ts index a8452918..91325238 100644 --- a/client/src/app/admin/instance/dataset/containers/edit-dataset.component.ts +++ b/client/src/app/admin/instance/dataset/containers/edit-dataset.component.ts @@ -12,12 +12,10 @@ import { Component, OnInit } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; -import { Instance, Survey, DatasetFamily, Dataset } from 'src/app/metamodel/models'; +import { Instance, DatasetFamily, Dataset, Database } from 'src/app/metamodel/models'; import { FileInfo } from 'src/app/admin/store/models'; import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; -import * as attributeActions from 'src/app/metamodel/actions/attribute.actions'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; import * as tableActions from 'src/app/admin/store/actions/table.actions'; import * as tableSelector from 'src/app/admin/store/selectors/table.selector'; import * as datasetFamilySelector from 'src/app/metamodel/selectors/dataset-family.selector'; @@ -25,6 +23,7 @@ import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector import * as adminFileExplorerActions from 'src/app/admin/store/actions/admin-file-explorer.actions'; import * as adminFileExplorerSelector from 'src/app/admin/store/selectors/admin-file-explorer.selector'; import * as imageActions from 'src/app/metamodel/actions/image.actions'; +import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; @Component({ selector: 'app-edit-dataset', @@ -36,9 +35,9 @@ export class EditDatasetComponent implements OnInit { 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 databaseList: Observable<Database[]>; + public databaseListIsLoading: Observable<boolean>; + public databaseListIsLoaded: Observable<boolean>; public tableListIsLoading: Observable<boolean>; public tableListIsLoaded: Observable<boolean>; public tableList: Observable<string[]>; @@ -55,9 +54,9 @@ export class EditDatasetComponent implements OnInit { 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.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); + this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); + this.databaseList = store.select(databaseSelector.selectAllDatabases); this.tableListIsLoading = store.select(tableSelector.selectTableListIsLoading); this.tableListIsLoaded = store.select(tableSelector.selectTableListIsLoaded); this.tableList = store.select(tableSelector.selectAllTables); diff --git a/client/src/app/admin/instance/dataset/containers/new-dataset.component.html b/client/src/app/admin/instance/dataset/containers/new-dataset.component.html index 4b1f5cb8..f2e0d9e6 100644 --- a/client/src/app/admin/instance/dataset/containers/new-dataset.component.html +++ b/client/src/app/admin/instance/dataset/containers/new-dataset.component.html @@ -15,13 +15,13 @@ </div> <div class="container"> - <app-spinner *ngIf="(surveyListIsLoading | async) || (datasetFamilyListIsLoading | async)"></app-spinner> + <app-spinner *ngIf="(datasetFamilyListIsLoading | async) || (databaseListIsLoading | async)"></app-spinner> - <div *ngIf="(surveyListIsLoaded | async) && (datasetFamilyListIsLoaded | async)" class="row"> + <div *ngIf="(datasetFamilyListIsLoaded | async) && (databaseListIsLoaded | async)" class="row"> <div class="col-12"> <app-dataset-form [instance]="instance | async" - [surveyList]="surveyList | async" + [databaseList]="databaseList | async" [tableListIsLoading]="tableListIsLoading | async" [tableListIsLoaded]="tableListIsLoaded | async" [tableList]="tableList | async" @@ -30,7 +30,7 @@ [files]="files | async" [filesIsLoading]="filesIsLoading | async" [filesIsLoaded]="filesIsLoaded | async" - (changeSurvey)="loadTableList($event)" + (changeDatabase)="loadTableList($event)" (loadRootDirectory)="loadRootDirectory($event)" (onSubmit)="addNewDataset($event)" #formDataset> diff --git a/client/src/app/admin/instance/dataset/containers/new-dataset.component.ts b/client/src/app/admin/instance/dataset/containers/new-dataset.component.ts index dcaef239..833accca 100644 --- a/client/src/app/admin/instance/dataset/containers/new-dataset.component.ts +++ b/client/src/app/admin/instance/dataset/containers/new-dataset.component.ts @@ -14,9 +14,8 @@ import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { Store } from '@ngrx/store'; -import { Instance, Survey, DatasetFamily, Dataset } from 'src/app/metamodel/models'; +import { Instance, DatasetFamily, Dataset, Database } from 'src/app/metamodel/models'; import { FileInfo } from 'src/app/admin/store/models'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; import * as tableActions from 'src/app/admin/store/actions/table.actions'; import * as tableSelector from 'src/app/admin/store/selectors/table.selector'; import * as datasetFamilySelector from 'src/app/metamodel/selectors/dataset-family.selector'; @@ -24,6 +23,7 @@ import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector'; import * as adminFileExplorerActions from 'src/app/admin/store/actions/admin-file-explorer.actions'; import * as adminFileExplorerSelector from 'src/app/admin/store/selectors/admin-file-explorer.selector'; +import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; @Component({ selector: 'app-new-dataset', @@ -31,9 +31,9 @@ import * as adminFileExplorerSelector from 'src/app/admin/store/selectors/admin- }) export class NewDatasetComponent implements OnInit { public instance: Observable<Instance>; - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; + public databaseList: Observable<Database[]>; + public databaseListIsLoading: Observable<boolean>; + public databaseListIsLoaded: Observable<boolean>; public tableListIsLoading: Observable<boolean>; public tableListIsLoaded: Observable<boolean>; public tableList: Observable<string[]>; @@ -47,9 +47,9 @@ export class NewDatasetComponent implements OnInit { constructor(private store: Store<{ }>, private route: ActivatedRoute) { this.instance = store.select(instanceSelector.selectInstanceByRouteName); - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); + this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); + this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); + this.databaseList = store.select(databaseSelector.selectAllDatabases); this.tableListIsLoading = store.select(tableSelector.selectTableListIsLoading); this.tableListIsLoaded = store.select(tableSelector.selectTableListIsLoaded); this.tableList = store.select(tableSelector.selectAllTables); diff --git a/client/src/app/admin/survey/components/index.ts b/client/src/app/admin/survey/components/index.ts deleted file mode 100644 index c0cb4786..00000000 --- a/client/src/app/admin/survey/components/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * 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 { SurveyTableComponent } from "./survey-table.component"; -import { SurveyFormComponent } from "./survey-form.component"; - -export const dummiesComponents = [ - SurveyTableComponent, - SurveyFormComponent -]; diff --git a/client/src/app/admin/survey/components/survey-form.component.html b/client/src/app/admin/survey/components/survey-form.component.html deleted file mode 100644 index 8bca8d14..00000000 --- a/client/src/app/admin/survey/components/survey-form.component.html +++ /dev/null @@ -1,45 +0,0 @@ -<form [formGroup]="form" (ngSubmit)="submit()" novalidate> - <div class="form-group"> - <label for="name">Name</label> - <input type="text" class="form-control" id="name" name="name" formControlName="name"> - </div> - <div class="form-group"> - <label for="label">Label</label> - <input type="text" class="form-control" id="label" name="label" formControlName="label"> - </div> - <div class="form-group"> - <label for="id_database">Database</label> - <select class="form-control" id="id_database" name="id_database" formControlName="id_database"> - <option></option> - <option *ngFor="let database of databaseList" [ngValue]="database.id">{{database.label}}</option> - </select> - </div> - <div class="form-group"> - <label for="description">Description</label> - <textarea class="form-control" rows="5" id="description" name="description" formControlName="description"></textarea> - </div> - <div class="form-group"> - <div class="row"> - <div class="col-md-6"> - <label for="link">Link</label> - <input type="text" class="form-control" id="link" name="link" formControlName="link"> - </div> - <div class="col-md-6"> - <strong>Test it</strong> - <br> - <p style="margin-top: 13px;"> - <a [href]="form.controls.link.value" target="_blank"> - <span class="fa fa-link"></span> {{ form.controls.link.value }} - </a> - </p> - </div> - </div> - </div> - <div class="form-group"> - <label for="manager">Manager</label> - <input type="text" class="form-control" id="manager" name="manager" formControlName="manager"> - </div> - <div class="form-group"> - <ng-content></ng-content> - </div> -</form> diff --git a/client/src/app/admin/survey/components/survey-form.component.ts b/client/src/app/admin/survey/components/survey-form.component.ts deleted file mode 100644 index 0f63402a..00000000 --- a/client/src/app/admin/survey/components/survey-form.component.ts +++ /dev/null @@ -1,49 +0,0 @@ -/** - * 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, Input, Output, EventEmitter, OnInit } from '@angular/core'; -import { FormGroup, FormControl, Validators } from '@angular/forms'; - -import { Survey, Database } from 'src/app/metamodel/models'; - -@Component({ - selector: 'app-survey-form', - templateUrl: 'survey-form.component.html' -}) -export class SurveyFormComponent implements OnInit { - @Input() survey: Survey; - @Input() databaseList: Database[]; - @Output() onSubmit: EventEmitter<Survey> = new EventEmitter(); - - public form = new FormGroup({ - name: new FormControl('', [Validators.required]), - label: new FormControl('', [Validators.required]), - id_database: new FormControl('', [Validators.required]), - description: new FormControl('', [Validators.required]), - link: new FormControl('', [Validators.required]), - manager: new FormControl('', [Validators.required]) - }); - - ngOnInit() { - if (this.survey) { - this.form.patchValue(this.survey); - } - } - - submit() { - if (this.survey) { - this.onSubmit.emit({ - ...this.survey, - ...this.form.value - }); - } else { - this.onSubmit.emit(this.form.value); - } - } -} diff --git a/client/src/app/admin/survey/components/survey-table.component.html b/client/src/app/admin/survey/components/survey-table.component.html deleted file mode 100644 index d537039f..00000000 --- a/client/src/app/admin/survey/components/survey-table.component.html +++ /dev/null @@ -1,41 +0,0 @@ -<div class="table-responsive"> - <table class="table table-striped" aria-describedby="Survey list"> - <thead> - <tr> - <th scope="col">Name</th> - <th scope="col">Label</th> - <th scope="col">Description</th> - <th scope="col">Link</th> - <th scope="col">Manager</th> - <th scope="col">Database</th> - <th scope="col">Nb datasets</th> - <th scope="col">Edit</th> - <th scope="col">Delete</th> - </tr> - </thead> - <tbody> - <tr *ngFor="let survey of surveyList"> - <td class="align-middle">{{ survey.name }}</td> - <td class="align-middle">{{ survey.label }}</td> - <td class="align-middle">{{ survey.description }}</td> - <td class="align-middle"><a [href]="survey.link" target="_blank">{{ survey.link }}</a></td> - <td class="align-middle">{{ survey.manager }}</td> - <td class="align-middle">{{ getDatabaseById(survey.id_database).label }}</td> - <td class="align-middle">{{ survey.nb_datasets }}</td> - <td class="align-middle"> - <a title="Edit this survey" routerLink="/admin/survey/edit-survey/{{survey.name}}" class="btn btn-outline-primary"> - <span class="fas fa-edit"></span> - </a> - </td> - <td class="align-middle"> - <app-delete-btn - [disabled]="survey.nb_datasets > 0" - [type]="'survey'" - [label]="survey.label" - (confirm)="deleteSurvey.emit(survey)"> - </app-delete-btn> - </td> - </tr> - </tbody> - </table> -</div> diff --git a/client/src/app/admin/survey/components/survey-table.component.ts b/client/src/app/admin/survey/components/survey-table.component.ts deleted file mode 100644 index 97b38fae..00000000 --- a/client/src/app/admin/survey/components/survey-table.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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, Input, Output, ChangeDetectionStrategy, EventEmitter } from '@angular/core'; - -import { Survey, Database } from 'src/app/metamodel/models'; - -@Component({ - selector: 'app-survey-table', - templateUrl: 'survey-table.component.html', - changeDetection: ChangeDetectionStrategy.OnPush -}) -export class SurveyTableComponent { - @Input() surveyList: Survey[]; - @Input() databaseList: Database[]; - @Output() deleteSurvey: EventEmitter<Survey> = new EventEmitter(); - - getDatabaseById(idDatabase: number): Database { - return this.databaseList.find(database => database.id === idDatabase); - } -} diff --git a/client/src/app/admin/survey/containers/edit-survey.component.html b/client/src/app/admin/survey/containers/edit-survey.component.html deleted file mode 100644 index 2f80c1d9..00000000 --- a/client/src/app/admin/survey/containers/edit-survey.component.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="container-fluid"> - <nav aria-label="breadcrumb"> - <ol class="breadcrumb"> - <li class="breadcrumb-item"><a routerLink="/admin/survey/survey-list">Surveys</a></li> - <li *ngIf="(surveyListIsLoaded | async)" class="breadcrumb-item active" aria-current="page">Edit survey {{ (survey | async).name }}</li> - </ol> - </nav> -</div> - -<div class="container"> - <app-spinner *ngIf="(databaseListIsLoading | async) || (surveyListIsLoading | async)"></app-spinner> - - <div *ngIf="(databaseListIsLoaded | async) && (surveyListIsLoaded | async)" class="row"> - <div class="col-12"> - <app-survey-form [survey]="survey | async" [databaseList]="databaseList | async" (onSubmit)="editSurvey($event)" #formSurvey> - <button [disabled]="!formSurvey.form.valid || formSurvey.form.pristine" type="submit" class="btn btn-primary"> - <span class="fa fa-database"></span> Update survey information - </button> - - <a routerLink="/admin/survey/survey-list" type="button" class="btn btn-danger">Cancel</a> - </app-survey-form> - </div> - </div> -</div> diff --git a/client/src/app/admin/survey/containers/edit-survey.component.ts b/client/src/app/admin/survey/containers/edit-survey.component.ts deleted file mode 100644 index e25e0224..00000000 --- a/client/src/app/admin/survey/containers/edit-survey.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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 } from '@angular/core'; -import { Observable } from 'rxjs'; -import { Store } from '@ngrx/store'; - -import { Survey, Database } from 'src/app/metamodel/models'; -import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; -import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; - -@Component({ - selector: 'app-edit-survey', - templateUrl: 'edit-survey.component.html' -}) -export class EditSurveyComponent { - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public survey: Observable<Survey>; - public databaseListIsLoading: Observable<boolean>; - public databaseListIsLoaded: Observable<boolean>; - public databaseList: Observable<Database[]>; - - constructor(private store: Store<{ }>) { - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.survey = store.select(surveySelector.selectSurveyByRouteName); - this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); - this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); - this.databaseList = this.store.select(databaseSelector.selectAllDatabases); - } - - editSurvey(survey: Survey) { - this.store.dispatch(surveyActions.editSurvey({ survey })); - } -} diff --git a/client/src/app/admin/survey/containers/new-survey.component.html b/client/src/app/admin/survey/containers/new-survey.component.html deleted file mode 100644 index b89b7899..00000000 --- a/client/src/app/admin/survey/containers/new-survey.component.html +++ /dev/null @@ -1,24 +0,0 @@ -<div class="container-fluid"> - <nav aria-label="breadcrumb"> - <ol class="breadcrumb"> - <li class="breadcrumb-item"><a routerLink="/admin/survey/survey-list">Surveys</a></li> - <li class="breadcrumb-item active" aria-current="page">New survey</li> - </ol> - </nav> -</div> - -<div class="container"> - <app-spinner *ngIf="databaseListIsLoading | async"></app-spinner> - - <div *ngIf="databaseListIsLoaded | async" class="row"> - <div class="col-12"> - <app-survey-form [databaseList]="databaseList | async" (onSubmit)="addNewSurvey($event)" #formSurvey> - <button [disabled]="!formSurvey.form.valid || formSurvey.form.pristine" type="submit" class="btn btn-primary"> - <span class="fa fa-database"></span> Add the new survey - </button> - - <a routerLink="/admin/survey/survey-list" type="button" class="btn btn-danger">Cancel</a> - </app-survey-form> - </div> - </div> -</div> diff --git a/client/src/app/admin/survey/containers/new-survey.component.ts b/client/src/app/admin/survey/containers/new-survey.component.ts deleted file mode 100644 index 1caeeb29..00000000 --- a/client/src/app/admin/survey/containers/new-survey.component.ts +++ /dev/null @@ -1,36 +0,0 @@ -/** - * 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 } from '@angular/core'; -import { Observable } from 'rxjs'; -import { Store } from '@ngrx/store'; - -import { Survey, Database } from 'src/app/metamodel/models' -import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; -import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; - -@Component({ - selector: 'app-new-survey', - templateUrl: 'new-survey.component.html' -}) -export class NewSurveyComponent { - public databaseListIsLoading: Observable<boolean>; - public databaseListIsLoaded: Observable<boolean>; - public databaseList: Observable<Database[]>; - - constructor(private store: Store<{ }>) { - this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); - this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); - this.databaseList = store.select(databaseSelector.selectAllDatabases); - } - - addNewSurvey(survey: Survey) { - this.store.dispatch(surveyActions.addSurvey({ survey })); - } -} diff --git a/client/src/app/admin/survey/containers/survey-list.component.html b/client/src/app/admin/survey/containers/survey-list.component.html deleted file mode 100644 index 2dd778cc..00000000 --- a/client/src/app/admin/survey/containers/survey-list.component.html +++ /dev/null @@ -1,29 +0,0 @@ -<div class="container-fluid"> - <nav aria-label="breadcrumb"> - <ol class="breadcrumb"> - <li class="breadcrumb-item active" aria-current="page">Surveys</li> - </ol> - </nav> - - <app-spinner *ngIf="(surveyListIsLoading | async) || (databaseListIsLoading | async)"></app-spinner> - - <ng-container *ngIf="(surveyListIsLoaded | async) && (databaseListIsLoaded | async)"> - <div class="row"> - <div class="col-12"> - <button title="Add a new survey" class="btn btn-outline-success float-right" routerLink="/admin/survey/new-survey"> - <span class="fas fa-plus"></span> New survey - </button> - </div> - </div> - - <div class="row mt-1"> - <div class="col-12"> - <app-survey-table - [surveyList]="surveyList | async" - [databaseList]="databaseList | async" - (deleteSurvey)="deleteSurvey($event)"> - </app-survey-table> - </div> - </div> - </ng-container> -</div> diff --git a/client/src/app/admin/survey/containers/survey-list.component.ts b/client/src/app/admin/survey/containers/survey-list.component.ts deleted file mode 100644 index 3e3fee49..00000000 --- a/client/src/app/admin/survey/containers/survey-list.component.ts +++ /dev/null @@ -1,43 +0,0 @@ -/** - * 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 } from '@angular/core'; -import { Observable } from 'rxjs'; -import { Store } from '@ngrx/store'; - -import { Survey, Database } from 'src/app/metamodel/models'; -import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; -import * as databaseSelector from 'src/app/metamodel/selectors/database.selector'; - -@Component({ - selector: 'app-survey-list', - templateUrl: 'survey-list.component.html' -}) -export class SurveyListComponent { - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; - public databaseListIsLoading: Observable<boolean>; - public databaseListIsLoaded: Observable<boolean>; - public databaseList: Observable<Database[]>; - - constructor(private store: Store<{ }>) { - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); - this.databaseListIsLoading = store.select(databaseSelector.selectDatabaseListIsLoading); - this.databaseListIsLoaded = store.select(databaseSelector.selectDatabaseListIsLoaded); - this.databaseList = store.select(databaseSelector.selectAllDatabases); - } - - deleteSurvey(survey: Survey) { - this.store.dispatch(surveyActions.deleteSurvey({ survey })); - } -} diff --git a/client/src/app/admin/survey/survey-routing.module.ts b/client/src/app/admin/survey/survey-routing.module.ts deleted file mode 100644 index 0cf63471..00000000 --- a/client/src/app/admin/survey/survey-routing.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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 { NgModule } from '@angular/core'; -import { Routes, RouterModule } from '@angular/router'; - -import { SurveyListComponent } from './containers/survey-list.component'; -import { NewSurveyComponent } from './containers/new-survey.component'; -import { EditSurveyComponent } from './containers/edit-survey.component'; - -const routes: Routes = [ - { path: 'survey-list', component: SurveyListComponent }, - { path: 'new-survey', component: NewSurveyComponent }, - { path: 'edit-survey/:name', component: EditSurveyComponent } -]; - -/** - * @class - * @classdesc Survey routing module. - */ -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class SurveyRoutingModule { } - -export const routedComponents = [ - SurveyListComponent, - NewSurveyComponent, - EditSurveyComponent -]; diff --git a/client/src/app/admin/survey/survey.module.ts b/client/src/app/admin/survey/survey.module.ts deleted file mode 100644 index 44ae22dd..00000000 --- a/client/src/app/admin/survey/survey.module.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * 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 { NgModule } from '@angular/core'; - -import { SharedModule } from 'src/app/shared/shared.module'; -import { SurveyRoutingModule, routedComponents } from './survey-routing.module'; -import { dummiesComponents } from './components'; - -import { AdminSharedModule } from '../admin-shared/admin-shared.module'; - -/** - * @class - * @classdesc Settings module. - */ -@NgModule({ - imports: [ - SharedModule, - SurveyRoutingModule, - AdminSharedModule - ], - declarations: [ - routedComponents, - dummiesComponents - ] -}) -export class SurveyModule { } diff --git a/client/src/app/instance/documentation/components/dataset-by-family.component.html b/client/src/app/instance/documentation/components/dataset-by-family.component.html index 9ec4e190..68c74aa3 100644 --- a/client/src/app/instance/documentation/components/dataset-by-family.component.html +++ b/client/src/app/instance/documentation/components/dataset-by-family.component.html @@ -13,7 +13,6 @@ class="list-unstyled px-3 pt-3 pb-0"> <app-dataset-card-doc [dataset]="dataset" - [survey]="surveyList | surveyByName:dataset.survey_name" [instanceSelected]="instanceSelected"> </app-dataset-card-doc> <hr *ngIf="!isLast"> @@ -41,7 +40,6 @@ <div *ngFor="let dataset of (datasetList | datasetListByFamily:family.id); last as isLast"> <app-dataset-card-doc [dataset]="dataset" - [survey]="surveyList | surveyByName:dataset.survey_name" [instanceSelected]="instanceSelected"> </app-dataset-card-doc> <hr *ngIf="!isLast"> diff --git a/client/src/app/instance/documentation/components/dataset-by-family.component.ts b/client/src/app/instance/documentation/components/dataset-by-family.component.ts index affe5c7a..6e07e089 100644 --- a/client/src/app/instance/documentation/components/dataset-by-family.component.ts +++ b/client/src/app/instance/documentation/components/dataset-by-family.component.ts @@ -9,7 +9,7 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; -import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; +import { Dataset, DatasetFamily } from 'src/app/metamodel/models'; /** * @class @@ -24,6 +24,5 @@ import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; export class DatasetByFamilyComponent { @Input() datasetList: Dataset[]; @Input() datasetFamilyList: DatasetFamily[]; - @Input() surveyList: Survey[]; @Input() instanceSelected: string; } diff --git a/client/src/app/instance/documentation/components/dataset-card-doc.component.html b/client/src/app/instance/documentation/components/dataset-card-doc.component.html index ef6dda4c..4a502483 100644 --- a/client/src/app/instance/documentation/components/dataset-card-doc.component.html +++ b/client/src/app/instance/documentation/components/dataset-card-doc.component.html @@ -10,17 +10,6 @@ <div class="row"> <p class="my-3">{{ dataset.description }}</p> </div> - <div class="row"> - <button class="btn btn-link p-0" - popover="{{ survey.description }}" - popoverTitle="{{ survey.label }}" - placement="bottom" - triggers="mouseenter:mouseleave"> - <small> - More about {{ survey.label }} survey <span class="fas fa-question-circle"></span> - </small> - </button> - </div> </div> <div class="col-auto"> <button (click)="selectDataset(dataset.name)" diff --git a/client/src/app/instance/documentation/components/dataset-card-doc.component.ts b/client/src/app/instance/documentation/components/dataset-card-doc.component.ts index fe852245..8fbef499 100644 --- a/client/src/app/instance/documentation/components/dataset-card-doc.component.ts +++ b/client/src/app/instance/documentation/components/dataset-card-doc.component.ts @@ -10,7 +10,7 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; import { Router } from '@angular/router'; -import { Survey, Dataset } from 'src/app/metamodel/models'; +import { Dataset } from 'src/app/metamodel/models'; /** * @class @@ -22,7 +22,6 @@ import { Survey, Dataset } from 'src/app/metamodel/models'; changeDetection: ChangeDetectionStrategy.OnPush }) export class DatasetCardDocComponent { - @Input() survey: Survey; @Input() dataset: Dataset; @Input() instanceSelected: string; diff --git a/client/src/app/instance/documentation/containers/dataset-list.component.html b/client/src/app/instance/documentation/containers/dataset-list.component.html index 91d2e149..8c69e6de 100644 --- a/client/src/app/instance/documentation/containers/dataset-list.component.html +++ b/client/src/app/instance/documentation/containers/dataset-list.component.html @@ -1,11 +1,9 @@ <app-spinner *ngIf="(datasetFamilyListIsLoading | async) - || (datasetListIsLoading | async) - || (surveyListIsLoading | async)"> + || (datasetListIsLoading | async)"> </app-spinner> <div *ngIf="(datasetFamilyListIsLoaded | async) - && (datasetListIsLoaded | async) - && (surveyListIsLoaded | async)" class="container"> + && (datasetListIsLoaded | async)" class="container"> <div class="row mt-4"> <ng-container *ngIf="(datasetList | async).length === 0"> <div class="col-12 lead text-center"> @@ -20,7 +18,6 @@ <app-dataset-by-family [datasetList]="datasetList | async" [datasetFamilyList]="datasetFamilyList | async" - [surveyList]="surveyList | async" [instanceSelected]="instanceSelected | async"> </app-dataset-by-family> </div> diff --git a/client/src/app/instance/documentation/containers/dataset-list.component.ts b/client/src/app/instance/documentation/containers/dataset-list.component.ts index 058c704e..ec7b244e 100644 --- a/client/src/app/instance/documentation/containers/dataset-list.component.ts +++ b/client/src/app/instance/documentation/containers/dataset-list.component.ts @@ -15,10 +15,9 @@ import { Observable } from 'rxjs'; import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; import * as datasetFamilySelector from 'src/app/metamodel/selectors/dataset-family.selector'; import * as datasetSelector from 'src/app/metamodel/selectors/dataset.selector'; -import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; +import { Dataset, DatasetFamily } from 'src/app/metamodel/models'; import * as authSelector from '../../../auth/auth.selector'; import * as instanceSelector from '../../../metamodel/selectors/instance.selector'; -import * as surveySelector from '../../../metamodel/selectors/survey.selector'; /** * @class @@ -37,9 +36,6 @@ export class DatasetListComponent implements OnInit { public datasetFamilyListIsLoading: Observable<boolean>; public datasetFamilyListIsLoaded: Observable<boolean>; public datasetFamilyList: Observable<DatasetFamily[]>; - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; public datasetListIsLoading: Observable<boolean>; public datasetListIsLoaded: Observable<boolean>; public datasetList: Observable<Dataset[]>; @@ -50,9 +46,6 @@ export class DatasetListComponent implements OnInit { this.datasetFamilyListIsLoading = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoading); this.datasetFamilyListIsLoaded = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoaded); this.datasetFamilyList = store.select(datasetFamilySelector.selectAllDatasetFamilies); - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); this.datasetListIsLoading = store.select(datasetSelector.selectDatasetListIsLoading); this.datasetListIsLoaded = store.select(datasetSelector.selectDatasetListIsLoaded); this.datasetList = store.select(datasetSelector.selectAllDatasets); diff --git a/client/src/app/instance/instance.component.ts b/client/src/app/instance/instance.component.ts index 6db00730..2b397dd5 100644 --- a/client/src/app/instance/instance.component.ts +++ b/client/src/app/instance/instance.component.ts @@ -19,7 +19,6 @@ import * as authActions from 'src/app/auth/auth.actions'; import * as authSelector from 'src/app/auth/auth.selector'; import * as datasetActions from 'src/app/metamodel/actions/dataset.actions'; import * as datasetFamilyActions from 'src/app/metamodel/actions/dataset-family.actions'; -import * as surveyActions from 'src/app/metamodel/actions/survey.actions'; import * as instanceSelector from 'src/app/metamodel/selectors/instance.selector'; import { AppConfigService } from 'src/app/app-config.service'; @@ -61,7 +60,6 @@ export class InstanceComponent implements OnInit, OnDestroy { // This micro task prevent the expression has changed after view init error Promise.resolve(null).then(() => this.store.dispatch(datasetFamilyActions.loadDatasetFamilyList())); Promise.resolve(null).then(() => this.store.dispatch(datasetActions.loadDatasetList())); - Promise.resolve(null).then(() => this.store.dispatch(surveyActions.loadSurveyList())); this.instanceSubscription = this.instance.subscribe(instance => { if (instance) { if (instance.search_by_criteria_allowed) { diff --git a/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.html b/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.html index 4395a45c..df4b2b65 100644 --- a/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.html +++ b/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.html @@ -3,7 +3,6 @@ <app-datasets-by-family [datasetFamily]="datasetFamily" [datasetList]="getDatasetsByFamily(datasetFamily.id)" - [surveyList]="surveyList" [selectedDatasets]="selectedDatasets" [isAllSelected]="getIsAllSelected(datasetFamily.id)" [isAllUnselected]="getIsAllUnselected(datasetFamily.id)" diff --git a/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.ts b/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.ts index 164643d4..69e65edc 100644 --- a/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.ts +++ b/client/src/app/instance/search-multiple/components/datasets/dataset-list.component.ts @@ -9,7 +9,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core'; -import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; +import { Dataset, DatasetFamily } from 'src/app/metamodel/models'; /** * @class @@ -23,7 +23,6 @@ import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; export class DatasetListComponent { @Input() datasetFamilyList: DatasetFamily[]; @Input() datasetList: Dataset[]; - @Input() surveyList: Survey[]; @Input() selectedDatasets: string[]; @Output() updateSelectedDatasets: EventEmitter<string[]> = new EventEmitter(); diff --git a/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.html b/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.html index c0ab965e..b63ad383 100644 --- a/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.html +++ b/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.html @@ -36,8 +36,6 @@ <ng-template #datasetInfo class="text-left"> {{ dataset.description }} - <br><br> - {{ getSurveyDescription(dataset.survey_name) }} </ng-template> </div> </div> diff --git a/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.ts b/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.ts index 85cb44b0..79fa49b6 100644 --- a/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.ts +++ b/client/src/app/instance/search-multiple/components/datasets/datasets-by-family.component.ts @@ -9,7 +9,7 @@ import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; -import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; +import { Dataset, DatasetFamily } from 'src/app/metamodel/models'; /** * @class @@ -25,7 +25,6 @@ import { Dataset, DatasetFamily, Survey } from 'src/app/metamodel/models'; export class DatasetsByFamilyComponent { @Input() datasetFamily: DatasetFamily; @Input() datasetList: Dataset[]; - @Input() surveyList: Survey[]; @Input() selectedDatasets: string[]; @Input() isAllSelected: boolean; @Input() isAllUnselected: boolean; @@ -82,15 +81,4 @@ export class DatasetsByFamilyComponent { }); this.updateSelectedDatasets.emit(clonedSelectedDatasets); } - - /** - * Returns survey description of the given survey name. - * - * @param {string} surveyName - The survey name. - * - * @return string - */ - getSurveyDescription(surveyName: string): string { - return this.surveyList.find(p => p.name === surveyName).description; - } } diff --git a/client/src/app/instance/search-multiple/containers/datasets.component.html b/client/src/app/instance/search-multiple/containers/datasets.component.html index 6c030e4a..3a2a1fa0 100644 --- a/client/src/app/instance/search-multiple/containers/datasets.component.html +++ b/client/src/app/instance/search-multiple/containers/datasets.component.html @@ -1,13 +1,12 @@ -<app-spinner *ngIf="(datasetFamilyListIsLoading | async) || (datasetListIsLoading | async) || (surveyListIsLoading | async)"> +<app-spinner *ngIf="(datasetFamilyListIsLoading | async) || (datasetListIsLoading | async)"> </app-spinner> -<div *ngIf="(datasetFamilyListIsLoaded | async) && (datasetListIsLoaded | async) && (surveyListIsLoaded | async)" class="row mt-4"> +<div *ngIf="(datasetFamilyListIsLoaded | async) && (datasetListIsLoaded | async)" class="row mt-4"> <div class="col-12 col-md-8 col-lg-9"> <div class="border rounded my-2"> <p class="border-bottom bg-light text-primary mb-0 py-4 pl-4">Datasets</p> <div class="px-3"> <app-dataset-list - [surveyList]="surveyList | async" [datasetFamilyList]="datasetFamilyList | async" [datasetList]="datasetList | async" [selectedDatasets]="selectedDatasets | async" diff --git a/client/src/app/instance/search-multiple/containers/datasets.component.ts b/client/src/app/instance/search-multiple/containers/datasets.component.ts index 816fa7c6..2f73aaa7 100644 --- a/client/src/app/instance/search-multiple/containers/datasets.component.ts +++ b/client/src/app/instance/search-multiple/containers/datasets.component.ts @@ -9,13 +9,8 @@ import { Component, OnInit } from '@angular/core'; -import { Store } from '@ngrx/store'; -import { Observable } from 'rxjs'; - -import { Survey } from 'src/app/metamodel/models'; import { AbstractSearchMultipleComponent } from './abstract-search-multiple.component'; import * as searchMultipleActions from '../../store/actions/search-multiple.actions'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; /** * @class @@ -29,17 +24,6 @@ import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; templateUrl: 'datasets.component.html' }) export class DatasetsComponent extends AbstractSearchMultipleComponent implements OnInit { - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; - - constructor(protected store: Store<{ }>) { - super(store); - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); - } - ngOnInit(): void { // Create a micro task that is processed after the current synchronous code // This micro task prevent the expression has changed after view init error diff --git a/client/src/app/instance/search/components/dataset/dataset-card.component.ts b/client/src/app/instance/search/components/dataset/dataset-card.component.ts index 18213276..f57589f6 100644 --- a/client/src/app/instance/search/components/dataset/dataset-card.component.ts +++ b/client/src/app/instance/search/components/dataset/dataset-card.component.ts @@ -10,7 +10,7 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; import { Router } from '@angular/router'; -import { Survey, Dataset } from 'src/app/metamodel/models'; +import { Dataset } from 'src/app/metamodel/models'; /** * @class @@ -22,7 +22,6 @@ import { Survey, Dataset } from 'src/app/metamodel/models'; changeDetection: ChangeDetectionStrategy.OnPush }) export class DatasetCardComponent { - @Input() survey: Survey; @Input() dataset: Dataset; @Input() instanceSelected: string; @Input() datasetSelected: string; diff --git a/client/src/app/instance/search/components/dataset/dataset-tabs.component.html b/client/src/app/instance/search/components/dataset/dataset-tabs.component.html index 0407fe89..e66f0106 100644 --- a/client/src/app/instance/search/components/dataset/dataset-tabs.component.html +++ b/client/src/app/instance/search/components/dataset/dataset-tabs.component.html @@ -16,7 +16,6 @@ <div *ngFor="let dataset of (datasetList | datasetListByFamily:family.id); last as isLast"> <app-dataset-card [dataset]="dataset" - [survey]="surveyList | surveyByName:dataset.survey_name" [instanceSelected]="instanceSelected" [datasetSelected]="datasetSelected"> </app-dataset-card> diff --git a/client/src/app/instance/search/components/dataset/dataset-tabs.component.ts b/client/src/app/instance/search/components/dataset/dataset-tabs.component.ts index 4f1df33a..c71df192 100644 --- a/client/src/app/instance/search/components/dataset/dataset-tabs.component.ts +++ b/client/src/app/instance/search/components/dataset/dataset-tabs.component.ts @@ -9,7 +9,7 @@ import { Component, Input, ChangeDetectionStrategy } from '@angular/core'; -import { Survey, Dataset, DatasetFamily } from 'src/app/metamodel/models'; +import { Dataset, DatasetFamily } from 'src/app/metamodel/models'; /** * @class @@ -22,7 +22,6 @@ import { Survey, Dataset, DatasetFamily } from 'src/app/metamodel/models'; changeDetection: ChangeDetectionStrategy.OnPush }) export class DatasetTabsComponent { - @Input() surveyList: Survey[]; @Input() datasetList: Dataset[]; @Input() datasetFamilyList: DatasetFamily[]; @Input() instanceSelected: string; diff --git a/client/src/app/instance/search/containers/dataset.component.html b/client/src/app/instance/search/containers/dataset.component.html index c1a85d26..d8857371 100644 --- a/client/src/app/instance/search/containers/dataset.component.html +++ b/client/src/app/instance/search/containers/dataset.component.html @@ -1,11 +1,9 @@ <app-spinner *ngIf="(datasetFamilyListIsLoading | async) - || (datasetListIsLoading | async) - || (surveyListIsLoading | async)"> + || (datasetListIsLoading | async)"> </app-spinner> <div *ngIf="(datasetFamilyListIsLoaded | async) - && (datasetListIsLoaded | async) - && (surveyListIsLoaded | async)" class="row mt-4"> + && (datasetListIsLoaded | async)" class="row mt-4"> <ng-container *ngIf="(datasetList | async).length === 0"> <div class="col-12 lead text-center"> Oops! No dataset available... @@ -17,7 +15,6 @@ <ng-container *ngIf="(datasetList | async).length > 0"> <div class="col-12 col-md-8 col-lg-9"> <app-dataset-tabs - [surveyList]="surveyList | async" [datasetList]="datasetList | async" [datasetFamilyList]="datasetFamilyList | async" [instanceSelected]="instanceSelected | async" diff --git a/client/src/app/instance/search/containers/dataset.component.ts b/client/src/app/instance/search/containers/dataset.component.ts index cbd886fd..93a9ac41 100644 --- a/client/src/app/instance/search/containers/dataset.component.ts +++ b/client/src/app/instance/search/containers/dataset.component.ts @@ -13,11 +13,10 @@ import { Store } from '@ngrx/store'; import { Observable, Subscription } from 'rxjs'; import { AbstractSearchComponent } from './abstract-search.component'; -import { Survey, DatasetFamily } from 'src/app/metamodel/models'; +import { DatasetFamily } from 'src/app/metamodel/models'; import * as searchActions from '../../store/actions/search.actions'; import * as authSelector from 'src/app/auth/auth.selector'; import * as datasetFamilySelector from 'src/app/metamodel/selectors/dataset-family.selector'; -import * as surveySelector from 'src/app/metamodel/selectors/survey.selector'; /** * @class @@ -32,9 +31,6 @@ export class DatasetComponent extends AbstractSearchComponent { public datasetFamilyListIsLoading: Observable<boolean>; public datasetFamilyListIsLoaded: Observable<boolean>; public datasetFamilyList: Observable<DatasetFamily[]>; - public surveyListIsLoading: Observable<boolean>; - public surveyListIsLoaded: Observable<boolean>; - public surveyList: Observable<Survey[]>; public datasetSelectedSubscription: Subscription; constructor(protected store: Store<{ }>) { @@ -43,9 +39,6 @@ export class DatasetComponent extends AbstractSearchComponent { this.datasetFamilyListIsLoading = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoading); this.datasetFamilyListIsLoaded = store.select(datasetFamilySelector.selectDatasetFamilyListIsLoaded); this.datasetFamilyList = store.select(datasetFamilySelector.selectAllDatasetFamilies); - this.surveyListIsLoading = store.select(surveySelector.selectSurveyListIsLoading); - this.surveyListIsLoaded = store.select(surveySelector.selectSurveyListIsLoaded); - this.surveyList = store.select(surveySelector.selectAllSurveys); } ngOnInit(): void { diff --git a/client/src/app/metamodel/actions/survey.actions.ts b/client/src/app/metamodel/actions/survey.actions.ts deleted file mode 100644 index 637c251c..00000000 --- a/client/src/app/metamodel/actions/survey.actions.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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 { createAction, props } from '@ngrx/store'; - -import { Survey } from '../models'; - -export const loadSurveyList = createAction('[Metamodel] Load Survey List'); -export const loadSurveyListSuccess = createAction('[Metamodel] Load Survey List Success', props<{ surveys: Survey[] }>()); -export const loadSurveyListFail = createAction('[Metamodel] Load Survey List Fail'); -export const addSurvey = createAction('[Metamodel] Add Survey', props<{ survey: Survey }>()); -export const addSurveySuccess = createAction('[Metamodel] Add Survey Success', props<{ survey: Survey }>()); -export const addSurveyFail = createAction('[Metamodel] Add Survey Fail'); -export const editSurvey = createAction('[Metamodel] Edit Survey', props<{ survey: Survey }>()); -export const editSurveySuccess = createAction('[Metamodel] Edit Survey Success', props<{ survey: Survey }>()); -export const editSurveyFail = createAction('[Metamodel] Edit Survey Fail'); -export const deleteSurvey = createAction('[Metamodel] Delete Survey', props<{ survey: Survey }>()); -export const deleteSurveySuccess = createAction('[Metamodel] Delete Survey Success', props<{ survey: Survey }>()); -export const deleteSurveyFail = createAction('[Metamodel] Delete Survey Fail'); diff --git a/client/src/app/metamodel/effects/index.ts b/client/src/app/metamodel/effects/index.ts index ef77bb0b..da1337e4 100644 --- a/client/src/app/metamodel/effects/index.ts +++ b/client/src/app/metamodel/effects/index.ts @@ -8,7 +8,6 @@ */ import { DatabaseEffects } from './database.effects'; -import { SurveyEffects } from './survey.effects'; import { InstanceEffects } from './instance.effects'; import { DatasetFamilyEffects } from './dataset-family.effects'; import { DatasetEffects } from './dataset.effects'; @@ -25,7 +24,6 @@ import { ConeSearchConfigEffects } from './cone-search-config.effects' export const metamodelEffects = [ DatabaseEffects, - SurveyEffects, InstanceEffects, DatasetFamilyEffects, DatasetEffects, diff --git a/client/src/app/metamodel/effects/survey.effects.spec.ts b/client/src/app/metamodel/effects/survey.effects.spec.ts deleted file mode 100644 index 13ac0bbb..00000000 --- a/client/src/app/metamodel/effects/survey.effects.spec.ts +++ /dev/null @@ -1,298 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { Router } from '@angular/router'; - -import { provideMockActions } from '@ngrx/effects/testing'; -import { EffectsMetadata, getEffectsMetadata } from '@ngrx/effects'; -import { Observable } from 'rxjs'; -import { cold, hot } from 'jasmine-marbles'; -import { ToastrService } from 'ngx-toastr'; - -import { SurveyEffects } from './survey.effects'; -import { SurveyService } from '../services/survey.service'; -import * as surveyActions from '../actions/survey.actions'; -import { SURVEY, SURVEY_LIST } from '../../../test-data'; - -describe('[Metamodel][Effects] SurveyEffects', () => { - let actions = new Observable(); - let effects: SurveyEffects; - let metadata: EffectsMetadata<SurveyEffects>; - let service: SurveyService; - let toastr: ToastrService; - let router: Router; - - beforeEach(() => { - TestBed.configureTestingModule({ - providers: [ - SurveyEffects, - { provide: SurveyService, useValue: { }}, - { provide: Router, useValue: { navigate: jest.fn() }}, - { provide: ToastrService, useValue: { - success: jest.fn(), - error: jest.fn() - }}, - provideMockActions(() => actions) - ] - }).compileComponents(); - effects = TestBed.inject(SurveyEffects); - metadata = getEffectsMetadata(effects); - service = TestBed.inject(SurveyService); - toastr = TestBed.inject(ToastrService); - router = TestBed.inject(Router); - }); - - it('should be created', () => { - expect(effects).toBeTruthy(); - }); - - describe('loadSurveys$ effect', () => { - it('should dispatch the loadSurveyListSuccess action on success', () => { - const action = surveyActions.loadSurveyList(); - const outcome = surveyActions.loadSurveyListSuccess({ surveys: SURVEY_LIST }); - - actions = hot('-a', { a: action }); - const response = cold('-a|', { a: SURVEY_LIST }); - const expected = cold('--b', { b: outcome }); - service.retrieveSurveyList = jest.fn(() => response); - - expect(effects.loadSurveys$).toBeObservable(expected); - }); - - it('should dispatch the loadSurveyListFail action on HTTP failure', () => { - const action = surveyActions.loadSurveyList(); - const error = new Error(); - const outcome = surveyActions.loadSurveyListFail(); - - actions = hot('-a', { a: action }); - const response = cold('-#|', { }, error); - const expected = cold('--b', { b: outcome }); - service.retrieveSurveyList = jest.fn(() => response); - - expect(effects.loadSurveys$).toBeObservable(expected); - }); - }); - - describe('addSurvey$ effect', () => { - it('should dispatch the addSurveySuccess action on success', () => { - const action = surveyActions.addSurvey({ survey: SURVEY }); - const outcome = surveyActions.addSurveySuccess({ survey: SURVEY }); - - actions = hot('-a', { a: action }); - const response = cold('-a|', { a: SURVEY }); - const expected = cold('--b', { b: outcome }); - service.addSurvey = jest.fn(() => response); - - expect(effects.addSurvey$).toBeObservable(expected); - }); - - it('should dispatch the addSurveyFail action on HTTP failure', () => { - const action = surveyActions.addSurvey({ survey: SURVEY }); - const error = new Error(); - const outcome = surveyActions.addSurveyFail(); - - actions = hot('-a', { a: action }); - const response = cold('-#|', { }, error); - const expected = cold('--b', { b: outcome }); - service.addSurvey = jest.fn(() => response); - - expect(effects.addSurvey$).toBeObservable(expected); - }); - }); - - describe('addSurveySuccess$ effect', () => { - it('should not dispatch', () => { - expect(metadata.addSurveySuccess$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display a success notification', () => { - const toastrSpy = jest.spyOn(toastr, 'success'); - const routerSpy = jest.spyOn(router, 'navigate'); - const action = surveyActions.addSurveySuccess({ survey: SURVEY }); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.addSurveySuccess$).toBeObservable(expected); - expect(toastrSpy).toHaveBeenCalledTimes(1); - expect(toastrSpy).toHaveBeenCalledWith( - 'Survey successfully added', - 'The new survey was added into the database' - ); - expect(routerSpy).toHaveBeenCalledTimes(1); - expect(routerSpy).toHaveBeenCalledWith(['/admin/survey/survey-list']); - }); - }); - - describe('addSurveyFail$ effect', () => { - it('should not dispatch', () => { - expect(metadata.addSurveyFail$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display an error notification', () => { - const spy = jest.spyOn(toastr, 'error'); - const action = surveyActions.addSurveyFail(); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.addSurveyFail$).toBeObservable(expected); - expect(spy).toHaveBeenCalledTimes(1); - expect(spy).toHaveBeenCalledWith( - 'Failure to add survey', - 'The new survey could not be added into the database' - ); - }); - }); - - describe('editSurvey$ effect', () => { - it('should dispatch the editSurveySuccess action on success', () => { - const action = surveyActions.editSurvey({ survey: SURVEY }); - const outcome = surveyActions.editSurveySuccess({ survey: SURVEY }); - - actions = hot('-a', { a: action }); - const response = cold('-a|', { a: SURVEY }); - const expected = cold('--b', { b: outcome }); - service.editSurvey = jest.fn(() => response); - - expect(effects.editSurvey$).toBeObservable(expected); - }); - - it('should dispatch the editSurveyFail action on HTTP failure', () => { - const action = surveyActions.editSurvey({ survey: SURVEY }); - const error = new Error(); - const outcome = surveyActions.editSurveyFail(); - - actions = hot('-a', { a: action }); - const response = cold('-#|', { }, error); - const expected = cold('--b', { b: outcome }); - service.editSurvey = jest.fn(() => response); - - expect(effects.editSurvey$).toBeObservable(expected); - }); - }); - - describe('editSurveySuccess$ effect', () => { - it('should not dispatch', () => { - expect(metadata.editSurveySuccess$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display a success notification', () => { - const toastrSpy = jest.spyOn(toastr, 'success'); - const routerSpy = jest.spyOn(router, 'navigate'); - const action = surveyActions.editSurveySuccess({ survey: SURVEY }); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.editSurveySuccess$).toBeObservable(expected); - expect(toastrSpy).toHaveBeenCalledTimes(1); - expect(toastrSpy).toHaveBeenCalledWith( - 'Survey successfully edited', - 'The existing survey has been edited into the database' - ); - expect(routerSpy).toHaveBeenCalledTimes(1); - expect(routerSpy).toHaveBeenCalledWith(['/admin/survey/survey-list']); - }); - }); - - describe('editSurveyFail$ effect', () => { - it('should not dispatch', () => { - expect(metadata.editSurveyFail$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display an error notification', () => { - const spy = jest.spyOn(toastr, 'error'); - const action = surveyActions.editSurveyFail(); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.editSurveyFail$).toBeObservable(expected); - expect(spy).toHaveBeenCalledTimes(1); - expect(spy).toHaveBeenCalledWith( - 'Failure to edit survey', - 'The existing survey could not be edited into the database' - ); - }); - }); - - describe('deleteSurvey$ effect', () => { - it('should dispatch the deleteSurveySuccess action on success', () => { - const action = surveyActions.deleteSurvey({ survey: SURVEY }); - const outcome = surveyActions.deleteSurveySuccess({ survey: SURVEY }); - - actions = hot('-a', { a: action }); - const response = cold('-a|', { a: SURVEY }); - const expected = cold('--b', { b: outcome }); - service.deleteSurvey = jest.fn(() => response); - - expect(effects.deleteSurvey$).toBeObservable(expected); - }); - - it('should dispatch the deleteSurveyFail action on HTTP failure', () => { - const action = surveyActions.deleteSurvey({ survey: SURVEY }); - const error = new Error(); - const outcome = surveyActions.deleteSurveyFail(); - - actions = hot('-a', { a: action }); - const response = cold('-#|', { }, error); - const expected = cold('--b', { b: outcome }); - service.deleteSurvey = jest.fn(() => response); - - expect(effects.deleteSurvey$).toBeObservable(expected); - }); - }); - - describe('deleteSurveySuccess$ effect', () => { - it('should not dispatch', () => { - expect(metadata.deleteSurveySuccess$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display a success notification', () => { - const toastrSpy = jest.spyOn(toastr, 'success'); - const action = surveyActions.deleteSurveySuccess({ survey: SURVEY }); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.deleteSurveySuccess$).toBeObservable(expected); - expect(toastrSpy).toHaveBeenCalledTimes(1); - expect(toastrSpy).toHaveBeenCalledWith( - 'Survey successfully deleted', - 'The existing survey has been deleted' - ); - }); - }); - - describe('deleteSurveyFail$ effect', () => { - it('should not dispatch', () => { - expect(metadata.deleteSurveyFail$).toEqual( - expect.objectContaining({ dispatch: false }) - ); - }); - - it('should display an error notification', () => { - const spy = jest.spyOn(toastr, 'error'); - const action = surveyActions.deleteSurveyFail(); - - actions = hot('a', { a: action }); - const expected = cold('a', { a: action }); - - expect(effects.deleteSurveyFail$).toBeObservable(expected); - expect(spy).toHaveBeenCalledTimes(1); - expect(spy).toHaveBeenCalledWith( - 'Failure to delete survey', - 'The existing survey could not be deleted from the database' - ); - }); - }); -}); diff --git a/client/src/app/metamodel/effects/survey.effects.ts b/client/src/app/metamodel/effects/survey.effects.ts deleted file mode 100644 index 7d6cc653..00000000 --- a/client/src/app/metamodel/effects/survey.effects.ts +++ /dev/null @@ -1,160 +0,0 @@ -/** - * 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 { Injectable } from '@angular/core'; -import { Router } from '@angular/router'; - -import { Actions, createEffect, ofType } from '@ngrx/effects'; -import { of } from 'rxjs'; -import { map, tap, mergeMap, catchError } from 'rxjs/operators'; -import { ToastrService } from 'ngx-toastr'; - -import * as surveyActions from '../actions/survey.actions'; -import { SurveyService } from '../services/survey.service'; - -/** - * @class - * @classdesc Survey effects. - */ -@Injectable() -export class SurveyEffects { - - /** - * Calls action to retrieve survey list. - */ - loadSurveys$ = createEffect((): any => - this.actions$.pipe( - ofType(surveyActions.loadSurveyList), - mergeMap(() => this.surveyService.retrieveSurveyList() - .pipe( - map(surveys => surveyActions.loadSurveyListSuccess({ surveys })), - catchError(() => of(surveyActions.loadSurveyListFail())) - ) - ) - ) - ); - - /** - * Calls action to add survey. - */ - addSurvey$ = createEffect((): any => - this.actions$.pipe( - ofType(surveyActions.addSurvey), - mergeMap(action => this.surveyService.addSurvey(action.survey) - .pipe( - map(survey => surveyActions.addSurveySuccess({ survey })), - catchError(() => of(surveyActions.addSurveyFail())) - ) - ) - ) - ); - - /** - * Displays add survey success notification. - */ - addSurveySuccess$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.addSurveySuccess), - tap(() => { - this.router.navigate(['/admin/survey/survey-list']); - this.toastr.success('Survey successfully added', 'The new survey was added into the database') - }) - ), { dispatch: false } - ); - - /** - * Displays add survey error notification. - */ - addSurveyFail$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.addSurveyFail), - tap(() => this.toastr.error('Failure to add survey', 'The new survey could not be added into the database')) - ), { dispatch: false } - ); - - /** - * Calls action to modify a survey. - */ - editSurvey$ = createEffect((): any => - this.actions$.pipe( - ofType(surveyActions.editSurvey), - mergeMap(action => this.surveyService.editSurvey(action.survey) - .pipe( - map(survey => surveyActions.editSurveySuccess({ survey })), - catchError(() => of(surveyActions.editSurveyFail())) - ) - ) - ) - ); - - /** - * Displays edit survey success notification. - */ - editSurveySuccess$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.editSurveySuccess), - tap(() => { - this.router.navigate(['/admin/survey/survey-list']); - this.toastr.success('Survey successfully edited', 'The existing survey has been edited into the database') - }) - ), { dispatch: false } - ); - - /** - * Displays edit survey error notification. - */ - editSurveyFail$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.editSurveyFail), - tap(() => this.toastr.error('Failure to edit survey', 'The existing survey could not be edited into the database')) - ), { dispatch: false } - ); - - /** - * Calls action to remove a survey. - */ - deleteSurvey$ = createEffect((): any => - this.actions$.pipe( - ofType(surveyActions.deleteSurvey), - mergeMap(action => this.surveyService.deleteSurvey(action.survey.name) - .pipe( - map(() => surveyActions.deleteSurveySuccess({ survey: action.survey })), - catchError(() => of(surveyActions.deleteSurveyFail())) - ) - ) - ) - ); - - /** - * Displays delete survey success notification. - */ - deleteSurveySuccess$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.deleteSurveySuccess), - tap(() => this.toastr.success('Survey successfully deleted', 'The existing survey has been deleted')) - ), { dispatch: false } - ); - - /** - * Displays edit survey error notification. - */ - deleteSurveyFail$ = createEffect(() => - this.actions$.pipe( - ofType(surveyActions.deleteSurveyFail), - tap(() => this.toastr.error('Failure to delete survey', 'The existing survey could not be deleted from the database')) - ), { dispatch: false } - ); - - constructor( - private actions$: Actions, - private surveyService: SurveyService, - private router: Router, - private toastr: ToastrService - ) { } -} diff --git a/client/src/app/metamodel/metamodel.reducer.ts b/client/src/app/metamodel/metamodel.reducer.ts index a0268b14..b248a52d 100644 --- a/client/src/app/metamodel/metamodel.reducer.ts +++ b/client/src/app/metamodel/metamodel.reducer.ts @@ -11,7 +11,6 @@ import { combineReducers, createFeatureSelector } from '@ngrx/store'; import { RouterReducerState } from 'src/app/custom-route-serializer'; import * as database from './reducers/database.reducer'; -import * as survey from './reducers/survey.reducer'; import * as group from './reducers/group.reducer'; import * as instanceGroup from './reducers/instance-group.reducer'; import * as dataset from './reducers/dataset.reducer'; @@ -33,7 +32,6 @@ import * as coneSearchConfig from './reducers/cone-search-config.reducer'; */ export interface State { database: database.State; - survey: survey.State; group: group.State; instanceGroup: instanceGroup.State; dataset: dataset.State; @@ -51,7 +49,6 @@ export interface State { const reducers = { database: database.databaseReducer, - survey: survey.surveyReducer, group: group.groupReducer, instanceGroup: instanceGroup.instanceGroupReducer, dataset: dataset.datasetReducer, diff --git a/client/src/app/metamodel/models/dataset.model.ts b/client/src/app/metamodel/models/dataset.model.ts index 8ed53e7f..7307b456 100644 --- a/client/src/app/metamodel/models/dataset.model.ts +++ b/client/src/app/metamodel/models/dataset.model.ts @@ -29,7 +29,7 @@ export interface Dataset { datatable_enabled: boolean; datatable_selectable_rows: boolean; cone_search_config_id: number; - survey_name: string; + id_database: number; id_dataset_family: number; full_data_path: string; } diff --git a/client/src/app/metamodel/models/index.ts b/client/src/app/metamodel/models/index.ts index 23780f1d..bcc7cbd8 100644 --- a/client/src/app/metamodel/models/index.ts +++ b/client/src/app/metamodel/models/index.ts @@ -8,7 +8,6 @@ */ export * from './database.model'; -export * from './survey.model'; export * from './group.model'; export * from './instance-group.model'; export * from './dataset.model'; diff --git a/client/src/app/metamodel/models/survey.model.ts b/client/src/app/metamodel/models/survey.model.ts deleted file mode 100644 index c23ab90a..00000000 --- a/client/src/app/metamodel/models/survey.model.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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. - */ - -/** - * Interface for survey. - * - * @interface Survey - */ -export interface Survey { - name: string; - label: string; - description: string; - link: string; - manager: string; - id_database: number; - nb_datasets: number; -} diff --git a/client/src/app/metamodel/reducers/survey.reducer.spec.ts b/client/src/app/metamodel/reducers/survey.reducer.spec.ts deleted file mode 100644 index 2e54b0f7..00000000 --- a/client/src/app/metamodel/reducers/survey.reducer.spec.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { Action } from '@ngrx/store'; - -import * as fromSurvey from './survey.reducer'; -import * as surveyActions from '../actions/survey.actions'; -import { SURVEY, SURVEY_LIST } from '../../../test-data'; - -describe('[Metamodel][Reducers] Survey reducer', () => { - it('unknown action should return the default state', () => { - const { initialState } = fromSurvey; - const action = { type: 'Unknown' }; - const state = fromSurvey.surveyReducer(initialState, action); - expect(state).toBe(initialState); - }); - - it('loadSurveyList action should set surveyListIsLoading to true', () => { - const { initialState } = fromSurvey; - const action = surveyActions.loadSurveyList(); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(0); - expect(state.entities).toEqual({ }); - expect(state.surveyListIsLoading).toEqual(true); - expect(state.surveyListIsLoaded).toEqual(false); - expect(state).not.toBe(initialState); - }); - - it('loadSurveyListSuccess action should add survey list, set surveyListIsLoading to false and set surveyListIsLoaded to true', () => { - const { initialState } = fromSurvey; - const action = surveyActions.loadSurveyListSuccess({ surveys: SURVEY_LIST }); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(2); - expect(state.ids).toContain('survey-one'); - expect(state.ids).toContain('survey-two'); - expect(Object.keys(state.entities).length).toEqual(2); - expect(state.surveyListIsLoading).toEqual(false); - expect(state.surveyListIsLoaded).toEqual(true); - expect(state).not.toBe(initialState); - }); - - it('loadSurveyListFail action should set surveyListIsLoading to false', () => { - const { initialState } = fromSurvey; - const action = surveyActions.loadSurveyListFail(); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(0); - expect(state.entities).toEqual({ }); - expect(state.surveyListIsLoading).toEqual(false); - expect(state.surveyListIsLoaded).toEqual(false); - expect(state).not.toBe(initialState); - }); - - it('addSurveySuccess action should add a survey', () => { - const { initialState } = fromSurvey; - const action = surveyActions.addSurveySuccess({ survey: SURVEY }); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(1); - expect(state.ids).toContain('mySurvey'); - expect(Object.keys(state.entities).length).toEqual(1); - expect(state.surveyListIsLoading).toEqual(false); - expect(state.surveyListIsLoaded).toEqual(false); - expect(state).not.toBe(initialState); - }); - - it('editSurveySuccess action should modify a survey', () => { - const initialState = { - ...fromSurvey.initialState, - ids: ['mySurvey'], - entities: { 'mySurvey': { ...SURVEY, label: 'label' }} - }; - const action = surveyActions.editSurveySuccess({ survey: SURVEY }); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(1); - expect(state.ids).toContain('mySurvey'); - expect(Object.keys(state.entities).length).toEqual(1); - expect(state.entities['mySurvey']).toEqual(SURVEY); - expect(state.surveyListIsLoading).toEqual(false); - expect(state.surveyListIsLoaded).toEqual(false); - expect(state).not.toBe(initialState); - }); - - it('deleteSurveySuccess action should modify a survey', () => { - const initialState = { - ...fromSurvey.initialState, - ids: ['mySurvey'], - entities: { 'mySurvey': SURVEY } - }; - const action = surveyActions.deleteSurveySuccess({ survey: SURVEY }); - const state = fromSurvey.surveyReducer(initialState, action); - expect(state.ids.length).toEqual(0); - expect(state.entities).toEqual( { }); - expect(state.surveyListIsLoading).toEqual(false); - expect(state.surveyListIsLoaded).toEqual(false); - expect(state).not.toBe(initialState); - }); - - it('should get surveyListIsLoading', () => { - const action = {} as Action; - const state = fromSurvey.surveyReducer(undefined, action); - - expect(fromSurvey.selectSurveyListIsLoading(state)).toEqual(false); - }); - - it('should get surveyListIsLoaded', () => { - const action = {} as Action; - const state = fromSurvey.surveyReducer(undefined, action); - - expect(fromSurvey.selectSurveyListIsLoaded(state)).toEqual(false); - }); -}); diff --git a/client/src/app/metamodel/reducers/survey.reducer.ts b/client/src/app/metamodel/reducers/survey.reducer.ts deleted file mode 100644 index 7514b7b3..00000000 --- a/client/src/app/metamodel/reducers/survey.reducer.ts +++ /dev/null @@ -1,84 +0,0 @@ -/** - * 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 { createReducer, on } from '@ngrx/store'; -import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity'; - -import { Survey } from '../models'; -import * as surveyActions from '../actions/survey.actions'; - -/** - * Interface for survey state. - * - * @interface State - */ -export interface State extends EntityState<Survey> { - surveyListIsLoading: boolean; - surveyListIsLoaded: boolean; -} - -export const adapter: EntityAdapter<Survey> = createEntityAdapter<Survey>({ - selectId: (survey: Survey) => survey.name, - sortComparer: (a: Survey, b: Survey) => a.name.localeCompare(b.name) -}); - -export const initialState: State = adapter.getInitialState({ - surveyListIsLoading: false, - surveyListIsLoaded: false -}); - -export const surveyReducer = createReducer( - initialState, - on(surveyActions.loadSurveyList, (state) => { - return { - ...state, - surveyListIsLoading: true - } - }), - on(surveyActions.loadSurveyListSuccess, (state, { surveys }) => { - return adapter.setAll( - surveys, - { - ...state, - surveyListIsLoading: false, - surveyListIsLoaded: true - } - ); - }), - on(surveyActions.loadSurveyListFail, (state) => { - return { - ...state, - surveyListIsLoading: false - } - }), - on(surveyActions.addSurveySuccess, (state, { survey }) => { - return adapter.addOne(survey, state) - }), - on(surveyActions.editSurveySuccess, (state, { survey }) => { - return adapter.setOne(survey, state) - }), - on(surveyActions.deleteSurveySuccess, (state, { survey }) => { - return adapter.removeOne(survey.name, state) - }) -); - -const { - selectIds, - selectEntities, - selectAll, - selectTotal, -} = adapter.getSelectors(); - -export const selectSurveyIds = selectIds; -export const selectSurveyEntities = selectEntities; -export const selectAllSurveys = selectAll; -export const selectSurveyTotal = selectTotal; - -export const selectSurveyListIsLoading = (state: State) => state.surveyListIsLoading; -export const selectSurveyListIsLoaded = (state: State) => state.surveyListIsLoaded; diff --git a/client/src/app/metamodel/selectors/survey.selector.spec.ts b/client/src/app/metamodel/selectors/survey.selector.spec.ts deleted file mode 100644 index 21885ff6..00000000 --- a/client/src/app/metamodel/selectors/survey.selector.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -import * as surveySelector from './survey.selector'; -import * as fromSurvey from '../reducers/survey.reducer'; -import { SURVEY } from '../../../test-data'; - -describe('[Metamodel][Selector] Survey selector', () => { - it('should get survey state', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyState(state)).toEqual(state.metamodel.survey); - }); - - it('should get survey IDs', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyIds(state).length).toEqual(0); - }); - - it('should get survey entities', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyEntities(state)).toEqual({ }); - }); - - it('should get all surveys', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectAllSurveys(state).length).toEqual(0); - }); - - it('should get survey count', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyTotal(state)).toEqual(0); - }); - - it('should get surveyListIsLoading', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyListIsLoading(state)).toBe(false); - }); - - it('should get surveyListIsLoaded', () => { - const state = { metamodel: { survey: { ...fromSurvey.initialState }}}; - expect(surveySelector.selectSurveyListIsLoaded(state)).toBe(false); - }); - - it('should get survey by route', () => { - const state = { - router: { state: { params: { name: 'survey-one' }}}, - metamodel: { - survey: { - ...fromSurvey.initialState, - ids: ['survey-one'], - entities: { 'survey-one': SURVEY } - } - } - }; - expect(surveySelector.selectSurveyByRouteName(state)).toEqual(SURVEY); - }); -}); diff --git a/client/src/app/metamodel/selectors/survey.selector.ts b/client/src/app/metamodel/selectors/survey.selector.ts deleted file mode 100644 index 4132d8bc..00000000 --- a/client/src/app/metamodel/selectors/survey.selector.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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 { createSelector } from '@ngrx/store'; - -import * as reducer from '../metamodel.reducer'; -import * as fromSurvey from '../reducers/survey.reducer'; - -export const selectSurveyState = createSelector( - reducer.getMetamodelState, - (state: reducer.State) => state.survey -); - -export const selectSurveyIds = createSelector( - selectSurveyState, - fromSurvey.selectSurveyIds -); - -export const selectSurveyEntities = createSelector( - selectSurveyState, - fromSurvey.selectSurveyEntities -); - -export const selectAllSurveys = createSelector( - selectSurveyState, - fromSurvey.selectAllSurveys -); - -export const selectSurveyTotal = createSelector( - selectSurveyState, - fromSurvey.selectSurveyTotal -); - -export const selectSurveyListIsLoading = createSelector( - selectSurveyState, - fromSurvey.selectSurveyListIsLoading -); - -export const selectSurveyListIsLoaded = createSelector( - selectSurveyState, - fromSurvey.selectSurveyListIsLoaded -); - -export const selectSurveyByRouteName = createSelector( - selectSurveyEntities, - reducer.selectRouterState, - (entities, router) => entities[router.state.params.name] -); diff --git a/client/src/app/metamodel/services/index.ts b/client/src/app/metamodel/services/index.ts index 1dc26fea..0d59591f 100644 --- a/client/src/app/metamodel/services/index.ts +++ b/client/src/app/metamodel/services/index.ts @@ -8,7 +8,6 @@ */ import { DatabaseService } from './database.service'; -import { SurveyService } from './survey.service'; import { GroupService } from './group.service'; import { InstanceGroupService } from './instance-group.service'; import { DatasetService } from './dataset.service'; @@ -25,7 +24,6 @@ import { ConeSearchConfigService } from './cone-search-config.service'; export const metamodelServices = [ DatabaseService, - SurveyService, GroupService, InstanceGroupService, DatasetService, diff --git a/client/src/app/metamodel/services/survey.service.spec.ts b/client/src/app/metamodel/services/survey.service.spec.ts deleted file mode 100644 index de82c5e0..00000000 --- a/client/src/app/metamodel/services/survey.service.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { TestBed, inject } from '@angular/core/testing'; -import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; - -import { SurveyService } from './survey.service'; -import { AppConfigService } from 'src/app/app-config.service'; -import { Survey } from '../models'; -import { SURVEY } from '../../../test-data'; - -describe('[Instance][Metamodel][Services] SurveyService', () => { - let service: SurveyService; - - beforeEach(() => { - TestBed.configureTestingModule({ - imports: [HttpClientTestingModule], - providers: [ - { provide: AppConfigService, useValue: { apiUrl: 'http://testing.com' } }, - SurveyService - ] - }); - service = TestBed.inject(SurveyService); - }); - - it('#retrieveSurveyList() should return an Observable<Survey[]>', - inject([HttpTestingController, SurveyService],(httpMock: HttpTestingController, service: SurveyService) => { - const mockResponse = []; - - service.retrieveSurveyList().subscribe((event: Survey[]) => { - expect(event).toEqual(mockResponse); - }); - - const mockRequest = httpMock.expectOne('http://testing.com/survey'); - - expect(mockRequest.cancelled).toBeFalsy(); - expect(mockRequest.request.method).toEqual('GET'); - expect(mockRequest.request.responseType).toEqual('json'); - mockRequest.flush(mockResponse); - - httpMock.verify(); - } - ) - ); - - it('#addSurvey() should return an Observable<Survey>', - inject([HttpTestingController, SurveyService],(httpMock: HttpTestingController, service: SurveyService) => { - const mockResponse = SURVEY; - - service.addSurvey(SURVEY).subscribe((event: Survey) => { - expect(event).toEqual(mockResponse); - }); - - const mockRequest = httpMock.expectOne('http://testing.com/survey'); - - expect(mockRequest.cancelled).toBeFalsy(); - expect(mockRequest.request.method).toEqual('POST'); - expect(mockRequest.request.responseType).toEqual('json'); - mockRequest.flush(mockResponse); - - httpMock.verify(); - } - ) - ); - - it('#editSurvey() should return an Observable<Survey>', - inject([HttpTestingController, SurveyService],(httpMock: HttpTestingController, service: SurveyService) => { - const mockResponse = SURVEY; - - service.editSurvey(SURVEY).subscribe((event: Survey) => { - expect(event).toEqual(mockResponse); - }); - - const mockRequest = httpMock.expectOne('http://testing.com/survey/mySurvey'); - - expect(mockRequest.cancelled).toBeFalsy(); - expect(mockRequest.request.method).toEqual('PUT'); - expect(mockRequest.request.responseType).toEqual('json'); - mockRequest.flush(mockResponse); - - httpMock.verify(); - } - ) - ); - - it('#deleteSurvey() should return an Observable<object>', - inject([HttpTestingController, SurveyService],(httpMock: HttpTestingController, service: SurveyService) => { - const mockResponse = {}; - - service.deleteSurvey('mySurvey').subscribe((event: object) => { - expect(event).toEqual(mockResponse); - }); - - const mockRequest = httpMock.expectOne('http://testing.com/survey/mySurvey'); - - expect(mockRequest.cancelled).toBeFalsy(); - expect(mockRequest.request.method).toEqual('DELETE'); - expect(mockRequest.request.responseType).toEqual('json'); - mockRequest.flush(mockResponse); - - httpMock.verify(); - } - ) - ); -}); diff --git a/client/src/app/metamodel/services/survey.service.ts b/client/src/app/metamodel/services/survey.service.ts deleted file mode 100644 index 926e6618..00000000 --- a/client/src/app/metamodel/services/survey.service.ts +++ /dev/null @@ -1,67 +0,0 @@ -/** - * 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 { Injectable } from '@angular/core'; -import { HttpClient } from '@angular/common/http'; - -import { Observable } from 'rxjs'; - -import { Survey } from '../models'; -import { AppConfigService } from 'src/app/app-config.service'; - -/** - * @class - * @classdesc Survey service. - */ -@Injectable() -export class SurveyService { - constructor(private http: HttpClient, private config: AppConfigService) { } - - /** - * Retrieves survey list. - * - * @return Observable<Survey[]> - */ - retrieveSurveyList(): Observable<Survey[]> { - return this.http.get<Survey[]>(`${this.config.apiUrl}/survey`); - } - - /** - * Adds a new survey. - * - * @param {Survey} newSurvey - The survey. - * - * @return Observable<Survey> - */ - addSurvey(newSurvey: Survey): Observable<Survey> { - return this.http.post<Survey>(`${this.config.apiUrl}/survey`, newSurvey); - } - - /** - * Modifies a survey. - * - * @param {Survey} survey - The survey. - * - * @return Observable<Survey> - */ - editSurvey(survey: Survey): Observable<Survey> { - return this.http.put<Survey>(`${this.config.apiUrl}/survey/${survey.name}`, survey); - } - - /** - * Removes a survey. - * - * @param {string} surveyName - The survey name. - * - * @return Observable<object> - */ - deleteSurvey(surveyName: string): Observable<object> { - return this.http.delete(`${this.config.apiUrl}/survey/${surveyName}`); - } -} diff --git a/client/src/app/shared/pipes/index.ts b/client/src/app/shared/pipes/index.ts index 0de129d3..f8ab54f4 100644 --- a/client/src/app/shared/pipes/index.ts +++ b/client/src/app/shared/pipes/index.ts @@ -9,7 +9,6 @@ import { DatasetListByFamilyPipe } from './dataset-list-by-family.pipe'; import { AttributeListByFamilyPipe } from './attribute-list-by-family.pipe'; -import { SurveyByNamePipe } from './survey-by-name.pipe'; import { OptionListBySelectPipe } from './option-list-by-select.pipe'; import { OutputFamilyByIdPipe } from './output-family-by-id.pipe'; import { DatasetByNamePipe } from './dataset-by-name.pipe'; @@ -18,7 +17,6 @@ import { InstanceByNamePipe } from './instance-by-name.pipe'; export const sharedPipes = [ DatasetListByFamilyPipe, AttributeListByFamilyPipe, - SurveyByNamePipe, OptionListBySelectPipe, OutputFamilyByIdPipe, DatasetByNamePipe, diff --git a/client/src/app/shared/pipes/survey-by-name.pipe.spec.ts b/client/src/app/shared/pipes/survey-by-name.pipe.spec.ts deleted file mode 100644 index 33e78e02..00000000 --- a/client/src/app/shared/pipes/survey-by-name.pipe.spec.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { SurveyByNamePipe } from './survey-by-name.pipe'; -import { SURVEY_LIST } from '../../../test-data'; - -describe('[Shared][Pipes] SurveyByNamePipe', () => { - let pipe = new SurveyByNamePipe(); - - it('should return survey corresponding to the given name', () => { - expect(pipe.transform(SURVEY_LIST, 'survey-one')).toEqual(SURVEY_LIST[0]); - }); -}); diff --git a/client/src/app/shared/pipes/survey-by-name.pipe.ts b/client/src/app/shared/pipes/survey-by-name.pipe.ts deleted file mode 100644 index 9546c92f..00000000 --- a/client/src/app/shared/pipes/survey-by-name.pipe.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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 { Survey } from 'src/app/metamodel/models'; - -/** - * @class - * @classdesc Returns survey corresponding to the given name. - * - * @example - * // returns survey object that matching with the 'mySurvey' name among the survey list - * {{ surveyList | surveyByName:'mySurvey' }} - */ -@Pipe({ name: 'surveyByName' }) -export class SurveyByNamePipe implements PipeTransform { - transform(surveyList: Survey[], surveyName: string): Survey { - return surveyList.find(survey => survey.name === surveyName); - } -} diff --git a/conf-dev/create-db.sh b/conf-dev/create-db.sh index e9d7d859..f46d5c55 100644 --- a/conf-dev/create-db.sh +++ b/conf-dev/create-db.sh @@ -51,22 +51,17 @@ curl -d '{"label":"Test","dbname":"anis_test","dbtype":"pdo_pgsql","dbhost":"db" # Add default instance curl -d '{"name":"default","label":"Default instance","description":"Instance for the test","display":10,"data_path":"\/DEFAULT","files_path":"\/INSTANCE_FILES","public":true,"portal_logo":"","design_color":"#7AC29A","design_background_color":"#ffffff","design_logo":"/logo.png","design_favicon":"/favicon.ico","home_component":"WelcomeComponent","home_component_config":{"home_component_text":"AstroNomical Information System","home_component_logo":"/home_component_logo.png"},"samp_enabled":true,"back_to_portal":true,"search_by_criteria_allowed":true,"search_by_criteria_label":"Search","search_multiple_allowed":false,"search_multiple_label":"Search multiple","search_multiple_all_datasets_selected":false,"documentation_allowed":false,"documentation_label":"Documentation"}' --header 'Content-Type: application/json' -X POST http://localhost/instance -# Add ANIS, SVOM and IRIS surveys -curl -d '{"name":"anis_survey","label":"ANIS survey","description":"Survey used for testing","link":"https://anis.lam.fr","manager":"F. Agneray","id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/survey -curl -d '{"name":"svom","label":"SVOM","description":"Survey used for testing","link":"https://www.svom.eu","manager":"S. Basa","id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/survey -curl -d '{"name":"iris","label":"IRiS","description":"Survey used for testing","link":"http://iris.lam.fr","manager":"S. Basa","id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/survey - # Add dataset families curl -d '{"label":"Default dataset family","display":10,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/instance/default/dataset-family curl -d '{"label":"SVOM dataset family","display":20,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/instance/default/dataset-family curl -d '{"label":"IRiS dataset family","display":30,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/instance/default/dataset-family # Add datasets -curl -d '{"name":"vipers_dr2_w1","table_ref":"aspic_vipers_dr2_w1","label":"VIPERS-W1 (DR2)","description":"VIPERS W1 dataset","display":10,"data_path":"\/ASPIC\/VIPERS_DR2","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"survey_name":"anis_survey"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset -curl -d '{"name":"sp_cards","table_ref":"sp_cards","label":"SP Metadata","description":"Contains metadata of scientific products (Core Program & General Program)","display":30,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"survey_name":"svom"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/2/dataset -curl -d '{"name":"observations","table_ref":"v_observation","label":"IRiS obs","description":"IRiS observations","display":10,"data_path":"\/IRIS\/observations","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"survey_name":"iris"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/3/dataset -curl -d '{"name":"vvds_f02_udeep","table_ref":"aspic_vvds_f02_udeep","label":"VVDS2h Ultra Deep","description":"VVDS2h Ultra Deep","display":20,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"survey_name":"anis_survey"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset -curl -d '{"name":"products","table_ref":"products","label":"Scientific Products","description":"SR3 & SR4 products list","display":20,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"survey_name":"svom"}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/2/dataset +curl -d '{"name":"vipers_dr2_w1","table_ref":"aspic_vipers_dr2_w1","label":"VIPERS-W1 (DR2)","description":"VIPERS W1 dataset","display":10,"data_path":"\/ASPIC\/VIPERS_DR2","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset +curl -d '{"name":"sp_cards","table_ref":"sp_cards","label":"SP Metadata","description":"Contains metadata of scientific products (Core Program & General Program)","display":30,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/2/dataset +curl -d '{"name":"observations","table_ref":"v_observation","label":"IRiS obs","description":"IRiS observations","display":10,"data_path":"\/IRIS\/observations","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/3/dataset +curl -d '{"name":"vvds_f02_udeep","table_ref":"aspic_vvds_f02_udeep","label":"VVDS2h Ultra Deep","description":"VVDS2h Ultra Deep","display":20,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/1/dataset +curl -d '{"name":"products","table_ref":"products","label":"Scientific Products","description":"SR3 & SR4 products list","display":20,"data_path":"","public":true,"download_enabled":true,"download_json":true,"download_csv":true,"download_ascii":true,"download_vo":false,"server_link_enabled":false,"datatable_enabled":true,"datatable_selectable_rows":false,"id_database":1}' --header 'Content-Type: application/json' -X POST http://localhost/dataset-family/2/dataset # Add vipers_dr2_w1 attributes curl -d '{"label":"Default","display":10,"opened":true}' --header 'Content-Type: application/json' -X POST http://localhost/dataset/vipers_dr2_w1/criteria-family diff --git a/server/app/routes.php b/server/app/routes.php index 29ee92f3..919f8211 100644 --- a/server/app/routes.php +++ b/server/app/routes.php @@ -35,8 +35,6 @@ $app->group('', function (RouteCollectorProxy $group) { $app->group('', function (RouteCollectorProxy $group) { $group->map([OPTIONS, GET, POST], '/instance-group', App\Action\InstanceGroupListAction::class); $group->map([OPTIONS, GET, PUT, DELETE], '/instance-group/{id}', App\Action\InstanceGroupAction::class); - $group->map([OPTIONS, GET, POST], '/survey', App\Action\SurveyListAction::class); - $group->map([OPTIONS, GET, PUT, DELETE], '/survey/{name}', App\Action\SurveyAction::class); $group->map([OPTIONS, GET, POST], '/instance', App\Action\InstanceListAction::class); $group->map([OPTIONS, GET, PUT, DELETE], '/instance/{name}', App\Action\InstanceAction::class); $group->map([OPTIONS, GET], '/instance/{name}/file-explorer[{fpath:.*}]', App\Action\InstanceFileExplorerAction::class); diff --git a/server/doctrine-proxy/__CG__AppEntityDataset.php b/server/doctrine-proxy/__CG__AppEntityDataset.php index f20ff747..3d5f3a35 100644 --- a/server/doctrine-proxy/__CG__AppEntityDataset.php +++ b/server/doctrine-proxy/__CG__AppEntityDataset.php @@ -67,10 +67,10 @@ class Dataset extends \App\Entity\Dataset implements \Doctrine\ORM\Proxy\Proxy public function __sleep() { if ($this->__isInitialized__) { - return ['__isInitialized__', 'name', 'tableRef', 'label', 'description', 'display', 'dataPath', 'public', 'downloadEnabled', 'downloadJson', 'downloadCsv', 'downloadAscii', 'downloadVo', 'serverLinkEnabled', 'datatableEnabled', 'datatableSelectableRows', '' . "\0" . 'App\\Entity\\Dataset' . "\0" . 'coneSearchConfig', 'survey', 'datasetFamily', 'attributes']; + return ['__isInitialized__', 'name', 'tableRef', 'label', 'description', 'display', 'dataPath', 'public', 'downloadEnabled', 'downloadJson', 'downloadCsv', 'downloadAscii', 'downloadVo', 'serverLinkEnabled', 'datatableEnabled', 'datatableSelectableRows', '' . "\0" . 'App\\Entity\\Dataset' . "\0" . 'coneSearchConfig', 'database', 'datasetFamily', 'attributes']; } - return ['__isInitialized__', 'name', 'tableRef', 'label', 'description', 'display', 'dataPath', 'public', 'downloadEnabled', 'downloadJson', 'downloadCsv', 'downloadAscii', 'downloadVo', 'serverLinkEnabled', 'datatableEnabled', 'datatableSelectableRows', '' . "\0" . 'App\\Entity\\Dataset' . "\0" . 'coneSearchConfig', 'survey', 'datasetFamily', 'attributes']; + return ['__isInitialized__', 'name', 'tableRef', 'label', 'description', 'display', 'dataPath', 'public', 'downloadEnabled', 'downloadJson', 'downloadCsv', 'downloadAscii', 'downloadVo', 'serverLinkEnabled', 'datatableEnabled', 'datatableSelectableRows', '' . "\0" . 'App\\Entity\\Dataset' . "\0" . 'coneSearchConfig', 'database', 'datasetFamily', 'attributes']; } /** @@ -525,12 +525,23 @@ class Dataset extends \App\Entity\Dataset implements \Doctrine\ORM\Proxy\Proxy /** * {@inheritDoc} */ - public function setSurvey($survey) + public function setDatabase($database) { - $this->__initializer__ && $this->__initializer__->__invoke($this, 'setSurvey', [$survey]); + $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDatabase', [$database]); - return parent::setSurvey($survey); + return parent::setDatabase($database); + } + + /** + * {@inheritDoc} + */ + public function getDatabase() + { + + $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDatabase', []); + + return parent::getDatabase(); } /** diff --git a/server/src/Action/DatasetListAction.php b/server/src/Action/DatasetListAction.php index bc3f8b5b..471659cd 100644 --- a/server/src/Action/DatasetListAction.php +++ b/server/src/Action/DatasetListAction.php @@ -16,7 +16,7 @@ use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; use Slim\Exception\HttpBadRequestException; use Slim\Exception\HttpNotFoundException; -use App\Entity\Survey; +use App\Entity\Database; use App\Entity\DatasetFamily; use App\Entity\Dataset; @@ -74,7 +74,7 @@ final class DatasetListAction extends AbstractAction 'display', 'data_path', 'public', - 'survey_name' + 'id_database' ); foreach ($fields as $a) { if ($this->isEmptyField($a, $parsedBody)) { @@ -85,17 +85,17 @@ final class DatasetListAction extends AbstractAction } } - // Survey is mandatory to add a new dataset - $surveyName = $parsedBody['survey_name']; - $survey = $this->em->find('App\Entity\Survey', $surveyName); - if (is_null($survey)) { + // Database is mandatory to add a new dataset + $idDatabase = $parsedBody['id_database']; + $database = $this->em->find('App\Entity\Database', $idDatabase); + if (is_null($database)) { throw new HttpBadRequestException( $request, - 'Survey with name ' . $surveyName . ' is not found' + 'Database with id ' . $idDatabase . ' is not found' ); } - $dataset = $this->postDataset($parsedBody, $survey, $datasetFamily); + $dataset = $this->postDataset($parsedBody, $database, $datasetFamily); $payload = json_encode($dataset); $response = $response->withStatus(201); } @@ -108,14 +108,14 @@ final class DatasetListAction extends AbstractAction * Create a new dataset doctrine object and save it * * @param array $parsedBody Contains the values ​​of the new dataset sent by the user - * @param Survey $survey Contains the survey doctrine object + * @param Database $database Contains the database doctrine object * @param DatasetFamily $datasetFamily Contains the dataset family doctrine object * * @return Dataset */ private function postDataset( array $parsedBody, - Survey $survey, + Database $database, DatasetFamily $datasetFamily ): Dataset { $dataset = new Dataset($parsedBody['name']); @@ -133,7 +133,7 @@ final class DatasetListAction extends AbstractAction $dataset->setServerLinkEnabled($parsedBody['server_link_enabled']); $dataset->setDatatableEnabled($parsedBody['datatable_enabled']); $dataset->setDatatableSelectableRows($parsedBody['datatable_selectable_rows']); - $dataset->setSurvey($survey); + $dataset->setDatabase($database); $dataset->setDatasetFamily($datasetFamily); $this->em->persist($dataset); diff --git a/server/src/Action/SearchAction.php b/server/src/Action/SearchAction.php index 52051a9e..7ee5e492 100644 --- a/server/src/Action/SearchAction.php +++ b/server/src/Action/SearchAction.php @@ -136,7 +136,7 @@ final class SearchAction extends AbstractAction try { // Configure the Anis Query Builder - $connection = $this->connectionFactory->create($dataset->getSurvey()->getDatabase()); + $connection = $this->connectionFactory->create($dataset->getDatabase()); $this->anisQueryBuilder->setDoctrineQueryBuilder($connection->createQueryBuilder()); $this->anisQueryBuilder->setDatasetSelected($dataset); diff --git a/server/src/Action/SurveyAction.php b/server/src/Action/SurveyAction.php deleted file mode 100644 index 0aeee0f1..00000000 --- a/server/src/Action/SurveyAction.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -/* - * This file is part of Anis Server. - * - * (c) 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. - */ -declare(strict_types=1); - -namespace App\Action; - -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\ResponseInterface; -use Slim\Exception\HttpBadRequestException; -use Slim\Exception\HttpNotFoundException; -use App\Entity\Database; -use App\Entity\Survey; - -/** - * @author François Agneray <francois.agneray@lam.fr> - * @package App\Action - */ -final class SurveyAction extends AbstractAction -{ - /** - * `GET` Returns the survey found - * `PUT` Full update the survey and returns the new version - * `DELETE` Delete the survey found and return a confirmation message - * - * @param ServerRequestInterface $request PSR-7 This object represents the HTTP request - * @param ResponseInterface $response PSR-7 This object represents the HTTP response - * @param string[] $args This table contains information transmitted in the URL (see routes.php) - * - * @return ResponseInterface - */ - public function __invoke( - ServerRequestInterface $request, - ResponseInterface $response, - array $args - ): ResponseInterface { - if ($request->getMethod() === OPTIONS) { - return $response->withHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, OPTIONS'); - } - - // Search the correct survey with primary key - $survey = $this->em->find('App\Entity\Survey', $args['name']); - - // If survey is not found 404 - if (is_null($survey)) { - throw new HttpNotFoundException( - $request, - 'Survey with name ' . $args['name'] . ' is not found' - ); - } - - if ($request->getMethod() === GET) { - $payload = json_encode($survey, JSON_UNESCAPED_SLASHES); - } - - if ($request->getMethod() === PUT) { - $parsedBody = $request->getParsedBody(); - - // If mandatories empty fields 400 - foreach (array('label', 'description', 'link', 'manager', 'id_database') as $a) { - if ($this->isEmptyField($a, $parsedBody)) { - throw new HttpBadRequestException( - $request, - 'Param ' . $a . ' needed to edit the survey' - ); - } - } - - // Database exists ? - $idDatabase = $parsedBody['id_database']; - $database = $this->em->find('App\Entity\Database', $idDatabase); - if (is_null($database)) { - throw new HttpBadRequestException( - $request, - 'Database with id ' . $idDatabase . ' is not found' - ); - } - - $this->editSurvey($survey, $parsedBody, $database); - $payload = json_encode($survey, JSON_UNESCAPED_SLASHES); - } - - if ($request->getMethod() === DELETE) { - $name = $survey->getName(); - $this->em->remove($survey); - $this->em->flush(); - $payload = json_encode(array('message' => 'Survey ' . $name . ' is removed!')); - } - - $response->getBody()->write($payload); - return $response; - } - - /** - * Update survey object with setters - * - * @param Survey $survey The survey to update - * @param string[] $parsedBody Contains the new values ​​of the survey sent by the user - * @param Database $database Contains the database doctrine object to set to the survey - */ - private function editSurvey(Survey $survey, array $parsedBody, Database $database): void - { - $survey->setLabel($parsedBody['label']); - $survey->setDescription($parsedBody['description']); - $survey->setLink($parsedBody['link']); - $survey->setManager($parsedBody['manager']); - $survey->setDatabase($database); - $this->em->flush(); - } -} diff --git a/server/src/Action/SurveyListAction.php b/server/src/Action/SurveyListAction.php deleted file mode 100644 index 852cff12..00000000 --- a/server/src/Action/SurveyListAction.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -/* - * This file is part of Anis Server. - * - * (c) 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. - */ -declare(strict_types=1); - -namespace App\Action; - -use Psr\Http\Message\ServerRequestInterface; -use Psr\Http\Message\ResponseInterface; -use Slim\Exception\HttpBadRequestException; -use App\Entity\Database; -use App\Entity\Survey; - -/** - * @author François Agneray <francois.agneray@lam.fr> - * @package App\Action - */ -final class SurveyListAction extends AbstractAction -{ - /** - * `GET` Returns a list of all surveys listed in the metamodel database - * `POST` Add a new survey - * - * @param ServerRequestInterface $request PSR-7 This object represents the HTTP request - * @param ResponseInterface $response PSR-7 This object represents the HTTP response - * @param string[] $args This table contains information transmitted in the URL (see routes.php) - * - * @return ResponseInterface - */ - public function __invoke( - ServerRequestInterface $request, - ResponseInterface $response, - array $args - ): ResponseInterface { - if ($request->getMethod() === OPTIONS) { - return $response->withHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS'); - } - - if ($request->getMethod() === GET) { - $surveys = $this->em->getRepository('App\Entity\Survey')->findAll(); - $payload = json_encode($surveys, JSON_UNESCAPED_SLASHES); - } - - if ($request->getMethod() === POST) { - $parsedBody = $request->getParsedBody(); - - // To work this action needs information to add a survey - foreach (array('name', 'label', 'description', 'link', 'manager', 'id_database') as $a) { - if ($this->isEmptyField($a, $parsedBody)) { - throw new HttpBadRequestException( - $request, - 'Param ' . $a . ' needed to add a new survey' - ); - } - } - - // Database exists ? - $idDatabase = $parsedBody['id_database']; - $database = $this->em->find('App\Entity\Database', $idDatabase); - if (is_null($database)) { - throw new HttpBadRequestException( - $request, - 'Database with id ' . $idDatabase . ' is not found' - ); - } - - $survey = $this->postSurvey($parsedBody, $database); - $payload = json_encode($survey, JSON_UNESCAPED_SLASHES); - $response = $response->withStatus(201); - } - - $response->getBody()->write($payload); - return $response; - } - - /** - * @param array $parsedBody Contains the values ​​of the new survey sent by the user - * @param Database $select Database on which the survey refers - * - * @return Survey - */ - private function postSurvey(array $parsedBody, Database $database): Survey - { - $survey = new Survey($parsedBody['name']); - $survey->setLabel($parsedBody['label']); - $survey->setDescription($parsedBody['description']); - $survey->setLink($parsedBody['link']); - $survey->setManager($parsedBody['manager']); - $survey->setDatabase($database); - - $this->em->persist($survey); - $this->em->flush(); - - return $survey; - } -} diff --git a/server/src/Entity/Dataset.php b/server/src/Entity/Dataset.php index c3a4f876..990d98a4 100644 --- a/server/src/Entity/Dataset.php +++ b/server/src/Entity/Dataset.php @@ -138,12 +138,12 @@ class Dataset implements \JsonSerializable private $coneSearchConfig; /** - * @var Survey + * @var Database * - * @ManyToOne(targetEntity="Survey", inversedBy="datasets") - * @JoinColumn(name="survey_name", referencedColumnName="name", nullable=false) + * @ManyToOne(targetEntity="Database") + * @JoinColumn(name="id_database", referencedColumnName="id", nullable=false) */ - protected $survey; + protected $database; /** * @var DatasetFamily @@ -321,14 +321,14 @@ class Dataset implements \JsonSerializable $this->coneSearchConfig = $coneSearchConfig; } - public function setSurvey($survey) + public function setDatabase($database) { - $this->survey = $survey; + $this->database = $database; } - public function getSurvey() + public function getDatabase() { - return $this->survey; + return $this->database; } public function getDatasetFamily() @@ -370,7 +370,7 @@ class Dataset implements \JsonSerializable 'datatable_enabled' => $this->getDatatableEnabled(), 'datatable_selectable_rows' => $this->getDatatableSelectableRows(), 'cone_search_config_id' => is_null($this->getConeSearchConfig()) ? null : $this->getConeSearchConfig()->getId(), - 'survey_name' => $this->getSurvey()->getName(), + 'id_database' => $this->getDatabase()->getId(), 'id_dataset_family' => $this->getDatasetFamily()->getId(), 'full_data_path' => $this->getFullDataPath() ]; diff --git a/server/src/Entity/Survey.php b/server/src/Entity/Survey.php deleted file mode 100644 index e2081089..00000000 --- a/server/src/Entity/Survey.php +++ /dev/null @@ -1,153 +0,0 @@ -<?php - -/* - * This file is part of Anis Server. - * - * (c) 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. - */ -declare(strict_types=1); - -namespace App\Entity; - -/** - * @author François Agneray <francois.agneray@lam.fr> - * @package App\Entity - * - * @Entity - * @Table(name="survey") - */ -class Survey implements \JsonSerializable -{ - /** - * @var string - * - * @Id - * @Column(type="string", nullable=false) - */ - protected $name; - - /** - * @var string - * - * @Column(type="text", nullable=false) - */ - protected $label; - - /** - * @var string - * - * @Column(type="text", nullable=true) - */ - protected $description; - - /** - * @var string - * - * @Column(type="string", nullable=true) - */ - protected $link; - - /** - * @var string - * - * @Column(type="string", nullable=false) - */ - protected $manager; - - /** - * @var Database - * - * @ManyToOne(targetEntity="Database") - * @JoinColumn(name="database_id", referencedColumnName="id", nullable=false) - */ - protected $database; - - /** - * @var Dataset[] - * - * @OneToMany(targetEntity="Dataset", mappedBy="survey") - */ - protected $datasets; - - public function __construct(string $name) - { - $this->name = $name; - $this->datasets = new \Doctrine\Common\Collections\ArrayCollection(); - } - - public function getName() - { - return $this->name; - } - - public function getLabel() - { - return $this->label; - } - - public function setLabel($label) - { - $this->label = $label; - } - - public function getDescription() - { - return $this->description; - } - - public function setDescription($description) - { - $this->description = $description; - } - - public function getLink() - { - return $this->link; - } - - public function setLink($link) - { - $this->link = $link; - } - - public function getManager() - { - return $this->manager; - } - - public function setManager($manager) - { - $this->manager = $manager; - } - - public function setDatabase($database) - { - $this->database = $database; - } - - public function getDatabase() - { - return $this->database; - } - - public function getDatasets() - { - return $this->datasets; - } - - public function jsonSerialize(): array - { - return [ - 'name' => $this->getName(), - 'label' => $this->getLabel(), - 'description' => $this->getDescription(), - 'link' => $this->getLink(), - 'manager' => $this->getManager(), - 'id_database' => $this->getDatabase()->getId(), - 'nb_datasets' => count($this->getDatasets()) - ]; - } -} -- GitLab