Added notifications on dataset table

This commit is contained in:
Nikolaos Laskaris 2017-11-07 14:04:58 +02:00
parent a952cc529d
commit ff856c6d14
2 changed files with 33 additions and 14 deletions

View File

@ -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();
}

View File

@ -15,7 +15,7 @@
</select>
</th>
<th>
<button class="btn btn-default" (click)="getDatasets()">
<button class="btn btn-default" (click)="getDatasets('false')">
<span class="glyphicon glyphicon-refresh"></span>
</button>
</th>