fix(console): label policy setHideLoginNameSuffix (#1593)

* fix: label policy

* set primary, secondary color
This commit is contained in:
Max Peintner 2021-04-20 10:27:58 +02:00 committed by GitHub
parent 576995af05
commit 32bfd25b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 80 additions and 72 deletions

View File

@ -1,16 +1,13 @@
<app-detail-layout [backRouterLink]="['/iam/policies']" [title]="'POLICY.LABEL.TITLE' | translate" <app-detail-layout [backRouterLink]="['/iam/policies']" [title]="'POLICY.LABEL.TITLE' | translate"
[description]="'POLICY.LABEL.DESCRIPTION' | translate"> [description]="'POLICY.LABEL.DESCRIPTION' | translate">
<div class="content" *ngIf="labelData"> <p class="default" *ngIf="isDefault"> {{'POLICY.DEFAULTLABEL' | translate}}</p>
<cnsl-form-field class="form-field" appearance="outline">
<cnsl-label>{{'POLICY.LABEL.PRIMARYCOLOR' | translate}}</cnsl-label>
<input cnslInput [(ngModel)]="labelData.primaryColor" />
</cnsl-form-field>
<cnsl-form-field class="form-field" appearance="outline"> <div class="content" *ngIf="labelData">
<cnsl-label>{{'POLICY.LABEL.SECONDARYCOLOR' | translate}}</cnsl-label> <mat-slide-toggle class="toggle" color="primary" ngDefaultControl
<input cnslInput [(ngModel)]="labelData.secondaryColor" /> [(ngModel)]="labelData.hideLoginNameSuffix">
</cnsl-form-field> {{'POLICY.DATA.HIDELOGINNAMESUFFIX' | translate}}
</mat-slide-toggle>
</div> </div>
<div class="btn-container"> <div class="btn-container">

View File

@ -3,12 +3,11 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
margin: 0 -.5rem;
.form-field {
flex: 1;
margin: 0 .5rem;
} }
.default {
color: var(--color-main);
margin-top: 0;
} }
.btn-container { .btn-container {

View File

@ -5,6 +5,7 @@ import { GetLabelPolicyResponse, UpdateLabelPolicyRequest } from 'src/app/proto/
import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb'; import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
import { AdminService } from 'src/app/services/admin.service'; import { AdminService } from 'src/app/services/admin.service';
import { ToastService } from 'src/app/services/toast.service'; import { ToastService } from 'src/app/services/toast.service';
import { CnslLinks } from '../../links/links.component'; import { CnslLinks } from '../../links/links.component';
import { IAM_COMPLEXITY_LINK, IAM_LOGIN_POLICY_LINK, IAM_POLICY_LINK } from '../../policy-grid/policy-links'; import { IAM_COMPLEXITY_LINK, IAM_LOGIN_POLICY_LINK, IAM_POLICY_LINK } from '../../policy-grid/policy-links';
import { PolicyComponentServiceType } from '../policy-component-types.enum'; import { PolicyComponentServiceType } from '../policy-component-types.enum';
@ -52,10 +53,19 @@ export class LabelPolicyComponent implements OnDestroy {
const req = new UpdateLabelPolicyRequest(); const req = new UpdateLabelPolicyRequest();
req.setPrimaryColor(this.labelData.primaryColor); req.setPrimaryColor(this.labelData.primaryColor);
req.setSecondaryColor(this.labelData.secondaryColor); req.setSecondaryColor(this.labelData.secondaryColor);
req.setHideLoginNameSuffix(this.labelData.hideLoginNameSuffix);
this.adminService.updateLabelPolicy(req).then(() => { this.adminService.updateLabelPolicy(req).then(() => {
this.toast.showInfo('POLICY.TOAST.SET', true); this.toast.showInfo('POLICY.TOAST.SET', true);
}).catch(error => { }).catch(error => {
this.toast.showError(error); this.toast.showError(error);
}); });
} }
public get isDefault(): boolean {
if (this.labelData) {
return (this.labelData as LabelPolicy.AsObject).isDefault;
} else {
return false;
}
}
} }

View File

@ -9,8 +9,9 @@ import { TranslateModule } from '@ngx-translate/core';
import { HasRoleModule } from 'src/app/directives/has-role/has-role.module'; import { HasRoleModule } from 'src/app/directives/has-role/has-role.module';
import { DetailLayoutModule } from 'src/app/modules/detail-layout/detail-layout.module'; import { DetailLayoutModule } from 'src/app/modules/detail-layout/detail-layout.module';
import { InputModule } from 'src/app/modules/input/input.module'; import { InputModule } from 'src/app/modules/input/input.module';
import { LinksModule } from '../../links/links.module';
import { InfoSectionModule } from '../../info-section/info-section.module';
import { LinksModule } from '../../links/links.module';
import { LabelPolicyRoutingModule } from './label-policy-routing.module'; import { LabelPolicyRoutingModule } from './label-policy-routing.module';
import { LabelPolicyComponent } from './label-policy.component'; import { LabelPolicyComponent } from './label-policy.component';
@ -29,6 +30,7 @@ import { LabelPolicyComponent } from './label-policy.component';
TranslateModule, TranslateModule,
DetailLayoutModule, DetailLayoutModule,
LinksModule, LinksModule,
InfoSectionModule,
], ],
}) })
export class LabelPolicyModule { } export class LabelPolicyModule { }