Format code
This commit is contained in:
@@ -1,21 +1,18 @@
|
|||||||
// import { AuthGuard } from "./auth/auth.guard";
|
// import { AuthGuard } from "./auth/auth.guard";
|
||||||
import { NgModule, inject } from "@angular/core";
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule, Routes } from "@angular/router";
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
import { LoginComponent } from "./components/loginPage/login.component";
|
import { LoginComponent } from './components/loginPage/login.component';
|
||||||
import { IndexComponent } from "./components/indexPage/index.component";
|
import { DashboardComponent } from './components/dashboard/dashboard.component';
|
||||||
import { DashboardComponent } from "./components/dashboard/dashboard.component";
|
import { AuthGuard } from './auth/auth.guard';
|
||||||
import { AuthService } from "./auth/auth.service";
|
|
||||||
import { AuthGuard } from "./auth/auth.guard";
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: "login", component: LoginComponent },
|
{ path: 'login', component: LoginComponent },
|
||||||
// { path: "index", component: IndexComponent, canActivate: [AuthGuard] },
|
|
||||||
{
|
{
|
||||||
path: "dashboard",
|
path: 'dashboard',
|
||||||
component: DashboardComponent,
|
component: DashboardComponent,
|
||||||
canActivate: [AuthGuard],
|
canActivate: [AuthGuard],
|
||||||
},
|
},
|
||||||
{ path: "", redirectTo: "/dashboard", pathMatch: "full" },
|
{ path: '', redirectTo: '/dashboard', pathMatch: 'full' },
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { HttpErrorResponse } from "@angular/common/http";
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from '@angular/core';
|
||||||
import { AuthService } from "src/app/auth/auth.service";
|
import { AuthService } from 'src/app/auth/auth.service';
|
||||||
import { LoginService } from "src/app/auth/login.service";
|
import { LoginService } from 'src/app/auth/login.service';
|
||||||
import { ErrorService } from "src/app/services/error.service";
|
import { ErrorService } from 'src/app/services/error.service';
|
||||||
import { PageSecurityService } from "src/app/services/pageSecurity.service";
|
import { PageSecurityService } from 'src/app/auth/pageSecurity.service';
|
||||||
import { LoaderService } from "../loader/loader.service";
|
import { LoaderService } from '../loader/loader.service';
|
||||||
import { NotificationService } from "src/app/services/notification.service";
|
import { NotificationService } from 'src/app/services/notification.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-header",
|
selector: 'app-header',
|
||||||
templateUrl: "./header.component.html",
|
templateUrl: './header.component.html',
|
||||||
styleUrls: ["./header.component.scss"],
|
styleUrls: ['./header.component.scss'],
|
||||||
})
|
})
|
||||||
export class HeaderComponent implements OnInit {
|
export class HeaderComponent implements OnInit {
|
||||||
userLoggedIn: Boolean = false;
|
userLoggedIn: Boolean = false;
|
||||||
@@ -37,32 +37,32 @@ export class HeaderComponent implements OnInit {
|
|||||||
if (resp.successful) {
|
if (resp.successful) {
|
||||||
// alert("Signed out successfully"); /// XXX
|
// alert("Signed out successfully"); /// XXX
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Signed out successfully",
|
'Signed out successfully',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-success",
|
'snackbar-success',
|
||||||
true,
|
true,
|
||||||
"check"
|
'check'
|
||||||
);
|
);
|
||||||
this.loginService.removeSessionCurrentUser();
|
this.loginService.removeSessionCurrentUser();
|
||||||
this.pageSecurityService.gotoLoginPage();
|
this.pageSecurityService.gotoLoginPage();
|
||||||
} else {
|
} else {
|
||||||
// alert("Signed out failed with error. " + resp.detailedMessage); /// XXX
|
// alert("Signed out failed with error. " + resp.detailedMessage); /// XXX
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Signed out failed with error. " + resp.detailedMessage,
|
'Signed out failed with error. ' + resp.detailedMessage,
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"information-slab-circle-outline"
|
'information-slab-circle-outline'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// alert("Signed out failed with error. Unknown error."); /// XXX
|
// alert("Signed out failed with error. Unknown error."); /// XXX
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Signed out failed with error. Unknown error.",
|
'Signed out failed with error. Unknown error.',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"information-slab-circle-outline"
|
'information-slab-circle-outline'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.loaderService.hide();
|
this.loaderService.hide();
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Injectable } from "@angular/core";
|
import { Injectable } from '@angular/core';
|
||||||
import { HttpErrorResponse } from "@angular/common/http";
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
import { NotificationService } from "./notification.service";
|
import { NotificationService } from './notification.service';
|
||||||
import { LoginService } from "../auth/login.service";
|
import { LoginService } from '../auth/login.service';
|
||||||
import { PageSecurityService } from "./pageSecurity.service";
|
import { PageSecurityService } from '../auth/pageSecurity.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: "root",
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class ErrorService {
|
export class ErrorService {
|
||||||
constructor(
|
constructor(
|
||||||
@@ -17,45 +17,45 @@ export class ErrorService {
|
|||||||
handleError(error: HttpErrorResponse): void {
|
handleError(error: HttpErrorResponse): void {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
if (error.status === 0) {
|
if (error.status === 0) {
|
||||||
console.log("Client error.");
|
console.log('Client error.');
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Client error",
|
'Client error',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"alert-circle-outline"
|
'alert-circle-outline'
|
||||||
);
|
);
|
||||||
} else if (error.status === 401 || error.status === 403) {
|
} else if (error.status === 401 || error.status === 403) {
|
||||||
console.log("You are not authorized.");
|
console.log('You are not authorized.');
|
||||||
// todo: redirect to login page?
|
// todo: redirect to login page?
|
||||||
|
|
||||||
this.loginService.removeSessionCurrentUser();
|
this.loginService.removeSessionCurrentUser();
|
||||||
this.pageSecurityService.gotoLoginPage();
|
this.pageSecurityService.gotoLoginPage();
|
||||||
|
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"You are not authorized",
|
'You are not authorized',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"cancel"
|
'cancel'
|
||||||
);
|
);
|
||||||
} else if (error.status === 500) {
|
} else if (error.status === 500) {
|
||||||
console.log("Server error occurred.");
|
console.log('Server error occurred.');
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Server error occurred",
|
'Server error occurred',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"server-off"
|
'server-off'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("Unknown error: " + error.status);
|
console.log('Unknown error: ' + error.status);
|
||||||
this.notificationService.showSnackbar(
|
this.notificationService.showSnackbar(
|
||||||
"Unknown error",
|
'Unknown error',
|
||||||
3000,
|
3000,
|
||||||
"snackbar-warning",
|
'snackbar-warning',
|
||||||
true,
|
true,
|
||||||
"alert-circle-outline"
|
'alert-circle-outline'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user