Add decoration, admin, request module; remove authEnabled flag
parent
3361caaf4a
commit
6eca7c581e
|
@ -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 {
|
||||
}
|
|
@ -45,10 +45,10 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a routerLink="{{config.requestPromotionPath}}">Beförderung</a>
|
||||
<a routerLink="{{config.request}}/{{config.requestPromotionPath}}">Beförderung</a>
|
||||
</li>
|
||||
<li>
|
||||
<a routerLink="{{config.requestAwardPath}}">Orden/ Auszeichnung</a>
|
||||
<a routerLink="{{config.request}}/{{config.requestAwardPath}}">Orden/ Auszeichnung</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -60,10 +60,10 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a [ngClass]="{'unprocessed-child': promotionService.hasUnprocessedPromotion}" routerLink="{{config.confirmPromotionPath}}">Beförderung</a>
|
||||
<a [ngClass]="{'unprocessed-child': promotionService.hasUnprocessedPromotion}" routerLink="{{config.request}}/{{config.confirmPromotionPath}}">Beförderung</a>
|
||||
</li>
|
||||
<li>
|
||||
<a [ngClass]="{'unprocessed-child': awardingService.hasUnprocessedAwards}" routerLink="{{config.confirmAwardPath}}">Orden/ Auszeichnung</a>
|
||||
<a [ngClass]="{'unprocessed-child': awardingService.hasUnprocessedAwards}" routerLink="{{config.request}}/{{config.confirmAwardPath}}">Orden/ Auszeichnung</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
@ -73,8 +73,8 @@
|
|||
<li *ngIf="loginService.hasPermission(4)" routerLinkActive="active">
|
||||
<a routerLink='{{config.adminPanelPath}}' class="link">Admin Panel</a>
|
||||
</li>
|
||||
<li *ngIf="authEnabled" class="link" style="cursor: pointer">
|
||||
<a *ngIf="loginService.isLoggedIn()" (click)="logout()">Abmelden</a>
|
||||
<li *ngIf="loginService.isLoggedIn()" class="link" style="cursor: pointer">
|
||||
<a (click)="logout()">Abmelden</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
})
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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');
|
||||
|
|
@ -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;
|
||||
}
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
import {Component} from "@angular/core";
|
||||
|
||||
@Component({
|
||||
selector: 'request',
|
||||
templateUrl: 'request.component.html',
|
||||
styleUrls: ['request.component.css']
|
||||
})
|
||||
export class RequestComponent {
|
||||
constructor() {
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue