Commit 2e81cc7a8ae3a7ef9da2a4888d58add8ebf05547
Exists in
master
and in
30 other branches
Merge branch 'ngforward' of softwarepublico.gov.br:noosfero-themes/angular-theme into ngforward
Showing
5 changed files
with
22 additions
and
11 deletions
Show diff stats
src/app/profile/profile.component.ts
@@ -98,7 +98,7 @@ export class ProfileComponent { | @@ -98,7 +98,7 @@ export class ProfileComponent { | ||
98 | }).then((response: restangular.IResponse) => { | 98 | }).then((response: restangular.IResponse) => { |
99 | this.boxes = response.data.boxes; | 99 | this.boxes = response.data.boxes; |
100 | }).catch(() => { | 100 | }).catch(() => { |
101 | - notificationService.error("notification.profile.not_found"); | 101 | + notificationService.error({ message: "notification.profile.not_found" }); |
102 | }); | 102 | }); |
103 | } | 103 | } |
104 | } | 104 | } |
src/app/shared/services/notification.service.spec.ts
@@ -18,7 +18,7 @@ describe("Components", () => { | @@ -18,7 +18,7 @@ describe("Components", () => { | ||
18 | sweetAlert.swal = jasmine.createSpy("swal"); | 18 | sweetAlert.swal = jasmine.createSpy("swal"); |
19 | 19 | ||
20 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); | 20 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); |
21 | - component.error("message", "title"); | 21 | + component.error({ message: "message", title: "title" }); |
22 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ | 22 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ |
23 | text: "message", | 23 | text: "message", |
24 | title: "title", | 24 | title: "title", |
@@ -45,7 +45,7 @@ describe("Components", () => { | @@ -45,7 +45,7 @@ describe("Components", () => { | ||
45 | sweetAlert.swal = jasmine.createSpy("swal"); | 45 | sweetAlert.swal = jasmine.createSpy("swal"); |
46 | 46 | ||
47 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); | 47 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); |
48 | - component.success("title", "message", 1000); | 48 | + component.success({ title: "title", message: "message", timer: 1000 }); |
49 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ | 49 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ |
50 | type: "success" | 50 | type: "success" |
51 | })); | 51 | })); |
@@ -69,7 +69,7 @@ describe("Components", () => { | @@ -69,7 +69,7 @@ describe("Components", () => { | ||
69 | sweetAlert.swal = jasmine.createSpy("swal"); | 69 | sweetAlert.swal = jasmine.createSpy("swal"); |
70 | 70 | ||
71 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); | 71 | let component: NotificationService = new NotificationService(<any>helpers.mocks.$log, <any>sweetAlert, <any>helpers.mocks.translatorService); |
72 | - component.success("title", "message"); | 72 | + component.success({ title: "title", message: "message" }); |
73 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ | 73 | expect(sweetAlert.swal).toHaveBeenCalledWith(jasmine.objectContaining({ |
74 | type: "success", | 74 | type: "success", |
75 | timer: NotificationService.DEFAULT_SUCCESS_TIMER | 75 | timer: NotificationService.DEFAULT_SUCCESS_TIMER |
src/app/shared/services/notification.service.ts
@@ -15,24 +15,33 @@ export class NotificationService { | @@ -15,24 +15,33 @@ export class NotificationService { | ||
15 | public static DEFAULT_ERROR_MESSAGE = "notification.error.default.message"; | 15 | public static DEFAULT_ERROR_MESSAGE = "notification.error.default.message"; |
16 | public static DEFAULT_SUCCESS_TIMER = 1000; | 16 | public static DEFAULT_SUCCESS_TIMER = 1000; |
17 | 17 | ||
18 | - error(message: string = NotificationService.DEFAULT_ERROR_MESSAGE, title: string = NotificationService.DEFAULT_ERROR_TITLE) { | 18 | + error({ |
19 | + message = NotificationService.DEFAULT_ERROR_MESSAGE, | ||
20 | + title = NotificationService.DEFAULT_ERROR_TITLE, | ||
21 | + showConfirmButton = true | ||
22 | + } = {}) { | ||
19 | this.$log.debug("Notification error:", title, message, this.translatorService.currentLanguage()); | 23 | this.$log.debug("Notification error:", title, message, this.translatorService.currentLanguage()); |
20 | this.SweetAlert.swal({ | 24 | this.SweetAlert.swal({ |
21 | title: this.translatorService.translate(title), | 25 | title: this.translatorService.translate(title), |
22 | text: this.translatorService.translate(message), | 26 | text: this.translatorService.translate(message), |
23 | - type: "error" | 27 | + type: "error", |
28 | + showConfirmButton: showConfirmButton | ||
24 | }); | 29 | }); |
25 | } | 30 | } |
26 | 31 | ||
27 | httpError(status: number, data: any): boolean { | 32 | httpError(status: number, data: any): boolean { |
28 | - this.error(`notification.http_error.${status}.message`); | 33 | + this.error({ message: `notification.http_error.${status}.message` }); |
29 | return true; // return true to indicate that the error was already handled | 34 | return true; // return true to indicate that the error was already handled |
30 | } | 35 | } |
31 | 36 | ||
32 | - success(title: string, text: string, timer: number = NotificationService.DEFAULT_SUCCESS_TIMER) { | 37 | + success({ |
38 | + title, | ||
39 | + message, | ||
40 | + timer = NotificationService.DEFAULT_SUCCESS_TIMER | ||
41 | + }) { | ||
33 | this.SweetAlert.swal({ | 42 | this.SweetAlert.swal({ |
34 | title: title, | 43 | title: title, |
35 | - text: text, | 44 | + text: message, |
36 | type: "success", | 45 | type: "success", |
37 | timer: timer | 46 | timer: timer |
38 | }); | 47 | }); |
src/languages/en.json
@@ -21,5 +21,6 @@ | @@ -21,5 +21,6 @@ | ||
21 | "notification.error.default.message": "Something went wrong!", | 21 | "notification.error.default.message": "Something went wrong!", |
22 | "notification.error.default.title": "Oops...", | 22 | "notification.error.default.title": "Oops...", |
23 | "notification.profile.not_found": "Page not found", | 23 | "notification.profile.not_found": "Page not found", |
24 | - "notification.http_error.401.message": "Unauthorized" | 24 | + "notification.http_error.401.message": "Unauthorized", |
25 | + "notification.http_error.500.message": "Server error" | ||
25 | } | 26 | } |
src/languages/pt.json
@@ -21,5 +21,6 @@ | @@ -21,5 +21,6 @@ | ||
21 | "notification.error.default.message": "Algo deu errado!", | 21 | "notification.error.default.message": "Algo deu errado!", |
22 | "notification.error.default.title": "Oops...", | 22 | "notification.error.default.title": "Oops...", |
23 | "notification.profile.not_found": "Página não encontrada", | 23 | "notification.profile.not_found": "Página não encontrada", |
24 | - "notification.http_error.401.message": "Não autorizado" | 24 | + "notification.http_error.401.message": "Não autorizado", |
25 | + "notification.http_error.500.message": "Erro no servidor" | ||
25 | } | 26 | } |