Browse Source

Refactor `tb-logo`, add support in login page to open link in a new tab on right-click.

pull/14057/head
deaflynx 1 year ago
parent
commit
f28641093b
  1. 2
      ui-ngx/src/app/modules/login/pages/login/login.component.html
  2. 15
      ui-ngx/src/app/shared/components/logo.component.html
  3. 8
      ui-ngx/src/app/shared/components/logo.component.scss
  4. 17
      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></tb-logo> <tb-logo isLogin 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>

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

@ -15,6 +15,17 @@
limitations under the License. limitations under the License.
--> -->
<a [routerLink]="isLogin ? '' : logoLink" (click)="onLogoClick()"> @if (isLogin) {
<a href="https://thingsboard.io" target="_blank">
<ng-container *ngTemplateOutlet="logo"></ng-container>
</a>
} @else {
<a [routerLink]="logoLink">
<ng-container *ngTemplateOutlet="logo"></ng-container>
</a>
}
<ng-template #logo>
<img [src]="logoSrc" aria-label="logo" alt="Logo"/> <img [src]="logoSrc" aria-label="logo" alt="Logo"/>
</a> </ng-template>

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

@ -16,23 +16,19 @@
:host { :host {
pointer-events: auto; pointer-events: auto;
a img { a img {
display: block;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
} }
:host.login-logo { :host-context(.login-logo) {
display: inline-block;
width: 280px; width: 280px;
height: 60px; height: 60px;
a { a {
display: inline-block;
width: 100%;
height: 100%;
text-decoration: none; text-decoration: none;
border: none; border: none;
transform: none; transform: none;
&:focus { &:focus {
outline: 0; outline: 0;
} }

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

@ -14,7 +14,7 @@
/// limitations under the License. /// limitations under the License.
/// ///
import { Component, Input, OnInit, HostBinding } from '@angular/core'; import { Component, Input, OnInit } from '@angular/core';
import { coerceBoolean } from '@shared/decorators/coercion'; 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';
@ -30,11 +30,6 @@ import { UrlHolder } from '@shared/pipe/image.pipe';
}) })
export class LogoComponent implements OnInit { export class LogoComponent implements OnInit {
@HostBinding('class.login-logo')
get isLoginLogoClass() {
return this.isLogin;
}
@Input() @Input()
@coerceBoolean() @coerceBoolean()
isLogin: boolean = false; isLogin: boolean = false;
@ -54,14 +49,4 @@ export class LogoComponent implements OnInit {
this.logoLink = this.authService.defaultUrl(true, authState); this.logoLink = this.authService.defaultUrl(true, authState);
} }
} }
onLogoClick() {
if (this.isLogin) {
this.gotoThingsboard();
}
}
private gotoThingsboard() {
window.open('https://thingsboard.io', '_blank');
}
} }

Loading…
Cancel
Save