From 72cad823fb57f96439341e4b1c35b9e16a2b647f Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 5 Feb 2018 11:44:40 +0200 Subject: [PATCH 1/5] add researcher from dmp editor --- .../add-researchers.component.html | 19 +++++++ .../add-researchers.component.ts | 39 +++++++++++++ dmp-frontend/src/app/app.module.ts | 2 - dmp-frontend/src/app/dmps/dmps.module.ts | 7 ++- .../app/dmps/editor/dmp-editor.component.html | 56 ++++++++++--------- .../app/dmps/editor/dmp-editor.component.ts | 17 +++++- .../app/models/researcher/ResearcherModel.ts | 12 ++++ .../researchers/researchers.service.ts | 31 ++++++++++ dmp-frontend/src/assets/lang/en.json | 11 +++- 9 files changed, 163 insertions(+), 31 deletions(-) create mode 100644 dmp-frontend/src/app/add-researchers/add-researchers.component.html create mode 100644 dmp-frontend/src/app/add-researchers/add-researchers.component.ts create mode 100644 dmp-frontend/src/app/services/researchers/researchers.service.ts diff --git a/dmp-frontend/src/app/add-researchers/add-researchers.component.html b/dmp-frontend/src/app/add-researchers/add-researchers.component.html new file mode 100644 index 000000000..9c13f0eea --- /dev/null +++ b/dmp-frontend/src/app/add-researchers/add-researchers.component.html @@ -0,0 +1,19 @@ +
+

{{'ADDRESEARCHERS-EDITOR.TITLE' | translate}}

+
+ + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
+
+
+ + +
+
+
\ No newline at end of file diff --git a/dmp-frontend/src/app/add-researchers/add-researchers.component.ts b/dmp-frontend/src/app/add-researchers/add-researchers.component.ts new file mode 100644 index 000000000..78aadbc11 --- /dev/null +++ b/dmp-frontend/src/app/add-researchers/add-researchers.component.ts @@ -0,0 +1,39 @@ +import { JsonSerializer } from '../utilities/JsonSerializer'; +import { RequestItem } from '../models/criteria/RequestItem'; +import { Component, OnInit, Inject } from "@angular/core"; +import { FormGroup } from '@angular/forms'; +import { Params, ActivatedRoute, Router } from '@angular/router'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material'; +import { ResearcherModel } from '@app/models/researcher/ResearcherModel'; +import { ResearcherService } from '@app/services/researchers/researchers.service'; + +@Component({ + selector: 'add-researchers-component', + templateUrl: 'add-researchers.component.html', + providers: [ResearcherService] + +}) +export class AddResearchersComponent implements OnInit { + + private formGroup: FormGroup; + + constructor( + private researcherService: ResearcherService, + private route: ActivatedRoute, + public router: Router, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { } + + ngOnInit(): void { + let researcher = new ResearcherModel(); + this.formGroup = researcher.buildForm(); + } + + + send(value: any) { + this.researcherService.createResearcher(this.formGroup.value).subscribe( + null, null, () => this.dialogRef.close() + ); + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 46d74de9d..0da556738 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -25,7 +25,6 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { FigurecardComponent } from './shared/components/figurecard/figurecard.component'; import { InvitationAcceptedComponent } from './invitation-accepted/invitation-accepted.component'; -import { InvitationComponent } from './invitation/invitation.component'; import { HomepageComponent } from './homepage/homepage.component'; import { PageNotFoundComponent } from './not-found.component'; import { AppComponent } from './app.component'; @@ -33,7 +32,6 @@ import { NgModule } from "@angular/core"; import { DatasetProfileModule } from './dataset-profile-form/dataset-profile.module'; import { WelcomepageComponent } from '@app/welcomepage/welcomepage.component'; - @NgModule({ declarations: [ AppComponent, diff --git a/dmp-frontend/src/app/dmps/dmps.module.ts b/dmp-frontend/src/app/dmps/dmps.module.ts index 598b96d85..e6f3385a8 100644 --- a/dmp-frontend/src/app/dmps/dmps.module.ts +++ b/dmp-frontend/src/app/dmps/dmps.module.ts @@ -13,6 +13,8 @@ import { CommonModule } from '@angular/common'; import { SharedModule } from '../shared/shared.module' import { NgModule } from '@angular/core'; +import { AddResearchersComponent } from '@app/add-researchers/add-researchers.component'; + @NgModule({ imports: [ CommonModule, @@ -35,6 +37,7 @@ import { NgModule } from '@angular/core'; DataManagementPlanEditorComponent, InvitationComponent, InvitationAcceptedComponent, + AddResearchersComponent ], exports: [ @@ -42,10 +45,12 @@ import { NgModule } from '@angular/core'; DataManagementPlanEditorComponent, InvitationComponent, InvitationAcceptedComponent, + AddResearchersComponent ], entryComponents: [ - InvitationComponent + InvitationComponent, + AddResearchersComponent ], providers: [ BaseHttpService diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html index 3768100f5..aa650f1c6 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html @@ -18,15 +18,12 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} - + + (inputChange)="filterProfiles($event)" requireMatch required>
{{chip.label.substring(0, 1).toUpperCase()}}
{{chip.label}} @@ -37,9 +34,11 @@
- {{'GENERAL.VALIDATION.REQUIRED' | translate}} + + {{'GENERAL.VALIDATION.REQUIRED' | translate}} +
- + @@ -55,28 +54,35 @@ - - -
{{chip.name.substring(0, 1).toUpperCase()}}
- {{chip.name}} -
- -
- {{option.name}} -
-
- -
+
+ + +
{{chip.name.substring(0, 1).toUpperCase()}}
+ {{chip.name}} +
+ +
+ {{option.name}} +
+
+ +
+ + +
+ -

Associated Users

- +

Associated Users

+ person
{{user.name}}
-
- + +
diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts index 9fed22ddd..a27c74f0a 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts @@ -1,5 +1,5 @@ import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core"; -import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; +import { MatPaginator, MatSort, MatSnackBar, MatDialog } from "@angular/material"; import { Router, ActivatedRoute, Params } from "@angular/router"; import { TranslateService } from "@ngx-translate/core"; import { DataSource } from "@angular/cdk/table"; @@ -20,6 +20,7 @@ import { AutoCompleteConfiguration } from "../../shared/components/autocomplete/ import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria"; import { ProjectService } from "../../services/project/project.service"; import { DmpUsersModel } from "@app/models/dmpUsers/DmpUsersModel"; +import { AddResearchersComponent } from "@app/add-researchers/add-researchers.component"; @@ -56,7 +57,8 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { public snackBar: MatSnackBar, public router: Router, public language: TranslateService, - private _service: DataManagementPlanService + private _service: DataManagementPlanService, + public dialog: MatDialog ) { } @@ -209,4 +211,15 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { } } + addResearcher(rowId: any, rowName: any) { + let dialogRef = this.dialog.open(AddResearchersComponent, { + height: '255px', + width: '700px', + data: { + dmpId: rowId, + dmpName: rowName + } + }); + } + } \ No newline at end of file diff --git a/dmp-frontend/src/app/models/researcher/ResearcherModel.ts b/dmp-frontend/src/app/models/researcher/ResearcherModel.ts index 03cbace90..8ad928280 100644 --- a/dmp-frontend/src/app/models/researcher/ResearcherModel.ts +++ b/dmp-frontend/src/app/models/researcher/ResearcherModel.ts @@ -1,8 +1,10 @@ import { Serializable } from "../Serializable"; +import { FormGroup, FormBuilder } from '@angular/forms'; export class ResearcherModel implements Serializable { public id: String; public name: String; + public lastName: String; public uri: String; public email: String; @@ -14,4 +16,14 @@ export class ResearcherModel implements Serializable { return this; } + + buildForm(): FormGroup { + let formGroup = new FormBuilder().group({ + firstName:[this.name], + lastName:[this.lastName] + }) + + return formGroup; + } + } \ No newline at end of file diff --git a/dmp-frontend/src/app/services/researchers/researchers.service.ts b/dmp-frontend/src/app/services/researchers/researchers.service.ts new file mode 100644 index 000000000..07a0dbaaa --- /dev/null +++ b/dmp-frontend/src/app/services/researchers/researchers.service.ts @@ -0,0 +1,31 @@ +import { Invitation } from '../../models/invitation/Invitation'; +import { UserInvitationCriteria } from '../../models/criteria/invitation/UserInvitationCriteria'; +import { User } from '../../models/invitation/User'; +import { HostConfiguration } from '../../app.constants'; +import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service'; +import { Injectable } from "@angular/core"; +import { HttpHeaders } from '@angular/common/http'; +import { Observable } from 'rxjs/Observable'; +import { RequestItem } from '../../models/criteria/RequestItem'; +import { ResearcherModel } from '@app/models/researcher/ResearcherModel'; + +@Injectable() +export class ResearcherService { + + private actionUrl: string; + private headers: HttpHeaders; + + constructor(private http: BaseHttpService) { + + this.actionUrl = HostConfiguration.Server + 'researchers/'; + + this.headers = new HttpHeaders(); + this.headers = this.headers.set('Content-Type', 'application/json'); + this.headers = this.headers.set('Accept', 'application/json'); + } + + public createResearcher(researcher: ResearcherModel) { + return this.http.post(this.actionUrl + "create", researcher, { headers: this.headers }); + } + +} \ No newline at end of file diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index 4ec10f343..43cc7e433 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -199,5 +199,14 @@ "USER": "User", "MANAGER": "Manager" } - } + }, + "ADDRESEARCHERS-EDITOR": { + "TITLE": "Add a Researcher", + "FIRST_NAME": "First Name", + "LAST_NAME": "Last Name", + "ACTIONS": { + "SAVE": "Save", + "CANCEL": "Cancel" + } + } } \ No newline at end of file From 2fb06c63d0f1bbf034ce40221aba3e56a88eed7e Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 5 Feb 2018 12:34:25 +0200 Subject: [PATCH 2/5] Confirmation message dmp delete --- dmp-frontend/src/app/dmps/dmps.module.ts | 3 ++- .../app/dmps/editor/dmp-editor.component.html | 2 +- .../app/dmps/editor/dmp-editor.component.ts | 25 +++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/dmps/dmps.module.ts b/dmp-frontend/src/app/dmps/dmps.module.ts index e6f3385a8..4ae220f53 100644 --- a/dmp-frontend/src/app/dmps/dmps.module.ts +++ b/dmp-frontend/src/app/dmps/dmps.module.ts @@ -9,7 +9,7 @@ import { DataManagementPlanRoutes } from './dmps.routes'; import { HttpClient, HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { CommonModule } from '@angular/common'; - +import { CovalentDialogsModule } from '@covalent/core'; import { SharedModule } from '../shared/shared.module' import { NgModule } from '@angular/core'; @@ -30,6 +30,7 @@ import { AddResearchersComponent } from '@app/add-researchers/add-researchers.co deps: [HttpClient] } }), + CovalentDialogsModule ], declarations: [ diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html index aa650f1c6..b2af3ecb7 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html @@ -88,7 +88,7 @@ - +
diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts index a27c74f0a..f095ae735 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts @@ -21,7 +21,8 @@ import { ProjectCriteria } from "../../models/criteria/project/ProjectCriteria"; import { ProjectService } from "../../services/project/project.service"; import { DmpUsersModel } from "@app/models/dmpUsers/DmpUsersModel"; import { AddResearchersComponent } from "@app/add-researchers/add-researchers.component"; - +import { ViewContainerRef } from '@angular/core'; +import { TdDialogService } from '@covalent/core'; @Component({ @@ -58,7 +59,9 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { public router: Router, public language: TranslateService, private _service: DataManagementPlanService, - public dialog: MatDialog + public dialog: MatDialog, + private _dialogService: TdDialogService, + private _viewContainerRef: ViewContainerRef ) { } @@ -222,4 +225,22 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { }); } + openConfirm(dmpLabel): void { + this._dialogService.openConfirm({ + message: 'Are you sure you want to delete the "' + dmpLabel +'"', + disableClose: true || false, // defaults to false + viewContainerRef: this._viewContainerRef, //OPTIONAL + title: 'Confirm', //OPTIONAL, hides if not provided + cancelButton: 'No', //OPTIONAL, defaults to 'CANCEL' + acceptButton: 'Yes' //OPTIONAL, defaults to 'ACCEPT' + // width: '500px', //OPTIONAL, defaults to 400px + }).afterClosed().subscribe((accept: boolean) => { + if (accept) { + // DO SOMETHING + } else { + // DO SOMETHING ELSE + } + }); + } + } \ No newline at end of file From 18a6c7cc85aaf4c262a98d0af2a7fb851d03c805 Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 5 Feb 2018 12:38:11 +0200 Subject: [PATCH 3/5] rename column version --> latest version --- dmp-frontend/src/app/dmps/listing/dmp-listing.component.html | 2 +- dmp-frontend/src/assets/lang/en.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html index d5fb341bb..a21575fe5 100644 --- a/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html +++ b/dmp-frontend/src/app/dmps/listing/dmp-listing.component.html @@ -41,7 +41,7 @@ - {{'DMP-LISTING.COLUMNS.VERSION' | translate}} + {{'DMP-LISTING.COLUMNS.LATEST_VERSION' | translate}} {{row.version}} diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index 405fbba39..bd964d6f6 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -47,7 +47,7 @@ "PROFILE": "Profile", "CREATION-TIME": "Creation Time", "ORGANISATIONS": "Organisations", - "VERSION": "Version", + "LATEST_VERSION": "Latest Version", "ACTIONS": "Actions", "DATASETS":"Datasets" }, From b3bf19be0bdf41ace97c60b8e9ef776cceb1cdc4 Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 5 Feb 2018 13:26:23 +0200 Subject: [PATCH 4/5] dmp delete --- dmp-frontend/src/app/dmps/editor/dmp-editor.component.html | 2 +- dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts | 6 ++++-- .../data-management-plan/data-management-plan.service.ts | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html index b2af3ecb7..fcc41ff99 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.html @@ -88,7 +88,7 @@ - + diff --git a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts index f095ae735..642b6ddc0 100644 --- a/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/dmps/editor/dmp-editor.component.ts @@ -225,7 +225,7 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { }); } - openConfirm(dmpLabel): void { + openConfirm(dmpLabel, id): void { this._dialogService.openConfirm({ message: 'Are you sure you want to delete the "' + dmpLabel +'"', disableClose: true || false, // defaults to false @@ -236,7 +236,9 @@ export class DataManagementPlanEditorComponent implements AfterViewInit { // width: '500px', //OPTIONAL, defaults to 400px }).afterClosed().subscribe((accept: boolean) => { if (accept) { - // DO SOMETHING + this.dataManagementPlanService.delete(id).subscribe(()=>{ + this.router.navigate(['/dmps']) + }); } else { // DO SOMETHING ELSE } diff --git a/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts b/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts index 2f6b7e96b..8eb65373f 100644 --- a/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts +++ b/dmp-frontend/src/app/services/data-management-plan/data-management-plan.service.ts @@ -52,4 +52,8 @@ export class DataManagementPlanService { createDataManagementPlanClone(dataManagementPlanModel: DataManagementPlanModel, id:String): Observable { return this.http.post(this.actionUrl + 'clone/' + id , dataManagementPlanModel, { headers: this.headers }); } + + delete(id: String): Observable { + return this.http.delete(this.actionUrl + 'delete/' + id, { headers: this.headers }); + } } From 3df3ed15ce5789abef9df9ec55d435317b9ddb2d Mon Sep 17 00:00:00 2001 From: annampak Date: Tue, 6 Feb 2018 15:56:33 +0200 Subject: [PATCH 5/5] Dataset Profile Datatable Admin- material was implemented --- dmp-frontend/src/app/app-routing.module.ts | 1 + .../dataset-profile.router.ts | 1 - .../dataset-admin-listing.component.html | 94 +++++++++++ .../dataset-admin-listing.component.scss | 35 ++++ .../dataset-admin-listing.component.ts | 156 ++++++++++++++++++ .../dataset-admin.module.ts | 54 ++++++ .../dataset-admin.routes.ts | 7 + .../datasetProfileAfmin.service.ts | 10 +- .../navigation/navigation.component.html | 1 + dmp-frontend/src/assets/lang/en.json | 3 +- 10 files changed, 354 insertions(+), 8 deletions(-) create mode 100644 dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.html create mode 100644 dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.scss create mode 100644 dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts create mode 100644 dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts create mode 100644 dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index f70d29cdf..05223d28e 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -16,6 +16,7 @@ const appRoutes: Routes = [ { path: '', redirectTo: '/welcome', pathMatch: 'full' }, { path: "unauthorized", loadChildren: './unauthorized/unauthorized.module#UnauthorizedModule' }, { path: "users", loadChildren: './users/users.module#UsersModule' }, + { path: "datasetsProfiles", loadChildren: './datasets-admin-listing/dataset-admin.module#DatasetAdminModule' }, { path: "welcome", component: WelcomepageComponent } ]; diff --git a/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts index 44e2337e6..e4f05656b 100644 --- a/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts +++ b/dmp-frontend/src/app/dataset-profile-form/dataset-profile.router.ts @@ -2,7 +2,6 @@ import { RouterModule, Routes } from '@angular/router'; import { FormComponent } from 'app/dataset-profile-form/form/form.component'; export const DatasetProfileRoutes: Routes = [ - //{ path: "new/:dmpId", component: DatasetWizardComponent, canActivate: [AuthGuard] } { path: ':id', component: FormComponent diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.html b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.html new file mode 100644 index 000000000..78465427a --- /dev/null +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.html @@ -0,0 +1,94 @@ +
+

{{titlePrefix}} {{'DATASET-LISTING.TITLE' | translate}}

+ + + + + + + + + + + + {{'DATASET-LISTING.COLUMNS.NAME' | translate}} + {{row.label}} + + + + + {{'DATASET-LISTING.COLUMNS.DMP' | translate}} + {{row.dmp}} + + + + + {{'DATASET-LISTING.COLUMNS.PROFILE' | translate}} + {{row.profile}} + + + + + {{'DATASET-LISTING.COLUMNS.DATAREPOSITORIES' | translate}} + {{row.dataRepositories}} + + + + + {{'DATASET-LISTING.COLUMNS.REGISTRIES' | translate}} + {{row.registries}} + + + + + {{'DATASET-LISTING.COLUMNS.SERVICES' | translate}} + {{row.services}} + + + + + + + + {{'DATASET-LISTING.COLUMNS.DESCRIPTION' | translate}} + {{row.description}} + + + + + {{'DATASET-LISTING.COLUMNS.CREATED' | translate}} + {{row.created | date:'shortDate'}} + + + + + {{'DATASET-LISTING.COLUMNS.ACTIONS' | translate}} + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.scss b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.scss new file mode 100644 index 000000000..2688cb118 --- /dev/null +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.scss @@ -0,0 +1,35 @@ +.mat-table { + margin: 24px; +} + +.mat-fab-bottom-right { + top: auto !important; + right: 20px !important; + bottom: 10px !important; + left: auto !important; + position: fixed !important; +} + +.full-width { + width: 100%; +} + +.mat-card { + margin: 16px 0; +} + +.mat-row { + cursor: pointer; +} + +mat-row:hover { + background-color: lightgray; +} + +// mat-row:nth-child(even){ +// background-color:red; +// } + +mat-row:nth-child(odd){ + background-color:#eef0fb; + } \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts new file mode 100644 index 000000000..02332b1df --- /dev/null +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin-listing.component.ts @@ -0,0 +1,156 @@ +import { DataTableRequest } from '../models/data-table/DataTableRequest'; +import { DatasetListingModel } from '../models/datasets/DatasetListingModel'; +import { DatasetCriteria } from '../models/criteria/dataset/DatasetCriteria'; +import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core"; +import { MatPaginator, MatSort, MatSnackBar } from "@angular/material"; +import { Router, Params, ActivatedRoute } from "@angular/router"; +import { TranslateService } from "@ngx-translate/core"; +import { DataSource } from "@angular/cdk/table"; + +import { Observable } from "rxjs/Observable"; +import { PageEvent } from '@angular/material'; +import { DataManagementPlanService } from "@app/services/data-management-plan/data-management-plan.service"; +import { DataManagementPlanModel } from "@app/models/data-managemnt-plans/DataManagementPlanModel"; +import { DatasetCriteriaComponent } from '@app/shared/components/criteria/datasets/datasets-criteria.component'; +import { DatasetProfileAdmin } from '@app/services/datasetProfileAdmin/datasetProfileAfmin.service'; + + +@Component({ + selector: 'app-dataset-admin-listing-component', + templateUrl: 'dataset-admin-listing.component.html', + styleUrls: ['./dataset-admin-listing.component.scss'], + providers: [DatasetProfileAdmin, DataManagementPlanService] +}) +export class DatasetAdminListingComponent implements OnInit { + + @ViewChild(MatPaginator) _paginator: MatPaginator; + @ViewChild(MatSort) sort: MatSort; + @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; + + + dataSource: DatasetDataSource | null; + displayedColumns: String[] = ['label', 'dmp', 'profile', 'dataRepositories', 'registries', 'services', 'description', 'created', 'actions']; + pageEvent: PageEvent; + titlePrefix: String; + dmpId: String; + + statuses = [ + { value: '0', viewValue: 'Active' }, + { value: '1', viewValue: 'Inactive' } + ]; + + constructor( + private datasetService: DatasetProfileAdmin, + private router: Router, + private languageService: TranslateService, + public snackBar: MatSnackBar, + public route: ActivatedRoute, + public dataManagementPlanService: DataManagementPlanService + ) { + + } + + + ngOnInit() { + this.route.params.subscribe((params: Params) => { + this.dmpId = params['dmpId']; + if (this.dmpId != null) this.setDmpTitle(this.dmpId); + this.criteria.setCriteria(this.getDefaultCriteria(this.dmpId)); + this.refresh(); + this.criteria.setRefreshCallback(() => this.refresh()); + }); + } + + setDmpTitle(dmpId: String) { + this.dataManagementPlanService.getSingle(dmpId).map(data => data as DataManagementPlanModel) + .subscribe(data => { + this.titlePrefix = data.label; + }); + } + + refresh() { + this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); + } + + rowClick(rowId: String) { + this.router.navigate(['form/' + rowId]); + } + + getDefaultCriteria(dmpId: String): DatasetCriteria { + const defaultCriteria = new DatasetCriteria(); + if (dmpId != null) { + defaultCriteria.dmpIds.push(dmpId); + } + return defaultCriteria; + } + + // makeItPublic(id: String) { + // debugger; + // this.datasetService.makeDatasetPublic(id).subscribe(); + // } + +} + +export class DatasetDataSource extends DataSource { + + totalCount = 0; + isLoadingResults = false; + + constructor( + private _service: DatasetProfileAdmin, + private _paginator: MatPaginator, + private _sort: MatSort, + private _languageService: TranslateService, + private _snackBar: MatSnackBar, + private _criteria: DatasetCriteriaComponent + ) { + super(); + + } + + connect(): Observable { + const displayDataChanges = [ + this._paginator.page + //this._sort.matSortChange + ]; + + + return Observable.merge(...displayDataChanges) + .startWith(null) + .switchMap(() => { + setTimeout(() => { + this.isLoadingResults = true; + }); + const startIndex = this._paginator.pageIndex * this._paginator.pageSize; + let fields: Array = new Array() + if (this._sort.active) fields = this._sort.direction === "asc" ? ["+" + this._sort.active] : ["-" + this._sort.active]; + const request = new DataTableRequest(startIndex, this._paginator.pageSize, { fields: fields }); + request.criteria = this._criteria.criteria; + return this._service.getPaged(request); + }) + /*.catch((error: any) => { + this._snackBar.openFromComponent(SnackBarNotificationComponent, { + data: { message: 'GENERAL.SNACK-BAR.FORMS-BAD-REQUEST', language: this._languageService }, + duration: 3000, + extraClasses: ['snackbar-warning'] + }); + //this._criteria.criteria.onCallbackError(error); + return Observable.of(null); + })*/ + .map(result => { + setTimeout(() => { + this.isLoadingResults = false; + }); + return result; + }) + .map(result => { + if (!result) { return []; } + if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; } + return result.data; + }); + } + + disconnect() { + // No-op + } +} \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts new file mode 100644 index 000000000..c678fc47d --- /dev/null +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.module.ts @@ -0,0 +1,54 @@ +import { RouterModule } from '@angular/router'; +import { TranslateHttpLoader } from '@ngx-translate/http-loader'; +import { DatasetService } from '../services/dataset/dataset.service'; +import { DynamicFormModule } from '../form/dynamic-form.module'; +import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core'; +import { DatasetAdminRoutes } from './dataset-admin.routes'; +import { DatasetAdminListingComponent } from './dataset-admin-listing.component'; +import { CommonModule } from '@angular/common'; +import { HttpClient, HttpClientModule } from '@angular/common/http'; +import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; + +import { SharedModule } from '../shared/shared.module' +@NgModule({ + imports: [ + CommonModule, + FormsModule, + HttpClientModule, + SharedModule, + RouterModule.forChild(DatasetAdminRoutes), + ReactiveFormsModule, + DynamicFormModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: HttpLoaderFactory, + deps: [HttpClient] + } + }), + ], + + declarations: [ + DatasetAdminListingComponent, + ], + + exports: [ + DatasetAdminListingComponent, + RouterModule + ], + providers: [ + DatasetService + ] +}) + +export class DatasetAdminModule { + constructor(private translate: TranslateService) { + translate.setDefaultLang('en'); + translate.use('en'); + } +} + +export function HttpLoaderFactory(httpClient: HttpClient) { + return new TranslateHttpLoader(httpClient, 'assets/lang/', '.json'); +} \ No newline at end of file diff --git a/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts new file mode 100644 index 000000000..fdfb9be7f --- /dev/null +++ b/dmp-frontend/src/app/datasets-admin-listing/dataset-admin.routes.ts @@ -0,0 +1,7 @@ +import { AuthGuard } from '../guards/auth.guard'; +import { DatasetAdminListingComponent } from './dataset-admin-listing.component'; +import { RouterModule, Routes } from '@angular/router'; + +export const DatasetAdminRoutes: Routes = [ + { path: '', component: DatasetAdminListingComponent, canActivate: [AuthGuard] }, +]; diff --git a/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts index 6ceba92ca..a6305b739 100644 --- a/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts +++ b/dmp-frontend/src/app/services/datasetProfileAdmin/datasetProfileAfmin.service.ts @@ -9,6 +9,7 @@ import { DatasetModel } from '../../models/datasets/DatasetModel'; import { DatasetCriteria } from '../../models/criteria/dataset/DatasetCriteria'; import { DatasetProfileModelAdmin } from '../../models/datasetProfileAdmin/DatasetProfileModelAdmin'; +import { DatasetListingModel } from '@app/models/datasets/DatasetListingModel'; @Injectable() @@ -36,12 +37,9 @@ export class DatasetProfileAdmin { getDatasetProfileById(datasetProfileID){ return this.http.get(this.actionUrl + 'get/' + datasetProfileID, { headers: this.headers }) } - // getPaged(dataTableRequest: DataTableRequest): Observable> { - // return this.http.post>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers }); - // } - // makeDatasetPublic(id: String){ - // return this.http.get(this.actionUrl + 'makepublic/' + id, { headers: this.headers }) - // } + getPaged(dataTableRequest: DataTableRequest): Observable> { + return this.http.post>(this.actionUrl + 'datasetprofiles/getPaged', dataTableRequest, { headers: this.headers }); + } } diff --git a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html index 2d2045813..61cbcb5fd 100644 --- a/dmp-frontend/src/app/shared/components/navigation/navigation.component.html +++ b/dmp-frontend/src/app/shared/components/navigation/navigation.component.html @@ -5,6 +5,7 @@ +
diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index bd964d6f6..f19754f5e 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -26,7 +26,8 @@ "PROJECTS": "Projects", "DMPS": "Plans", "DATASETS": "Datasets", - "USERS": "Users" + "USERS": "Users", + "DATASETS(ADMIN)":"Datasets (Admin)" }, "PROJECT-LISTING": {