mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-20 20:08:46 +00:00
feat: rehauled console (#3525)
* new console * move npm ci to angular build * rel path for assets * local grpc copy * login policy, rm clear views, features rel path * lock Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
co-authored by
Livio Amstutz
parent
00f7dbe875
commit
08ae39ae19
@@ -0,0 +1,20 @@
|
||||
import { Directive, ElementRef, HostListener, Renderer2 } from '@angular/core';
|
||||
import { NavigationService } from 'src/app/services/navigation.service';
|
||||
|
||||
@Directive({
|
||||
selector: '[cnslBack]',
|
||||
})
|
||||
export class BackDirective {
|
||||
@HostListener('click')
|
||||
onClick(): void {
|
||||
this.navigation.back();
|
||||
}
|
||||
|
||||
constructor(private navigation: NavigationService, private elRef: ElementRef, private renderer2: Renderer2) {
|
||||
if (navigation.isBackPossible) {
|
||||
// this.renderer2.removeStyle(this.elRef.nativeElement, 'visibility');
|
||||
} else {
|
||||
this.renderer2.setStyle(this.elRef.nativeElement, 'display', 'none');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { BackDirective } from './back.directive';
|
||||
|
||||
@NgModule({
|
||||
declarations: [BackDirective],
|
||||
imports: [CommonModule],
|
||||
exports: [BackDirective],
|
||||
})
|
||||
export class BackModule {}
|
||||
@@ -7,7 +7,8 @@ export class CopyToClipboardDirective {
|
||||
@Input() valueToCopy: string = '';
|
||||
@Output() copiedValue: EventEmitter<string> = new EventEmitter();
|
||||
|
||||
@HostListener('click', ['$event.target']) onMouseEnter(): void {
|
||||
@HostListener('click', ['$event']) onMouseEnter($event: any): void {
|
||||
$event.preventDefault();
|
||||
this.copytoclipboard(this.valueToCopy);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
|
||||
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: '[cnslHasFeature]',
|
||||
})
|
||||
|
||||
export class HasFeatureDirective {
|
||||
private hasView: boolean = false;
|
||||
@Input() public set hasFeature(features: string[] | RegExp[]) {
|
||||
@Input() public set hasFeature(features: string[] | RegExp[] | undefined) {
|
||||
if (features && features.length > 0) {
|
||||
this.authService.canUseFeature(features).subscribe(isAllowed => {
|
||||
this.authService.canUseFeature(features).subscribe((isAllowed) => {
|
||||
if (isAllowed && !this.hasView) {
|
||||
this.viewContainerRef.clear();
|
||||
this.viewContainerRef.createEmbeddedView(this.templateRef);
|
||||
@@ -18,7 +16,12 @@ export class HasFeatureDirective {
|
||||
this.viewContainerRef.clear();
|
||||
this.hasView = false;
|
||||
}
|
||||
})
|
||||
});
|
||||
} else {
|
||||
if (!this.hasView) {
|
||||
this.viewContainerRef.clear();
|
||||
this.viewContainerRef.createEmbeddedView(this.templateRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +29,5 @@ export class HasFeatureDirective {
|
||||
private authService: GrpcAuthService,
|
||||
protected templateRef: TemplateRef<any>,
|
||||
protected viewContainerRef: ViewContainerRef,
|
||||
) { }
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
|
||||
})
|
||||
export class HasRoleDirective {
|
||||
private hasView: boolean = false;
|
||||
@Input() public set hasRole(roles: string[] | RegExp[]) {
|
||||
@Input() public set hasRole(roles: string[] | RegExp[] | undefined) {
|
||||
if (roles && roles.length > 0) {
|
||||
this.authService.isAllowed(roles).subscribe((isAllowed) => {
|
||||
if (isAllowed && !this.hasView) {
|
||||
@@ -17,6 +17,11 @@ export class HasRoleDirective {
|
||||
this.hasView = false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!this.hasView) {
|
||||
this.viewContainerRef.clear();
|
||||
this.viewContainerRef.createEmbeddedView(this.templateRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user