diff --git a/src/app/profile/profile.component.ts b/src/app/profile/profile.component.ts index 2f7ca7c..ad29ca2 100644 --- a/src/app/profile/profile.component.ts +++ b/src/app/profile/profile.component.ts @@ -98,7 +98,7 @@ export class ProfileComponent { }).then((response: restangular.IResponse) => { this.boxes = response.data.boxes; }).catch(() => { - notificationService.error("notification.profile.not_found"); + notificationService.error({ message: "notification.profile.not_found" }); }); } } diff --git a/src/app/shared/services/notification.service.spec.ts b/src/app/shared/services/notification.service.spec.ts index ea07a54..84ae614 100644 --- a/src/app/shared/services/notification.service.spec.ts +++ b/src/app/shared/services/notification.service.spec.ts @@ -18,7 +18,7 @@ describe("Components", () => { sweetAlert.swal = jasmine.createSpy("swal"); let component: NotificationService = new NotificationService(helpers.mocks.$log, sweetAlert, helpers.mocks.translatorService); - component.error("message", "title"); + component.error({ message: "message", title: "title" }); expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ text: "message", title: "title", @@ -45,7 +45,7 @@ describe("Components", () => { sweetAlert.swal = jasmine.createSpy("swal"); let component: NotificationService = new NotificationService(helpers.mocks.$log, sweetAlert, helpers.mocks.translatorService); - component.success("title", "message", 1000); + component.success({ title: "title", message: "message", timer: 1000 }); expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ type: "success" })); @@ -69,7 +69,7 @@ describe("Components", () => { sweetAlert.swal = jasmine.createSpy("swal"); let component: NotificationService = new NotificationService(helpers.mocks.$log, sweetAlert, helpers.mocks.translatorService); - component.success("title", "message"); + component.success({ title: "title", message: "message" }); expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ type: "success", timer: NotificationService.DEFAULT_SUCCESS_TIMER diff --git a/src/app/shared/services/notification.service.ts b/src/app/shared/services/notification.service.ts index 23a8bee..1b5f866 100644 --- a/src/app/shared/services/notification.service.ts +++ b/src/app/shared/services/notification.service.ts @@ -15,24 +15,33 @@ export class NotificationService { public static DEFAULT_ERROR_MESSAGE = "notification.error.default.message"; public static DEFAULT_SUCCESS_TIMER = 1000; - error(message: string = NotificationService.DEFAULT_ERROR_MESSAGE, title: string = NotificationService.DEFAULT_ERROR_TITLE) { + error({ + message = NotificationService.DEFAULT_ERROR_MESSAGE, + title = NotificationService.DEFAULT_ERROR_TITLE, + showConfirmButton = true + } = {}) { this.$log.debug("Notification error:", title, message, this.translatorService.currentLanguage()); this.SweetAlert.swal({ title: this.translatorService.translate(title), text: this.translatorService.translate(message), - type: "error" + type: "error", + showConfirmButton: showConfirmButton }); } httpError(status: number, data: any): boolean { - this.error(`notification.http_error.${status}.message`); + this.error({ message: `notification.http_error.${status}.message` }); return true; // return true to indicate that the error was already handled } - success(title: string, text: string, timer: number = NotificationService.DEFAULT_SUCCESS_TIMER) { + success({ + title, + message, + timer = NotificationService.DEFAULT_SUCCESS_TIMER + }) { this.SweetAlert.swal({ title: title, - text: text, + text: message, type: "success", timer: timer }); -- libgit2 0.21.2