dataset criteria

This commit is contained in:
annampak 2017-12-18 13:26:13 +02:00
parent aab679df29
commit 934dcb8130
11 changed files with 150 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<div class="container-fluid">
<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-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
@ -37,9 +37,15 @@
<mat-cell *matCellDef="let row"> {{row.description}} </mat-cell>
</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 -->
<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>
</ng-container>

View File

@ -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;
}

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> {
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<DatasetListingModel> {
this.uri = item.uri;
this.status = item.status;
this.description = item.description;
this.created = item.created;
return this;
}

View File

@ -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;
/*

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="name" [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="name" [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 { 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: [

View File

@ -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"
}
}
}