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