Added default routes
This commit is contained in:
parent
4c21fa631a
commit
8717491d57
@ -8,6 +8,9 @@ import { AuthGuard } from './modules/shared/guards/auth/auth.guard';
|
|||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{ path: '', redirectTo: 'home', pathMatch: 'full' },
|
{ path: '', redirectTo: 'home', pathMatch: 'full' },
|
||||||
{ path: 'home', component: HomeComponent, pathMatch: 'full' },
|
{ path: 'home', component: HomeComponent, pathMatch: 'full' },
|
||||||
|
{ path: 'host', loadChildren: () => import('./modules/view/host/host.module').then(m => m.HostModule), canActivate: [AuthGuard], data: { role: AuthRoles.Admin } },
|
||||||
|
{ path: 'gameserver', loadChildren: () => import('./modules/view/gameserver/gameserver.module').then(m => m.GameserverModule), canActivate: [AuthGuard], data: { role: AuthRoles.User } },
|
||||||
|
{ path: 'support', loadChildren: () => import('./modules/view/support/support.module').then(m => m.SupportModule), canActivate: [AuthGuard], data: { role: AuthRoles.Support } },
|
||||||
{ path: 'change-password', loadChildren: () => import('./modules/view/change-password/change-password.module').then(m => m.ChangePasswordModule), canActivate: [AuthGuard] },
|
{ path: 'change-password', loadChildren: () => import('./modules/view/change-password/change-password.module').then(m => m.ChangePasswordModule), canActivate: [AuthGuard] },
|
||||||
{ path: 'user-settings', loadChildren: () => import('./modules/view/user-settings/user-settings.module').then(m => m.UserSettingsModule), canActivate: [AuthGuard] },
|
{ path: 'user-settings', loadChildren: () => import('./modules/view/user-settings/user-settings.module').then(m => m.UserSettingsModule), canActivate: [AuthGuard] },
|
||||||
{ path: 'auth', loadChildren: () => import('./modules/auth/auth.module').then(m => m.AuthModule) },
|
{ path: 'auth', loadChildren: () => import('./modules/auth/auth.module').then(m => m.AuthModule) },
|
||||||
|
@ -29,17 +29,32 @@ export class SidebarComponent implements OnInit, OnChanges {
|
|||||||
async setMenu(isSidebarOpen: boolean) {
|
async setMenu(isSidebarOpen: boolean) {
|
||||||
this.menuItems = [];
|
this.menuItems = [];
|
||||||
this.menuItems = [
|
this.menuItems = [
|
||||||
{ label: isSidebarOpen ? this.translateService.instant('sidebar.home') : '', icon: 'pi pi-th-large', routerLink: 'home' },
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.home') : '', icon: 'pi pi-home', routerLink: 'home' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (await this.authService.hasUserPermission(AuthRoles.User) && !await this.authService.hasUserPermission(AuthRoles.Admin)) {
|
||||||
|
this.menuItems.push(
|
||||||
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.gameserver') : '', icon: 'pi pi-desktop', routerLink: 'gameserver' },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (await this.authService.hasUserPermission(AuthRoles.Support) && !await this.authService.hasUserPermission(AuthRoles.Admin)) {
|
||||||
|
this.menuItems.push(
|
||||||
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.support') : '', icon: 'pi pi-ticket', routerLink: 'support' },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (await this.authService.hasUserPermission(AuthRoles.Admin)) {
|
if (await this.authService.hasUserPermission(AuthRoles.Admin)) {
|
||||||
this.menuItems.push(
|
this.menuItems.push(
|
||||||
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.host') : '', icon: 'pi pi-sitemap', routerLink: 'host' },
|
||||||
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.gameserver') : '', icon: 'pi pi-desktop', routerLink: 'gameserver' },
|
||||||
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.support') : '', icon: 'pi pi-ticket', routerLink: 'support' },
|
||||||
{ separator: true },
|
{ separator: true },
|
||||||
{ label: isSidebarOpen ? this.translateService.instant('sidebar.config') : '', icon: 'pi pi-cog', routerLink: '/admin/settings' },
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.config') : '', icon: 'pi pi-cog', routerLink: '/admin/settings' },
|
||||||
{ label: isSidebarOpen ? this.translateService.instant('sidebar.auth_user_list') : '', icon: 'pi pi-user-edit', routerLink: '/admin/users' },
|
{ label: isSidebarOpen ? this.translateService.instant('sidebar.auth_user_list') : '', icon: 'pi pi-user-edit', routerLink: '/admin/users' },
|
||||||
);
|
);
|
||||||
this.menuItems = this.menuItems.slice();
|
|
||||||
}
|
}
|
||||||
|
this.menuItems = this.menuItems.slice();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ngOnChanges(changes: SimpleChanges): Promise<void> {
|
async ngOnChanges(changes: SimpleChanges): Promise<void> {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
export enum AuthRoles {
|
export enum AuthRoles {
|
||||||
Normal = 0,
|
User = 0,
|
||||||
Admin = 1
|
Support = 1,
|
||||||
|
Admin = 2
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export class AuthUserComponent implements OnInit {
|
|||||||
isEditingNew: boolean = false;
|
isEditingNew: boolean = false;
|
||||||
|
|
||||||
authRoles = [
|
authRoles = [
|
||||||
{ label: AuthRoles[AuthRoles.Normal].toString(), value: AuthRoles.Normal },
|
{ label: AuthRoles[AuthRoles.User].toString(), value: AuthRoles.User },
|
||||||
{ label: AuthRoles[AuthRoles.Admin].toString(), value: AuthRoles.Admin }
|
{ label: AuthRoles[AuthRoles.Admin].toString(), value: AuthRoles.Admin }
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ export class AuthUserComponent implements OnInit {
|
|||||||
lastName: "",
|
lastName: "",
|
||||||
eMail: "",
|
eMail: "",
|
||||||
password: "",
|
password: "",
|
||||||
authRole: AuthRoles.Normal
|
authRole: AuthRoles.User
|
||||||
};
|
};
|
||||||
|
|
||||||
isFirstNameInvalid: boolean = false;
|
isFirstNameInvalid: boolean = false;
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
<p>gameserver works!</p>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { GameserverComponent } from './gameserver.component';
|
||||||
|
|
||||||
|
describe('GameserverComponent', () => {
|
||||||
|
let component: GameserverComponent;
|
||||||
|
let fixture: ComponentFixture<GameserverComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ GameserverComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(GameserverComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gswi-gameserver',
|
||||||
|
templateUrl: './gameserver.component.html',
|
||||||
|
styleUrls: ['./gameserver.component.scss']
|
||||||
|
})
|
||||||
|
export class GameserverComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/app/modules/view/gameserver/gameserver-routing.module.ts
Normal file
13
src/app/modules/view/gameserver/gameserver-routing.module.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { GameserverComponent } from './components/gameserver/gameserver.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: '', component: GameserverComponent }
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class GameserverRoutingModule { }
|
19
src/app/modules/view/gameserver/gameserver.module.ts
Normal file
19
src/app/modules/view/gameserver/gameserver.module.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { GameserverComponent } from './components/gameserver/gameserver.component';
|
||||||
|
import { GameserverRoutingModule } from './gameserver-routing.module';
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
GameserverComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
GameserverRoutingModule,
|
||||||
|
SharedModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class GameserverModule { }
|
@ -0,0 +1 @@
|
|||||||
|
<p>host works!</p>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { HostComponent } from './host.component';
|
||||||
|
|
||||||
|
describe('HostComponent', () => {
|
||||||
|
let component: HostComponent;
|
||||||
|
let fixture: ComponentFixture<HostComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ HostComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(HostComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
16
src/app/modules/view/host/components/host/host.component.ts
Normal file
16
src/app/modules/view/host/components/host/host.component.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gswi-host',
|
||||||
|
templateUrl: './host.component.html',
|
||||||
|
styleUrls: ['./host.component.scss']
|
||||||
|
})
|
||||||
|
export class HostComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
console.log('hello');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/app/modules/view/host/host-routing.module.ts
Normal file
13
src/app/modules/view/host/host-routing.module.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { HostComponent } from './components/host/host.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: '', component: HostComponent }
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class HostRoutingModule { }
|
19
src/app/modules/view/host/host.module.ts
Normal file
19
src/app/modules/view/host/host.module.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { HostComponent } from './components/host/host.component';
|
||||||
|
import { HostRoutingModule } from './host-routing.module';
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
HostComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
HostRoutingModule,
|
||||||
|
SharedModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class HostModule { }
|
@ -0,0 +1 @@
|
|||||||
|
<p>support works!</p>
|
@ -0,0 +1,25 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { SupportComponent } from './support.component';
|
||||||
|
|
||||||
|
describe('SupportComponent', () => {
|
||||||
|
let component: SupportComponent;
|
||||||
|
let fixture: ComponentFixture<SupportComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
declarations: [ SupportComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(SupportComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,15 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'gswi-support',
|
||||||
|
templateUrl: './support.component.html',
|
||||||
|
styleUrls: ['./support.component.scss']
|
||||||
|
})
|
||||||
|
export class SupportComponent implements OnInit {
|
||||||
|
|
||||||
|
constructor() { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/app/modules/view/support/support-routing.module.ts
Normal file
13
src/app/modules/view/support/support-routing.module.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule, Routes } from '@angular/router';
|
||||||
|
import { SupportComponent } from './components/support/support.component';
|
||||||
|
|
||||||
|
const routes: Routes = [
|
||||||
|
{ path: '', component: SupportComponent }
|
||||||
|
];
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [RouterModule.forChild(routes)],
|
||||||
|
exports: [RouterModule]
|
||||||
|
})
|
||||||
|
export class SupportRoutingModule { }
|
19
src/app/modules/view/support/support.module.ts
Normal file
19
src/app/modules/view/support/support.module.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { SupportComponent } from './components/support/support.component';
|
||||||
|
import { SupportRoutingModule } from './support-routing.module';
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [
|
||||||
|
SupportComponent
|
||||||
|
],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
SupportRoutingModule,
|
||||||
|
SharedModule
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class SupportModule { }
|
@ -230,7 +230,8 @@ export class AuthService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const token = this.getDecodedToken();
|
const token = this.getDecodedToken();
|
||||||
return token['http://schemas.microsoft.com/ws/2008/06/identity/claims/role'] === AuthRoles[role];
|
const roleId: number = +AuthRoles[token['http://schemas.microsoft.com/ws/2008/06/identity/claims/role']];
|
||||||
|
return roleId >= +role;
|
||||||
}
|
}
|
||||||
|
|
||||||
getEMailFromDecodedToken(token: string): string {
|
getEMailFromDecodedToken(token: string): string {
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
"logout": "Ausloggen"
|
"logout": "Ausloggen"
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"home": "Home",
|
"home": "Dashboard",
|
||||||
|
"host": "Hosts",
|
||||||
|
"gameserver": "Server",
|
||||||
|
"support": "Tickets",
|
||||||
"config": "Konfiguration",
|
"config": "Konfiguration",
|
||||||
"auth_user_list": "Benutzer"
|
"auth_user_list": "Benutzer"
|
||||||
},
|
},
|
||||||
@ -82,7 +85,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"header": "App",
|
"header": "GSWI",
|
||||||
"login": {},
|
"login": {},
|
||||||
"register": {},
|
"register": {},
|
||||||
"forgot_password": {
|
"forgot_password": {
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
"logout": "Logout"
|
"logout": "Logout"
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"home": "Home",
|
"home": "Dashboard",
|
||||||
|
"host": "Hosts",
|
||||||
|
"gameserver": "Server",
|
||||||
|
"support": "Tickets",
|
||||||
"config": "Configuration",
|
"config": "Configuration",
|
||||||
"auth_user_list": "User"
|
"auth_user_list": "User"
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user