web-remote/src/app/components/login/login.component.ts

30 lines
932 B
TypeScript

import { Component, OnInit } from '@angular/core';
import { Credentials } from '../../responses';
import { MatDialogRef, MatSnackBar } from '@angular/material';
import { OpenLPService } from '../../openlp.service';
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
username: string;
password: string;
constructor(private dialogRef: MatDialogRef<LoginComponent>, private openlpService: OpenLPService,
private snackBar: MatSnackBar) { }
ngOnInit() {
}
performLogin() {
this.openlpService.login({username: this.username, password: this.password}).subscribe(
result => {
this.snackBar.open('Successfully logged in', '', {duration: 2000});
this.dialogRef.close(result);
},
err => this.snackBar.open('Login failed', '', {duration: 2000})
);
}
}