diff --git a/static/src/app/admin/admin.module.ts b/static/src/app/admin/admin.module.ts new file mode 100644 index 0000000..d8b597f --- /dev/null +++ b/static/src/app/admin/admin.module.ts @@ -0,0 +1,15 @@ +import {NgModule} from "@angular/core"; +import {AdminComponent} from "./admin.component"; +import {SharedModule} from "../shared.module"; +import {AppUserStore} from "../services/stores/app-user.store"; +import {AppUserService} from "../services/app-user-service/app-user.service"; +import {CommonModule} from "@angular/common"; +import {RouterModule} from "@angular/router"; + +@NgModule({ + declarations: [AdminComponent], + imports: [CommonModule, SharedModule, RouterModule.forChild([{path: '', component: AdminComponent}])], + providers: [AppUserStore, AppUserService] +}) +export class AdminModule { +} diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 04b8a4f..239d81b 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -45,10 +45,10 @@ @@ -60,10 +60,10 @@ @@ -73,8 +73,8 @@
  • Admin Panel
  • - diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index c033920..e594b3d 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -1,7 +1,6 @@ import {Component, Inject, Optional} from '@angular/core'; import {Router} from '@angular/router'; import {LoginService} from './services/login-service/login-service'; -import {AUTH_ENABLED} from './app.tokens'; import {PromotionService} from "./services/promotion-service/promotion.service"; import {AwardingService} from "./services/awarding-service/awarding.service"; import {RouteConfig} from "./app.config"; @@ -15,8 +14,7 @@ export class AppComponent { config = RouteConfig; - constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled, - private loginService: LoginService, + constructor(private loginService: LoginService, private promotionService: PromotionService, private awardingService: AwardingService, private router: Router) { diff --git a/static/src/app/app.config.ts b/static/src/app/app.config.ts index d45a62f..b19bbeb 100644 --- a/static/src/app/app.config.ts +++ b/static/src/app/app.config.ts @@ -28,8 +28,9 @@ export const RouteConfig = { statsPath: 'stats', userPath: 'users', overviewPath: 'overview', - requestAwardPath: 'request-award', - requestPromotionPath: 'request-promotion', + request: 'request', + requestAwardPath: 'award', + requestPromotionPath: 'promotion', confirmAwardPath: 'confirm-award', confirmPromotionPath: 'confirm-promotion' } diff --git a/static/src/app/app.module.ts b/static/src/app/app.module.ts index 3ada4d6..24ca5f7 100644 --- a/static/src/app/app.module.ts +++ b/static/src/app/app.module.ts @@ -4,27 +4,21 @@ import {HttpModule} from '@angular/http'; import {AppComponent} from './app.component'; import {LoginService} from "./services/login-service/login-service"; import {appRouting, routingComponents, routingProviders} from './app.routing'; -import {AUTH_ENABLED} from './app.tokens'; import {SquadService} from "./services/squad-service/squad.service"; import {SquadStore} from "./services/stores/squad.store"; import {DecorationStore} from "./services/stores/decoration.store"; import {DecorationService} from "./services/decoration-service/decoration.service"; import {SquadItemComponent} from "./squads/squad-list/squad-item.component"; -import {DecorationComponent} from "./decorations/decoration.component"; import {RankItemComponent} from "./ranks/rank-list/rank-item.component"; import {RankStore} from "./services/stores/rank.store"; import {RankService} from "./services/rank-service/rank.service"; -import {DecorationItemComponent} from "./decorations/decoration-list/decoration-item.component"; import {AppConfig} from "./app.config"; import {LoginGuardAdmin, LoginGuardHL, LoginGuardSQL} from "./login/login.guard"; import {AwardingService} from "./services/awarding-service/awarding.service"; import {HttpClient} from "./services/http-client"; import {ArmyService} from "./services/army-service/army.service"; import {ClipboardModule} from 'ngx-clipboard'; -import {AppUserService} from "./services/app-user-service/app-user.service"; -import {AppUserStore} from "./services/stores/app-user.store"; import {PromotionService} from "./services/promotion-service/promotion.service"; -import {FilterRankPipe} from "./filter/filter.pipe"; import {SharedModule} from "./shared.module"; import {BrowserAnimationsModule} from "@angular/platform-browser/animations"; @@ -37,8 +31,6 @@ import {BrowserAnimationsModule} from "@angular/platform-browser/animations"; LoginGuardHL, LoginGuardAdmin, ArmyService, - AppUserService, - AppUserStore, SquadService, SquadStore, DecorationService, @@ -49,15 +41,11 @@ import {BrowserAnimationsModule} from "@angular/platform-browser/animations"; PromotionService, AppConfig, routingProviders, - {provide: AUTH_ENABLED, useValue: true} ], declarations: [ AppComponent, routingComponents, - DecorationComponent, - DecorationItemComponent, RankItemComponent, - FilterRankPipe, SquadItemComponent], bootstrap: [AppComponent] }) diff --git a/static/src/app/app.routing.ts b/static/src/app/app.routing.ts index 6ae6371..097c775 100644 --- a/static/src/app/app.routing.ts +++ b/static/src/app/app.routing.ts @@ -3,17 +3,10 @@ import {LoginComponent} from "./login/index"; import {NotFoundComponent} from "./common/not-found/not-found.component"; import {LoginGuardAdmin, LoginGuardHL, LoginGuardMT, LoginGuardSQL} from "./login/login.guard"; import {squadsRoutes, squadsRoutingComponents} from "./squads/squads.routing"; -import {decorationsRoutes, decorationsRoutingComponents} from "./decorations/decoration.routing"; import {ranksRoutes, ranksRoutingComponents} from "./ranks/ranks.routing"; import {armyRoutes, armyRoutingComponents} from "./army/army.routing"; import {SignupComponent} from "./login/signup.component"; -import {AdminComponent} from "./admin/admin.component"; -import {RequestAwardComponent} from "./request/award/req-award.component"; -import {RequestPromotionComponent} from "./request/promotion/req-promotion.component"; -import {ConfirmPromotionComponent} from "./request/confirm-promotion/confirm-promotion.component"; -import {ConfirmAwardComponent} from "./request/confirm-award/confirm-award.component"; import {RouteConfig} from "./app.config"; -import {statsRoutingComponents} from "./statistic/stats.routing"; export const appRoutes: Routes = [ @@ -25,17 +18,14 @@ export const appRoutes: Routes = [ {path: RouteConfig.loginPath, component: LoginComponent}, {path: RouteConfig.signUpPath, component: SignupComponent}, - {path: RouteConfig.requestAwardPath, component: RequestAwardComponent, canActivate: [LoginGuardSQL]}, - {path: RouteConfig.requestPromotionPath, component: RequestPromotionComponent, canActivate: [LoginGuardSQL]}, - {path: RouteConfig.confirmAwardPath, component: ConfirmAwardComponent, canActivate: [LoginGuardHL]}, - {path: RouteConfig.confirmPromotionPath, component: ConfirmPromotionComponent, canActivate: [LoginGuardHL]}, + {path: RouteConfig.request, loadChildren: './request/request.module#RequestModule'}, {path: RouteConfig.userPath, loadChildren: './users/users.module#UsersModule', canActivate: [LoginGuardHL]}, {path: RouteConfig.squadPath, children: squadsRoutes, canActivate: [LoginGuardHL]}, - {path: RouteConfig.decorationPath, children: decorationsRoutes, canActivate: [LoginGuardHL]}, + {path: RouteConfig.decorationPath, loadChildren: './decorations/decoration.module#DecorationsModule', canActivate: [LoginGuardHL]}, {path: RouteConfig.rankPath, children: ranksRoutes, canActivate: [LoginGuardHL]}, - {path: RouteConfig.adminPanelPath, component: AdminComponent, canActivate: [LoginGuardAdmin]}, + {path: RouteConfig.adminPanelPath, loadChildren: './admin/admin.module#AdminModule', canActivate: [LoginGuardAdmin]}, /** Redirect Konfigurationen **/ {path: '404', component: NotFoundComponent}, @@ -44,8 +34,7 @@ export const appRoutes: Routes = [ export const appRouting = RouterModule.forRoot(appRoutes); -export const routingComponents = [LoginComponent, SignupComponent, RequestAwardComponent, RequestPromotionComponent, ConfirmAwardComponent, - ConfirmPromotionComponent, AdminComponent, ...armyRoutingComponents, NotFoundComponent, - ...squadsRoutingComponents, ...decorationsRoutingComponents, ...ranksRoutingComponents]; +export const routingComponents = [LoginComponent, SignupComponent, + ...armyRoutingComponents, NotFoundComponent, ...squadsRoutingComponents, ...ranksRoutingComponents]; export const routingProviders = [LoginGuardSQL, LoginGuardHL, LoginGuardMT, LoginGuardAdmin]; diff --git a/static/src/app/app.tokens.ts b/static/src/app/app.tokens.ts deleted file mode 100644 index ba88f65..0000000 --- a/static/src/app/app.tokens.ts +++ /dev/null @@ -1,6 +0,0 @@ -import {OpaqueToken} from '@angular/core'; - -export const AUTH_ENABLED = new OpaqueToken('AUTH_ENABLED'); - -export const SOCKET_IO = new OpaqueToken('socket-io'); - diff --git a/static/src/app/decorations/decoration.module.ts b/static/src/app/decorations/decoration.module.ts new file mode 100644 index 0000000..249a929 --- /dev/null +++ b/static/src/app/decorations/decoration.module.ts @@ -0,0 +1,15 @@ +import {decorationRoutesModule, decorationsRoutingComponents} from "./decoration.routing"; +import {SharedModule} from "../shared.module"; +import {CommonModule} from "@angular/common"; +import {DecorationStore} from "../services/stores/decoration.store"; +import {DecorationService} from "../services/decoration-service/decoration.service"; +import {NgModule} from "@angular/core"; + +@NgModule({ + declarations: decorationsRoutingComponents, + imports: [CommonModule, SharedModule, decorationRoutesModule], + providers: [DecorationStore, DecorationService] +}) +export class DecorationsModule { + static routes = decorationRoutesModule; +} diff --git a/static/src/app/decorations/decoration.routing.ts b/static/src/app/decorations/decoration.routing.ts index 7afcf03..8f5cb04 100644 --- a/static/src/app/decorations/decoration.routing.ts +++ b/static/src/app/decorations/decoration.routing.ts @@ -1,7 +1,9 @@ -import {Routes} from "@angular/router"; +import {RouterModule, Routes} from "@angular/router"; import {DecorationComponent} from "./decoration.component"; import {DecorationListComponent} from "./decoration-list/decoration-list.component"; import {EditDecorationComponent} from "./edit-decoration/edit-decoration.component"; +import {ModuleWithProviders} from "@angular/core"; +import {DecorationItemComponent} from "./decoration-list/decoration-item.component"; export const decorationsRoutes: Routes = [{ path: '', component: DecorationComponent, @@ -23,5 +25,7 @@ export const decorationsRoutes: Routes = [{ outlet: 'right' }]; -export const decorationsRoutingComponents = [DecorationComponent, DecorationListComponent, EditDecorationComponent]; +export const decorationRoutesModule: ModuleWithProviders = RouterModule.forChild(decorationsRoutes); + +export const decorationsRoutingComponents = [DecorationItemComponent, DecorationComponent, DecorationListComponent, EditDecorationComponent]; diff --git a/static/src/app/request/request.component.ts b/static/src/app/request/request.component.ts new file mode 100644 index 0000000..eab67db --- /dev/null +++ b/static/src/app/request/request.component.ts @@ -0,0 +1,11 @@ +import {Component} from "@angular/core"; + +@Component({ + selector: 'request', + templateUrl: 'request.component.html', + styleUrls: ['request.component.css'] +}) +export class RequestComponent { + constructor() { + } +} diff --git a/static/src/app/request/request.module.ts b/static/src/app/request/request.module.ts new file mode 100644 index 0000000..f00e6d6 --- /dev/null +++ b/static/src/app/request/request.module.ts @@ -0,0 +1,22 @@ +import {CommonModule} from "@angular/common"; +import {SharedModule} from "../shared.module"; +import {requestRouterModule} from "./request.routing"; +import {NgModule} from "@angular/core"; +import {FilterRankPipe} from "../filter/filter.pipe"; +import {RequestComponent} from "./request.component"; +import {ConfirmAwardComponent} from "./confirm-award/confirm-award.component"; +import {ConfirmPromotionComponent} from "./confirm-promotion/confirm-promotion.component"; +import {RequestAwardComponent} from "./award/req-award.component"; +import {RequestPromotionComponent} from "./promotion/req-promotion.component"; +import {UserService} from "../services/user-service/user.service"; +import {UserStore} from "../services/stores/user.store"; + +@NgModule({ + declarations: [RequestComponent, RequestPromotionComponent, RequestAwardComponent, ConfirmPromotionComponent, + ConfirmAwardComponent, FilterRankPipe], + imports: [CommonModule, SharedModule, requestRouterModule], + providers: [UserStore, UserService] +}) +export class RequestModule { + static routes = requestRouterModule; +} diff --git a/static/src/app/request/request.routing.ts b/static/src/app/request/request.routing.ts new file mode 100644 index 0000000..33d0137 --- /dev/null +++ b/static/src/app/request/request.routing.ts @@ -0,0 +1,38 @@ +import {RouterModule, Routes} from "@angular/router"; +import {ModuleWithProviders} from "@angular/core"; +import {ConfirmAwardComponent} from "./confirm-award/confirm-award.component"; +import {ConfirmPromotionComponent} from "./confirm-promotion/confirm-promotion.component"; +import {RequestAwardComponent} from "./award/req-award.component"; +import {RequestPromotionComponent} from "./promotion/req-promotion.component"; + +import {RequestComponent} from "./request.component"; +import {RouteConfig} from "../app.config"; +import {LoginGuardHL, LoginGuardSQL} from "../login/login.guard"; + + +export const requestRoutes: Routes = [{ + path: '', component: RequestComponent +}, + { + path: RouteConfig.requestAwardPath, + component: RequestAwardComponent, + canActivate: [LoginGuardSQL] + }, + { + path: RouteConfig.requestPromotionPath, + component: RequestPromotionComponent, + canActivate: [LoginGuardSQL] + }, + { + path: RouteConfig.confirmAwardPath, + component: ConfirmAwardComponent, + canActivate: [LoginGuardHL] + }, + { + path: RouteConfig.confirmPromotionPath, + component: ConfirmPromotionComponent, + canActivate: [LoginGuardHL] + } +]; + +export const requestRouterModule: ModuleWithProviders = RouterModule.forChild(requestRoutes); diff --git a/static/src/app/services/login-service/login-service.ts b/static/src/app/services/login-service/login-service.ts index f337a74..c12a530 100644 --- a/static/src/app/services/login-service/login-service.ts +++ b/static/src/app/services/login-service/login-service.ts @@ -1,17 +1,15 @@ -import {Inject, Injectable, Optional} from "@angular/core"; +import {Injectable} from "@angular/core"; import {Http, Response} from "@angular/http"; import "rxjs/add/operator/map"; import {AppConfig} from "../../app.config"; -import {AUTH_ENABLED} from "../../app.tokens"; import {AppUser} from "../../models/model-interfaces"; import {AwardingService} from "../awarding-service/awarding.service"; import {PromotionService} from "../promotion-service/promotion.service"; @Injectable() export class LoginService { - constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled = false, - private http: Http, + constructor(private http: Http, private config: AppConfig, private awardingService: AwardingService, private promotionService: PromotionService) { @@ -47,7 +45,7 @@ export class LoginService { } isLoggedIn() { - return !this.authEnabled || localStorage.getItem('currentUser') != null; + return localStorage.getItem('currentUser') != null; } hasPermission(level : number) {