Skip to content
This repository was archived by the owner on Mar 18, 2023. It is now read-only.

Commit b8b5f9c

Browse files
BastianGemvolkflo
authored andcommitted
fix(ui): add error handling to register client functionality
If an error occurs during the registration of a client, which can be triggered on the 'My Clients' page, nothing happened so far. We added snackbar messages to inform the user about what happened with the registration request.
1 parent efa1632 commit b8b5f9c

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

src/app/components/my-apps/my-apps.component.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { IClientVersionExt } from '../../interfaces/IClientVersionSummaryExt';
5353
import { ContractService } from '../../services/contract/contract.service';
5454
import { OrganizationService } from '../../services/org/organization.service';
5555
import { BreakContractComponent } from '../dialogs/break-contract/break-contract.component';
56+
import { HttpErrorResponse } from '@angular/common/http';
5657

5758
@Component({
5859
selector: 'app-my-apps',
@@ -379,11 +380,26 @@ export class MyAppsComponent implements OnInit {
379380
entityId: extendedClientVersion.client.id,
380381
entityVersion: extendedClientVersion.version
381382
};
382-
this.clientService.registerClient(action).subscribe(() => {
383-
console.info(
384-
`Client ${action.organizationId}/${action.entityId}/${action.entityVersion} successfully registered`
385-
);
386-
extendedClientVersion.status = 'Registered';
383+
this.clientService.registerClient(action).subscribe({
384+
next: () => {
385+
this.snackbarService.showPrimarySnackBar(
386+
this.translator.instant('CLIENTS.REGISTER_CLIENT_SUCCEED', {
387+
clientName: action.entityId,
388+
clientVersion: action.entityVersion
389+
}) as string
390+
);
391+
console.info(
392+
`Client ${action.organizationId}/${action.entityId}/${action.entityVersion} successfully registered`
393+
);
394+
extendedClientVersion.registerable = false;
395+
extendedClientVersion.status = 'Registered';
396+
},
397+
error: (err: HttpErrorResponse) => {
398+
this.snackbarService.showErrorSnackBar(
399+
this.translator.instant('CLIENTS.REGISTER_CLIENT_FAILED') as string,
400+
err
401+
);
402+
}
387403
});
388404
}
389405

src/assets/i18n/de.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
"FAILED_WHILE_FETCHING_CLIENTS": "Fehler beim Laden der Clients",
100100
"DELETE_CLIENT_FAILED": "Fehler beim Löschen des Client",
101101
"DELETE_CONTRACT_FAILED": "Fehler beim Löschen des Vertrags",
102+
"REGISTER_CLIENT_FAILED": "Fehler beim Registrieren des Client",
103+
"REGISTER_CLIENT_SUCCEED": "Der Client {{ clientName }} ({{ clientVersion }}) wurde erfolgreich registriert",
102104
"NO_PROBES": "Für diese API liegen keine Policy-Daten vor",
103105
"RETIRED_API": "Diese API kann nicht mehr verwendet werden.",
104106
"SELECT": "Aus vorhandenen Anwendungen auswählen",

src/assets/i18n/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@
9999
"FAILED_WHILE_FETCHING_CLIENTS": "Failed while fetching clients",
100100
"DELETE_CLIENT_FAILED": "Failed while removing the client",
101101
"DELETE_CONTRACT_FAILED": "Failed while removing the contract",
102+
"REGISTER_CLIENT_FAILED": "Failed while registering the client",
103+
"REGISTER_CLIENT_SUCCEED": "The client {{ clientName }} ({{ clientVersion }}) has been successfully registered",
102104
"NO_PROBES": "There is no policy data for the current API",
103105
"RETIRED_API": "This API is retired and can no longer be used.",
104106
"SELECT": "Select from available Clients",

0 commit comments

Comments
 (0)