From 407c520fe94ba8017e8d492cad5a6d59920a3acb Mon Sep 17 00:00:00 2001 From: annampak Date: Mon, 30 Oct 2017 18:37:17 +0200 Subject: [PATCH] bug fixes --- dmp-frontend/src/app/app.module.ts | 11 ++--- .../src/app/datasets/dataset.component.ts | 44 +++++++++++++++---- dmp-frontend/src/app/datasets/dataset.html | 4 +- dmp-frontend/src/app/dmps/dmp.component.ts | 6 +-- dmp-frontend/src/app/dmps/dmps.html | 2 +- .../src/app/form/dynamic-form.component.ts | 2 +- dmp-frontend/src/app/modal/modal.component.ts | 3 +- .../src/app/services/server.service.ts | 6 ++- 8 files changed, 55 insertions(+), 23 deletions(-) diff --git a/dmp-frontend/src/app/app.module.ts b/dmp-frontend/src/app/app.module.ts index 882838ec7..5e2e28c5a 100644 --- a/dmp-frontend/src/app/app.module.ts +++ b/dmp-frontend/src/app/app.module.ts @@ -56,11 +56,12 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http'; DataTableModule ], - providers: [{ - provide: HTTP_INTERCEPTORS, - useClass: GlobalInterceptor, - multi: true, - }, + providers: [ + // { + // provide: HTTP_INTERCEPTORS, + // useClass: GlobalInterceptor, + // multi: true, + // }, ServerService, dataModelBuilder, AuthGuard, PaginationService, TokenService, LocalStorageService, RestBase, EestoreService ], bootstrap: [AppComponent] diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index ebbcf3362..2a52f649a 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -119,7 +119,7 @@ export class DatasetsComponent implements OnInit { } reloadDatasets(params) { - this.datasetResource = new DataTableResource(this.datasets); + // this.datasetResource = new DataTableResource(this.datasets); this.datasetResource.query(params).then(datasets => this.datasets = datasets); } @@ -128,11 +128,11 @@ export class DatasetsComponent implements OnInit { this.datasetResource.count().then(count => this.datasetCount = count); } - selectDataset(item) {debugger; + selectDataset(item) { this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profileId, datasetId:item.id, datasetProperties:item.properties}])); } - SaveNewDataset() { + SaveNewDataset() { this.dataset.dmp = { "id": this.dmpIdforDatasets } this.dataset.profile = { "id": this.dataset.profile } this.serverService.createDatasetForDmp(this.dataset).subscribe( @@ -142,18 +142,45 @@ export class DatasetsComponent implements OnInit { } ) $("#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(); + } + + CallDatasets(){ 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); var params = { limit: 8, offset: 0, sortAsc: false } this.afterLoad(); @@ -162,7 +189,7 @@ export class DatasetsComponent implements OnInit { } ); } - + // special params: translations = { indexColumn: 'Index column', @@ -194,11 +221,12 @@ export class DatasetsComponent implements OnInit { ); } - editRow(item) { - this.dataset.label = item.label; + editRow(item) { debugger; + this.dataset.label = item.name; this.dataset.uri = item.uriDataset; this.dataset.dmp = item.dmp; this.dataset.profile = item.profileId; + this.dataset.id = item.id; $("#newDatasetModal").modal("show"); } diff --git a/dmp-frontend/src/app/datasets/dataset.html b/dmp-frontend/src/app/datasets/dataset.html index a2f857691..d01d201a9 100644 --- a/dmp-frontend/src/app/datasets/dataset.html +++ b/dmp-frontend/src/app/datasets/dataset.html @@ -1,6 +1,6 @@
@@ -84,7 +84,7 @@
diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index 96cf185fd..f6a769c26 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -81,7 +81,7 @@ console.log(response); this.dmpResource.query(params).then(dmps => this.dmps = dmps); } ); - (err: HttpErrorResponse) => { + (err: HttpErrorResponse) => {debugger; if (err.error instanceof Error) { // A client-side or network error occurred. Handle it accordingly. console.log('An error occurred:', err.error.message); @@ -113,7 +113,7 @@ console.log(response); } reloadDmps(params) { - this.dmpResource = new DataTableResource(this.dmps); + //this.dmpResource = new DataTableResource(this.dmps); this.dmpResource.query(params).then(projects => this.dmps = projects); } @@ -142,7 +142,7 @@ filterGrid() { SaveNewDmp(){ - console.log(this.dmp, this.dmp.projectsDropDownKey); debugger; + console.log(this.dmp, this.dmp.projectsDropDownKey); //this.http.post('http://someurl', JSON.stringify(this.project)) this.dmp.project = {"id":this.dmp.project}; diff --git a/dmp-frontend/src/app/dmps/dmps.html b/dmp-frontend/src/app/dmps/dmps.html index 2e38113cb..40fdfa6ba 100644 --- a/dmp-frontend/src/app/dmps/dmps.html +++ b/dmp-frontend/src/app/dmps/dmps.html @@ -6,7 +6,7 @@ diff --git a/dmp-frontend/src/app/form/dynamic-form.component.ts b/dmp-frontend/src/app/form/dynamic-form.component.ts index 6988de433..754335fe2 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.ts +++ b/dmp-frontend/src/app/form/dynamic-form.component.ts @@ -54,7 +54,7 @@ export class DynamicFormComponent implements OnInit { //let id = this.route.snapshot.paramMap.get('id'); //get the project id - let sub = this.route.params.subscribe(params => {debugger; + let sub = this.route.params.subscribe(params => { this.id = params.id; this.datasetId = params.datasetId; this.datasetProperties = params.datasetProperties diff --git a/dmp-frontend/src/app/modal/modal.component.ts b/dmp-frontend/src/app/modal/modal.component.ts index cb135700c..ad8ac94c6 100644 --- a/dmp-frontend/src/app/modal/modal.component.ts +++ b/dmp-frontend/src/app/modal/modal.component.ts @@ -97,8 +97,7 @@ export class ModalComponent implements OnInit { this.show = false; } - showDatasets(dmpId, event) { - debugger; + showDatasets(dmpId, event) { this.dataSetVisibe = true; $("#exampleModalDmps").modal("hide"); this.show = false; diff --git a/dmp-frontend/src/app/services/server.service.ts b/dmp-frontend/src/app/services/server.service.ts index d5e8b7a3d..f3162e85a 100644 --- a/dmp-frontend/src/app/services/server.service.ts +++ b/dmp-frontend/src/app/services/server.service.ts @@ -121,9 +121,13 @@ public getAllDatsetsProfile(){ return this.restBase.get("datasetprofile/getAll"); } -public getDatsetsProfile(id){debugger; +public getDatsetsProfile(id){ return this.restBase.get("datasetprofiles/"+id); } + +public updateDatsetsProfile(data:any){ + return this.restBase.post("dataset/update", data); +} logOut() {