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:
Max Peintner
2022-04-28 10:35:02 +00:00
committed by GitHub
co-authored by Livio Amstutz
parent 00f7dbe875
commit 08ae39ae19
668 changed files with 47746 additions and 19117 deletions
@@ -1,44 +1,44 @@
<cnsl-detail-layout [backRouterLink]="[ serviceType === PolicyComponentServiceType.ADMIN ? '/iam/policies' : '/org']"
[title]="'POLICY.PWD_AGE.TITLE' | translate" [description]="'POLICY.PWD_AGE.DESCRIPTION' | translate">
<ng-template cnslHasRole [hasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT && !isDefault"
matTooltip="{{'POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()" mat-stroked-button>
{{'POLICY.RESET' | translate}}
<cnsl-detail-layout [hasBackButton]="true" [title]="'POLICY.PWD_AGE.TITLE' | translate"
[description]="'POLICY.PWD_AGE.DESCRIPTION' | translate">
<ng-template cnslHasRole [hasRole]="['policy.delete']">
<button *ngIf="serviceType === PolicyComponentServiceType.MGMT && !isDefault"
matTooltip="{{'POLICY.RESET' | translate}}" color="warn" (click)="removePolicy()" mat-stroked-button>
{{'POLICY.RESET' | translate}}
</button>
</ng-template>
<div class="content" *ngIf="ageData">
<div class="row">
<span class="left-desc cnsl-secondary-text">{{'POLICY.DATA.EXPIREWARNDAYS' | translate}}</span>
<span class="fill-space"></span>
<div class="length-wrapper">
<button mat-icon-button (click)="incrementExpireWarnDays()">
<mat-icon>add</mat-icon>
</button>
</ng-template>
<div class="content" *ngIf="ageData">
<div class="row">
<span class="left-desc">{{'POLICY.DATA.EXPIREWARNDAYS' | translate}}</span>
<span class="fill-space"></span>
<div class="length-wrapper">
<button mat-icon-button (click)="incrementExpireWarnDays()">
<mat-icon>add</mat-icon>
</button>
<span>{{ageData?.expireWarnDays}}</span>
<button mat-icon-button (click)="decrementExpireWarnDays()">
<mat-icon>remove</mat-icon>
</button>
</div>
</div>
<div class="row">
<span class="left-desc">{{'POLICY.DATA.MAXAGEDAYS' | translate}}</span>
<span class="fill-space"></span>
<div class="length-wrapper">
<button mat-icon-button (click)="incrementMaxAgeDays()">
<mat-icon>add</mat-icon>
</button>
<span>{{ageData?.maxAgeDays}}</span>
<button mat-icon-button (click)="decrementMaxAgeDays()">
<mat-icon>remove</mat-icon>
</button>
</div>
</div>
<span>{{ageData?.expireWarnDays}}</span>
<button mat-icon-button (click)="decrementExpireWarnDays()">
<mat-icon>remove</mat-icon>
</button>
</div>
</div>
<div class="btn-container">
<button (click)="savePolicy()" color="primary" type="submit"
mat-raised-button>{{ 'ACTIONS.SAVE' | translate }}</button>
<div class="row">
<span class="left-desc cnsl-secondary-text">{{'POLICY.DATA.MAXAGEDAYS' | translate}}</span>
<span class="fill-space"></span>
<div class="length-wrapper">
<button mat-icon-button (click)="incrementMaxAgeDays()">
<mat-icon>add</mat-icon>
</button>
<span>{{ageData?.maxAgeDays}}</span>
<button mat-icon-button (click)="decrementMaxAgeDays()">
<mat-icon>remove</mat-icon>
</button>
</div>
</div>
</div>
<div class="btn-container">
<button (click)="savePolicy()" color="primary" type="submit" mat-raised-button>{{ 'ACTIONS.SAVE' | translate
}}</button>
</div>
</cnsl-detail-layout>
@@ -7,11 +7,10 @@
.row {
display: flex;
align-items: center;
padding: .3rem 0;
padding: 0.3rem 0;
.left-desc {
color: var(--grey);
font-size: .9rem;
font-size: 0.9rem;
}
.fill-space {
@@ -21,7 +20,7 @@
.length-wrapper {
display: flex;
align-items: center;
margin-right: -.6rem;
margin-right: -0.6rem;
}
}
}
@@ -8,12 +8,12 @@ import {
} from 'src/app/proto/generated/zitadel/management_pb';
import { PasswordAgePolicy } from 'src/app/proto/generated/zitadel/policy_pb';
import { AdminService } from 'src/app/services/admin.service';
import { Breadcrumb, BreadcrumbService, BreadcrumbType } from 'src/app/services/breadcrumb.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { ToastService } from 'src/app/services/toast.service';
import { PolicyComponentServiceType } from '../policy-component-types.enum';
@Component({
selector: 'cnsl-password-age-policy',
templateUrl: './password-age-policy.component.html',
@@ -32,35 +32,56 @@ export class PasswordAgePolicyComponent implements OnDestroy {
private route: ActivatedRoute,
private toast: ToastService,
private injector: Injector,
breadcrumbService: BreadcrumbService,
) {
this.sub = this.route.data.pipe(switchMap(data => {
this.serviceType = data.serviceType;
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
this.service = this.injector.get(ManagementService as Type<ManagementService>);
break;
case PolicyComponentServiceType.ADMIN:
this.service = this.injector.get(AdminService as Type<AdminService>);
break;
}
this.sub = this.route.data
.pipe(
switchMap((data) => {
this.serviceType = data.serviceType;
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
this.service = this.injector.get(ManagementService as Type<ManagementService>);
return this.route.params;
})).subscribe(() => {
this.getData().then(resp => {
if (resp.policy) {
this.ageData = resp.policy;
}
const iambread = new Breadcrumb({
type: BreadcrumbType.IAM,
name: 'IAM',
routerLink: ['/system'],
});
const bread: Breadcrumb = {
type: BreadcrumbType.ORG,
routerLink: ['/org'],
};
breadcrumbService.setBreadcrumb([iambread, bread]);
break;
case PolicyComponentServiceType.ADMIN:
this.service = this.injector.get(AdminService as Type<AdminService>);
const iamBread = new Breadcrumb({
type: BreadcrumbType.IAM,
name: 'IAM',
routerLink: ['/system'],
});
breadcrumbService.setBreadcrumb([iamBread]);
break;
}
return this.route.params;
}),
)
.subscribe(() => {
this.getData().then((resp) => {
if (resp.policy) {
this.ageData = resp.policy;
}
});
});
});
}
public ngOnDestroy(): void {
this.sub.unsubscribe();
}
private async getData():
Promise<MgmtGetPasswordAgePolicyResponse.AsObject | AdminGetPasswordAgePolicyResponse.AsObject> {
private async getData(): Promise<MgmtGetPasswordAgePolicyResponse.AsObject | AdminGetPasswordAgePolicyResponse.AsObject> {
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
return (this.service as ManagementService).getPasswordAgePolicy();
@@ -71,14 +92,17 @@ export class PasswordAgePolicyComponent implements OnDestroy {
public removePolicy(): void {
if (this.serviceType === PolicyComponentServiceType.MGMT) {
(this.service as ManagementService).resetPasswordAgePolicyToDefault().then(() => {
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
setTimeout(() => {
this.getData();
}, 1000);
}).catch(error => {
this.toast.showError(error);
});
(this.service as ManagementService)
.resetPasswordAgePolicyToDefault()
.then(() => {
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
setTimeout(() => {
this.getData();
}, 1000);
})
.catch((error) => {
this.toast.showError(error);
});
}
}
@@ -110,34 +134,34 @@ export class PasswordAgePolicyComponent implements OnDestroy {
switch (this.serviceType) {
case PolicyComponentServiceType.MGMT:
if (this.ageData.isDefault) {
(this.service as ManagementService).addCustomPasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
}).catch(error => {
this.toast.showError(error);
});
(this.service as ManagementService)
.addCustomPasswordAgePolicy(this.ageData.maxAgeDays, this.ageData.expireWarnDays)
.then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
})
.catch((error) => {
this.toast.showError(error);
});
} else {
(this.service as ManagementService).updateCustomPasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
}).catch(error => {
this.toast.showError(error);
});
(this.service as ManagementService)
.updateCustomPasswordAgePolicy(this.ageData.maxAgeDays, this.ageData.expireWarnDays)
.then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
})
.catch((error) => {
this.toast.showError(error);
});
}
break;
case PolicyComponentServiceType.ADMIN:
(this.service as AdminService).updatePasswordAgePolicy(
this.ageData.maxAgeDays,
this.ageData.expireWarnDays,
).then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
}).catch(error => {
this.toast.showError(error);
});
(this.service as AdminService)
.updatePasswordAgePolicy(this.ageData.maxAgeDays, this.ageData.expireWarnDays)
.then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true);
})
.catch((error) => {
this.toast.showError(error);
});
break;
}
}