From d1d455e89fe4a2b6f19826bc439e6cc8a3924906 Mon Sep 17 00:00:00 2001 From: annampak Date: Fri, 27 Oct 2017 13:00:46 +0300 Subject: [PATCH 1/3] change function name --- dmp-frontend/src/app/dmps/dmp.component.ts | 4 ++-- dmp-frontend/src/app/dmps/dmps.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index f33ff88dc..aacf8149e 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -56,7 +56,7 @@ export class DmpComponent implements OnInit{ this.dmps = []; this.serverService.getDmpOfUser().subscribe( response => { - + debugger; response.forEach(resp => { let pr = new Dmp(); pr.id = resp.id; @@ -111,7 +111,7 @@ afterLoad(){ this.dmpResource.count().then(count => this.dmpCount = count); } -myFunction() { +filterGrid() { var input, filter, table, tr, td, i; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index 61b39922f..e47f4d735 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -3,12 +3,12 @@
Filter: - +
- + From 7b5f032c1d4e99c38deea8e39927131fcdcc54f9 Mon Sep 17 00:00:00 2001 From: annampak Date: Fri, 27 Oct 2017 17:08:10 +0300 Subject: [PATCH 2/3] show dataset, create, save --- .../src/app/datasets/dataset.component.ts | 49 +++++++++++++++- dmp-frontend/src/app/datasets/dataset.html | 57 ++++++++++++++++++- dmp-frontend/src/app/dmps/dmp.component.ts | 35 +++++++++--- dmp-frontend/src/app/dmps/dmps.html | 10 ++-- dmp-frontend/src/app/entities/model/dmp.ts | 8 ++- dmp-frontend/src/app/services/rest-base.ts | 8 +-- .../src/app/services/server.service.ts | 15 ++++- 7 files changed, 158 insertions(+), 24 deletions(-) diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index dee3b502d..04119c4bc 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -6,6 +6,8 @@ import { Project } from '../entities/model/project'; import { Dataset } from '../entities/model/dataset'; import { Dmp } from '../entities/model/dmp'; import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-data-table-bootstrap-4'; +import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; +import { Param } from '../entities/model/param'; @Component({ selector: 'datasets-table', @@ -31,9 +33,12 @@ export class DatasetsComponent implements OnInit{ returnUrl: string; @Input() datasets: Dataset[]; + @Input() datasetProfileDropDown: DropdownField; datasetResource :DataTableResource; @Input() datasetCount = 0; - + @Input() dmpIdforDatasets: string; + dataset:any; + @ViewChild(DataTable) projectsTable; dataSetValue:boolean @@ -54,13 +59,26 @@ export class DatasetsComponent implements OnInit{ private route: ActivatedRoute, private router: Router, private ngZone: NgZone){ + this.dataset = { + id:null, + label:'', + reference:'', + uri:'', + properties:'', + profile:{"id": ''}, + dmp:{"id": ''} + } + + this.datasetProfileDropDown = new DropdownField(); + this.datasetProfileDropDown.options = []; } ngOnInit() { //this.projects = this.serverService.getDummyProjects(); this.datasets = []; - this.serverService.getAllDataSet().subscribe( + console.log(this.dmpIdforDatasets); + this.serverService.getDatasetForDmp({"id":this.dmpIdforDatasets}).subscribe( response => { console.log("response"); @@ -77,7 +95,22 @@ export class DatasetsComponent implements OnInit{ this.datasetResource.query(params).then(datasets => this.datasets = datasets); }); } - ); + ); + + 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; + params.value = datasetprofile.label; + this.datasetProfileDropDown.options.push(params); + }); + + } + ) } reloadDatasets(params) { @@ -94,6 +127,16 @@ rowClick(rowEvent){ this.ngZone.run(() => this.router.navigateByUrl('dynamic-form', rowEvent.row.item.id)); } +SaveNewDataset(){debugger; + this.dataset.dmp={"id": this.dmpIdforDatasets} + this.dataset.profile = {"id": this.dataset.profile} + this.serverService.createDatasetForDmp(this.dataset).subscribe( + response=>{ + console.log(response); + } + ) +} + // special params: translations = { indexColumn: 'Index column', diff --git a/dmp-frontend/src/app/datasets/dataset.html b/dmp-frontend/src/app/datasets/dataset.html index e67e40fe9..3f01d7242 100644 --- a/dmp-frontend/src/app/datasets/dataset.html +++ b/dmp-frontend/src/app/datasets/dataset.html @@ -15,10 +15,65 @@ -->
- +
+
+ + \ No newline at end of file diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 80050af2a..670159a8b 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -13,6 +13,8 @@ import { HttpErrorResponse } from '@angular/common/http'; import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai import { NgForm } from '@angular/forms'; +declare var $ :any; + @Component({ selector: 'dmps', templateUrl: 'dmps.html', @@ -23,9 +25,10 @@ export class DmpComponent implements OnInit{ @Input() dmps: Dmp[]; dmp:any; dmpResource :DataTableResource; + dmpIdforDatasets: string; @Input() dmpCount = 0; @Input() projectsDropDown:DropdownField; - //@Input() dataSetVisibe:boolean; + @Input() dataSetVisibe:boolean; @Input() projects: Project[]; @ViewChild(DataTable) dmpsTable; @@ -36,7 +39,7 @@ export class DmpComponent implements OnInit{ private serverService: ServerService, private route: ActivatedRoute, private router: Router){ - this.projectsDropDown = new DropdownField(); + this.projectsDropDown = new DropdownField(); this.projectsDropDown.options = []; this.projects = []; this.dmp = { @@ -56,14 +59,15 @@ export class DmpComponent implements OnInit{ this.dmps = []; this.serverService.getDmpOfUser().subscribe( response => { - debugger; +console.log(response); response.forEach(resp => { - let pr = new Dmp(); - pr.id = resp.id; - pr.id = resp.label; - pr.name = resp.abbreviation; - pr.dataset = resp.definition; - this.dmps.push(pr); + let dmp = new Dmp(); + dmp.id = resp.id; + dmp.label = resp.label; + dmp.version = resp.version; + dmp.dataset = resp.dataset; + dmp.projectLabel = resp.project.label; + this.dmps.push(dmp); var params = {limit:8,offset:0, sortAsc:false} this.afterLoad(); this.dmpResource.query(params).then(dmps => this.dmps = dmps); @@ -159,5 +163,18 @@ signOut() {     this.serverService.logOut(); } +selectDmp(rowEvent){ + this.dmpIdforDatasets = rowEvent.row.item.id; + this.dataSetVisibe = true; +} + +editRow(dmp){ + this.dmp.label = this.dmp.label; + this.dmp.abbreviation = this.dmp.abbreviation; + this.dmp.uri = this.dmp.uri; + this.dmp.id = this.dmp.id; + $("#newDmpModal").modal("show"); +} + } diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index e47f4d735..23d340aad 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -7,10 +7,12 @@ + [expandableRows]="true" [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true" (rowClick)="selectDmp($event)"> + + @@ -42,7 +44,7 @@ - + - + Sign out \ No newline at end of file diff --git a/dmp-frontend/src/app/entities/model/dmp.ts b/dmp-frontend/src/app/entities/model/dmp.ts index 70af07deb..861f3ea91 100644 --- a/dmp-frontend/src/app/entities/model/dmp.ts +++ b/dmp-frontend/src/app/entities/model/dmp.ts @@ -3,5 +3,11 @@ import { Injectable } from '@angular/core'; export class Dmp { id:string; dataset: string; - name: string; + label: string; + organisations:string; + previous:string; + profile:string; + profileData:string; + projectLabel:string; + version: number; } \ No newline at end of file diff --git a/dmp-frontend/src/app/services/rest-base.ts b/dmp-frontend/src/app/services/rest-base.ts index 467701587..33da83bc4 100644 --- a/dmp-frontend/src/app/services/rest-base.ts +++ b/dmp-frontend/src/app/services/rest-base.ts @@ -15,17 +15,17 @@ export class RestBase { this.xml2jsonOBJ = new X2JS(); } - /* + protocol: string = "http"; hostname: string ="dl010.madgik.di.uoa.gr" ;//"localhost";//"dl010.madgik.di.uoa.gr";// port: number = 8080;//8080;// webappname: string = "dmp-backend";//"dmp-backend-new";// - */ + - protocol: string = "http"; + /* protocol: string = "http"; hostname: string = "dionysus.di.uoa.gr" ; port: number = 7070; - webappname: string = "dmp-backend"; + webappname: string = "dmp-backend";*/ proxyPath : string = this.protocol+"://"+this.hostname+":"+this.port+"/"+this.webappname+"/proxy/"; diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index faa9210fa..6ca912e34 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -106,10 +106,21 @@ export class ServerService { public createDmpForCurrentUser(data:any){ - debugger; - return this.restBase.post("dmp/createofuser", data); + return this.restBase.post("dmp/createofuser", data); } + public getDatasetForDmp(data:any){ + return this.restBase.post("/dmp/getdatasets", data); +} + +public createDatasetForDmp(data:any){debugger; + return this.restBase.post("dataset/create", data); +} + +public getAllDatsetsProfile(){ + return this.restBase.get("datasetprofile/getAll"); +} + logOut() { From bed9322767928ac1bfb6448141ba4fe69fb4b6b3 Mon Sep 17 00:00:00 2001 From: annampak Date: Fri, 27 Oct 2017 19:38:31 +0300 Subject: [PATCH 3/3] load datatables afte save. minor fixes --- .../src/app/datasets/dataset.component.ts | 51 +++++++++++++++++-- dmp-frontend/src/app/dmps/dmp.component.ts | 49 ++++++++++++++---- dmp-frontend/src/app/dmps/dmps.html | 4 +- .../src/app/services/server.service.ts | 2 +- dmp-frontend/src/app/tabs/tabs.component.ts | 8 +-- 5 files changed, 92 insertions(+), 22 deletions(-) diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index 04119c4bc..37637f632 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -9,6 +9,8 @@ import { DataTable, DataTableTranslations, DataTableResource } from 'angular-4-d import { DropdownField } from '../../app/form/fields/dropdown/field-dropdown'; import { Param } from '../entities/model/param'; +declare var $ :any; + @Component({ selector: 'datasets-table', templateUrl: 'dataset.html', @@ -39,7 +41,7 @@ export class DatasetsComponent implements OnInit{ @Input() dmpIdforDatasets: string; dataset:any; - @ViewChild(DataTable) projectsTable; + //@ViewChild(DataTable) projectsTable; dataSetValue:boolean @Input() @@ -74,7 +76,7 @@ export class DatasetsComponent implements OnInit{ } - ngOnInit() { + ngOnInit() {debugger; //this.projects = this.serverService.getDummyProjects(); this.datasets = []; console.log(this.dmpIdforDatasets); @@ -115,7 +117,7 @@ export class DatasetsComponent implements OnInit{ reloadDatasets(params) { this.datasetResource = new DataTableResource(this.datasets); - this.datasetResource.query(params).then(projects => this.datasets = projects); + this.datasetResource.query(params).then(datasets => this.datasets = datasets); } afterLoad(){ @@ -133,8 +135,29 @@ SaveNewDataset(){debugger; this.serverService.createDatasetForDmp(this.dataset).subscribe( response=>{ console.log(response); - } + + } ) + $("#newDatasetModal").modal("hide"); + 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; + this.datasets.push(dt); + var params = {limit:8,offset:0, sortAsc:false} + this.afterLoad(); + this.datasetResource.query(params).then(datasets => this.datasets = datasets); + }); + } + ); } // special params: @@ -146,6 +169,26 @@ SaveNewDataset(){debugger; paginationRange: 'Result range' }; +getDatasetForDmpMethod(dmpid){ + this.serverService.getDatasetForDmp({"id":dmpid}).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; + this.datasets.push(dt); + var params = {limit:8,offset:0, sortAsc:false} + this.afterLoad(); + this.datasetResource.query(params).then(datasets => this.datasets = datasets); + }); + } +); +} } diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 670159a8b..ad6ce707d 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core'; import {GoogleSignInSuccess} from 'angular-google-signin'; import { Router, ActivatedRoute } from '@angular/router'; import { ServerService } from '../../app/services/server.service'; @@ -12,6 +12,7 @@ import { ModalComponent } from '../modal/modal.component'; import { HttpErrorResponse } from '@angular/common/http'; import { FormGroup, FormControl } from '@angular/forms'; //na dw an xreiazontai import { NgForm } from '@angular/forms'; +import { DatasetsComponent } from '../datasets/dataset.component'; declare var $ :any; @@ -31,8 +32,10 @@ export class DmpComponent implements OnInit{ @Input() dataSetVisibe:boolean; @Input() projects: Project[]; + @ViewChild(DataTable) dmpsTable; @ViewChild(DataTable) datasetsTable; + @ViewChild(DatasetsComponent) datasetsComponent:DatasetsComponent; @ViewChild('isignOutBtn') isignOutBtn; constructor( @@ -42,6 +45,7 @@ export class DmpComponent implements OnInit{ this.projectsDropDown = new DropdownField(); this.projectsDropDown.options = []; this.projects = []; + this.dataSetVisibe = false; this.dmp = { label: '', abbreviation:'', @@ -119,10 +123,10 @@ filterGrid() { var input, filter, table, tr, td, i; input = document.getElementById("myInput"); filter = input.value.toUpperCase(); - table = document.getElementById("projects-grid"); + table = document.getElementById("dmps-grid"); tr = table.getElementsByTagName("tr"); for (i = 0; i < tr.length; i++) { - td = tr[i].getElementsByTagName("td")[3]; + td = tr[i].getElementsByTagName("td")[4]; if (td) { if (td.innerText.toUpperCase().indexOf(filter) > -1) { tr[i].style.display = ""; @@ -145,9 +149,28 @@ SaveNewDmp(){ .subscribe( response =>{ console.log("response"); - console.log(response); + console.log(response); + this.dmps = []; + this.serverService.getDmpOfUser().subscribe( + response => { + response.forEach(resp => { + let dmp = new Dmp(); + dmp.id = resp.id; + dmp.label = resp.label; + dmp.version = resp.version; + dmp.dataset = resp.dataset; + dmp.projectLabel = resp.project.label; + this.dmps.push(dmp); + var params = {limit:8,offset:0, sortAsc:false} + this.afterLoad(); + this.dmpResource.query(params).then(dmps => this.dmps = dmps); + } + ); + }); } ); + + $("#newDmpModal").modal("hide"); } // special params: @@ -163,16 +186,20 @@ signOut() {     this.serverService.logOut(); } -selectDmp(rowEvent){ +selectDmp(rowEvent){debugger; this.dmpIdforDatasets = rowEvent.row.item.id; - this.dataSetVisibe = true; + if(this.dataSetVisibe == false) + this.dataSetVisibe = true; + else + this.datasetsComponent.getDatasetForDmpMethod(rowEvent.row.item.id); } -editRow(dmp){ - this.dmp.label = this.dmp.label; - this.dmp.abbreviation = this.dmp.abbreviation; - this.dmp.uri = this.dmp.uri; - this.dmp.id = this.dmp.id; +editRow(item){debugger; + this.dmp.label = item.label; + this.dmp.abbreviation = item.abbreviation; + this.dmp.uri = item.uri; + this.dmp.id = item.id; + this.dmp.project = item.project; $("#newDmpModal").modal("show"); } diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index 23d340aad..339f3b443 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -7,7 +7,7 @@ + [translations]="translations" [indexColumnHeader]="'#'" [selectOnRowClick]="true" (rowClick)="selectDmp($event)"> @@ -112,7 +112,7 @@ - + Sign out \ No newline at end of file diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index 6ca912e34..a3e0969ef 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -113,7 +113,7 @@ export class ServerService { return this.restBase.post("/dmp/getdatasets", data); } -public createDatasetForDmp(data:any){debugger; +public createDatasetForDmp(data:any){ return this.restBase.post("dataset/create", data); } diff --git a/dmp-frontend/src/app/tabs/tabs.component.ts b/dmp-frontend/src/app/tabs/tabs.component.ts index 810811461..e48e6bd6c 100644 --- a/dmp-frontend/src/app/tabs/tabs.component.ts +++ b/dmp-frontend/src/app/tabs/tabs.component.ts @@ -4,12 +4,12 @@ import { Component } from '@angular/core'; selector: 'my-app', template: `