diff --git a/dmp-frontend/src/app/datasets/dataset.component.ts b/dmp-frontend/src/app/datasets/dataset.component.ts index 9f0599768..d3da0f538 100644 --- a/dmp-frontend/src/app/datasets/dataset.component.ts +++ b/dmp-frontend/src/app/datasets/dataset.component.ts @@ -12,6 +12,10 @@ import { StatusToString } from '../pipes/various/status-to-string'; declare var $: any; + +import '../../assets/custom.js'; +declare function simple_notifier(type: string, title: string, message:string): any; + @Component({ selector: 'datasets-table', templateUrl: 'dataset.html', @@ -87,11 +91,7 @@ export class DatasetsComponent implements OnInit { //this.projects = this.serverService.getDummyProjects(); this.datasets = []; console.log(this.dmpIdforDatasets); - this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe( - response => { - this.tableData = response; - } - ); + this.getDatasets(); this.serverService.getAllDatsetsProfile().subscribe( response => { @@ -100,7 +100,12 @@ export class DatasetsComponent implements OnInit { params.key = datasetprofile.id; params.value = datasetprofile.label; this.datasetProfileDropDown.options.push(params); - }); + }, + error => { + simple_notifier("danger",null,"Could not load User's Dataset Profiles"); + } + + ); } ) @@ -124,10 +129,13 @@ export class DatasetsComponent implements OnInit { this.dataset.profile = { "id": this.dataset.profile } this.serverService.createDatasetForDmp(this.dataset).subscribe( response => { - console.log(response); + simple_notifier("success",null,"Created dataset"); this.getDatasets(); if (this.saveAndDescribe == true) this.describeDataset(response); + }, + error=>{ + simple_notifier("danger",null,"Could not create Dataset"); } ) $("#newDatasetModal").modal("hide"); @@ -138,10 +146,13 @@ export class DatasetsComponent implements OnInit { this.dataset.profile = { "id": this.dataset.profile } this.serverService.updateDatsetsProfile(this.dataset).subscribe( response => { - console.log(response); + simple_notifier("success",null,"Dataset edited"); this.getDatasets(); if (this.saveAndDescribe == true) this.describeDataset(response); + }, + error => { + simple_notifier("danger",null,"Could not edit dataset"); } ) $("#newDatasetModal").modal("hide"); @@ -149,10 +160,15 @@ export class DatasetsComponent implements OnInit { } - getDatasets(){ + getDatasets(muted?: boolean){ this.serverService.getDatasetForDmp({ "id": this.dmpIdforDatasets }).subscribe( - response => { + response => { this.tableData = response; + if(muted && muted!=true) + simple_notifier("success",null,"Updated datasets table"); + }, + error => { + simple_notifier("danger",null,"Could not update datasets table"); } ); } @@ -162,6 +178,9 @@ export class DatasetsComponent implements OnInit { this.serverService.getDatasetForDmp({ "id": dmpid }).subscribe( response => { this.tableData = response; + }, + error => { + console.log("could not retrieve dataset for dpm: "+dmpid); } ); } @@ -201,13 +220,13 @@ export class DatasetsComponent implements OnInit { deleteRow(dataset, $event){ this.serverService.deleteDataset(dataset).subscribe( response => { - console.log("Deleted Successfully the dataset") + simple_notifier("success",null,"Deleted dataset"); + this.getDatasets(); }, err => { - console.log("Could not delete the dataset") + simple_notifier("danger",null,"Could not delete the dataset"); } ); - this.getDatasets(); } diff --git a/dmp-frontend/src/app/datasets/dataset.html b/dmp-frontend/src/app/datasets/dataset.html index 4f32337c4..a4621f0b9 100644 --- a/dmp-frontend/src/app/datasets/dataset.html +++ b/dmp-frontend/src/app/datasets/dataset.html @@ -15,7 +15,7 @@ -