Browse Source

UI: Refactor tb-logo

pull/14057/head
Vladyslav_Prykhodko 10 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()"> <form class="tb-login-form" [formGroup]="loginFormGroup" (ngSubmit)="login()">
<fieldset class="flex flex-col"> <fieldset class="flex flex-col">
<div class="flex flex-col items-center justify-start" style="padding: 15px 0;"> <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> </div>
<mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async"> <mat-progress-bar color="warn" mode="indeterminate" *ngIf="isLoading$ | async">
</mat-progress-bar> </mat-progress-bar>

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

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

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

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

Loading…
Cancel
Save