Browse Source

UI: Refactor tb-logo

pull/14057/head
Vladyslav_Prykhodko 9 months ago
parent
commit
ff7de8cf76
  1. 2
      ui-ngx/src/app/modules/login/pages/login/login.component.html
  2. 6
      ui-ngx/src/app/shared/components/logo.component.html
  3. 9
      ui-ngx/src/app/shared/components/logo.component.scss
  4. 15
      ui-ngx/src/app/shared/components/logo.component.ts

2
ui-ngx/src/app/modules/login/pages/login/login.component.html

@ -21,7 +21,7 @@
<form class="tb-login-form" [formGroup]="loginFormGroup" (ngSubmit)="login()">
<fieldset class="flex flex-col">
<div class="flex flex-col items-center justify-start" style="padding: 15px 0;">
<tb-logo isLogin class="login-logo"></tb-logo>
<tb-logo link="https://thingsboard.io" target="_blank" class="login-logo"></tb-logo>
</div>
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
</mat-progress-bar>

6
ui-ngx/src/app/shared/components/logo.component.html

@ -15,12 +15,12 @@
limitations under the License.
-->
@if (isLogin) {
<a href="https://thingsboard.io" target="_blank">
@if (isExternal) {
<a [href]="link" [target]="target">
<ng-container *ngTemplateOutlet="logo"></ng-container>
</a>
} @else {
<a [routerLink]="link">
<a [routerLink]="link" [target]="target">
<ng-container *ngTemplateOutlet="logo"></ng-container>
</a>
}

9
ui-ngx/src/app/shared/components/logo.component.scss

@ -15,9 +15,12 @@
*/
:host {
pointer-events: auto;
a img {
width: 100%;
height: 100%;
a {
border: none;
img {
width: 100%;
height: 100%;
}
}
}

15
ui-ngx/src/app/shared/components/logo.component.ts

@ -15,7 +15,6 @@
///
import { Component, Input, OnInit } from '@angular/core';
import { coerceBoolean } from '@shared/decorators/coercion';
import { AuthService } from '@core/auth/auth.service';
import { AppState } from '@core/core.state';
import { Store } from '@ngrx/store';
@ -30,24 +29,28 @@ import { UrlHolder } from '@shared/pipe/image.pipe';
})
export class LogoComponent implements OnInit {
@Input()
@coerceBoolean()
isLogin: boolean = false;
@Input()
src: string | UrlHolder = 'assets/logo_title_white.svg';
@Input()
link: string | UrlTree;
@Input()
target: string = null;
isExternal = false;
constructor(private authService: AuthService,
private store: Store<AppState>) {
}
ngOnInit() {
if (!this.isLogin && !this.link) {
if (!this.link) {
const authState = getCurrentAuthState(this.store);
this.link = this.authService.defaultUrl(true, authState);
}
if (typeof this.link === 'string' && this.link.startsWith('http')) {
this.isExternal = true;
}
}
}

Loading…
Cancel
Save