fix(console): apply labelpolicy if icon is provided, signout page (#4499)

* label policy as observable

* signedout policy via state

* add caching

* disable loading spinner on signedout

* cleanup

* catch error

* update deps

* move policy to localstorage

* handle labelpolicy for users without org

Co-authored-by: Livio Spring <[email protected]>
Co-authored-by: Fabi <[email protected]>
This commit is contained in:
Max Peintner
2022-10-17 14:09:34 +02:00
committed by GitHub
co-authored by Livio Spring Fabi
parent bb16852e84
commit da51b481ee
18 changed files with 355 additions and 536 deletions
@@ -1,13 +1,23 @@
<div class="signed-out-wrap">
<div class="block">
<div class="signed-out-header">
<img alt="zitadel logo" *ngIf="dark; else lighttheme" src="./assets/images/zitadel-logo-light.svg" />
<ng-template #lighttheme>
<img alt="zitadel logo" src="./assets/images/zitadel-logo-dark.svg" />
<ng-container *ngIf="labelpolicy; else zitadelLogo">
<img alt="logo" *ngIf="dark && labelpolicy.logoUrlDark; else lighttheme" [src]="labelpolicy.logoUrlDark" />
<ng-template #lighttheme>
<img *ngIf="labelpolicy.logoUrl; else zitadelLogo" alt="logo" [src]="labelpolicy.logoUrl" />
</ng-template>
</ng-container>
<ng-template #zitadelLogo>
<img alt="zitadel logo" *ngIf="dark; else zitadellighttheme" src="./assets/images/zitadel-logo-light.svg" />
<ng-template #zitadellighttheme>
<img alt="zitadel logo" src="./assets/images/zitadel-logo-dark.svg" />
</ng-template>
</ng-template>
<p class="cnsl-secondary-text">{{ 'USER.SIGNEDOUT' | translate }}</p>
<button
<a
class="cnsl-action-button"
matTooltip="{{ 'ACTIONS.LOGIN' | translate }}"
color="primary"
@@ -16,7 +26,7 @@
>
<i class="las la-sign-in-alt"></i>
<span>{{ 'USER.SIGNEDOUT_BTN' | translate }}</span>
</button>
</a>
</div>
</div>
</div>
@@ -18,8 +18,7 @@
p {
text-align: center;
font-size: 14px;
margin: 0;
margin-bottom: 3rem;
margin: 2rem 0 3rem 0;
}
img {
@@ -1,5 +1,8 @@
import { Component } from '@angular/core';
import { LabelPolicy } from 'src/app/proto/generated/zitadel/policy_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ThemeService } from 'src/app/services/theme.service';
const LABELPOLICY_LOCALSTORAGE_KEY = 'labelPolicyOnSignout';
@Component({
selector: 'cnsl-signedout',
@@ -9,10 +12,25 @@ import { ThemeService } from 'src/app/services/theme.service';
export class SignedoutComponent {
public dark: boolean = true;
constructor(themeService: ThemeService) {
themeService.loadPrivateLabelling();
public labelpolicy?: LabelPolicy.AsObject;
public queryParams = { state: '' };
constructor(themeService: ThemeService, authService: GrpcAuthService) {
const theme = localStorage.getItem('theme');
this.dark = theme === 'dark-theme' ? true : theme === 'light-theme' ? false : true;
const lP = localStorage.getItem(LABELPOLICY_LOCALSTORAGE_KEY);
if (lP) {
const parsed = JSON.parse(lP);
localStorage.removeItem(LABELPOLICY_LOCALSTORAGE_KEY);
if (parsed) {
this.labelpolicy = parsed;
themeService.applyLabelPolicy(parsed);
authService.labelpolicy.next(parsed);
authService.labelPolicyLoading$.next(false);
}
} else {
authService.labelPolicyLoading$.next(false);
}
}
}