fix(console): add model for api keys, fix toast, binding (#1757)

* fix: add model for api keys, fix toast, binding

* show api clientid
This commit is contained in:
Max Peintner 2021-05-20 10:26:53 +02:00 committed by GitHub
parent d0a5ad94d2
commit 1ba70d2012
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 496 additions and 472 deletions

View File

@ -4,7 +4,8 @@
<ng-container *ngIf="keyResponse"> <ng-container *ngIf="keyResponse">
<div class="row"> <div class="row">
<p class="left">{{'USER.MACHINE.ID' | translate}}</p> <p class="left">{{'USER.MACHINE.ID' | translate}}</p>
<p class="right">{{keyResponse?.keyId}}</p> <p class="right">{{$any(keyResponse)?.id}}</p>
<p class="right">{{$any(keyResponse)?.keyId}}</p>
</div> </div>
<div class="row"> <div class="row">

View File

@ -1,7 +1,7 @@
import { Component, Inject } from '@angular/core'; import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
import { AddMachineKeyResponse } from 'src/app/proto/generated/zitadel/management_pb'; import { AddAppKeyResponse, AddMachineKeyResponse } from 'src/app/proto/generated/zitadel/management_pb';
@Component({ @Component({
selector: 'app-show-key-dialog', selector: 'app-show-key-dialog',
@ -9,7 +9,7 @@ import { AddMachineKeyResponse } from 'src/app/proto/generated/zitadel/managemen
styleUrls: ['./show-key-dialog.component.scss'], styleUrls: ['./show-key-dialog.component.scss'],
}) })
export class ShowKeyDialogComponent { export class ShowKeyDialogComponent {
public keyResponse!: AddMachineKeyResponse.AsObject; public keyResponse!: AddMachineKeyResponse.AsObject | AddAppKeyResponse.AsObject;
constructor( constructor(
public dialogRef: MatDialogRef<ShowKeyDialogComponent>, public dialogRef: MatDialogRef<ShowKeyDialogComponent>,
@ -21,7 +21,10 @@ export class ShowKeyDialogComponent {
public saveFile(): void { public saveFile(): void {
const json = atob(this.keyResponse.keyDetails.toString()); const json = atob(this.keyResponse.keyDetails.toString());
const blob = new Blob([json], { type: 'text/plain;charset=utf-8' }); const blob = new Blob([json], { type: 'text/plain;charset=utf-8' });
saveAs(blob, `${this.keyResponse.keyId}.json`); const name = (this.keyResponse as AddMachineKeyResponse.AsObject).keyId ?
(this.keyResponse as AddMachineKeyResponse.AsObject).keyId :
(this.keyResponse as AddAppKeyResponse.AsObject).id;
saveAs(blob, `${name}.json`);
} }
public closeDialog(): void { public closeDialog(): void {

View File

@ -180,7 +180,7 @@
</span> </span>
<span class="right"> <span class="right">
<span> <span>
{{'APP.API.AUTHMETHOD.'+oidcAppRequest?.authMethodType | translate}} {{'APP.API.AUTHMETHOD.'+apiAppRequest?.authMethodType | translate}}
</span> </span>
</span> </span>
</div> </div>

View File

@ -72,6 +72,19 @@
<i *ngIf="copiedKey == 'clientId'" class="las la-clipboard-check"></i> <i *ngIf="copiedKey == 'clientId'" class="las la-clipboard-check"></i>
</button> </button>
</div> </div>
</div>
<div class="environment" *ngIf="app?.apiConfig?.clientId">
<span class="key">{{'APP.API.INFO.CLIENTID' | translate}}</span>
<div class="environment-row">
<span>{{this.app.apiConfig?.clientId}}</span>
<button color="primary" [disabled]="copiedKey == this.app.apiConfig?.clientId"
[matTooltip]="(copiedKey != this.app.apiConfig?.clientId ? 'USER.PAGES.COPY' : 'USER.PAGES.COPIED' ) | translate"
appCopyToClipboard [valueToCopy]="this.app.apiConfig?.clientId"
(copiedValue)="copiedKey = 'clientId'" mat-icon-button>
<i *ngIf="copiedKey != 'clientId'" class="las la-clipboard"></i>
<i *ngIf="copiedKey == 'clientId'" class="las la-clipboard-check"></i>
</button>
</div>
</div> </div>
<ng-container *ngFor="let environmentV of (environmentMap | keyvalue)"> <ng-container *ngFor="let environmentV of (environmentMap | keyvalue)">
<div *ngIf="environmentV.value" class="environment"> <div *ngIf="environmentV.value" class="environment">

View File

@ -511,7 +511,7 @@ export class AppDetailComponent implements OnInit, OnDestroy {
const config = { api: this.app.apiConfig }; const config = { api: this.app.apiConfig };
this.currentAuthMethod = this.authMethodFromPartialConfig(config); this.currentAuthMethod = this.authMethodFromPartialConfig(config);
} }
this.toast.showInfo('APP.TOAST.OIDCUPDATED', true); this.toast.showInfo('APP.TOAST.APIUPDATED', true);
}) })
.catch(error => { .catch(error => {
this.toast.showError(error); this.toast.showError(error);
@ -540,7 +540,6 @@ export class AppDetailComponent implements OnInit, OnDestroy {
this.toast.showInfo('APP.TOAST.CLIENTSECRETREGENERATED', true); this.toast.showInfo('APP.TOAST.CLIENTSECRETREGENERATED', true);
this.dialog.open(AppSecretDialogComponent, { this.dialog.open(AppSecretDialogComponent, {
data: { data: {
// clientId: data.toObject().clientId ?? '',
clientSecret: resp.clientSecret, clientSecret: resp.clientSecret,
}, },
width: '400px', width: '400px',

View File

@ -1151,6 +1151,9 @@
} }
}, },
"API": { "API": {
"INFO": {
"CLIENTID": "Client Id"
},
"REGENERATESECRET": "Client Secret neu generieren", "REGENERATESECRET": "Client Secret neu generieren",
"SELECTION": { "SELECTION": {
"TITLE": "API", "TITLE": "API",
@ -1195,6 +1198,7 @@
"REACTIVATED": "Anwendung reaktiviert.", "REACTIVATED": "Anwendung reaktiviert.",
"DEACTIVATED": "Anwendung deaktiviert.", "DEACTIVATED": "Anwendung deaktiviert.",
"OIDCUPDATED": "OIDC-Konfiguration geändert.", "OIDCUPDATED": "OIDC-Konfiguration geändert.",
"APIUPDATED":"API Konfiguration geändert.",
"UPDATED": "App geändert.", "UPDATED": "App geändert.",
"CLIENTSECRETREGENERATED": "Client Secret generiert.", "CLIENTSECRETREGENERATED": "Client Secret generiert.",
"DELETED": "App gelöscht.", "DELETED": "App gelöscht.",

View File

@ -1152,6 +1152,9 @@
} }
}, },
"API": { "API": {
"INFO": {
"CLIENTID": "Client Id"
},
"REGENERATESECRET": "Regenerate Client Secret", "REGENERATESECRET": "Regenerate Client Secret",
"SELECTION": { "SELECTION": {
"TITLE": "API", "TITLE": "API",
@ -1196,6 +1199,7 @@
"REACTIVATED": "Application reactivated.", "REACTIVATED": "Application reactivated.",
"DEACTIVATED": "Application deactivated.", "DEACTIVATED": "Application deactivated.",
"OIDCUPDATED": "OIDC configuration updated.", "OIDCUPDATED": "OIDC configuration updated.",
"APIUPDATED":"API configuration updated",
"UPDATED": "App updated.", "UPDATED": "App updated.",
"CLIENTSECRETREGENERATED": "client secret generated.", "CLIENTSECRETREGENERATED": "client secret generated.",
"DELETED": "App deleted.", "DELETED": "App deleted.",