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.
MODIFY
src/app/components/my-apps/my-apps.component.ts
src/app/components/my-apps/my-apps.component.ts
@@ -53,6 +53,7 @@ import { IClientVersionExt } from '../../interfaces/IClientVersionSummaryExt';
import { ContractService } from '../../services/contract/contract.service';
import { OrganizationService } from '../../services/org/organization.service';
import { BreakContractComponent } from '../dialogs/break-contract/break-contract.component';
+import { HttpErrorResponse } from '@angular/common/http';
@Component({
selector: 'app-my-apps',
@@ -379,11 +380,26 @@ export class MyAppsComponent implements OnInit {
entityId: extendedClientVersion.client.id,
entityVersion: extendedClientVersion.version
};
- this.clientService.registerClient(action).subscribe(() => {
+ this.clientService.registerClient(action).subscribe({
+ next: () => {
+ this.snackbarService.showPrimarySnackBar(
+ this.translator.instant('CLIENTS.REGISTER_CLIENT_SUCCEED', {
+ clientName: action.entityId,
+ clientVersion: action.entityVersion
+ }) as string
+ );
console.info(
`Client ${action.organizationId}/${action.entityId}/${action.entityVersion} successfully registered`
);
+ extendedClientVersion.registerable = false;
extendedClientVersion.status = 'Registered';
+ },
+ error: (err: HttpErrorResponse) => {
+ this.snackbarService.showErrorSnackBar(
+ this.translator.instant('CLIENTS.REGISTER_CLIENT_FAILED') as string,
+ err
+ );
+ }
});
}

MODIFY
src/assets/i18n/en.json
src/assets/i18n/en.json
"FAILED_WHILE_FETCHING_CLIENTS": "Failed while fetching clients",
"DELETE_CLIENT_FAILED": "Failed while removing the client",
"DELETE_CONTRACT_FAILED": "Failed while removing the contract",
+ "REGISTER_CLIENT_FAILED": "Failed while registering the client",
+ "REGISTER_CLIENT_SUCCEED": "The client {{ clientName }} ({{ clientVersion }}) has been successfully registered",
"NO_PROBES": "There is no policy data for the current API",
"RETIRED_API": "This API is retired and can no longer be used.",
"SELECT": "Select from available Clients",

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.