Merge branch 'task/differ-api-and-app-routes' of hardi/opt-cc into master
						commit
						33c465aeb6
					
				| 
						 | 
				
			
			@ -1,16 +1,18 @@
 | 
			
		|||
const rootRoute = '/api';
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
  auth: '/authenticate',
 | 
			
		||||
  signUp: '/authenticate/signup',
 | 
			
		||||
  awards: '/awardings',
 | 
			
		||||
  command: '/cmd',
 | 
			
		||||
  cmdCreateSig: '/cmd/createSignature',
 | 
			
		||||
  decorations: '/decorations',
 | 
			
		||||
  overview: '/overview',
 | 
			
		||||
  ranks: '/ranks',
 | 
			
		||||
  signatures: '/signatures',
 | 
			
		||||
  squads: '/squads',
 | 
			
		||||
  users: '/users',
 | 
			
		||||
  account: '/account',
 | 
			
		||||
  request: '/request',
 | 
			
		||||
  wars: '/wars'
 | 
			
		||||
  auth: rootRoute + '/authenticate',
 | 
			
		||||
  signUp: rootRoute + '/authenticate/signup',
 | 
			
		||||
  awards: rootRoute + '/awardings',
 | 
			
		||||
  command: rootRoute + '/cmd',
 | 
			
		||||
  cmdCreateSig: rootRoute + '/cmd/createSignature',
 | 
			
		||||
  decorations: rootRoute + '/decorations',
 | 
			
		||||
  overview: rootRoute + '/overview',
 | 
			
		||||
  ranks: rootRoute + '/ranks',
 | 
			
		||||
  signatures: rootRoute + '/signatures',
 | 
			
		||||
  squads: rootRoute + '/squads',
 | 
			
		||||
  users: rootRoute + '/users',
 | 
			
		||||
  account: rootRoute + '/account',
 | 
			
		||||
  request: rootRoute + '/request',
 | 
			
		||||
  wars: rootRoute + '/wars'
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,21 +103,29 @@ errorResponseWare(app);
 | 
			
		|||
 | 
			
		||||
// Start the server
 | 
			
		||||
if (process.env.NODE_ENV !== config.test.env) {
 | 
			
		||||
  mongoose.connect(config.database.uri + config.database.db);
 | 
			
		||||
  app.listen(config.port, (err) => {
 | 
			
		||||
    if (err !== undefined) {
 | 
			
		||||
      debug('Error on startup, ', err);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      debug('Listening on port ' + config.port);
 | 
			
		||||
      signatureCronJob.start();
 | 
			
		||||
      backupCronJob.start();
 | 
			
		||||
    }
 | 
			
		||||
  const mongoosePromise = mongoose.connect(config.database.uri + config.database.db, {
 | 
			
		||||
    useMongoClient: true
 | 
			
		||||
  });
 | 
			
		||||
  mongoosePromise.then((db) => {
 | 
			
		||||
    app.listen(config.port, (err) => {
 | 
			
		||||
      if (err !== undefined) {
 | 
			
		||||
        debug('Error on startup, ', err);
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        debug('Listening on port ' + config.port);
 | 
			
		||||
        signatureCronJob.start();
 | 
			
		||||
        backupCronJob.start();
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
  })
 | 
			
		||||
} else {
 | 
			
		||||
  mongoose.connect(config.database.uri + config.test.db);
 | 
			
		||||
  app.listen(config.test.port);
 | 
			
		||||
  console.log('Listening on port ' + config.test.port);
 | 
			
		||||
  const mongoosePromise = mongoose.connect(config.database.uri + config.test.db, {
 | 
			
		||||
    useMongoClient: true
 | 
			
		||||
  });
 | 
			
		||||
  mongoosePromise.then((db) => {
 | 
			
		||||
    app.listen(config.test.port);
 | 
			
		||||
    console.log('Listening on port ' + config.test.port);
 | 
			
		||||
  })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = app;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,10 +16,10 @@
 | 
			
		|||
 | 
			
		||||
        <ul class="nav navbar-nav">
 | 
			
		||||
          <li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/login' class="link">Login</a>
 | 
			
		||||
            <a routerLink='{{config.loginPath}}' class="link">Login</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/cc-overview' class="link">Armeeübersicht</a>
 | 
			
		||||
            <a routerLink='{{config.overviewPath}}' class="link">Armeeübersicht</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li class="dropdown">
 | 
			
		||||
            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
 | 
			
		||||
| 
						 | 
				
			
			@ -29,29 +29,29 @@
 | 
			
		|||
            </a>
 | 
			
		||||
            <ul class="dropdown-menu scrollable-menu">
 | 
			
		||||
              <li *ngIf="loginService.hasPermission(3)">
 | 
			
		||||
                <a routerLink='/cc-wars' class="link">Hinzufügen...</a>
 | 
			
		||||
                <a routerLink='{{config.warPath}}' class="link">Hinzufügen...</a>
 | 
			
		||||
              </li>
 | 
			
		||||
              <li>
 | 
			
		||||
                <a routerLink='/cc-statistic' class="link">Übersicht</a>
 | 
			
		||||
                <a routerLink='{{config.statsPath}}' class="link">Übersicht</a>
 | 
			
		||||
              </li>
 | 
			
		||||
              <li *ngFor="let war of wars">
 | 
			
		||||
                <a [routerLink]="['/cc-wars/' + war._id]">{{war.title}}
 | 
			
		||||
                <a routerLink='{{config.warPath}}/{{war._id}}'>{{war.title}}
 | 
			
		||||
                  <small>{{war.date | date: 'dd.MM.yy'}}</small>
 | 
			
		||||
                </a>
 | 
			
		||||
              </li>
 | 
			
		||||
            </ul>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(2)" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/cc-users' class="link">Teilnehmer</a>
 | 
			
		||||
            <a routerLink='{{config.userPath}}' class="link">Teilnehmer</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(2)" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/cc-squads' class="link">Squads</a>
 | 
			
		||||
            <a routerLink='{{config.squadPath}}' class="link">Squads</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(2)" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/cc-decorations' class="link">Auszeichnungen</a>
 | 
			
		||||
            <a routerLink='{{config.decorationPath}}' class="link">Auszeichnungen</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(2)" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/cc-ranks' class="link">Ränge</a>
 | 
			
		||||
            <a routerLink='{{config.rankPath}}' class="link">Ränge</a>
 | 
			
		||||
          </li>
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(1) && !loginService.hasPermission(2) && loginService.hasSquad()"
 | 
			
		||||
              class="dropdown">
 | 
			
		||||
| 
						 | 
				
			
			@ -62,10 +62,10 @@
 | 
			
		|||
            </a>
 | 
			
		||||
            <ul class="dropdown-menu">
 | 
			
		||||
              <li>
 | 
			
		||||
                <a [routerLink]="['/request-promotion']">Beförderung</a>
 | 
			
		||||
                <a routerLink="{{config.requestPromotionPath}}">Beförderung</a>
 | 
			
		||||
              </li>
 | 
			
		||||
              <li>
 | 
			
		||||
                <a [routerLink]="['/request-award']">Orden/ Auszeichnung</a>
 | 
			
		||||
                <a routerLink="{{config.requestAwardPath}}">Orden/ Auszeichnung</a>
 | 
			
		||||
              </li>
 | 
			
		||||
            </ul>
 | 
			
		||||
          </li>
 | 
			
		||||
| 
						 | 
				
			
			@ -77,10 +77,10 @@
 | 
			
		|||
            </a>
 | 
			
		||||
            <ul class="dropdown-menu">
 | 
			
		||||
              <li>
 | 
			
		||||
                <a [ngClass]="{'unprocessed-child': promotionService.hasUnprocessedPromotion}" [routerLink]="['/confirm-promotion']">Beförderung</a>
 | 
			
		||||
                <a [ngClass]="{'unprocessed-child': promotionService.hasUnprocessedPromotion}" routerLink="{{config.confirmPromotionPath}}">Beförderung</a>
 | 
			
		||||
              </li>
 | 
			
		||||
              <li>
 | 
			
		||||
                <a [ngClass]="{'unprocessed-child': awardingService.hasUnprocessedAwards}" [routerLink]="['/confirm-award']">Orden/ Auszeichnung</a>
 | 
			
		||||
                <a [ngClass]="{'unprocessed-child': awardingService.hasUnprocessedAwards}" routerLink="{{config.confirmAwardPath}}">Orden/ Auszeichnung</a>
 | 
			
		||||
              </li>
 | 
			
		||||
            </ul>
 | 
			
		||||
          </li>
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +88,7 @@
 | 
			
		|||
 | 
			
		||||
        <ul class="nav navbar-nav" style="float: right">
 | 
			
		||||
          <li *ngIf="loginService.hasPermission(4)" routerLinkActive="active">
 | 
			
		||||
            <a routerLink='/admin-panel' class="link">Admin Panel</a>
 | 
			
		||||
            <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>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,11 +1,12 @@
 | 
			
		|||
import {Component, Inject, Optional} from '@angular/core';
 | 
			
		||||
import {Router} from '@angular/router';
 | 
			
		||||
import {Route, Router} from '@angular/router';
 | 
			
		||||
import {LoginService} from './services/login-service/login-service';
 | 
			
		||||
import {AUTH_ENABLED} from './app.tokens';
 | 
			
		||||
import {WarService} from "./services/war-service/war.service";
 | 
			
		||||
import {War} from "./models/model-interfaces";
 | 
			
		||||
import {PromotionService} from "./services/promotion-service/promotion.service";
 | 
			
		||||
import {AwardingService} from "./services/awarding-service/awarding.service";
 | 
			
		||||
import {RouteConfig} from "./app.config";
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'app-root',
 | 
			
		||||
| 
						 | 
				
			
			@ -16,6 +17,8 @@ export class AppComponent {
 | 
			
		|||
 | 
			
		||||
  wars: War[] = [];
 | 
			
		||||
 | 
			
		||||
  config = RouteConfig;
 | 
			
		||||
 | 
			
		||||
  constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled,
 | 
			
		||||
              private loginService: LoginService,
 | 
			
		||||
              private warService: WarService,
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +41,7 @@ export class AppComponent {
 | 
			
		|||
 | 
			
		||||
  logout() {
 | 
			
		||||
    this.loginService.logout();
 | 
			
		||||
    this.router.navigate(['cc-overview']);
 | 
			
		||||
    this.router.navigate([RouteConfig.overviewPath]);
 | 
			
		||||
    return false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,19 +1,36 @@
 | 
			
		|||
 | 
			
		||||
export class AppConfig {
 | 
			
		||||
 | 
			
		||||
  public readonly apiUrl = '';
 | 
			
		||||
  public readonly apiUrl = '/api';
 | 
			
		||||
 | 
			
		||||
  public readonly apiAppUserPath        = '/account/';
 | 
			
		||||
  public readonly apiAwardPath          = '/awardings';
 | 
			
		||||
  public readonly apiDecorationPath     = '/decorations/';
 | 
			
		||||
  public readonly apiAuthenticationPath = '/authenticate';
 | 
			
		||||
  public readonly apiSignupPath         = '/authenticate/signup';
 | 
			
		||||
  public readonly apiRankPath           = '/ranks/';
 | 
			
		||||
  public readonly apiSquadPath          = '/squads/';
 | 
			
		||||
  public readonly apiUserPath           = '/users/';
 | 
			
		||||
  public readonly apiOverviewPath       = '/overview';
 | 
			
		||||
  public readonly apiRequestAwardPath   = '/request/award';
 | 
			
		||||
  public readonly apiPromotionPath      = '/request/promotion';
 | 
			
		||||
  public readonly apiWarPath            = '/wars';
 | 
			
		||||
  public readonly apiAppUserPath        = this.apiUrl + '/account/';
 | 
			
		||||
  public readonly apiAwardPath          = this.apiUrl + '/awardings';
 | 
			
		||||
  public readonly apiDecorationPath     = this.apiUrl + '/decorations/';
 | 
			
		||||
  public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
 | 
			
		||||
  public readonly apiSignupPath         = this.apiUrl + '/authenticate/signup';
 | 
			
		||||
  public readonly apiRankPath           = this.apiUrl + '/ranks/';
 | 
			
		||||
  public readonly apiSquadPath          = this.apiUrl + '/squads/';
 | 
			
		||||
  public readonly apiUserPath           = this.apiUrl + '/users/';
 | 
			
		||||
  public readonly apiOverviewPath       = this.apiUrl + '/overview';
 | 
			
		||||
  public readonly apiRequestAwardPath   = this.apiUrl + '/request/award';
 | 
			
		||||
  public readonly apiPromotionPath      = this.apiUrl + '/request/promotion';
 | 
			
		||||
  public readonly apiWarPath            = this.apiUrl + '/wars';
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const RouteConfig = {
 | 
			
		||||
  adminPanelPath: 'admin-panel',
 | 
			
		||||
  decorationPath: 'decorations',
 | 
			
		||||
  loginPath: 'login',
 | 
			
		||||
  signUpPath: 'signup',
 | 
			
		||||
  rankPath: 'ranks',
 | 
			
		||||
  squadPath: 'squads',
 | 
			
		||||
  statsPath: 'stats',
 | 
			
		||||
  userPath: 'users',
 | 
			
		||||
  overviewPath: 'overview',
 | 
			
		||||
  warPath: 'war',
 | 
			
		||||
  requestAwardPath: 'request-award',
 | 
			
		||||
  requestPromotionPath: 'request-promotion',
 | 
			
		||||
  confirmAwardPath: 'confirm-award',
 | 
			
		||||
  confirmPromotionPath: 'confirm-promotion'
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,30 +15,30 @@ import {ConfirmPromotionComponent} from "./request/confirm-promotion/confirm-pro
 | 
			
		|||
import {ConfirmAwardComponent} from "./request/confirm-award/confirm-award.component";
 | 
			
		||||
import {warRoutes, warsRoutingComponents} from "./wars/wars.routing";
 | 
			
		||||
import {StatisticComponent} from "./statistic/statistic.component";
 | 
			
		||||
 | 
			
		||||
import {RouteConfig} from "./app.config";
 | 
			
		||||
 | 
			
		||||
export const appRoutes: Routes = [
 | 
			
		||||
 | 
			
		||||
  {path: 'cc-overview', children: armyRoutes},
 | 
			
		||||
  {path: '', redirectTo: '/cc-overview', pathMatch: 'full'},
 | 
			
		||||
  {path: RouteConfig.overviewPath, children: armyRoutes},
 | 
			
		||||
  {path: '', redirectTo: RouteConfig.overviewPath, pathMatch: 'full'},
 | 
			
		||||
 | 
			
		||||
  {path: 'cc-wars', children: warRoutes},
 | 
			
		||||
  {path: 'cc-statistic', component: StatisticComponent},
 | 
			
		||||
  {path: RouteConfig.warPath, children: warRoutes},
 | 
			
		||||
  {path: RouteConfig.statsPath, component: StatisticComponent},
 | 
			
		||||
 | 
			
		||||
  {path: 'login', component: LoginComponent},
 | 
			
		||||
  {path: 'signup', component: SignupComponent},
 | 
			
		||||
  {path: RouteConfig.loginPath, component: LoginComponent},
 | 
			
		||||
  {path: RouteConfig.signUpPath, component: SignupComponent},
 | 
			
		||||
 | 
			
		||||
  {path: 'request-award', component: RequestAwardComponent, canActivate: [LoginGuardSQL]},
 | 
			
		||||
  {path: 'request-promotion', component: RequestPromotionComponent, canActivate: [LoginGuardSQL]},
 | 
			
		||||
  {path: 'confirm-award', component: ConfirmAwardComponent, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: 'confirm-promotion', component: ConfirmPromotionComponent, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {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: 'cc-users', children: usersRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: 'cc-squads', children: squadsRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: 'cc-decorations', children: decorationsRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: 'cc-ranks', children: ranksRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: RouteConfig.userPath, children: usersRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: RouteConfig.squadPath, children: squadsRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: RouteConfig.decorationPath, children: decorationsRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
  {path: RouteConfig.rankPath, children: ranksRoutes, canActivate: [LoginGuardHL]},
 | 
			
		||||
 | 
			
		||||
  {path: 'admin-panel', component: AdminComponent, canActivate: [LoginGuardAdmin]},
 | 
			
		||||
  {path: RouteConfig.adminPanelPath, component: AdminComponent, canActivate: [LoginGuardAdmin]},
 | 
			
		||||
 | 
			
		||||
  /** Redirect Konfigurationen **/
 | 
			
		||||
  {path: '404', component: NotFoundComponent},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
<div class="overview">
 | 
			
		||||
 | 
			
		||||
  <div>
 | 
			
		||||
    <img style="margin-left: 13%;" src="/signatures/{{user.username}}">
 | 
			
		||||
    <img style="margin-left: 13%;" src="resource/signature/{{user._id}}.png">
 | 
			
		||||
  </div>
 | 
			
		||||
  <div class="input-group" style="width: 662px; margin-left: 13%;">
 | 
			
		||||
    <input type="text" style="background: white;" class="form-control" [(ngModel)]="signatureUrl" readonly>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@ import {User} from "../models/model-interfaces";
 | 
			
		|||
import {ActivatedRoute, Router} from "@angular/router";
 | 
			
		||||
import {UserService} from "../services/user-service/user.service";
 | 
			
		||||
import {Subscription} from "rxjs/Subscription";
 | 
			
		||||
import {AppConfig, RouteConfig} from "../app.config";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +39,7 @@ export class ArmyMemberComponent {
 | 
			
		|||
  };
 | 
			
		||||
 | 
			
		||||
  backToOverview() {
 | 
			
		||||
    this.router.navigate(['cc-overview']);
 | 
			
		||||
    this.router.navigate([RouteConfig.overviewPath]);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
import {Component, OnInit} from "@angular/core";
 | 
			
		||||
import {Router} from "@angular/router";
 | 
			
		||||
import {LoginService} from "../services/login-service/login-service";
 | 
			
		||||
import {RouteConfig} from "../app.config";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
| 
						 | 
				
			
			@ -27,7 +28,7 @@ export class LoginComponent implements OnInit {
 | 
			
		|||
    // reset login status
 | 
			
		||||
    this.loginService.logout();
 | 
			
		||||
    // redirect on success
 | 
			
		||||
    this.returnUrl = '/cc-overview'
 | 
			
		||||
    this.returnUrl = RouteConfig.overviewPath;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  login(username: string, password: string) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
import {Component, OnInit} from "@angular/core";
 | 
			
		||||
import {ActivatedRoute, Router} from "@angular/router";
 | 
			
		||||
import {LoginService} from "../services/login-service/login-service";
 | 
			
		||||
import {RouteConfig} from "../app.config";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,7 @@ export class SignupComponent implements OnInit {
 | 
			
		|||
    // reset login status
 | 
			
		||||
    this.loginService.logout();
 | 
			
		||||
    // redirect on success
 | 
			
		||||
    this.returnUrl = '/cc-overview'
 | 
			
		||||
    this.returnUrl = RouteConfig.overviewPath;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  login(username: string, password: string, secret: string) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ export class AppUserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getUsers() {
 | 
			
		||||
    this.http.get(this.config.apiUrl + this.config.apiAppUserPath)
 | 
			
		||||
    this.http.get(this.config.apiAppUserPath)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do((users) => {
 | 
			
		||||
        this.appUserStore.dispatch({type: LOAD, data: users});
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +30,7 @@ export class AppUserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  updateUser(user: AppUser) {
 | 
			
		||||
      return this.http.patch(this.config.apiUrl + this.config.apiAppUserPath + user._id, user)
 | 
			
		||||
      return this.http.patch(this.config.apiAppUserPath + user._id, user)
 | 
			
		||||
        .map(res => res.json())
 | 
			
		||||
        .do(savedUser => {
 | 
			
		||||
          const action = {type: EDIT, data: savedUser};
 | 
			
		||||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ export class AppUserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  deleteUser(user) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiAppUserPath + user._id)
 | 
			
		||||
    return this.http.delete(this.config.apiAppUserPath + user._id)
 | 
			
		||||
      .do(res => {
 | 
			
		||||
        this.appUserStore.dispatch({type: REMOVE, data: user});
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,7 +11,7 @@ export class ArmyService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getArmy() {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiOverviewPath)
 | 
			
		||||
    return this.http.get(this.config.apiOverviewPath)
 | 
			
		||||
      .map(res => res.json());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ export class AwardingService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getUnconfirmedAwards(fraction?: string) {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiAwardPath + '?inProgress=true&fractFilter=' + fraction)
 | 
			
		||||
    return this.http.get(this.config.apiAwardPath + '?inProgress=true&fractFilter=' + fraction)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -29,25 +29,25 @@ export class AwardingService {
 | 
			
		|||
   * get awards array with populated decorations
 | 
			
		||||
   */
 | 
			
		||||
  getUserAwardings(userId: string) {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiAwardPath + '?userId=' + userId)
 | 
			
		||||
    return this.http.get(this.config.apiAwardPath + '?userId=' + userId)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  addAwarding(award: Award) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiAwardPath, award)
 | 
			
		||||
    return this.http.post(this.config.apiAwardPath, award)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  updateAward(award) {
 | 
			
		||||
    return this.http.patch(this.config.apiUrl + this.config.apiAwardPath + '/' + award._id, award)
 | 
			
		||||
    return this.http.patch(this.config.apiAwardPath + '/' + award._id, award)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  requestAwarding(award: Award) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiRequestAwardPath, award)
 | 
			
		||||
    return this.http.post(this.config.apiRequestAwardPath, award)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteAwarding(awardingId) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiAwardPath + '/' + awardingId)
 | 
			
		||||
    return this.http.delete(this.config.apiAwardPath + '/' + awardingId)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ export class DecorationService {
 | 
			
		|||
      searchParams.append('fractFilter', fractionFilter);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.http.get(this.config.apiUrl + this.config.apiDecorationPath, searchParams)
 | 
			
		||||
    this.http.get(this.config.apiDecorationPath, searchParams)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do((squads) => {
 | 
			
		||||
        this.decorationStore.dispatch({type: LOAD, data: squads});
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +37,7 @@ export class DecorationService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getDecoration(id: number | string): Observable<Decoration> {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiDecorationPath + id)
 | 
			
		||||
    return this.http.get(this.config.apiDecorationPath + id)
 | 
			
		||||
      .map(res => res.json());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -46,7 +46,7 @@ export class DecorationService {
 | 
			
		|||
   * update existing with patch PATCH
 | 
			
		||||
   */
 | 
			
		||||
  submitDecoration(decoration: Decoration, imageFile?) {
 | 
			
		||||
    let requestUrl = this.config.apiUrl + this.config.apiDecorationPath;
 | 
			
		||||
    let requestUrl = this.config.apiDecorationPath;
 | 
			
		||||
    let requestMethod: RequestMethod;
 | 
			
		||||
    let accessType;
 | 
			
		||||
    let body;
 | 
			
		||||
| 
						 | 
				
			
			@ -88,7 +88,7 @@ export class DecorationService {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
  deleteDecoration(decoration: Decoration) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiDecorationPath + decoration._id)
 | 
			
		||||
    return this.http.delete(this.config.apiDecorationPath + decoration._id)
 | 
			
		||||
      .do(res => {
 | 
			
		||||
        this.decorationStore.dispatch({type: REMOVE, data: decoration});
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,7 +18,7 @@ export class LoginService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  login(username: string, password: string) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiAuthenticationPath, {username: username, password: password})
 | 
			
		||||
    return this.http.post(this.config.apiAuthenticationPath, {username: username, password: password})
 | 
			
		||||
      .map((response: Response) => {
 | 
			
		||||
        // login successful if there's a jwt token in the response
 | 
			
		||||
        let user = response.json();
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ export class LoginService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  signUp(username: string, password: string, secret: string) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiSignupPath, {username: username, password: password, secret: secret})
 | 
			
		||||
    return this.http.post(this.config.apiSignupPath, {username: username, password: password, secret: secret})
 | 
			
		||||
      .map((response: Response) => {
 | 
			
		||||
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,7 +13,7 @@ export class PromotionService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getUnconfirmedPromotions(fraction?: string) {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiPromotionPath + '?inProgress=true&fractFilter=' + fraction)
 | 
			
		||||
    return this.http.get(this.config.apiPromotionPath + '?inProgress=true&fractFilter=' + fraction)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -26,21 +26,21 @@ export class PromotionService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getSquadPromotions(squadId: string) {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiPromotionPath + '?squadId=' + squadId)
 | 
			
		||||
    return this.http.get(this.config.apiPromotionPath + '?squadId=' + squadId)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  requestPromotion(promotion: Promotion) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiPromotionPath, promotion)
 | 
			
		||||
    return this.http.post(this.config.apiPromotionPath, promotion)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  updatePromotion(promotion) {
 | 
			
		||||
    return this.http.patch(this.config.apiUrl + this.config.apiPromotionPath + '/' + promotion._id, promotion)
 | 
			
		||||
    return this.http.patch(this.config.apiPromotionPath + '/' + promotion._id, promotion)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deletePromotion(promotionId) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiPromotionPath + promotionId)
 | 
			
		||||
    return this.http.delete(this.config.apiPromotionPath + promotionId)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ export class RankService {
 | 
			
		|||
      searchParams.append('fractFilter', fractionFilter);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.http.get(this.config.apiUrl + this.config.apiRankPath, searchParams)
 | 
			
		||||
    this.http.get(this.config.apiRankPath, searchParams)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do((ranks) => {
 | 
			
		||||
        this.rankStore.dispatch({type: LOAD, data: ranks});
 | 
			
		||||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ export class RankService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getRank(id: number | string): Observable<Decoration> {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiRankPath + id)
 | 
			
		||||
    return this.http.get(this.config.apiRankPath + id)
 | 
			
		||||
      .map(res => res.json());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,7 +47,7 @@ export class RankService {
 | 
			
		|||
   * update existing with patch PATCH
 | 
			
		||||
   */
 | 
			
		||||
  submitRank(rank: Rank, imageFile?) {
 | 
			
		||||
    let requestUrl = this.config.apiUrl + this.config.apiRankPath;
 | 
			
		||||
    let requestUrl = this.config.apiRankPath;
 | 
			
		||||
    let requestMethod: RequestMethod;
 | 
			
		||||
    let accessType;
 | 
			
		||||
    let body;
 | 
			
		||||
| 
						 | 
				
			
			@ -102,7 +102,7 @@ export class RankService {
 | 
			
		|||
      method: RequestMethod.Patch
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    return this.http.request(this.config.apiUrl + this.config.apiRankPath + rank._id, options)
 | 
			
		||||
    return this.http.request(this.config.apiRankPath + rank._id, options)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do(savedRank => {
 | 
			
		||||
        const action = {type: EDIT, data: savedRank};
 | 
			
		||||
| 
						 | 
				
			
			@ -124,7 +124,7 @@ export class RankService {
 | 
			
		|||
 | 
			
		||||
    // provide token as query value, because there is no actual body
 | 
			
		||||
    // and x-access-token is ignored in multipart request
 | 
			
		||||
    return this.http.patch(this.config.apiUrl + this.config.apiRankPath + rankId, formData)
 | 
			
		||||
    return this.http.patch(this.config.apiRankPath + rankId, formData)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do(savedDecoration => {
 | 
			
		||||
        const action = {type: EDIT, data: savedDecoration};
 | 
			
		||||
| 
						 | 
				
			
			@ -133,7 +133,7 @@ export class RankService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  deleteRank(rank: Rank) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiRankPath + rank._id)
 | 
			
		||||
    return this.http.delete(this.config.apiRankPath + rank._id)
 | 
			
		||||
      .do(res => {
 | 
			
		||||
        this.rankStore.dispatch({type: REMOVE, data: rank});
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ export class SquadService {
 | 
			
		|||
    searchParams.append('q', query);
 | 
			
		||||
    searchParams.append('fractFilter', fractionFilter);
 | 
			
		||||
 | 
			
		||||
    this.http.get(this.config.apiUrl + this.config.apiSquadPath, searchParams)
 | 
			
		||||
    this.http.get(this.config.apiSquadPath, searchParams)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do((squads) => {
 | 
			
		||||
        this.squadStore.dispatch({type: LOAD, data: squads});
 | 
			
		||||
| 
						 | 
				
			
			@ -35,7 +35,7 @@ export class SquadService {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
  getSquad(id: number | string): Observable<Squad> {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiSquadPath + id)
 | 
			
		||||
    return this.http.get(this.config.apiSquadPath + id)
 | 
			
		||||
      .map(res => res.json());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ export class SquadService {
 | 
			
		|||
   * update existing with patch PATCH
 | 
			
		||||
   */
 | 
			
		||||
  submitSquad(squad: Squad, imageFile?) {
 | 
			
		||||
    let requestUrl = this.config.apiUrl + this.config.apiSquadPath;
 | 
			
		||||
    let requestUrl = this.config.apiSquadPath;
 | 
			
		||||
    let requestMethod: RequestMethod;
 | 
			
		||||
    let accessType;
 | 
			
		||||
    let body;
 | 
			
		||||
| 
						 | 
				
			
			@ -85,7 +85,7 @@ export class SquadService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  deleteSquad(squad: Squad) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiSquadPath + squad._id)
 | 
			
		||||
    return this.http.delete(this.config.apiSquadPath + squad._id)
 | 
			
		||||
      .do(res => {
 | 
			
		||||
        this.squadStore.dispatch({type: REMOVE, data: squad});
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,7 +26,7 @@ export class UserService {
 | 
			
		|||
    if (squadFilter) {
 | 
			
		||||
      searchParams.append('squadId', squadFilter);
 | 
			
		||||
    }
 | 
			
		||||
    this.http.get(this.config.apiUrl + this.config.apiUserPath, searchParams)
 | 
			
		||||
    this.http.get(this.config.apiUserPath, searchParams)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do((users) => {
 | 
			
		||||
        this.userStore.dispatch({type: LOAD, data: users});
 | 
			
		||||
| 
						 | 
				
			
			@ -37,12 +37,12 @@ export class UserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getUser(_id: number | string): Observable<User> {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiUserPath + _id)
 | 
			
		||||
    return this.http.get(this.config.apiUserPath + _id)
 | 
			
		||||
      .map(res => res.json());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  submitUser(user) {
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiUserPath, user)
 | 
			
		||||
    return this.http.post(this.config.apiUserPath, user)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do(savedUser => {
 | 
			
		||||
        const action = {type: ADD, data: savedUser};
 | 
			
		||||
| 
						 | 
				
			
			@ -51,7 +51,7 @@ export class UserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  updateUser(user) {
 | 
			
		||||
    return this.http.put(this.config.apiUrl + this.config.apiUserPath + user._id, user)
 | 
			
		||||
    return this.http.put(this.config.apiUserPath + user._id, user)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
      .do(savedUser => {
 | 
			
		||||
        const action = {type: EDIT, data: savedUser};
 | 
			
		||||
| 
						 | 
				
			
			@ -60,7 +60,7 @@ export class UserService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  deleteUser(user) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiUserPath + user._id)
 | 
			
		||||
    return this.http.delete(this.config.apiUserPath + user._id)
 | 
			
		||||
      .do(res => {
 | 
			
		||||
        this.userStore.dispatch({type: REMOVE, data: user});
 | 
			
		||||
      });
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -11,12 +11,12 @@ export class WarService {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  getAllWars() {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiWarPath)
 | 
			
		||||
    return this.http.get(this.config.apiWarPath)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getWar(warId: string) {
 | 
			
		||||
    return this.http.get(this.config.apiUrl + this.config.apiWarPath + '/' + warId)
 | 
			
		||||
    return this.http.get(this.config.apiWarPath + '/' + warId)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -34,12 +34,12 @@ export class WarService {
 | 
			
		|||
      body.append('log', logFile, logFile.name);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return this.http.post(this.config.apiUrl + this.config.apiWarPath, body)
 | 
			
		||||
    return this.http.post(this.config.apiWarPath, body)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  deleteWar(id: string) {
 | 
			
		||||
    return this.http.delete(this.config.apiUrl + this.config.apiWarPath + '/' + id)
 | 
			
		||||
    return this.http.delete(this.config.apiWarPath + '/' + id)
 | 
			
		||||
      .map(res => res.json())
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue