From 5a7f002bdd5955f7f1e045275af2c11f8c39db4b Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Fri, 15 Sep 2017 21:02:43 +0200 Subject: [PATCH] Add duplicated user error on create --- api/cron-job/cron.js | 4 +--- .../users/edit-user/edit-user.component.html | 7 ++++++- .../users/edit-user/edit-user.component.ts | 20 ++++++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/api/cron-job/cron.js b/api/cron-job/cron.js index 15acbfe..b9c1790 100644 --- a/api/cron-job/cron.js +++ b/api/cron-job/cron.js @@ -39,7 +39,6 @@ const createAllSignatures = () => { + ': finished successful - UPDATE SIGNATURES'); }) }); - }; const createBackup = () => { @@ -55,11 +54,10 @@ const createBackup = () => { }) }; - // Execute daily @ 02:30 AM const cronJobSignature = cron.job('00 30 02 * * *', createAllSignatures); -// Execute every on Mon, Thu and Sat @ 04:00 AM +// Execute on Mon, Thu and Sat @ 04:00 AM const cronJobBackup = cron.job('00 00 04 * * mon,thu,sat', createBackup); module.exports = { diff --git a/static/src/app/users/edit-user/edit-user.component.html b/static/src/app/users/edit-user/edit-user.component.html index 07c609b..b052f21 100644 --- a/static/src/app/users/edit-user/edit-user.component.html +++ b/static/src/app/users/edit-user/edit-user.component.html @@ -57,10 +57,15 @@ Bestätigen + + {{error}} + + - Erfolgreich gespeichert + Erfolgreich gespeichert diff --git a/static/src/app/users/edit-user/edit-user.component.ts b/static/src/app/users/edit-user/edit-user.component.ts index c71981e..df115f3 100644 --- a/static/src/app/users/edit-user/edit-user.component.ts +++ b/static/src/app/users/edit-user/edit-user.component.ts @@ -28,6 +28,10 @@ export class EditUserComponent { ranksDisplay = 'none'; + showErrorLabel = false; + + error: string; + constructor(private router: Router, private route: ActivatedRoute, private userService: UserService, @@ -98,9 +102,19 @@ export class EditUserComponent { } else { this.userService.submitUser(updateObject) .subscribe(user => { - this.router.navigate(['..'], {relativeTo: this.route}); - return true; - }) + this.router.navigate(['..'], {relativeTo: this.route}); + return true; + }, + error => { + // duplicated user error message + if (error._body.indexOf('duplicate') >= 0) { + this.error = "Benutzername existiert bereits"; + this.showErrorLabel = true; + setTimeout(() => { + this.showErrorLabel = false; + }, 5000); + } + }) } }