diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index 374533109..f4cd4ce10 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -50,6 +50,7 @@ export class DatasetsComponent implements OnInit { @Input() datasetCount = 0; @Input() dmpIdforDatasets: string; dataset: any; + saveAndDescribe:boolean; //@ViewChild(DataTable) projectsTable; @@ -83,10 +84,11 @@ export class DatasetsComponent implements OnInit { this.datasetProfileDropDown = new DropdownField(); this.datasetProfileDropDown.options = []; + this.saveAndDescribe = false; } - ngOnInit() { + ngOnInit() { debugger; //this.projects = this.serverService.getDummyProjects(); this.datasets = []; console.log(this.dmpIdforDatasets);debugger; @@ -124,12 +126,37 @@ export class DatasetsComponent implements OnInit { 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(); + } + + CallDatasets(){ this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe( response => { @@ -170,20 +197,30 @@ export class DatasetsComponent implements OnInit { ); } - editRow(item) { + editRow(item) { debugger; this.dataset.label = item.label; - this.dataset.uri = item.uriDataset; - this.dataset.dmp = item.dmp; - this.dataset.profile = item.profileId; + this.dataset.uri = item.uri; + //this.dataset.dmp = item.dmp; + this.dataset.profile = item.profile.id; + this.dataset.id = item.id; $("#newDatasetModal").modal("show"); } newDataset() { this.dataset.label = ""; this.dataset.uri = ""; - this.dataset.dmp =this.dmpIdforDatasets; + this.dataset.dmp =this.dmpLabelforDatasets; this.dataset.profile = ""; $("#newDatasetModal").modal("show"); } + SaveDescribeDataset(){ + this.saveAndDescribe = true; + this.SaveDataset(); + } + + describeDataset(item) { + this.ngZone.run(() => this.router.navigate(['dynamic-form', {id: item.profileId, datasetId:item.id, datasetProperties:item.properties}])); + } + } diff --git a/dmp-frontend/src/app/datasets/dataset.html b/dmp-frontend/src/app/datasets/dataset.html index c2b7c7d8a..2915810ef 100644 --- a/dmp-frontend/src/app/datasets/dataset.html +++ b/dmp-frontend/src/app/datasets/dataset.html @@ -23,9 +23,9 @@