# Conflicts:
#	dmp-frontend/src/assets/lang/en.json
This commit is contained in:
Diamantis Tziotzios 2017-12-18 15:47:46 +02:00
commit e64e4e50aa
11 changed files with 156 additions and 18 deletions

View File

@ -1,7 +1,7 @@
<div class="container-fluid"> <div class="container-fluid">
<h3>{{'DATASET-LISTING.TITLE' | translate}}</h3> <h3>{{'DATASET-LISTING.TITLE' | translate}}</h3>
<app-projects-criteria-component></app-projects-criteria-component> <app-datasets-criteria-component></app-datasets-criteria-component>
<mat-card class="mat-card"> <mat-card class="mat-card">
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar> <mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
@ -37,9 +37,15 @@
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell> <mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</ng-container> </ng-container>
<!-- Column Definition: Created -->
<ng-container cdkColumnDef="created">
<mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.CREATED' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row">{{row.created}}</mat-cell>
</ng-container>
<!-- Column Definition: Submission Time --> <!-- Column Definition: Submission Time -->
<ng-container cdkColumnDef="actions"> <ng-container cdkColumnDef="actions">
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell> <mat-header-cell *matHeaderCellDef>{{'DATASET-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
<mat-cell *matCellDef="let row"></mat-cell> <mat-cell *matCellDef="let row"></mat-cell>
</ng-container> </ng-container>

View File

@ -4,8 +4,8 @@ import { Router } from "@angular/router";
import { TranslateService } from "@ngx-translate/core"; import { TranslateService } from "@ngx-translate/core";
import { DataSource } from "@angular/cdk/table"; import { DataSource } from "@angular/cdk/table";
import { ProjectCriteriaComponent } from "../shared/components/criteria/projects/projects-criteria.component"; import { DatasetCriteriaComponent } from "../shared/components/criteria/datasets/datasets-criteria.component";
import { ProjectCriteria } from "../models/criteria/project/ProjectCriteria"; import { DatasetCriteria } from "../models/criteria/dataset/DatasetCriteria";
import { Observable } from "rxjs/Observable"; import { Observable } from "rxjs/Observable";
import { DataTableRequest } from "../models/data-table/DataTableRequest"; import { DataTableRequest } from "../models/data-table/DataTableRequest";
import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component"; 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(MatPaginator) _paginator: MatPaginator;
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
@ViewChild(ProjectCriteriaComponent) criteria: ProjectCriteriaComponent; @ViewChild(DatasetCriteriaComponent) criteria: DatasetCriteriaComponent;
dataSource: DatasetDataSource | null; dataSource: DatasetDataSource | null;
displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'actions']; displayedColumns: String[] = ['label', 'reference', 'uri', 'status', 'description', 'created', 'actions'];
constructor( constructor(
private datasetService: DatasetService, private datasetService: DatasetService,
@ -51,15 +51,15 @@ export class DatasetListingComponent implements OnInit, AfterViewInit {
} }
refresh() { 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) { rowClick(rowId: String) {
this.router.navigate(['/project/' + rowId]); this.router.navigate(['/project/' + rowId]);
} }
getDefaultCriteria(): ProjectCriteria { getDefaultCriteria(): DatasetCriteria {
const defaultCriteria = new ProjectCriteria(); const defaultCriteria = new DatasetCriteria();
return defaultCriteria; return defaultCriteria;
} }
@ -76,7 +76,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
private _sort: MatSort, private _sort: MatSort,
private _languageService: TranslateService, private _languageService: TranslateService,
private _snackBar: MatSnackBar, private _snackBar: MatSnackBar,
private _criteria: ProjectCriteriaComponent private _criteria: DatasetCriteriaComponent
) { ) {
super(); super();
@ -113,7 +113,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
setTimeout(() => { setTimeout(() => {
this.isLoadingResults = false; this.isLoadingResults = false;
}); });
return result.data; return result.payload;
}) })
.map(result => { .map(result => {
if (!result) { return []; } if (!result) { return []; }

View File

@ -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<DashboardStatisticsModel>().fromJSONObject(data,DashboardStatisticsModel); this.dashboardStatisticsData = new JsonSerializer<DashboardStatisticsModel>().fromJSONObject(data,DashboardStatisticsModel);
}) })

View File

@ -0,0 +1,6 @@
import { BaseCriteria } from "../BaseCriteria";
export class DatasetCriteria extends BaseCriteria {
public Name: String;
public Status: Number;
}

View File

@ -0,0 +1,6 @@
import { BaseCriteriaErrorModel } from "../BaseCriteriaErrorModel";
export class DatasetCriteriaErrorModel extends BaseCriteriaErrorModel{
public Name: String;
public Status: Number;
}

View File

@ -2,11 +2,12 @@ import { Serializable } from "../Serializable";
export class DatasetListingModel implements Serializable<DatasetListingModel> { export class DatasetListingModel implements Serializable<DatasetListingModel> {
public id: String; public id: String;
private label:String; public label:String;
private reference: String; public reference: String;
private uri: String; public uri: String;
private description: String; public description: String;
private status: Number; public status: Number;
public created: Date;
fromJSONObject(item: any): DatasetListingModel { fromJSONObject(item: any): DatasetListingModel {
this.id = item.id; this.id = item.id;
@ -15,6 +16,7 @@ export class DatasetListingModel implements Serializable<DatasetListingModel> {
this.uri = item.uri; this.uri = item.uri;
this.status = item.status; this.status = item.status;
this.description = item.description; this.description = item.description;
this.created = item.created;
return this; return this;
} }

View File

@ -0,0 +1,37 @@
<form class="form-criteria">
<mat-card class="mat-card">
<div class="row">
<!-- <div class="col-sm-6 col-md-2">
<mat-form-field>
<input matInput
(focus)="periodStartPicker.open()"
(click)="periodStartPicker.open()"
placeholder=" {{'CRITERIA.FORMS.PERIOD-FROM'| translate}}"
[matDatepicker]="periodStartPicker"
name="projectCriteriaPeriodStart"
[ngModel]="this.criteria.PeriodStart" (ngModelChange)="controlModified()">
<mat-error *ngIf="getFormControl('created').errors?.backendError">{{baseErrorModel['Criteria.PeriodStart']}}</mat-error>
<mat-datepicker-toggle matSuffix [for]="periodStartPicker"></mat-datepicker-toggle>
<mat-datepicker #periodStartPicker></mat-datepicker>
</mat-form-field>
</div> -->
<div class="col-sm-6 col-md-2">
<mat-form-field>
<input matInput placeholder=" {{'CRITERIA.FORMS.NAME'| translate}}" name="datasetCriterianame" [ngModel]="this.criteria.Name" (ngModelChange)="controlModified()">
<mat-error *ngIf="getFormControl('name').errors?.backendError">{{baseErrorModel['Criteria.Name']}}</mat-error>
</mat-form-field>
</div>
<div class="col-sm-6 col-md-2">
<mat-form-field>
<input matInput placeholder=" {{'CRITERIA.FORMS.STATUS'| translate}}" name="datasetCriteriastatus" [ngModel]="this.criteria.Status" (ngModelChange)="controlModified()">
<mat-error *ngIf="getFormControl('status').errors?.backendError">{{baseErrorModel['Criteria.Status']}}</mat-error>
</mat-form-field>
</div>
</div>
</mat-card>
</form>
<!--matInput
(focus)="periodEndPicker.open()"
(click)="periodEndPicker.open()"
[matDatepicker]="periodEndPicker" -->

View File

@ -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<Validation>();
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;
}
}

View File

@ -6,6 +6,7 @@ import { SnackBarNotificationComponent } from './components/notificaiton/snack-b
import { MaterialModule } from './material/material.module'; import { MaterialModule } from './material/material.module';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { ProjectCriteriaComponent } from './components/criteria/projects/projects-criteria.component'; import { ProjectCriteriaComponent } from './components/criteria/projects/projects-criteria.component';
import { DatasetCriteriaComponent } from './components/criteria/datasets/datasets-criteria.component';
import { FormsModule } from '@angular/forms'; import { FormsModule } from '@angular/forms';
import { DataManagementPlanCriteriaComponent } from './components/criteria/data-management-plan/dmp-criteria.component'; import { DataManagementPlanCriteriaComponent } from './components/criteria/data-management-plan/dmp-criteria.component';
@ -22,6 +23,7 @@ import { DataManagementPlanCriteriaComponent } from './components/criteria/data-
NavigationComponent, NavigationComponent,
SnackBarNotificationComponent, SnackBarNotificationComponent,
ProjectCriteriaComponent, ProjectCriteriaComponent,
DatasetCriteriaComponent,
DataManagementPlanCriteriaComponent DataManagementPlanCriteriaComponent
], ],
@ -29,6 +31,7 @@ import { DataManagementPlanCriteriaComponent } from './components/criteria/data-
NavigationComponent, NavigationComponent,
SnackBarNotificationComponent, SnackBarNotificationComponent,
ProjectCriteriaComponent, ProjectCriteriaComponent,
DatasetCriteriaComponent,
DataManagementPlanCriteriaComponent DataManagementPlanCriteriaComponent
], ],
entryComponents: [ entryComponents: [

View File

@ -34,7 +34,9 @@
"REFERNCE": "Reference", "REFERNCE": "Reference",
"URI": "Uri", "URI": "Uri",
"STATUS": "Status", "STATUS": "Status",
"DESCRIPTION": "Description" "DESCRIPTION": "Description",
"CREATED": "Created",
"ACTIONS": "Actions"
} }
}, },
"PROJECT-EDITOR": { "PROJECT-EDITOR": {
@ -78,6 +80,12 @@
"LIKE": "Search", "LIKE": "Search",
"PERIOD-FROM": "Project Start", "PERIOD-FROM": "Project Start",
"PERIOD-TO": "Project End" "PERIOD-TO": "Project End"
},
"DATA-SETS": {
"LIKE": "Search",
"PERIOD-FROM": "Start",
"PERIOD-TO": "End",
"STATUS": "Status"
} }
} }
} }