Merge branch 'task/differ-api-and-app-routes' of hardi/opt-cc into master

pull/5/head v1.3.0
hardi 2017-08-05 09:37:31 +02:00 committed by HardiReady
commit 33c465aeb6
20 changed files with 149 additions and 116 deletions

View File

@ -1,16 +1,18 @@
const rootRoute = '/api';
module.exports = { module.exports = {
auth: '/authenticate', auth: rootRoute + '/authenticate',
signUp: '/authenticate/signup', signUp: rootRoute + '/authenticate/signup',
awards: '/awardings', awards: rootRoute + '/awardings',
command: '/cmd', command: rootRoute + '/cmd',
cmdCreateSig: '/cmd/createSignature', cmdCreateSig: rootRoute + '/cmd/createSignature',
decorations: '/decorations', decorations: rootRoute + '/decorations',
overview: '/overview', overview: rootRoute + '/overview',
ranks: '/ranks', ranks: rootRoute + '/ranks',
signatures: '/signatures', signatures: rootRoute + '/signatures',
squads: '/squads', squads: rootRoute + '/squads',
users: '/users', users: rootRoute + '/users',
account: '/account', account: rootRoute + '/account',
request: '/request', request: rootRoute + '/request',
wars: '/wars' wars: rootRoute + '/wars'
}; };

View File

@ -103,21 +103,29 @@ errorResponseWare(app);
// Start the server // Start the server
if (process.env.NODE_ENV !== config.test.env) { if (process.env.NODE_ENV !== config.test.env) {
mongoose.connect(config.database.uri + config.database.db); const mongoosePromise = mongoose.connect(config.database.uri + config.database.db, {
app.listen(config.port, (err) => { useMongoClient: true
if (err !== undefined) {
debug('Error on startup, ', err);
}
else {
debug('Listening on port ' + config.port);
signatureCronJob.start();
backupCronJob.start();
}
}); });
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 { } else {
mongoose.connect(config.database.uri + config.test.db); const mongoosePromise = mongoose.connect(config.database.uri + config.test.db, {
app.listen(config.test.port); useMongoClient: true
console.log('Listening on port ' + config.test.port); });
mongoosePromise.then((db) => {
app.listen(config.test.port);
console.log('Listening on port ' + config.test.port);
})
} }
module.exports = app; module.exports = app;

View File

@ -16,10 +16,10 @@
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active"> <li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
<a routerLink='/login' class="link">Login</a> <a routerLink='{{config.loginPath}}' class="link">Login</a>
</li> </li>
<li routerLinkActive="active"> <li routerLinkActive="active">
<a routerLink='/cc-overview' class="link">Armeeübersicht</a> <a routerLink='{{config.overviewPath}}' class="link">Armeeübersicht</a>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
@ -29,29 +29,29 @@
</a> </a>
<ul class="dropdown-menu scrollable-menu"> <ul class="dropdown-menu scrollable-menu">
<li *ngIf="loginService.hasPermission(3)"> <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>
<li> <li>
<a routerLink='/cc-statistic' class="link">Übersicht</a> <a routerLink='{{config.statsPath}}' class="link">Übersicht</a>
</li> </li>
<li *ngFor="let war of wars"> <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> <small>{{war.date | date: 'dd.MM.yy'}}</small>
</a> </a>
</li> </li>
</ul> </ul>
</li> </li>
<li *ngIf="loginService.hasPermission(2)" routerLinkActive="active"> <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>
<li *ngIf="loginService.hasPermission(2)" routerLinkActive="active"> <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>
<li *ngIf="loginService.hasPermission(2)" routerLinkActive="active"> <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>
<li *ngIf="loginService.hasPermission(2)" routerLinkActive="active"> <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>
<li *ngIf="loginService.hasPermission(1) && !loginService.hasPermission(2) && loginService.hasSquad()" <li *ngIf="loginService.hasPermission(1) && !loginService.hasPermission(2) && loginService.hasSquad()"
class="dropdown"> class="dropdown">
@ -62,10 +62,10 @@
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
<a [routerLink]="['/request-promotion']">Beförderung</a> <a routerLink="{{config.requestPromotionPath}}">Beförderung</a>
</li> </li>
<li> <li>
<a [routerLink]="['/request-award']">Orden/ Auszeichnung</a> <a routerLink="{{config.requestAwardPath}}">Orden/ Auszeichnung</a>
</li> </li>
</ul> </ul>
</li> </li>
@ -77,10 +77,10 @@
</a> </a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <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>
<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> </li>
</ul> </ul>
</li> </li>
@ -88,7 +88,7 @@
<ul class="nav navbar-nav" style="float: right"> <ul class="nav navbar-nav" style="float: right">
<li *ngIf="loginService.hasPermission(4)" routerLinkActive="active"> <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>
<li *ngIf="authEnabled" class="link" style="cursor: pointer"> <li *ngIf="authEnabled" class="link" style="cursor: pointer">
<a *ngIf="loginService.isLoggedIn()" (click)="logout()">Abmelden</a> <a *ngIf="loginService.isLoggedIn()" (click)="logout()">Abmelden</a>

View File

@ -1,11 +1,12 @@
import {Component, Inject, Optional} from '@angular/core'; 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 {LoginService} from './services/login-service/login-service';
import {AUTH_ENABLED} from './app.tokens'; import {AUTH_ENABLED} from './app.tokens';
import {WarService} from "./services/war-service/war.service"; import {WarService} from "./services/war-service/war.service";
import {War} from "./models/model-interfaces"; import {War} from "./models/model-interfaces";
import {PromotionService} from "./services/promotion-service/promotion.service"; import {PromotionService} from "./services/promotion-service/promotion.service";
import {AwardingService} from "./services/awarding-service/awarding.service"; import {AwardingService} from "./services/awarding-service/awarding.service";
import {RouteConfig} from "./app.config";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -16,6 +17,8 @@ export class AppComponent {
wars: War[] = []; wars: War[] = [];
config = RouteConfig;
constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled, constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled,
private loginService: LoginService, private loginService: LoginService,
private warService: WarService, private warService: WarService,
@ -38,7 +41,7 @@ export class AppComponent {
logout() { logout() {
this.loginService.logout(); this.loginService.logout();
this.router.navigate(['cc-overview']); this.router.navigate([RouteConfig.overviewPath]);
return false; return false;
} }

View File

@ -1,19 +1,36 @@
export class AppConfig { export class AppConfig {
public readonly apiUrl = ''; public readonly apiUrl = '/api';
public readonly apiAppUserPath = '/account/'; public readonly apiAppUserPath = this.apiUrl + '/account/';
public readonly apiAwardPath = '/awardings'; public readonly apiAwardPath = this.apiUrl + '/awardings';
public readonly apiDecorationPath = '/decorations/'; public readonly apiDecorationPath = this.apiUrl + '/decorations/';
public readonly apiAuthenticationPath = '/authenticate'; public readonly apiAuthenticationPath = this.apiUrl + '/authenticate';
public readonly apiSignupPath = '/authenticate/signup'; public readonly apiSignupPath = this.apiUrl + '/authenticate/signup';
public readonly apiRankPath = '/ranks/'; public readonly apiRankPath = this.apiUrl + '/ranks/';
public readonly apiSquadPath = '/squads/'; public readonly apiSquadPath = this.apiUrl + '/squads/';
public readonly apiUserPath = '/users/'; public readonly apiUserPath = this.apiUrl + '/users/';
public readonly apiOverviewPath = '/overview'; public readonly apiOverviewPath = this.apiUrl + '/overview';
public readonly apiRequestAwardPath = '/request/award'; public readonly apiRequestAwardPath = this.apiUrl + '/request/award';
public readonly apiPromotionPath = '/request/promotion'; public readonly apiPromotionPath = this.apiUrl + '/request/promotion';
public readonly apiWarPath = '/wars'; 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'
}

View File

@ -15,30 +15,30 @@ import {ConfirmPromotionComponent} from "./request/confirm-promotion/confirm-pro
import {ConfirmAwardComponent} from "./request/confirm-award/confirm-award.component"; import {ConfirmAwardComponent} from "./request/confirm-award/confirm-award.component";
import {warRoutes, warsRoutingComponents} from "./wars/wars.routing"; import {warRoutes, warsRoutingComponents} from "./wars/wars.routing";
import {StatisticComponent} from "./statistic/statistic.component"; import {StatisticComponent} from "./statistic/statistic.component";
import {RouteConfig} from "./app.config";
export const appRoutes: Routes = [ export const appRoutes: Routes = [
{path: 'cc-overview', children: armyRoutes}, {path: RouteConfig.overviewPath, children: armyRoutes},
{path: '', redirectTo: '/cc-overview', pathMatch: 'full'}, {path: '', redirectTo: RouteConfig.overviewPath, pathMatch: 'full'},
{path: 'cc-wars', children: warRoutes}, {path: RouteConfig.warPath, children: warRoutes},
{path: 'cc-statistic', component: StatisticComponent}, {path: RouteConfig.statsPath, component: StatisticComponent},
{path: 'login', component: LoginComponent}, {path: RouteConfig.loginPath, component: LoginComponent},
{path: 'signup', component: SignupComponent}, {path: RouteConfig.signUpPath, component: SignupComponent},
{path: 'request-award', component: RequestAwardComponent, canActivate: [LoginGuardSQL]}, {path: RouteConfig.requestAwardPath, component: RequestAwardComponent, canActivate: [LoginGuardSQL]},
{path: 'request-promotion', component: RequestPromotionComponent, canActivate: [LoginGuardSQL]}, {path: RouteConfig.requestPromotionPath, component: RequestPromotionComponent, canActivate: [LoginGuardSQL]},
{path: 'confirm-award', component: ConfirmAwardComponent, canActivate: [LoginGuardHL]}, {path: RouteConfig.confirmAwardPath, component: ConfirmAwardComponent, canActivate: [LoginGuardHL]},
{path: 'confirm-promotion', component: ConfirmPromotionComponent, canActivate: [LoginGuardHL]}, {path: RouteConfig.confirmPromotionPath, component: ConfirmPromotionComponent, canActivate: [LoginGuardHL]},
{path: 'cc-users', children: usersRoutes, canActivate: [LoginGuardHL]}, {path: RouteConfig.userPath, children: usersRoutes, canActivate: [LoginGuardHL]},
{path: 'cc-squads', children: squadsRoutes, canActivate: [LoginGuardHL]}, {path: RouteConfig.squadPath, children: squadsRoutes, canActivate: [LoginGuardHL]},
{path: 'cc-decorations', children: decorationsRoutes, canActivate: [LoginGuardHL]}, {path: RouteConfig.decorationPath, children: decorationsRoutes, canActivate: [LoginGuardHL]},
{path: 'cc-ranks', children: ranksRoutes, 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 **/ /** Redirect Konfigurationen **/
{path: '404', component: NotFoundComponent}, {path: '404', component: NotFoundComponent},

View File

@ -10,7 +10,7 @@
<div class="overview"> <div class="overview">
<div> <div>
<img style="margin-left: 13%;" src="/signatures/{{user.username}}"> <img style="margin-left: 13%;" src="resource/signature/{{user._id}}.png">
</div> </div>
<div class="input-group" style="width: 662px; margin-left: 13%;"> <div class="input-group" style="width: 662px; margin-left: 13%;">
<input type="text" style="background: white;" class="form-control" [(ngModel)]="signatureUrl" readonly> <input type="text" style="background: white;" class="form-control" [(ngModel)]="signatureUrl" readonly>

View File

@ -3,6 +3,7 @@ import {User} from "../models/model-interfaces";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {UserService} from "../services/user-service/user.service"; import {UserService} from "../services/user-service/user.service";
import {Subscription} from "rxjs/Subscription"; import {Subscription} from "rxjs/Subscription";
import {AppConfig, RouteConfig} from "../app.config";
@Component({ @Component({
@ -38,7 +39,7 @@ export class ArmyMemberComponent {
}; };
backToOverview() { backToOverview() {
this.router.navigate(['cc-overview']); this.router.navigate([RouteConfig.overviewPath]);
} }
} }

View File

@ -1,6 +1,7 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnInit} from "@angular/core";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import {LoginService} from "../services/login-service/login-service"; import {LoginService} from "../services/login-service/login-service";
import {RouteConfig} from "../app.config";
@Component({ @Component({
@ -27,7 +28,7 @@ export class LoginComponent implements OnInit {
// reset login status // reset login status
this.loginService.logout(); this.loginService.logout();
// redirect on success // redirect on success
this.returnUrl = '/cc-overview' this.returnUrl = RouteConfig.overviewPath;
} }
login(username: string, password: string) { login(username: string, password: string) {

View File

@ -1,6 +1,7 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnInit} from "@angular/core";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {LoginService} from "../services/login-service/login-service"; import {LoginService} from "../services/login-service/login-service";
import {RouteConfig} from "../app.config";
@Component({ @Component({
@ -30,7 +31,7 @@ export class SignupComponent implements OnInit {
// reset login status // reset login status
this.loginService.logout(); this.loginService.logout();
// redirect on success // redirect on success
this.returnUrl = '/cc-overview' this.returnUrl = RouteConfig.overviewPath;
} }
login(username: string, password: string, secret: string) { login(username: string, password: string, secret: string) {

View File

@ -19,7 +19,7 @@ export class AppUserService {
} }
getUsers() { getUsers() {
this.http.get(this.config.apiUrl + this.config.apiAppUserPath) this.http.get(this.config.apiAppUserPath)
.map(res => res.json()) .map(res => res.json())
.do((users) => { .do((users) => {
this.appUserStore.dispatch({type: LOAD, data: users}); this.appUserStore.dispatch({type: LOAD, data: users});
@ -30,7 +30,7 @@ export class AppUserService {
} }
updateUser(user: AppUser) { 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()) .map(res => res.json())
.do(savedUser => { .do(savedUser => {
const action = {type: EDIT, data: savedUser}; const action = {type: EDIT, data: savedUser};
@ -39,7 +39,7 @@ export class AppUserService {
} }
deleteUser(user) { 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 => { .do(res => {
this.appUserStore.dispatch({type: REMOVE, data: user}); this.appUserStore.dispatch({type: REMOVE, data: user});
}); });

View File

@ -11,7 +11,7 @@ export class ArmyService {
} }
getArmy() { getArmy() {
return this.http.get(this.config.apiUrl + this.config.apiOverviewPath) return this.http.get(this.config.apiOverviewPath)
.map(res => res.json()); .map(res => res.json());
} }

View File

@ -13,7 +13,7 @@ export class AwardingService {
} }
getUnconfirmedAwards(fraction?: string) { 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()) .map(res => res.json())
} }
@ -29,25 +29,25 @@ export class AwardingService {
* get awards array with populated decorations * get awards array with populated decorations
*/ */
getUserAwardings(userId: string) { 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()) .map(res => res.json())
} }
addAwarding(award: Award) { addAwarding(award: Award) {
return this.http.post(this.config.apiUrl + this.config.apiAwardPath, award) return this.http.post(this.config.apiAwardPath, award)
} }
updateAward(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()) .map(res => res.json())
} }
requestAwarding(award: Award) { requestAwarding(award: Award) {
return this.http.post(this.config.apiUrl + this.config.apiRequestAwardPath, award) return this.http.post(this.config.apiRequestAwardPath, award)
} }
deleteAwarding(awardingId) { deleteAwarding(awardingId) {
return this.http.delete(this.config.apiUrl + this.config.apiAwardPath + '/' + awardingId) return this.http.delete(this.config.apiAwardPath + '/' + awardingId)
} }
} }

View File

@ -26,7 +26,7 @@ export class DecorationService {
searchParams.append('fractFilter', fractionFilter); 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()) .map(res => res.json())
.do((squads) => { .do((squads) => {
this.decorationStore.dispatch({type: LOAD, data: squads}); this.decorationStore.dispatch({type: LOAD, data: squads});
@ -37,7 +37,7 @@ export class DecorationService {
} }
getDecoration(id: number | string): Observable<Decoration> { 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()); .map(res => res.json());
} }
@ -46,7 +46,7 @@ export class DecorationService {
* update existing with patch PATCH * update existing with patch PATCH
*/ */
submitDecoration(decoration: Decoration, imageFile?) { submitDecoration(decoration: Decoration, imageFile?) {
let requestUrl = this.config.apiUrl + this.config.apiDecorationPath; let requestUrl = this.config.apiDecorationPath;
let requestMethod: RequestMethod; let requestMethod: RequestMethod;
let accessType; let accessType;
let body; let body;
@ -88,7 +88,7 @@ export class DecorationService {
deleteDecoration(decoration: Decoration) { 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 => { .do(res => {
this.decorationStore.dispatch({type: REMOVE, data: decoration}); this.decorationStore.dispatch({type: REMOVE, data: decoration});
}); });

View File

@ -18,7 +18,7 @@ export class LoginService {
} }
login(username: string, password: string) { 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) => { .map((response: Response) => {
// login successful if there's a jwt token in the response // login successful if there's a jwt token in the response
let user = response.json(); let user = response.json();
@ -35,7 +35,7 @@ export class LoginService {
} }
signUp(username: string, password: string, secret: string) { 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) => { .map((response: Response) => {
}); });

View File

@ -13,7 +13,7 @@ export class PromotionService {
} }
getUnconfirmedPromotions(fraction?: string) { 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()) .map(res => res.json())
} }
@ -26,21 +26,21 @@ export class PromotionService {
} }
getSquadPromotions(squadId: string) { 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()) .map(res => res.json())
} }
requestPromotion(promotion: Promotion) { requestPromotion(promotion: Promotion) {
return this.http.post(this.config.apiUrl + this.config.apiPromotionPath, promotion) return this.http.post(this.config.apiPromotionPath, promotion)
} }
updatePromotion(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()) .map(res => res.json())
} }
deletePromotion(promotionId) { deletePromotion(promotionId) {
return this.http.delete(this.config.apiUrl + this.config.apiPromotionPath + promotionId) return this.http.delete(this.config.apiPromotionPath + promotionId)
} }
} }

View File

@ -27,7 +27,7 @@ export class RankService {
searchParams.append('fractFilter', fractionFilter); 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()) .map(res => res.json())
.do((ranks) => { .do((ranks) => {
this.rankStore.dispatch({type: LOAD, data: ranks}); this.rankStore.dispatch({type: LOAD, data: ranks});
@ -38,7 +38,7 @@ export class RankService {
} }
getRank(id: number | string): Observable<Decoration> { 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()); .map(res => res.json());
} }
@ -47,7 +47,7 @@ export class RankService {
* update existing with patch PATCH * update existing with patch PATCH
*/ */
submitRank(rank: Rank, imageFile?) { submitRank(rank: Rank, imageFile?) {
let requestUrl = this.config.apiUrl + this.config.apiRankPath; let requestUrl = this.config.apiRankPath;
let requestMethod: RequestMethod; let requestMethod: RequestMethod;
let accessType; let accessType;
let body; let body;
@ -102,7 +102,7 @@ export class RankService {
method: RequestMethod.Patch 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()) .map(res => res.json())
.do(savedRank => { .do(savedRank => {
const action = {type: EDIT, data: 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 // provide token as query value, because there is no actual body
// and x-access-token is ignored in multipart request // 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()) .map(res => res.json())
.do(savedDecoration => { .do(savedDecoration => {
const action = {type: EDIT, data: savedDecoration}; const action = {type: EDIT, data: savedDecoration};
@ -133,7 +133,7 @@ export class RankService {
} }
deleteRank(rank: Rank) { 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 => { .do(res => {
this.rankStore.dispatch({type: REMOVE, data: rank}); this.rankStore.dispatch({type: REMOVE, data: rank});
}); });

View File

@ -23,7 +23,7 @@ export class SquadService {
searchParams.append('q', query); searchParams.append('q', query);
searchParams.append('fractFilter', fractionFilter); 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()) .map(res => res.json())
.do((squads) => { .do((squads) => {
this.squadStore.dispatch({type: LOAD, data: squads}); this.squadStore.dispatch({type: LOAD, data: squads});
@ -35,7 +35,7 @@ export class SquadService {
getSquad(id: number | string): Observable<Squad> { 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()); .map(res => res.json());
} }
@ -45,7 +45,7 @@ export class SquadService {
* update existing with patch PATCH * update existing with patch PATCH
*/ */
submitSquad(squad: Squad, imageFile?) { submitSquad(squad: Squad, imageFile?) {
let requestUrl = this.config.apiUrl + this.config.apiSquadPath; let requestUrl = this.config.apiSquadPath;
let requestMethod: RequestMethod; let requestMethod: RequestMethod;
let accessType; let accessType;
let body; let body;
@ -85,7 +85,7 @@ export class SquadService {
} }
deleteSquad(squad: Squad) { 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 => { .do(res => {
this.squadStore.dispatch({type: REMOVE, data: squad}); this.squadStore.dispatch({type: REMOVE, data: squad});
}); });

View File

@ -26,7 +26,7 @@ export class UserService {
if (squadFilter) { if (squadFilter) {
searchParams.append('squadId', 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()) .map(res => res.json())
.do((users) => { .do((users) => {
this.userStore.dispatch({type: LOAD, data: users}); this.userStore.dispatch({type: LOAD, data: users});
@ -37,12 +37,12 @@ export class UserService {
} }
getUser(_id: number | string): Observable<User> { 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()); .map(res => res.json());
} }
submitUser(user) { 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()) .map(res => res.json())
.do(savedUser => { .do(savedUser => {
const action = {type: ADD, data: savedUser}; const action = {type: ADD, data: savedUser};
@ -51,7 +51,7 @@ export class UserService {
} }
updateUser(user) { 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()) .map(res => res.json())
.do(savedUser => { .do(savedUser => {
const action = {type: EDIT, data: savedUser}; const action = {type: EDIT, data: savedUser};
@ -60,7 +60,7 @@ export class UserService {
} }
deleteUser(user) { 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 => { .do(res => {
this.userStore.dispatch({type: REMOVE, data: user}); this.userStore.dispatch({type: REMOVE, data: user});
}); });

View File

@ -11,12 +11,12 @@ export class WarService {
} }
getAllWars() { getAllWars() {
return this.http.get(this.config.apiUrl + this.config.apiWarPath) return this.http.get(this.config.apiWarPath)
.map(res => res.json()) .map(res => res.json())
} }
getWar(warId: string) { 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()) .map(res => res.json())
} }
@ -34,12 +34,12 @@ export class WarService {
body.append('log', logFile, logFile.name); 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()) .map(res => res.json())
} }
deleteWar(id: string) { 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()) .map(res => res.json())
} }