Init webapp
This commit is contained in:
@@ -1,10 +1,76 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { HttpErrorResponse } from "@angular/common/http";
|
||||
import { Component, OnInit } from "@angular/core";
|
||||
import { AuthService } from "src/app/auth/auth.service";
|
||||
import { LoginService } from "src/app/auth/login.service";
|
||||
import { ErrorService } from "src/app/services/error.service";
|
||||
import { PageSecurityService } from "src/app/services/pageSecurity.service";
|
||||
import { LoaderService } from "../loader/loader.service";
|
||||
import { NotificationService } from "src/app/services/notification.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-header',
|
||||
templateUrl: './header.component.html',
|
||||
styleUrls: ['./header.component.scss']
|
||||
selector: "app-header",
|
||||
templateUrl: "./header.component.html",
|
||||
styleUrls: ["./header.component.scss"],
|
||||
})
|
||||
export class HeaderComponent {
|
||||
export class HeaderComponent implements OnInit {
|
||||
userLoggedIn: Boolean = false;
|
||||
|
||||
constructor(
|
||||
private loginService: LoginService,
|
||||
private pageSecurityService: PageSecurityService,
|
||||
private errorService: ErrorService,
|
||||
private loaderService: LoaderService,
|
||||
private notificationService: NotificationService,
|
||||
private authService: AuthService
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.userLoggedIn = this.authService.checkUserLoggedIn();
|
||||
}
|
||||
|
||||
public onClickLogout(): void {
|
||||
this.loaderService.hide();
|
||||
|
||||
this.loginService.signout().subscribe({
|
||||
next: (resp: any) => {
|
||||
if (resp != null) {
|
||||
if (resp.successful) {
|
||||
// alert("Signed out successfully"); /// XXX
|
||||
this.notificationService.showSnackbar(
|
||||
"Signed out successfully",
|
||||
3000,
|
||||
"snackbar-success",
|
||||
true,
|
||||
"check"
|
||||
);
|
||||
this.loginService.removeSessionCurrentUser();
|
||||
this.pageSecurityService.gotoLoginPage();
|
||||
} else {
|
||||
// alert("Signed out failed with error. " + resp.detailedMessage); /// XXX
|
||||
this.notificationService.showSnackbar(
|
||||
"Signed out failed with error. " + resp.detailedMessage,
|
||||
3000,
|
||||
"snackbar-warning",
|
||||
true,
|
||||
"information-slab-circle-outline"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// alert("Signed out failed with error. Unknown error."); /// XXX
|
||||
this.notificationService.showSnackbar(
|
||||
"Signed out failed with error. Unknown error.",
|
||||
3000,
|
||||
"snackbar-warning",
|
||||
true,
|
||||
"information-slab-circle-outline"
|
||||
);
|
||||
}
|
||||
this.loaderService.hide();
|
||||
},
|
||||
error: (error: HttpErrorResponse) => {
|
||||
this.errorService.handleError(error);
|
||||
this.loaderService.hide();
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user