mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-21 15:04:25 +00:00
* feat(console): app infos, api apps, fix redirects on create, fix role update, redesign idps, policy, prettier history (#1310) * idp fixes * idp cleanup and rehaul, complexity policy preview * policy fixes, orthodox redirect * link component, add links to policies * redirect pipe, state labels * Cnsl map changes (#1315) * map changes to different format * fix changes layout, cursor * set asc values * fix user appearance in changes, index * changes * app create with api * api app create * auth method for api config * authmethods, app card for api, authmethod in dev create * move machine keys to own module * jwt method for oidc * fix app edit * save toast * fix changes, change det in app detail * regenerate secret * chore(deps-dev): bump @angular-devkit/build-angular in /console (#1324) Bumps [@angular-devkit/build-angular](https://github.com/angular/angular-cli) from 0.1102.0 to 0.1102.1. - [Release notes](https://github.com/angular/angular-cli/releases) - [Commits](https://github.com/angular/angular-cli/commits) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix policy backlink Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> (cherry picked from commit 40a7e958d712f83585e25f18f4fff620de5e3269) * fix: i18n refs, unnecessary logs (#1343) (cherry picked from commit 2e04c977eba295cab6aa533379f6075d2e27ab42) * fix: tos link (#1345) (cherry picked from commit 5333ef10c169e3656e3ca8dfb8edf7f738fa0a26) * fix: reactivate/deactivate idp, remove idp provider (#1348) * fix: reactivate/deactivate idp, remove idp provider * fix build * fix(console): add jwt to selection, idp deactivate reactivate (#1347) * fix: log error on idp change * add jwt to method selection Co-authored-by: Max Peintner <[email protected]> (cherry picked from commit c8b9888427f4ea6b513d370f9fed555208594edf) * fix: reactivate/deactivate idp (#1351) (cherry picked from commit 54f395e2e05d4adb29321e9597d049800c033b61) Co-authored-by: Max Peintner <[email protected]>
142 lines
5.7 KiB
TypeScript
142 lines
5.7 KiB
TypeScript
import { SelectionModel } from '@angular/cdk/collections';
|
|
import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
|
|
import { MatDialog } from '@angular/material/dialog';
|
|
import { MatPaginator, PageEvent } from '@angular/material/paginator';
|
|
import { MatTableDataSource } from '@angular/material/table';
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
|
import { Moment } from 'moment';
|
|
import { BehaviorSubject, Observable } from 'rxjs';
|
|
import { ClientKeySearchResponse, MachineKeySearchResponse, MachineKeyType, MachineKeyView } from 'src/app/proto/generated/management_pb';
|
|
import { ManagementService } from 'src/app/services/mgmt.service';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
import { AddKeyDialogComponent, AddKeyDialogType } from 'src/app/modules/add-key-dialog/add-key-dialog.component';
|
|
import { ShowKeyDialogComponent } from 'src/app/modules/show-key-dialog/show-key-dialog.component';
|
|
|
|
@Component({
|
|
selector: 'app-machine-keys',
|
|
templateUrl: './machine-keys.component.html',
|
|
styleUrls: ['./machine-keys.component.scss'],
|
|
})
|
|
export class MachineKeysComponent implements OnInit {
|
|
@Input() userId!: string;
|
|
|
|
@ViewChild(MatPaginator) public paginator!: MatPaginator;
|
|
public dataSource: MatTableDataSource<MachineKeyView.AsObject> = new MatTableDataSource<MachineKeyView.AsObject>();
|
|
public selection: SelectionModel<MachineKeyView.AsObject> = new SelectionModel<MachineKeyView.AsObject>(true, []);
|
|
public keyResult!: MachineKeySearchResponse.AsObject | ClientKeySearchResponse.AsObject;
|
|
private loadingSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
|
public loading$: Observable<boolean> = this.loadingSubject.asObservable();
|
|
@Input() public displayedColumns: string[] = ['select', 'id', 'type', 'creationDate', 'expirationDate'];
|
|
|
|
@Output() public changedSelection: EventEmitter<Array<MachineKeyView.AsObject>> = new EventEmitter();
|
|
|
|
constructor(public translate: TranslateService, private mgmtService: ManagementService, private dialog: MatDialog,
|
|
private toast: ToastService) {
|
|
this.selection.changed.subscribe(() => {
|
|
this.changedSelection.emit(this.selection.selected);
|
|
});
|
|
}
|
|
|
|
public ngOnInit(): void {
|
|
this.getData(10, 0);
|
|
}
|
|
|
|
|
|
public isAllSelected(): boolean {
|
|
const numSelected = this.selection.selected.length;
|
|
const numRows = this.dataSource.data.length;
|
|
return numSelected === numRows;
|
|
}
|
|
|
|
public masterToggle(): void {
|
|
this.isAllSelected() ?
|
|
this.selection.clear() :
|
|
this.dataSource.data.forEach(row => this.selection.select(row));
|
|
}
|
|
|
|
|
|
public changePage(event: PageEvent): void {
|
|
this.getData(event.pageSize, event.pageIndex * event.pageSize);
|
|
}
|
|
|
|
public deleteSelectedKeys(): void {
|
|
const mappedDeletions = this.selection.selected.map(value => {
|
|
return this.mgmtService.DeleteMachineKey(value.id, this.userId);
|
|
});
|
|
Promise.all(mappedDeletions).then(() => {
|
|
this.selection.clear();
|
|
this.toast.showInfo('USER.TOAST.SELECTEDKEYSDELETED', true);
|
|
this.getData(10, 0);
|
|
}).catch(error => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
|
|
public openAddKey(): void {
|
|
const dialogRef = this.dialog.open(AddKeyDialogComponent, {
|
|
data: {},
|
|
width: '400px',
|
|
});
|
|
|
|
dialogRef.afterClosed().subscribe(resp => {
|
|
if (resp) {
|
|
const type: MachineKeyType = resp.type;
|
|
|
|
let date: Timestamp | undefined;
|
|
|
|
if (resp.date as Moment) {
|
|
const ts = new Timestamp();
|
|
console.log(resp.date.toDate());
|
|
const milliseconds = resp.date.toDate().getTime();
|
|
const seconds = Math.abs(milliseconds / 1000);
|
|
const nanos = (milliseconds - seconds * 1000) * 1000 * 1000;
|
|
ts.setSeconds(seconds);
|
|
ts.setNanos(nanos);
|
|
date = ts;
|
|
}
|
|
|
|
if (type) {
|
|
return this.mgmtService.AddMachineKey(this.userId, type, date).then((response) => {
|
|
if (response) {
|
|
setTimeout(() => {
|
|
this.refreshPage();
|
|
}, 1000);
|
|
|
|
this.dialog.open(ShowKeyDialogComponent, {
|
|
data: {
|
|
key: response.toObject(),
|
|
type: AddKeyDialogType.MACHINE
|
|
},
|
|
width: '400px',
|
|
});
|
|
}
|
|
}).catch((error: any) => {
|
|
this.toast.showError(error);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
private async getData(limit: number, offset: number): Promise<void> {
|
|
this.loadingSubject.next(true);
|
|
|
|
if (this.userId) {
|
|
this.mgmtService.SearchMachineKeys(this.userId, limit, offset).then(resp => {
|
|
this.keyResult = resp.toObject();
|
|
this.dataSource.data = this.keyResult.resultList;
|
|
this.loadingSubject.next(false);
|
|
}).catch((error: any) => {
|
|
this.toast.showError(error);
|
|
this.loadingSubject.next(false);
|
|
});
|
|
}
|
|
}
|
|
|
|
public refreshPage(): void {
|
|
this.getData(this.paginator.pageSize, this.paginator.pageIndex * this.paginator.pageSize);
|
|
}
|
|
}
|