Commit 63ba2e60 authored by François Agneray's avatar François Agneray
Browse files

#57 => done

parent 8e6fb10b
Pipeline #4943 passed with stages
in 12 minutes and 29 seconds
......@@ -24,7 +24,7 @@
<span class="fas fa-edit"></span>
</button>
&nbsp;
<button [disabled]="!isCriteriaFamilyEmpty(criteriaFamily.id)" (click)="openModal(templateForDel, criteriaFamily); $event.stopPropagation()" class="btn btn-outline-danger">
<button (click)="openModal(templateForDel, criteriaFamily); $event.stopPropagation()" class="btn btn-outline-danger">
<span class="fas fa-trash-alt"></span>
</button>
</td>
......@@ -70,9 +70,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this criteria family : <strong>{{ criteriaFamilySelected.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -3,7 +3,7 @@ import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter, Templa
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { CriteriaFamily, Attribute } from '../../../store/model';
import { CriteriaFamily } from '../../../store/model';
@Component({
selector: 'app-criteria-family-list',
......@@ -13,7 +13,6 @@ import { CriteriaFamily, Attribute } from '../../../store/model';
})
export class CriteriaFamilyListComponent {
@Input() criteriaFamilyList: CriteriaFamily[];
@Input() attributeList: Attribute[];
@Output() addCriteriaFamily: EventEmitter<CriteriaFamily> = new EventEmitter();
@Output() editCriteriaFamily: EventEmitter<CriteriaFamily> = new EventEmitter();
@Output() deleteCriteriaFamily: EventEmitter<CriteriaFamily> = new EventEmitter();
......@@ -23,14 +22,6 @@ export class CriteriaFamilyListComponent {
constructor(private modalService: BsModalService) { }
isCriteriaFamilyEmpty(idFamily: number): boolean {
return this.getAttributeListByFamily(idFamily).length === 0;
}
getAttributeListByFamily(idFamily: number): Attribute[] {
return this.attributeList.filter(attribute => attribute.id_criteria_family === idFamily);
}
openModal(template: TemplateRef<any>, criteriaFamily: CriteriaFamily) {
this.criteriaFamilySelected = criteriaFamily;
this.modalRef = this.modalService.show(template);
......
......@@ -72,9 +72,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this output category : <strong>{{ outputCategorySelected.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -72,9 +72,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this output family : <strong>{{ outputFamilySelected.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -67,7 +67,6 @@
<app-criteria-family-list
*ngSwitchCase="'cfamilies'"
[criteriaFamilyList]="criteriaFamilyList"
[attributeList]="attributeList"
(addCriteriaFamily)="addCriteriaFamily.emit($event)"
(editCriteriaFamily)="editCriteriaFamily.emit($event)"
(deleteCriteriaFamily)="deleteCriteriaFamily.emit($event)">
......
......@@ -10,6 +10,7 @@
<th scope="col">Port</th>
<th scope="col">Login</th>
<th scope="col">Password</th>
<th scope="col">Nb projects</th>
<th scope="col">Actions</th>
</tr>
</thead>
......@@ -22,13 +23,14 @@
<td class="align-middle">{{ database.dbhost }}</td>
<td class="align-middle">{{ database.dbport }}</td>
<td class="align-middle">{{ database.dblogin }}</td>
<td class="align-middle">{{ database.dbpassword }}</td>
<td class="align-middle">*******</td>
<td class="align-middle">{{ getNbProjectByDatabase(database.id) }}</td>
<td class="align-middle">
<a title="Edit this database" routerLink="/edit-database/{{database.id}}" class="btn btn-outline-primary">
<span class="fas fa-edit"></span>
</a>
&nbsp;
<button title="Delete this database" (click)="openModal(template, database); $event.stopPropagation()" class="btn btn-outline-danger">
<button [disabled]="!isNoProjectAttachedToDatabase(database.id)" title="Delete this database" (click)="openModal(template, database); $event.stopPropagation()" class="btn btn-outline-danger">
<span class="fas fa-trash-alt"></span>
</button>
</td>
......@@ -44,9 +46,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this database : <strong>{{ databaseForDel.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -3,7 +3,7 @@ import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter, Templa
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { Database } from '../../store/model';
import { Database, Project } from '../../store/model';
@Component({
selector: 'app-database-list',
......@@ -12,6 +12,7 @@ import { Database } from '../../store/model';
})
export class DatabaseListComponent {
@Input() databaseList: Database[];
@Input() projectList: Project[];
@Output() deleteDatabase: EventEmitter<Database> = new EventEmitter();
modalRef: BsModalRef;
......@@ -19,6 +20,14 @@ export class DatabaseListComponent {
constructor(private modalService: BsModalService) { }
isNoProjectAttachedToDatabase(idDatabase: number): boolean {
return this.getNbProjectByDatabase(idDatabase) === 0;
}
getNbProjectByDatabase(idDatabase: number): number {
return this.projectList.filter(p => p.id_database === idDatabase).length
}
openModal(template: TemplateRef<any>, database: Database) {
this.databaseForDel = database;
this.modalRef = this.modalService.show(template);
......
......@@ -5,9 +5,9 @@
</button>
</div>
<div class="btn-group mr-2" role="group" aria-label="Second group">
<a routerLink="group" title="Handle groups" class="btn btn-outline-primary">
<button [disabled]="!isAuthenticationEnabled()" routerLink="group" title="Handle groups" class="btn btn-outline-primary">
<span class="fas fa-users"></span> Handle groups
</a>
</button>
</div>
</div>
......@@ -75,9 +75,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this dataset family : <strong>{{ datasetFamilySelected.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
\ No newline at end of file
......@@ -3,7 +3,7 @@ import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter, Templa
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { DatasetFamily, Dataset } from '../../store/model';
import { Instance, DatasetFamily, Dataset } from '../../store/model';
@Component({
selector: 'app-dataset-family-list',
......@@ -12,6 +12,7 @@ import { DatasetFamily, Dataset } from '../../store/model';
changeDetection: ChangeDetectionStrategy.OnPush
})
export class DatasetFamilyListComponent {
@Input() instance: Instance;
@Input() datasetFamilyList: DatasetFamily[];
@Input() datasetList: Dataset[];
@Output() addDatasetFamily: EventEmitter<DatasetFamily> = new EventEmitter();
......@@ -28,6 +29,10 @@ export class DatasetFamilyListComponent {
return this.getDatasetListByFamily(idFamily).length === 0;
}
isAuthenticationEnabled(): boolean {
return this.instance.config.authentication.allowed;
}
getDatasetListByFamily(idFamily: number): Dataset[] {
return this.datasetList.filter(dataset => dataset.id_dataset_family === idFamily);
}
......
......@@ -48,9 +48,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this dataset : <strong>{{ datasetForDel.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
\ No newline at end of file
......@@ -56,9 +56,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this group : <strong>{{ groupForDel.role }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -40,9 +40,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this instance : <strong>{{ instanceForDel.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -25,11 +25,13 @@
<input type="text" class="form-control" name="link" [ngModel]="model.link" #link="ngModel" required>
</div>
<div class="col-md-6">
<u>Test it</u>
<b>Test it</b>
<br>
<a [href]="model.link" target="_blank">
<i class="fa fa-link"></i> {{ model.link }}
</a>
<p style="margin-top: 13px;">
<a [href]="link.value" target="_blank">
<i class="fa fa-link"></i> {{ link.value }}
</a>
</p>
</div>
</div>
</div>
......
......@@ -8,6 +8,7 @@
<th scope="col">Link</th>
<th scope="col">Manager</th>
<th scope="col">Database</th>
<th scope="col">Nb datasets</th>
<th scope="col">Actions</th>
</tr>
</thead>
......@@ -16,15 +17,16 @@
<td class="align-middle">{{ project.name }}</td>
<td class="align-middle">{{ project.label }}</td>
<td class="align-middle">{{ project.description }}</td>
<td class="align-middle">{{ project.link }}</td>
<td class="align-middle"><a [href]="project.link" target="_blank">{{ project.link }}</a></td>
<td class="align-middle">{{ project.manager }}</td>
<td class="align-middle">{{ getDatabaseById(project.id_database).label }}</td>
<td class="align-middle">{{ project.nb_datasets }}</td>
<td class="align-middle">
<a title="Edit this project" routerLink="/edit-project/{{project.name}}" class="btn btn-outline-primary">
<span class="fas fa-edit"></span>
</a>
&nbsp;
<button title="Delete this project" (click)="openModal(template, project); $event.stopPropagation()" class="btn btn-outline-danger">
<button [disabled]="!isNoDatasetsAttachedToProjectd(project.name)" title="Delete this project" (click)="openModal(template, project); $event.stopPropagation()" class="btn btn-outline-danger">
<span class="fas fa-trash-alt"></span>
</button>
</td>
......@@ -40,9 +42,9 @@
<div class="modal-body">
<p>Are you sure you want to delete this project : <strong>{{ projectForDel.label }}</strong> ?</p>
<p>
<button (click)="modalRef.hide()" class="btn btn-default">No</button>
<button (click)="modalRef.hide()" class="btn btn-outline-primary">No</button>
&nbsp;
<button (click)="confirmDel()" class="btn btn-danger">Yes</button>
<button (click)="confirmDel()" class="btn btn-outline-danger">Yes</button>
</p>
</div>
</ng-template>
......@@ -20,6 +20,10 @@ export class ProjectListComponent {
constructor(private modalService: BsModalService) { }
isNoDatasetsAttachedToProjectd(projectName: string): boolean {
return this.projectList.find(p => p.name === projectName).nb_datasets === 0;
}
getDatabaseById(idDatabase: number): Database {
return this.databaseList.find(database => database.id === idDatabase);
}
......
......@@ -14,7 +14,11 @@
<div class="row mt-1">
<div class="col-12">
<app-database-list [databaseList]="databaseList | async" (deleteDatabase)="deleteDatabase($event)"></app-database-list>
<app-database-list
[databaseList]="databaseList | async"
[projectList]="projectList | async"
(deleteDatabase)="deleteDatabase($event)">
</app-database-list>
</div>
</div>
</div>
\ No newline at end of file
......@@ -2,10 +2,12 @@ import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { Database } from '../../store/model';
import { Database, Project } from '../../store/model';
import * as databaseActions from '../../store/action/database.action';
import * as projectActions from '../../store/action/project.action';
import * as databaseReducer from '../../store/reducer/database.reducer';
import * as databaseSelector from '../../store/selector/database.selector';
import * as projectSelector from '../../store/selector/project.selector';
@Component({
selector: 'app-database',
......@@ -15,15 +17,22 @@ export class DatabaseComponent implements OnInit {
public databaseListIsLoading: Observable<boolean>;
public databaseListIsLoaded: Observable<boolean>;
public databaseList: Observable<Database[]>;
public projectListIsLoading: Observable<boolean>;
public projectListIsLoaded: Observable<boolean>;
public projectList: Observable<Project[]>;
constructor(private store: Store<databaseReducer.State>) {
this.databaseListIsLoading = store.select(databaseSelector.getDatabaseListIsLoading);
this.databaseListIsLoaded = store.select(databaseSelector.getDatabaseListIsLoaded);
this.databaseList = store.select(databaseSelector.getDatabaseList);
this.projectListIsLoading = store.select(projectSelector.getProjectListIsLoading);
this.projectListIsLoaded = store.select(projectSelector.getProjectListIsLoaded);
this.projectList = store.select(projectSelector.getProjectList);
}
ngOnInit() {
this.store.dispatch(new databaseActions.LoadDatabaseListAction());
this.store.dispatch(new projectActions.LoadProjectListAction());
}
deleteDatabase(database: Database) {
......
......@@ -2,7 +2,7 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="/instance-list">Instances</a></li>
<li class="breadcrumb-item active" aria-current="page">Configure instance {{ instanceSelected | async }}
<li class="breadcrumb-item active" aria-current="page">Configure instance {{ (instance | async).label }}
</li>
</ol>
</nav>
......@@ -16,7 +16,7 @@
</div>
<div *ngIf="(datasetFamilyListIsLoaded | async) && (datasetListIsLoaded | async)">
<app-dataset-family-list [datasetFamilyList]="datasetFamilyList | async" [datasetList]="datasetList | async"
<app-dataset-family-list [instance]="instance | async" [datasetFamilyList]="datasetFamilyList | async" [datasetList]="datasetList | async"
(addDatasetFamily)="addDatasetFamily($event)" (editDatasetFamily)="editDatasetFamily($event)"
(deleteDatasetFamily)="deleteDatasetFamily($event)" (deleteDataset)="deleteDataset($event)">
</app-dataset-family-list>
......
......@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
import { Store } from '@ngrx/store';
import { DatasetFamily, Dataset } from '../../store/model';
import { Instance, DatasetFamily, Dataset } from '../../store/model';
import * as instanceActions from '../../store/action/instance.action';
import * as instanceSelector from '../../store/selector/instance.selector';
import * as datasetFamilyActions from '../../store/action/dataset-family.action';
import * as datasetFamilySelector from '../../store/selector/dataset-family.selector';
......@@ -15,7 +16,7 @@ import * as metamodelReducer from '../../store/reducer';
templateUrl: 'configure-instance.component.html'
})
export class ConfigureInstanceComponent implements OnInit {
public instanceSelected: Observable<string>;
public instance: Observable<Instance>;
public datasetFamilyListIsLoading: Observable<boolean>;
public datasetFamilyListIsLoaded: Observable<boolean>;
public datasetFamilyList: Observable<DatasetFamily[]>;
......@@ -24,7 +25,7 @@ export class ConfigureInstanceComponent implements OnInit {
public datasetList: Observable<Dataset[]>;
constructor(private store: Store<metamodelReducer.State>) {
this.instanceSelected = store.select(instanceSelector.getInstanceSelected);
this.instance = store.select(instanceSelector.getInstanceByRouteName);
this.datasetFamilyListIsLoading = store.select(datasetFamilySelector.getDatasetFamilyListIsLoading);
this.datasetFamilyListIsLoaded = store.select(datasetFamilySelector.getDatasetFamilyListIsLoaded);
this.datasetFamilyList = store.select(datasetFamilySelector.getDatasetFamilyList);
......@@ -34,6 +35,7 @@ export class ConfigureInstanceComponent implements OnInit {
}
ngOnInit() {
this.store.dispatch(new instanceActions.LoadInstanceListAction());
this.store.dispatch(new datasetFamilyActions.LoadDatasetFamilyListAction());
this.store.dispatch(new datasetActions.LoadDatasetListAction());
}
......
......@@ -15,6 +15,8 @@ export const EDIT_PROJECT_FAIL = '[Project] Edit Project Fail';
export const DELETE_PROJECT = '[Project] Delete Project';
export const DELETE_PROJECT_SUCCESS = '[Project] Delete Project Success';
export const DELETE_PROJECT_FAIL = '[Project] Delete Project Fail';
export const INCREMENT_NB_DATASETS = '[Project] Increment Nb Datasets';
export const DECREMENT_NB_DATASETS = '[Project] Decrement Nb Datasets';
export class LoadProjectListAction implements Action {
type = LOAD_PROJECT_LIST;
......@@ -94,6 +96,18 @@ export class DeleteProjectFailAction implements Action {
constructor(public payload: {} = null) { }
}
export class IncrementNbDatasetsAction implements Action {
type = INCREMENT_NB_DATASETS;
constructor(public payload: string) { }
}
export class DecrementNbDatasetsAction implements Action {
type = DECREMENT_NB_DATASETS;
constructor(public payload: string) { }
}
export type Actions
= LoadProjectListAction
| LoadProjectListWipAction
......@@ -107,4 +121,6 @@ export type Actions
| EditProjectFailAction
| DeleteProjectAction
| DeleteProjectSuccessAction
| DeleteProjectFailAction;
| DeleteProjectFailAction
| IncrementNbDatasetsAction
| DecrementNbDatasetsAction;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment