From ec68fac2eafdc4013d2804dee64c29e953c6273d Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Fri, 28 Jun 2024 18:59:24 +0300 Subject: [PATCH 1/2] fix: show error notification when server returns error --- .../page-advanced-settings.component.ts | 8 ++++++-- .../page-agent-subscriptions.component.ts | 8 ++++++-- .../preference/pages/page-alias/page-alias.component.ts | 8 ++++++-- .../pages/page-api-auth/page-api-auth.component.ts | 6 ++++-- .../pages/page-mapping/page-mapping.component.ts | 7 ++++++- .../pages/page-profile/page-profile.component.ts | 4 +++- .../pages/page-scripts/page-scripts.component.ts | 5 +++-- .../page-system-overview.component.ts | 8 ++++++-- .../page-user-settings/page-user-settings.component.ts | 8 ++++++-- .../preference/pages/page-users/page-users.component.ts | 7 +++++-- 10 files changed, 51 insertions(+), 18 deletions(-) diff --git a/src/app/components/preference/pages/page-advanced-settings/page-advanced-settings.component.ts b/src/app/components/preference/pages/page-advanced-settings/page-advanced-settings.component.ts index c7df012e..04d342cd 100644 --- a/src/app/components/preference/pages/page-advanced-settings/page-advanced-settings.component.ts +++ b/src/app/components/preference/pages/page-advanced-settings/page-advanced-settings.component.ts @@ -118,8 +118,12 @@ export class PageAdvancedSettingsComponent implements OnInit, AfterViewInit, OnD result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }) }; if (item) { item.type = type; diff --git a/src/app/components/preference/pages/page-agent-subscriptions/page-agent-subscriptions.component.ts b/src/app/components/preference/pages/page-agent-subscriptions/page-agent-subscriptions.component.ts index b95f1c1d..c680e4f6 100644 --- a/src/app/components/preference/pages/page-agent-subscriptions/page-agent-subscriptions.component.ts +++ b/src/app/components/preference/pages/page-agent-subscriptions/page-agent-subscriptions.component.ts @@ -123,8 +123,12 @@ export class PageAgentSubscriptionsComponent implements OnInit, AfterViewInit, O result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; this.openDialog(DialogAgentsubComponent, item, onOpenDialog, isCopy); diff --git a/src/app/components/preference/pages/page-alias/page-alias.component.ts b/src/app/components/preference/pages/page-alias/page-alias.component.ts index 88fb5331..2cf9a319 100644 --- a/src/app/components/preference/pages/page-alias/page-alias.component.ts +++ b/src/app/components/preference/pages/page-alias/page-alias.component.ts @@ -133,8 +133,12 @@ export class PageAliasComponent implements OnInit, OnDestroy, AfterViewInit { result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; if (item) { item.actionType = type; diff --git a/src/app/components/preference/pages/page-api-auth/page-api-auth.component.ts b/src/app/components/preference/pages/page-api-auth/page-api-auth.component.ts index daf97310..ba59f7d3 100644 --- a/src/app/components/preference/pages/page-api-auth/page-api-auth.component.ts +++ b/src/app/components/preference/pages/page-api-auth/page-api-auth.component.ts @@ -135,6 +135,7 @@ export class PageApiAuthComponent implements OnInit, AfterViewInit, OnDestroy { ); } this.updateData(); + this.alertService.success(`${this.page} Successfully ${(_result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); }; const onOpenDialog = (result) => { @@ -145,8 +146,9 @@ export class PageApiAuthComponent implements OnInit, AfterViewInit, OnDestroy { result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(onServiceRes); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(onServiceRes, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; this.openDialog(DialogAuthKeyComponent, item, onOpenDialog, isCopy); diff --git a/src/app/components/preference/pages/page-mapping/page-mapping.component.ts b/src/app/components/preference/pages/page-mapping/page-mapping.component.ts index a99bc4b9..0e6e79b8 100644 --- a/src/app/components/preference/pages/page-mapping/page-mapping.component.ts +++ b/src/app/components/preference/pages/page-mapping/page-mapping.component.ts @@ -121,7 +121,12 @@ export class PageMappingComponent implements OnInit, AfterViewInit, OnDestroy { result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); }; diff --git a/src/app/components/preference/pages/page-profile/page-profile.component.ts b/src/app/components/preference/pages/page-profile/page-profile.component.ts index 6cc4fdc1..2360c9df 100644 --- a/src/app/components/preference/pages/page-profile/page-profile.component.ts +++ b/src/app/components/preference/pages/page-profile/page-profile.component.ts @@ -206,7 +206,9 @@ export class PageProfileComponent implements OnInit { } this.alertService.success(`${this.page} Successfully Updated`); - }); + }, () => { + this.alertService.error(`Failed to Update ${this.page}`) + }); } else { this.username.markAsTouched(); this.usergroup.markAsTouched(); diff --git a/src/app/components/preference/pages/page-scripts/page-scripts.component.ts b/src/app/components/preference/pages/page-scripts/page-scripts.component.ts index 862af506..3cd85811 100644 --- a/src/app/components/preference/pages/page-scripts/page-scripts.component.ts +++ b/src/app/components/preference/pages/page-scripts/page-scripts.component.ts @@ -123,8 +123,9 @@ export class PageScriptsComponent implements OnInit, AfterViewInit, OnDestroy { result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => this.updateData(), () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; this.openDialog(DialogScriptsComponent, Functions.cloneObject(item), onOpenDialog, isCopy); diff --git a/src/app/components/preference/pages/page-system-overview/page-system-overview.component.ts b/src/app/components/preference/pages/page-system-overview/page-system-overview.component.ts index 47fba29a..fe9b6e0c 100644 --- a/src/app/components/preference/pages/page-system-overview/page-system-overview.component.ts +++ b/src/app/components/preference/pages/page-system-overview/page-system-overview.component.ts @@ -186,8 +186,12 @@ export class PageSystemOverviewComponent implements OnInit, AfterViewInit, OnDes result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; this.openDialog(DialogUsersComponent, item, onOpenDialog, isCopy); diff --git a/src/app/components/preference/pages/page-user-settings/page-user-settings.component.ts b/src/app/components/preference/pages/page-user-settings/page-user-settings.component.ts index 842a6f37..9e976412 100644 --- a/src/app/components/preference/pages/page-user-settings/page-user-settings.component.ts +++ b/src/app/components/preference/pages/page-user-settings/page-user-settings.component.ts @@ -123,8 +123,12 @@ export class PageUserSettingsComponent implements OnInit, OnDestroy, AfterViewIn result.isCopy = isCopy; this.service[result.isnew ? 'add' : (isCopy ? 'copy' : 'update')](result.data) .toPromise() - .then(() => this.updateData()); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + .then(() => { + this.updateData(); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; if (item) { diff --git a/src/app/components/preference/pages/page-users/page-users.component.ts b/src/app/components/preference/pages/page-users/page-users.component.ts index 88660b7a..40d9baf1 100644 --- a/src/app/components/preference/pages/page-users/page-users.component.ts +++ b/src/app/components/preference/pages/page-users/page-users.component.ts @@ -135,8 +135,11 @@ export class PageUsersComponent implements OnInit, OnDestroy, AfterViewInit { this.authenticationService.logout(); this.router.navigate([{ outlets: { primary: null, system: 'login' } }]); } - }); - this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + this.alertService.success(`${this.page} Successfully ${(result.isnew ? 'Added' : (isCopy ? 'Copied' : 'Updated'))}`); + + }, () => { + this.alertService.error(`Failed to ${(result.isnew ? 'Add' : (isCopy ? 'Copy' : 'Update'))} ${this.page}`) + }); }; this.openDialog(DialogUsersComponent, Functions.cloneObject(item), onOpenDialog, isCopy); From 04e15e91d759dfea31501a272c2f3e226b1f0f8c Mon Sep 17 00:00:00 2001 From: Alexey Oplachko Date: Fri, 28 Jun 2024 18:59:34 +0300 Subject: [PATCH 2/2] fix: match tooltip to actual validation --- .../dialogs/dialog-users/dialog-users.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/components/preference/dialogs/dialog-users/dialog-users.component.html b/src/app/components/preference/dialogs/dialog-users/dialog-users.component.html index af5a3d28..e4dcd7e5 100644 --- a/src/app/components/preference/dialogs/dialog-users/dialog-users.component.html +++ b/src/app/components/preference/dialogs/dialog-users/dialog-users.component.html @@ -87,7 +87,7 @@ {{ password?.errors?.['maxlength']?.requiredLength }} {{'validators.maxChars' | translate }} - {{'validators.pattern' | translate }} [aA-Zz], [0-9] and "~!@#$%^&*()_"] + {{'validators.pattern' | translate }} [aA-zZ] and [0-9] - {{'validators.pattern' | translate }} [aA-Zz], [0-9] and "~!@#$%^&*()_"] + {{'validators.pattern' | translate }} [aA-zZ] and [0-9]