Fix public folder api path; Add Army Overview

pull/1/head
Florian Hartwich 2017-05-11 21:46:28 +02:00
parent e7c6379bf1
commit efd9dde6aa
13 changed files with 224 additions and 52 deletions

11
README.md Normal file
View File

@ -0,0 +1,11 @@
#Operation Pandora Trigger Commandcenter
_RESTful API using express.js and mongoose with mongodb + Angular4 Frontend_
##Installation
##Development
##License Information

View File

@ -1,8 +0,0 @@
#Operation Pandora Trigger Commandcenter RESTful API
_node.js project using express.js and mongoose with mongodb_
##Installation

View File

@ -35,8 +35,8 @@ mongoose.Promise = global.Promise;
const app = express();
// Middlewares *************************************************
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(express.static(path.join(__dirname, 'public')));
app.use(favicon(path.join(__dirname + '/..', 'public', 'favicon.ico')));
app.use(express.static(path.join(__dirname + '/..', 'public')));
app.use(bodyParser.json());
// logging
@ -63,7 +63,7 @@ app.use(urls.command, apiAuthenticationMiddleware, commandRouter);
// send index.html on all different paths
app.use(function (req, res) {
res.sendFile("public/index.html", {root: __dirname});
res.sendFile("public/index.html", {root: __dirname + '/..'});
});

View File

@ -1,34 +1,34 @@
server {
listen 80;
server_name cc.noarch.de;
return 302 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name cc.noarch.de;
ssl on;
ssl_certificate /etc/letsencrypt/live/noarch.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/noarch.de/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
location / {
gzip off;
proxy_set_header X-Forwarded-Ssl on;
client_max_body_size 5M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://localhost:8091;
}
}
listen 80;
server_name cc.noarch.de;
return 302 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name cc.noarch.de;
ssl on;
ssl_certificate /etc/letsencrypt/live/noarch.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/noarch.de/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
location / {
gzip off;
proxy_set_header X-Forwarded-Ssl on;
client_max_body_size 5M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://localhost:8091;
}
}

View File

@ -15,6 +15,9 @@
<div class="collapse navbar-collapse" id="mynavbar">
<ul class="nav navbar-nav">
<li *ngIf="loginService.isLoggedIn()" routerLinkActive="active">
<a routerLink='/cc-overview' class="link">Armeeübersicht</a>
</li>
<li *ngIf="loginService.isLoggedIn()" routerLinkActive="active">
<a routerLink='/cc-users' class="link">Teilnehmer</a>
</li>
@ -27,9 +30,6 @@
<li *ngIf="loginService.isLoggedIn()" routerLinkActive="active">
<a routerLink='/cc-ranks' class="link">Ränge</a>
</li>
<!--<li routerLinkActive="active">-->
<!--<a routerLink='/settings' class="link">Einstellungen</a>-->
<!--</li>-->
</ul>
<ul class="nav navbar-nav" style="float: right">

View File

@ -10,6 +10,7 @@ export class AppConfig {
public readonly apiRankPath = '/ranks/';
public readonly apiSquadPath = '/squads/';
public readonly apiUserPath = '/users/';
public readonly apiOverviewPath = '/overview';
public getAuthenticationHeader() :Headers {
let currentUser = JSON.parse(localStorage.getItem('currentUser'));

View File

@ -25,6 +25,7 @@ import {AppConfig} from "./app.config";
import {LoginGuard} 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";
@NgModule({
imports: [BrowserModule, FormsModule, ReactiveFormsModule, appRouting, HttpModule],
@ -32,6 +33,7 @@ import {HttpClient} from "./services/http-client";
HttpClient,
LoginService,
LoginGuard,
ArmyService,
UserService,
UserStore,
SquadService,

View File

@ -6,10 +6,13 @@ import {usersRoutes, usersRoutingComponents} from "./users/users.routing";
import {squadsRoutes, squadsRoutingComponents} from "./squads/squads.routing";
import {decorationsRoutes, decorationsRoutingComponents} from "./decorations/decoration.routing";
import {ranksRoutes, ranksRoutingComponents} from "./ranks/ranks.routing";
import {ArmyComponent} from "./army/army.component";
export const appRoutes: Routes = [
{path: 'cc-overview', component: ArmyComponent},
{path: 'login', component: LoginComponent},
{path: 'cc-users', children: usersRoutes, canActivate: [LoginGuard]},
{path: '', redirectTo: '/cc-users', pathMatch: 'full'},
@ -18,18 +21,14 @@ export const appRoutes: Routes = [
{path: 'cc-decorations', children: decorationsRoutes, canActivate: [LoginGuard]},
{path: 'cc-ranks', children: ranksRoutes, canActivate: [LoginGuard]},
/** Redirect Konfigurationen **/
{path: '404', component: NotFoundComponent},
{path: '**', redirectTo: '/404'}, // immer als letztes konfigurieren - erste Route die matched wird angesteuert
];
export const appRouting = RouterModule.forRoot(appRoutes);
export const routingComponents = [LoginComponent, NotFoundComponent, ...usersRoutingComponents,
export const routingComponents = [LoginComponent, ArmyComponent, NotFoundComponent, ...usersRoutingComponents,
...squadsRoutingComponents, ...decorationsRoutingComponents, ...ranksRoutingComponents];
export const routingProviders = [LoginGuard];

View File

@ -0,0 +1,32 @@
h1 {
width: 920px;
float: left;
margin-bottom: 50px;
}
img{
margin-top: 10px;
padding-right: 30px;
}
.div-table {
display: table;
border-radius: 10px;
margin-left: 1%;
width: auto;
background-color: rgba(240, 248, 255, 0.29);
border-spacing: 5px; /* cellspacing:poor IE support for this */
}
.div-table-row {
display: table-row;
width: auto;
clear: both;
}
.div-table-col {
float: left; /* fix for buggy browsers */
display: table-column;
padding: 5px 15px 5px 15px;
}

View File

@ -0,0 +1,61 @@
<h1>Übersicht über alle Spieler, Squads und Armeen</h1>
<div style="width: 1000px;">
<div class="div-table" style="width: 490px; float:left">
<h3 style="color: darkslateblue; font-weight: bolder; text-align: center;">NATO</h3>
<div *ngFor="let squad of army.NATO.squads">
<div class="div-table-row">
<div class="div-table-col">
<img src="resource/squad/{{squad._id}}.png">
</div>
<div class="div-table-col">
<div class=" div-table-row">
<h4>{{squad.name}}</h4>
</div>
<div class=" div-table-row">
<div *ngFor="let member of squad.members">
<div>{{member.rank}} {{member.username}}</div>
</div>
<br>
<br>
Mitglieder: {{squad.memberCount}}
</div>
</div>
</div>
</div>
<br>
<br>
<div style="padding-left: 80px">Armeemitglieder: {{army.NATO.memberCount}}</div>
</div>
<div class="div-table" style="width: 490px; float:right">
<h3 style="color: firebrick; font-weight: bolder; text-align: center">CSAT</h3>
<div *ngFor="let squad of army.CSAT.squads">
<div class="div-table-row">
<div class="div-table-col">
<img src="resource/squad/{{squad._id}}.png">
</div>
<div class="div-table-col">
<div class=" div-table-row">
<h4>{{squad.name}}</h4>
</div>
<div class=" div-table-row">
<div *ngFor="let member of squad.members">
<div>{{member.rank}} {{member.username}}</div>
</div>
<br>
<br>
Mitglieder: {{squad.memberCount}}
</div>
</div>
</div>
</div>
<br>
<br>
<div style="padding-left: 80px">Armeemitglieder: {{army.CSAT.memberCount}}</div>
</div>
</div>

View File

@ -0,0 +1,26 @@
import {Component} from "@angular/core";
import {Army} from "../models/model-interfaces";
import {ArmyService} from "../services/army-service/army.service";
@Component({
selector: 'army',
templateUrl: './army.component.html',
styleUrls: ['./army.component.css']
})
export class ArmyComponent {
army: Army = {NATO: {squads: [], memberCount: 0}, CSAT: {squads: [], memberCount:0}};
constructor(private armyService: ArmyService) {
}
ngOnInit() {
this.armyService.getArmy()
.subscribe(army => {
this.army = army;
console.log(army)
});
};
}

View File

@ -39,6 +39,35 @@ export interface Decoration {
isMedal?: boolean;
}
export interface Army {
NATO: {
squads: {
_id,
name,
memberCount,
members: {
_id,
username,
rank
}[],
}[],
memberCount
},
CSAT: {
squads: {
_id,
name,
memberCount,
members: {
_id,
username,
rank
}[],
}[],
memberCount
},
}
export interface Tag {
label: string;
}

View File

@ -0,0 +1,19 @@
import {Injectable} from "@angular/core";
import {AppConfig} from "../../app.config";
import {Http} from "@angular/http";
@Injectable()
export class ArmyService {
constructor(private http: Http,
private config: AppConfig) {
}
getArmy() {
return this.http.get(this.config.apiUrl + this.config.apiOverviewPath)
.map(res => res.json());
}
}