From 75c11d45437a11e154855a7497050467c75a640d Mon Sep 17 00:00:00 2001 From: Chris Witterholt Date: Thu, 25 Apr 2024 20:52:04 +0200 Subject: [PATCH] Refactor login component. --- src/app/components/login/login.component.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts index ba886ec..d4369cc 100644 --- a/src/app/components/login/login.component.ts +++ b/src/app/components/login/login.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component } from '@angular/core'; import { MatDialogRef } from '@angular/material/dialog'; import { MatSnackBar } from '@angular/material/snack-bar'; import { TranslateService } from '@ngx-translate/core'; @@ -10,7 +10,7 @@ import { OpenLPService } from '../../openlp.service'; templateUrl: './login.component.html', styleUrl: './login.component.scss' }) -export class LoginComponent implements OnInit { +export class LoginComponent { username: string; password: string; loginSucceededMessage: string; @@ -29,17 +29,13 @@ export class LoginComponent implements OnInit { }); } - ngOnInit() { - // Do nothing - } - performLogin() { - this.openlpService.login({username: this.username, password: this.password}).subscribe( - result => { - this.snackBar.open(this.loginSucceededMessage, '', {duration: 2000}); + this.openlpService.login({ username: this.username, password: this.password }).subscribe({ + next: result => { + this.snackBar.open(this.loginSucceededMessage, '', { duration: 2000 }); this.dialogRef.close(result); }, - () => this.snackBar.open(this.loginFailedMessage, '', {duration: 2000}) - ); + error: () => this.snackBar.open(this.loginFailedMessage, '', { duration: 2000 }) + }); } }