From 934dcb8130cc90e9db388c45c91192f541af04e3 Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 18 Dec 2017 13:26:13 +0200 Subject: [PATCH 1/2] dataset criteria --- .../dataset-listing.component.html | 10 ++- .../datasets_new/dataset-listing.component.ts | 14 ++-- .../criteria/dataset/DatasetCriteria.ts | 6 ++ .../dataset/DatasetCriteriaErrorModel.ts | 6 ++ .../models/datasets/DatasetListingModel.ts | 12 ++-- dmp-frontend/src/app/services/rest-base.ts | 2 +- .../datasets/datasets-criteria.component.css | 0 .../datasets/datasets-criteria.component.html | 37 ++++++++++ .../datasets/datasets-criteria.component.ts | 69 +++++++++++++++++++ dmp-frontend/src/app/shared/shared.module.ts | 3 + dmp-frontend/src/assets/lang/en.json | 8 ++- 11 files changed, 150 insertions(+), 17 deletions(-) create mode 100644 dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts create mode 100644 dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts create mode 100644 dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.css create mode 100644 dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html create mode 100644 dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html index a87ed6ea5..495384bed 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.html +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.html @@ -1,7 +1,7 @@

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

- + @@ -37,9 +37,15 @@ {{row.description}} + + + {{'DATASET-LISTING.COLUMNS.CREATED' | translate}} + {{row.created}} + + - {{'PROJECT-LISTING.COLUMNS.ACTIONS' | translate}} + {{'DATASET-LISTING.COLUMNS.ACTIONS' | translate}} diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts index e9068fac5..0e79a45ef 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts @@ -4,8 +4,8 @@ import { Router } from "@angular/router"; import { TranslateService } from "@ngx-translate/core"; import { DataSource } from "@angular/cdk/table"; -import { ProjectCriteriaComponent } from "../shared/components/criteria/projects/projects-criteria.component"; -import { ProjectCriteria } from "../models/criteria/project/ProjectCriteria"; +import { DatasetCriteriaComponent } from "../shared/components/criteria/datasets/datasets-criteria.component"; +import { DatasetCriteria } from "../models/criteria/dataset/DatasetCriteria"; import { Observable } from "rxjs/Observable"; import { DataTableRequest } from "../models/data-table/DataTableRequest"; import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component"; @@ -24,10 +24,10 @@ export class DatasetListingComponent implements OnInit, AfterViewInit { @ViewChild(MatPaginator) _paginator: MatPaginator; @ViewChild(MatSort) sort: MatSort; - @ViewChild(ProjectCriteriaComponent) criteria: ProjectCriteriaComponent; + @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent; dataSource: DatasetDataSource | null; - displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'actions']; + displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'created', 'actions']; constructor( private datasetService: DatasetService, @@ -51,15 +51,15 @@ export class DatasetListingComponent implements OnInit, AfterViewInit { } refresh() { - this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria, ); + this.dataSource = new DatasetDataSource(this.datasetService, this._paginator, this.sort, this.languageService, this.snackBar, this.criteria); } rowClick(rowId: String) { this.router.navigate(['/project/' + rowId]); } - getDefaultCriteria(): ProjectCriteria { - const defaultCriteria = new ProjectCriteria(); + getDefaultCriteria(): DatasetCriteria { + const defaultCriteria = new DatasetCriteria(); return defaultCriteria; } diff --git a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts new file mode 100644 index 000000000..0e219a6c7 --- /dev/null +++ b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteria.ts @@ -0,0 +1,6 @@ +import { BaseCriteria } from "../BaseCriteria"; + +export class DatasetCriteria extends BaseCriteria { + public Name: String; + public Status: Number; +} diff --git a/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts new file mode 100644 index 000000000..bfd401872 --- /dev/null +++ b/dmp-frontend/src/app/models/criteria/dataset/DatasetCriteriaErrorModel.ts @@ -0,0 +1,6 @@ +import { BaseCriteriaErrorModel } from "../BaseCriteriaErrorModel"; + +export class DatasetCriteriaErrorModel extends BaseCriteriaErrorModel{ + public Name: String; + public Status: Number; +} diff --git a/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts b/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts index c5d218824..633ab7fcc 100644 --- a/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts +++ b/dmp-frontend/src/app/models/datasets/DatasetListingModel.ts @@ -2,11 +2,12 @@ import { Serializable } from "../Serializable"; export class DatasetListingModel implements Serializable { public id: String; - private label:String; - private reference: String; - private uri: String; - private description: String; - private status: Number; + public label:String; + public reference: String; + public uri: String; + public description: String; + public status: Number; + public created: Date; fromJSONObject(item: any): DatasetListingModel { this.id = item.id; @@ -15,6 +16,7 @@ export class DatasetListingModel implements Serializable { this.uri = item.uri; this.status = item.status; this.description = item.description; + this.created = item.created; return this; } diff --git a/dmp-frontend/src/app/services/rest-base.ts b/dmp-frontend/src/app/services/rest-base.ts index 53ce4e7c1..e2ab6ab03 100644 --- a/dmp-frontend/src/app/services/rest-base.ts +++ b/dmp-frontend/src/app/services/rest-base.ts @@ -18,7 +18,7 @@ export class RestBase { protocol: string = "http"; - hostname: string ="192.168.32.103" + hostname: string ="192.168.32.171" port: number = 8080; /* diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.css b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.css new file mode 100644 index 000000000..e69de29bb diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html new file mode 100644 index 000000000..c5782c810 --- /dev/null +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html @@ -0,0 +1,37 @@ +
+ +
+ +
+ + + {{baseErrorModel['Criteria.Name']}} + +
+
+ + + {{baseErrorModel['Criteria.Status']}} + +
+
+
+
+ + \ No newline at end of file diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts new file mode 100644 index 000000000..a47ecc2fb --- /dev/null +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.ts @@ -0,0 +1,69 @@ +import { TranslateService } from '@ngx-translate/core'; +import { Component, OnInit } from '@angular/core'; +import { FormControl, FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { BaseCriteriaComponent } from '../base/base-criteria.component'; +import { ValidationContext, Validation } from '../../../../utilities/validators/ValidationContext'; +import { BackendErrorValidator } from '../../../../utilities/validators/BackendErrorValidator'; +import { DatasetCriteriaErrorModel } from '../../../../models/criteria/dataset/DatasetCriteriaErrorModel'; +import { DatasetCriteria } from '../../../../models/criteria/dataset/DatasetCriteria'; + +@Component({ + selector: 'app-datasets-criteria-component', + templateUrl: './datasets-criteria.component.html', + styleUrls: ['./datasets-criteria.component.css'], + providers: [ + ] +}) + +export class DatasetCriteriaComponent extends BaseCriteriaComponent implements OnInit { + + // public form: ProjectType; + // public formStatus: ProjectStatus; + public criteria: DatasetCriteria= new DatasetCriteria(); + + constructor( + public language: TranslateService, + public formBuilder: FormBuilder + ) { + super(new DatasetCriteriaErrorModel()); + } + + ngOnInit() { + super.ngOnInit(); + if (this.criteria == null) { this.criteria = new DatasetCriteria(); } + if (this.formGroup == null) { this.formGroup = this.buildForm(); } + } + + setCriteria(criteria: DatasetCriteria): void { + this.criteria = criteria; + this.formGroup = this.buildForm(); + } + + public fromJSONObject(item: any): DatasetCriteria { + this.criteria = new DatasetCriteria(); + this.criteria.Name = new String(item.name); + this.criteria.Status = new Number(item.status); + return this.criteria; + } + + buildForm(): FormGroup { + const context: ValidationContext = this.createValidationContext(); + + return this.formBuilder.group({ + name: [this.criteria.Name, context.getValidation('name').validators], + status: [this.criteria.Status, context.getValidation('status').validators], + // created: [this.criteria, context.getValidation('created').validators] + }); + } + + createValidationContext(): ValidationContext { + const validationContext: ValidationContext = new ValidationContext(); + const validationArray: Validation[] = new Array(); + + validationArray.push({ key: 'name', validators: [BackendErrorValidator(this.errorModel, 'Criteria.Name')] }); //must add 'Criteria.' because the criteria validator is inside the request validator + validationArray.push({ key: 'status', validators: [BackendErrorValidator(this.errorModel, 'Criteria.Status')] }); + + validationContext.validation = validationArray; + return validationContext; + } +} diff --git a/dmp-frontend/src/app/shared/shared.module.ts b/dmp-frontend/src/app/shared/shared.module.ts index f34ff67e0..11a5961d9 100644 --- a/dmp-frontend/src/app/shared/shared.module.ts +++ b/dmp-frontend/src/app/shared/shared.module.ts @@ -6,6 +6,7 @@ import { SnackBarNotificationComponent } from './components/notificaiton/snack-b import { MaterialModule } from './material/material.module'; import { TranslateModule } from '@ngx-translate/core'; import { ProjectCriteriaComponent } from './components/criteria/projects/projects-criteria.component'; +import { DatasetCriteriaComponent } from './components/criteria/datasets/datasets-criteria.component'; import { FormsModule } from '@angular/forms'; import { DataManagementPlanCriteriaComponent } from './components/criteria/data-management-plan/dmp-criteria.component'; @@ -22,6 +23,7 @@ import { DataManagementPlanCriteriaComponent } from './components/criteria/data- NavigationComponent, SnackBarNotificationComponent, ProjectCriteriaComponent, + DatasetCriteriaComponent, DataManagementPlanCriteriaComponent ], @@ -29,6 +31,7 @@ import { DataManagementPlanCriteriaComponent } from './components/criteria/data- NavigationComponent, SnackBarNotificationComponent, ProjectCriteriaComponent, + DatasetCriteriaComponent, DataManagementPlanCriteriaComponent ], entryComponents: [ diff --git a/dmp-frontend/src/assets/lang/en.json b/dmp-frontend/src/assets/lang/en.json index 48daff671..3b94012d9 100644 --- a/dmp-frontend/src/assets/lang/en.json +++ b/dmp-frontend/src/assets/lang/en.json @@ -29,7 +29,9 @@ "REFERNCE": "Reference", "URI": "Uri", "STATUS": "Status", - "DESCRIPTION": "Description" + "DESCRIPTION": "Description", + "CREATED": "Created", + "ACTIONS": "Actions" } }, "PROJECT-EDITOR": { @@ -41,7 +43,9 @@ "CRITERIA": { "FORMS": { "PERIOD-FROM": "Start", - "PERIOD-TO": "End" + "PERIOD-TO": "End", + "NAME": "Name", + "STATUS": "Status" } } } \ No newline at end of file From 11fa25da403fa599a6635874bb9f1c4ba7197b3f Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 18 Dec 2017 15:24:10 +0200 Subject: [PATCH 2/2] dataset criteria & payload json object --- .../src/app/datasets_new/dataset-listing.component.ts | 4 ++-- dmp-frontend/src/app/homepage/homepage.component.ts | 3 ++- .../criteria/datasets/datasets-criteria.component.html | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts index c733a2a56..0fd088961 100644 --- a/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts +++ b/dmp-frontend/src/app/datasets_new/dataset-listing.component.ts @@ -76,7 +76,7 @@ export class DatasetDataSource extends DataSource { private _sort: MatSort, private _languageService: TranslateService, private _snackBar: MatSnackBar, - private _criteria: ProjectCriteriaComponent + private _criteria: DatasetCriteriaComponent ) { super(); @@ -113,7 +113,7 @@ export class DatasetDataSource extends DataSource { setTimeout(() => { this.isLoadingResults = false; }); - return result.data; + return result.payload; }) .map(result => { if (!result) { return []; } diff --git a/dmp-frontend/src/app/homepage/homepage.component.ts b/dmp-frontend/src/app/homepage/homepage.component.ts index a7c8c6a8d..35f06d7a8 100644 --- a/dmp-frontend/src/app/homepage/homepage.component.ts +++ b/dmp-frontend/src/app/homepage/homepage.component.ts @@ -33,7 +33,8 @@ export class HomepageComponent implements OnInit{ } ); - this.dashBoardService.getStatistics().subscribe(data =>{ + this.dashBoardService.getStatistics().subscribe(results =>{ + let data = results['payload']; this.dashboardStatisticsData = new JsonSerializer().fromJSONObject(data,DashboardStatisticsModel); }) diff --git a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html index c5782c810..dafcd3bba 100644 --- a/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html +++ b/dmp-frontend/src/app/shared/components/criteria/datasets/datasets-criteria.component.html @@ -17,13 +17,13 @@
-->
- + {{baseErrorModel['Criteria.Name']}}
- + {{baseErrorModel['Criteria.Status']}}