Browse Source

Refactoring

pull/2124/head
Thomas 2 years ago
parent
commit
0a826be17e
  1. 14
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts
  2. 17
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html
  3. 11
      apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.scss

14
apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.component.ts

@ -16,7 +16,7 @@ import { TokenStorageService } from '@ghostfolio/client/services/token-storage.s
templateUrl: 'login-with-access-token-dialog.html' templateUrl: 'login-with-access-token-dialog.html'
}) })
export class LoginWithAccessTokenDialog { export class LoginWithAccessTokenDialog {
public hide = true; public isAccessTokenHidden = true;
public constructor( public constructor(
@Inject(MAT_DIALOG_DATA) public data: any, @Inject(MAT_DIALOG_DATA) public data: any,
@ -40,6 +40,12 @@ export class LoginWithAccessTokenDialog {
this.dialogRef.close(); this.dialogRef.close();
} }
public onLoginWithAccessToken() {
if (this.data.accessToken) {
this.dialogRef.close(this.data);
}
}
public async onLoginWithInternetIdentity() { public async onLoginWithInternetIdentity() {
try { try {
const { authToken } = await this.internetIdentityService.login(); const { authToken } = await this.internetIdentityService.login();
@ -49,10 +55,4 @@ export class LoginWithAccessTokenDialog {
this.router.navigate(['/']); this.router.navigate(['/']);
} catch {} } catch {}
} }
public onSubmit() {
if (this.data.accessToken) {
this.dialogRef.close(this.data);
}
}
} }

17
apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html

@ -6,18 +6,25 @@
<div class="py-3" mat-dialog-content> <div class="py-3" mat-dialog-content>
<div class="align-items-center d-flex flex-column"> <div class="align-items-center d-flex flex-column">
<form id="login" class="display-contents" (ngSubmit)="onSubmit()"> <form class="w-100" (ngSubmit)="onLoginWithAccessToken()">
<mat-form-field appearance="outline" class="without-hint w-100"> <mat-form-field appearance="outline" class="without-hint w-100">
<mat-label i18n>Security Token</mat-label> <mat-label i18n>Security Token</mat-label>
<input <input
matInput matInput
[type]="hide ? 'password' : 'text'"
name="password" name="password"
[type]="isAccessTokenHidden ? 'password' : 'text'"
[(ngModel)]="data.accessToken" [(ngModel)]="data.accessToken"
/> />
<div id="hide-password" matSuffix (click)="hide = !hide"> <button
<ion-icon name="{{hide ? 'eye-outline' : 'eye-off-outline'}}"></ion-icon> mat-button
</div> matSuffix
type="button"
(click)="isAccessTokenHidden = !isAccessTokenHidden"
>
<ion-icon
[name]="isAccessTokenHidden ? 'eye-outline' : 'eye-off-outline'"
></ion-icon>
</button>
</mat-form-field> </mat-form-field>
</form> </form>
<ng-container *ngIf="data.hasPermissionToUseSocialLogin"> <ng-container *ngIf="data.hasPermissionToUseSocialLogin">

11
apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.scss

@ -1,14 +1,3 @@
:host { :host {
display: block; display: block;
.display-contents {
display: contents;
}
#hide-password {
padding: 10px;
min-height: 44px;
display: flex;
align-items: center;
}
} }

Loading…
Cancel
Save