Browse Source

refactor: update data handling, implements feedback

pull/4393/head
tobikugel 1 month ago
committed by Thomas Kaul
parent
commit
073dd2fd8e
  1. 11
      apps/client/src/app/pages/register/register-page.component.ts
  2. 21
      apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts
  3. 10
      apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html
  4. 6
      apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.module.ts

11
apps/client/src/app/pages/register/register-page.component.ts

@ -68,11 +68,6 @@ export class RegisterPageComponent implements OnDestroy, OnInit {
public openShowAccessTokenDialog() { public openShowAccessTokenDialog() {
const dialogRef = this.dialog.open(ShowAccessTokenDialog, { const dialogRef = this.dialog.open(ShowAccessTokenDialog, {
data: {
accessToken: undefined,
authToken: undefined,
role: undefined
},
disableClose: true, disableClose: true,
width: '30rem' width: '30rem'
}); });
@ -80,9 +75,9 @@ export class RegisterPageComponent implements OnDestroy, OnInit {
dialogRef dialogRef
.afterClosed() .afterClosed()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe((data) => { .subscribe((authToken) => {
if (data?.authToken) { if (authToken) {
this.tokenStorageService.saveToken(data.authToken, true); this.tokenStorageService.saveToken(authToken, true);
this.router.navigate(['/']); this.router.navigate(['/']);
} }

21
apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.component.ts

@ -2,11 +2,10 @@ import { DataService } from '@ghostfolio/client/services/data.service';
import { import {
ChangeDetectionStrategy, ChangeDetectionStrategy,
ChangeDetectorRef,
Component, Component,
Inject,
ViewChild ViewChild
} from '@angular/core'; } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
import { MatStepper } from '@angular/material/stepper'; import { MatStepper } from '@angular/material/stepper';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators'; import { takeUntil } from 'rxjs/operators';
@ -20,13 +19,16 @@ import { takeUntil } from 'rxjs/operators';
}) })
export class ShowAccessTokenDialog { export class ShowAccessTokenDialog {
@ViewChild(MatStepper) stepper!: MatStepper; @ViewChild(MatStepper) stepper!: MatStepper;
public isCreateAccountButtonDisabled = true; public accessToken: string;
public authToken: string;
public disclaimerChecked = false; public disclaimerChecked = false;
public isCreateAccountButtonDisabled = true;
public role: string;
private unsubscribeSubject = new Subject<void>(); private unsubscribeSubject = new Subject<void>();
public constructor( public constructor(
@Inject(MAT_DIALOG_DATA) public data: any, private changeDetectorRef: ChangeDetectorRef,
private dataService: DataService private dataService: DataService
) {} ) {}
@ -43,12 +45,13 @@ export class ShowAccessTokenDialog {
.postUser() .postUser()
.pipe(takeUntil(this.unsubscribeSubject)) .pipe(takeUntil(this.unsubscribeSubject))
.subscribe(({ accessToken, authToken, role }) => { .subscribe(({ accessToken, authToken, role }) => {
this.data = { this.accessToken = accessToken;
accessToken, this.authToken = authToken;
authToken, this.role = role;
role
};
this.stepper.next(); this.stepper.next();
this.changeDetectorRef.markForCheck();
}); });
} }
} }

10
apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.html

@ -1,7 +1,7 @@
<h1 mat-dialog-title> <h1 mat-dialog-title>
<span i18n>Create Account</span> <span i18n>Create Account</span>
@if (data.role === 'ADMIN') { @if (role === 'ADMIN') {
<span class="badge badge-light ml-2">{{ data.role }}</span> <span class="badge badge-light ml-2">{{ role }}</span>
} }
</h1> </h1>
<div class="py-3" mat-dialog-content> <div class="py-3" mat-dialog-content>
@ -62,13 +62,13 @@
matInput matInput
readonly readonly
type="text" type="text"
[(value)]="data.accessToken" [(value)]="accessToken"
></textarea> ></textarea>
<div class="float-right mt-1"> <div class="float-right mt-1">
<button <button
color="secondary" color="secondary"
mat-flat-button mat-flat-button
[cdkCopyToClipboard]="data.accessToken" [cdkCopyToClipboard]="accessToken"
(click)="enableCreateAccountButton()" (click)="enableCreateAccountButton()"
> >
<ion-icon class="mr-1" name="copy-outline" /> <ion-icon class="mr-1" name="copy-outline" />
@ -83,7 +83,7 @@
mat-flat-button mat-flat-button
matStepperNext matStepperNext
[disabled]="isCreateAccountButtonDisabled" [disabled]="isCreateAccountButtonDisabled"
[mat-dialog-close]="data" [mat-dialog-close]="authToken"
> >
<span i18n>Create Account</span> <span i18n>Create Account</span>
<ion-icon class="ml-1" name="arrow-forward-outline" /> <ion-icon class="ml-1" name="arrow-forward-outline" />

6
apps/client/src/app/pages/register/show-access-token-dialog/show-access-token-dialog.module.ts

@ -23,13 +23,13 @@ import { ShowAccessTokenDialog } from './show-access-token-dialog.component';
CommonModule, CommonModule,
FormsModule, FormsModule,
MatButtonModule, MatButtonModule,
MatCheckboxModule,
MatDialogModule, MatDialogModule,
MatFormFieldModule, MatFormFieldModule,
MatInputModule, MatInputModule,
ReactiveFormsModule,
TextFieldModule,
MatStepperModule, MatStepperModule,
MatCheckboxModule ReactiveFormsModule,
TextFieldModule
], ],
providers: [ providers: [
{ {

Loading…
Cancel
Save