filters, enhancements

This commit is contained in:
annampak 2017-11-01 17:07:51 +02:00
parent c09cd7305c
commit 1e06430280
9 changed files with 124 additions and 113 deletions

View File

@ -104,9 +104,6 @@ export class DatasetsComponent implements OnInit {
this.serverService.getAllDatsetsProfile().subscribe(
response => {
console.log("response");
console.log(response);
//let params = new Param();
response.forEach((datasetprofile) => {
let params = new Param();
params.key = datasetprofile.id;
@ -118,62 +115,42 @@ export class DatasetsComponent implements OnInit {
)
}
selectDataset(item) {
this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profileId, datasetId:item.id, datasetProperties:item.properties}]));
}
SaveNewDataset() {
this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile }
this.serverService.createDatasetForDmp(this.dataset).subscribe(
response => {
console.log(response);
//if (this.saveAndDescribe == true)
//this.describeDataset(); PWS THA VRISKOUME TO ITEM GIA NA ANOIGEI TO SWSTO DATASET???
}
)
$("#newDatasetModal").modal("hide");
this.CallDatasets();
}
SaveEditedDataset(){
this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile }
this.serverService.updateDatsetsProfile(this.dataset).subscribe(
response => {
console.log(response);
}
)
$("#newDatasetModal").modal("hide");
this.CallDatasets();
}
SaveDataset(){
if(this.dataset.id ==null)
this.SaveNewDataset();
else
this.SaveEditedDataset();
if(this.dataset.id ==null){
this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile }
this.serverService.createDatasetForDmp(this.dataset).subscribe(
response => {
console.log(response);
this.getDatasets();
if (this.saveAndDescribe == true)
this.describeDataset(response);
}
)
$("#newDatasetModal").modal("hide");
}
else{
this.dataset.dmp = { "id": this.dmpIdforDatasets }
this.dataset.profile = { "id": this.dataset.profile }
this.serverService.updateDatsetsProfile(this.dataset).subscribe(
response => {
console.log(response);
this.getDatasets();
if (this.saveAndDescribe == true)
this.describeDataset(response);
}
)
$("#newDatasetModal").modal("hide");
}
}
CallDatasets(){
getDatasets(){
this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe(
response => {
console.log("response");
console.log(response);
this.datasets = [];
response.forEach(resp => {
let dt = new Dataset();
dt.id = resp.id;
dt.name = resp.label;
dt.uriDataset = resp.uri;
dt.dmp = resp.dmp.label;
dt.profile = resp.profile.label;
dt.profileId = resp.profile.id;
this.datasets.push(dt);
});
response => {
this.tableData = response;
}
);
}
@ -198,13 +175,19 @@ export class DatasetsComponent implements OnInit {
);
}
editRow(item) { debugger;
this.dataset.label = item.label;
this.dataset.uri = item.uri;
//this.dataset.dmp = item.dmp;
this.dataset.profile = item.profile.id;
this.dataset.id = item.id;
$("#newDatasetModal").modal("show");
editRow(item, event) { debugger;
if (event.toElement.id == "editDataset"){
this.dataset.label = item.label;
this.dataset.uri = item.uri;
//this.dataset.dmp = item.dmp;
this.dataset.profile = item.profile.id;
this.dataset.id = item.id;
$("#newDatasetModal").modal("show");
}
else if(event.toElement.id == "describeDataset"){
this.describeDataset(item);
}
}
newDataset() {
@ -220,8 +203,8 @@ export class DatasetsComponent implements OnInit {
this.SaveDataset();
}
describeDataset(item) {
this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profileId, datasetId:item.id, datasetProperties:item.properties}]));
describeDataset(item) {debugger;
this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profile.id, datasetId:item.id}]));
}
}

View File

@ -1,8 +1,5 @@
<div style="margin: auto; max-width: 1000px; margin-top:50px">
<table class="table table-striped" [mfData]="tableData | dmpTableFilter : filterQuery" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage"
<table class="table table-striped" [mfData]="tableData | datasetTableFilter : filterQuery | datasetstatusFilter: statusFilter" #mf="mfDataTable" [mfRowsOnPage]="rowsOnPage"
[(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<thead>
<tr>
@ -11,13 +8,13 @@
</th>
<th colspan="1">
<!-- <input class="form-control" [(ngModel)]="versionFilter" placeholder='Filter' /> -->
<select class="form-control" [id]="statusid" [(ngModel)]="statusDropDownkey" [name]="statusDropDown"
<select class="form-control" [id]="statusid" [(ngModel)]="statusFilter" [name]="statusDropDown"
#datasetfield >
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
</select>
</th>
<th>
<button class="btn btn-default" (click)="refreshTable($event)">
<button class="btn btn-default" (click)="getDatasets()">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</th>

View File

@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {DataTableModule} from 'angular2-datatable';
import { DatasetTableFilterPipe } from '../pipes/dataset-table-filter.pipe';
import { DatasetStatusFilterPipe } from '../pipes/dataset-status-filter.pipe';
import { DatasetsComponent } from './dataset.component';
@ -18,7 +19,8 @@ import { DatasetRoutingModule } from './dataset-routing.module';
],
declarations: [
DatasetsComponent,
DatasetTableFilterPipe
DatasetTableFilterPipe,
DatasetStatusFilterPipe
//ProjectDetailComponent
],
providers: [ ],

View File

@ -42,18 +42,16 @@ export class DmpComponent implements OnInit{
//visibility rules for containers
tableVisible: boolean = true;
editorVisible: boolean = false;
editorVisible: boolean = true;
// for tableIds
showIDs : boolean = false;
// END ALTERNATIVE
//@Input() dmps: Dmp[];
dmp:any;
@Input() dmpTableVisible: boolean;
@Input() dmpCount = 0;
@Input() projectsDropDown:DropdownField;
@Input() dataSetVisibe:boolean;
@ -76,6 +74,7 @@ export class DmpComponent implements OnInit{
this.projectsDropDown = new DropdownField();
this.projectsDropDown.options = [];
//this.projects = [];
this.dmpTableVisible = false;
this.dataSetVisibe = false;
this.dmp = {
id:null,
@ -232,9 +231,6 @@ newDmp(item){
$("#newDmpModal").modal("show");
}
refreshTable(){
this.getDmps();
}
}

View File

@ -1,6 +1,7 @@
<meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
<div [ngClass]="{true:'visible', false:'invisible'}[editorVisible]">
<table class="table table-striped" [mfData]="tableData | dmpTableFilter : filterQuery | dmpVersionFilter : versionFilter"
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
<thead>
@ -12,7 +13,7 @@
<input class="form-control" [(ngModel)]="versionFilter" placeholder='Filter' />
</th>
<th>
<button class="btn btn-default" (click)="refreshTable($event)">
<button class="btn btn-default" (click)="getDmps()">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</th>
@ -74,7 +75,7 @@
</tr>
</tfoot>
</table>
</div>
<!--Modal for new and edit DMP-->
<div class="modal fade" id="newDmpModal" tabindex="-1" role="dialog" aria-labelledby="newDmpModalLabel" aria-hidden="true">
@ -110,7 +111,7 @@
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">Version:</label>
<input class="form-control" id="abbreviation-text" [(ngModel)]="dmp.version" name="version" >
<input class="form-control" id="abbreviation-text" [(ngModel)]="dmp.version" name="version" disabled>
</div>
<div class="form-group">
<label for="abbreviation-text" class="form-control-label">Description:</label>

View File

@ -0,0 +1,26 @@
import * as _ from "lodash";
import { Pipe, PipeTransform } from "@angular/core";
@Pipe({
name: "datasetstatusFilter"
})
export class DatasetStatusFilterPipe implements PipeTransform {
transform(array: any[], status: string): any {
debugger;
if (status) {
return _.filter(array, row => {
return (
row.uri.indexOf(status) > -1 ||
//row.version == query ||
row.id.indexOf(status) > -1
)
});
}
return array;
}
}

View File

@ -2,7 +2,7 @@ import * as _ from "lodash";
import {Pipe, PipeTransform} from "@angular/core";
@Pipe({
name: "dmpTableFilter"
name: "datasetTableFilter"
})
export class DatasetTableFilterPipe implements PipeTransform {

View File

@ -9,7 +9,7 @@
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
</th>
<th>
<button class="btn btn-default" (click)="refreshTable($event)">
<button class="btn btn-default" (click)="getProjects()">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</th>

View File

@ -87,39 +87,45 @@ export class ProjectsComponent implements OnInit{
gapi.load('auth2', function() {
gapi.auth2.init({});
});
this.getProjects();
//this.projects = this.serverService.getDummyProjects();
this.projects = [];
this.serverService.getProjectOfUer().subscribe( //getProjects()
response => {
this.tableData = response;
response.forEach(resp => {
let pr = new Project();
pr.id = resp.id;
pr.label = resp.label;
pr.abbreviation = resp.abbreviation;
pr.definition = resp.definition;
pr.uri = resp.uri;
this.projects.push(pr);
}
);
}
// (err: HttpErrorResponse) => {
// if (err.error instanceof Error) {
// // A client-side or network error occurred. Handle it accordingly.
// console.log('An error occurred:', err.error.message);
// } else {
// // The backend returned an unsuccessful response code.
// // The response body may contain clues as to what went wrong,
// if(err.status == 401){
// this.isignOutBtn.nativeElement.click();
// }
// console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
// }
// }
);
}
getProjects(){
this.serverService.getProjectOfUer().subscribe( //getProjects()
response => {
this.tableData = response;
response.forEach(resp => {
let pr = new Project();
pr.id = resp.id;
pr.label = resp.label;
pr.abbreviation = resp.abbreviation;
pr.definition = resp.definition;
pr.uri = resp.uri;
this.projects.push(pr);
}
);
}
// (err: HttpErrorResponse) => {
// if (err.error instanceof Error) {
// // A client-side or network error occurred. Handle it accordingly.
// console.log('An error occurred:', err.error.message);
// } else {
// // The backend returned an unsuccessful response code.
// // The response body may contain clues as to what went wrong,
// if(err.status == 401){
// this.isignOutBtn.nativeElement.click();
// }
// console.log(`Backend returned code ${err.status}, body was: ${err.error}`);
// }
// }
);
}
getDMPs(){
this.serverService.listDmpsLabelID().subscribe(
response =>{