rdt-client/client/src/app/setup/setup.component.ts
Roger Far d0f7c9fb37
Some checks failed
Docker Image CI / build (push) Has been cancelled
Fixed broken setup state.
2024-01-05 14:33:10 -07:00

55 lines
1.2 KiB
TypeScript

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from '../auth.service';
@Component({
selector: 'app-setup',
templateUrl: './setup.component.html',
styleUrls: ['./setup.component.scss'],
})
export class SetupComponent {
public userName: string;
public password: string;
public provider = 0;
public token: string;
public error: string;
public working: boolean;
public step: number = 1;
constructor(private authService: AuthService, private router: Router) {}
public setup(): void {
this.error = null;
this.working = true;
this.authService.create(this.userName, this.password).subscribe(
() => {
this.step = 2;
this.working = false;
},
(err) => {
this.working = false;
this.error = err.error;
}
);
}
public setToken(): void {
this.authService.setupProvider(this.provider, this.token).subscribe(
() => {
this.step = 3;
this.working = false;
},
(err: any) => {
this.working = false;
this.error = err.error;
}
);
}
public close(): void {
this.router.navigate(['/']);
}
}