From be6ce2ee712312ce9e4f9ff40140fb34f00c4770 Mon Sep 17 00:00:00 2001 From: Nikolaos Laskaris Date: Tue, 7 Nov 2017 13:30:11 +0200 Subject: [PATCH] Added notifications on dmp.ts --- dmp-frontend/.angular-cli.json | 3 +- dmp-frontend/src/app/dmps/dmp.component.ts | 40 ++++++++++++---------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/dmp-frontend/.angular-cli.json b/dmp-frontend/.angular-cli.json index 9a6dc38ba..4991a0caf 100644 --- a/dmp-frontend/.angular-cli.json +++ b/dmp-frontend/.angular-cli.json @@ -23,9 +23,8 @@ "styles.css" ], "scripts": [ - "./../node_modules/jquery/dist/jquery.min.js", "./../node_modules/bootstrap/dist/js/bootstrap.min.js", - "./assets/xml2json.min.js", + "./assets/xml2json.min.js", "./assets/jquery.scrollTo.min.js" ], "environmentSource": "environments/environment.ts", diff --git a/dmp-frontend/src/app/dmps/dmp.component.ts b/dmp-frontend/src/app/dmps/dmp.component.ts index fb8ce823d..624612381 100644 --- a/dmp-frontend/src/app/dmps/dmp.component.ts +++ b/dmp-frontend/src/app/dmps/dmp.component.ts @@ -18,6 +18,9 @@ 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: 'dmps', templateUrl: 'dmps.html', @@ -87,15 +90,8 @@ export class DmpComponent implements OnInit{ } ngOnInit() { - - this.serverService.getDmpOfUser().subscribe( - response => { - this.tableData = response; - }, - (err: HttpErrorResponse) => { - - } - ); + + this.getDmps(); this.serverService.getAllProjects().subscribe( response => { @@ -109,7 +105,7 @@ export class DmpComponent implements OnInit{ }, (err: HttpErrorResponse) => { - + simple_notifier("danger",null,"Could not load User's Projects"); } ) } @@ -122,7 +118,7 @@ getDmps(){ this.tableData = response; }, (err: HttpErrorResponse) => { - + simple_notifier("danger",null,"Could not refresh DMPs"); } ); } @@ -137,7 +133,11 @@ newDMP(){ this.serverService.createDmpForCurrentUser(this.dmp) .subscribe( response =>{ + simple_notifier("success",null,"DMP created"); this.getDmps(); + }, + error => { + simple_notifier("danger",null,"Could not create the DMP"); } ); $("#newDmpModal").modal("hide"); @@ -150,7 +150,11 @@ updateDMP(){ this.serverService.updateDmp(this.dmp) .subscribe( response =>{ + simple_notifier("success",null,"Edited the DMP"); this.getDmps(); + }, + error =>{ + simple_notifier("danger",null,"Failed to edit the DMP"); } ); $("#newDmpModal").modal("hide"); @@ -162,10 +166,11 @@ cloneDMP(dmp){ dmp = {"id": dmp.id}; this.serverService.cloneDmp(dmp).subscribe( response => { + simple_notifier("success",null,"Successfully cloned the DMP"); this.getDmps(); }, error => { - console.log("Failed to clone dmp"); + simple_notifier("danger",null,"Failed to clone the DMP"); } ); $("#newVersionDmpModal").modal("hide"); @@ -235,19 +240,16 @@ newDmp(item){ } deleteRow(dmp, $event){ - console.log("delete row") - console.log(dmp); - console.log($event) this.serverService.deleteDmp(dmp).subscribe( response => { - console.log("Deleted Successfully the dmp") + simple_notifier("success",null,"Successfully deleted the DMP"); + this.getDmps(); }, (err: HttpErrorResponse) => { - console.log("Could not delete the dmp") + simple_notifier("danger",null,"Failed to delete the DMP"); } - ); - this.getDmps(); + ); }