Add statistics menu dropdown

pull/1/head
Florian Hartwich 2017-07-08 22:50:01 +02:00
parent ee61271550
commit 8c3d944561
8 changed files with 33 additions and 6 deletions

View File

@ -4,6 +4,10 @@ const mongoose = require('mongoose');
const Schema = mongoose.Schema; const Schema = mongoose.Schema;
const WarSchema = new Schema({ const WarSchema = new Schema({
title: {
type: String,
required: true
},
date: { date: {
type: Date, type: Date,
required: true required: true

View File

@ -27,7 +27,7 @@ const wars = express.Router();
wars.route('/') wars.route('/')
.get((req, res, next) => { .get((req, res, next) => {
const filter = {}; const filter = {};
WarModel.find(filter, {}, {sort: {date: 'asc'}}, (err, items) => { WarModel.find(filter, {}, {sort: {date: 'desc'}}, (err, items) => {
if (err) { if (err) {
err.status = codes.servererror; err.status = codes.servererror;
return next(err); return next(err);

View File

@ -31,7 +31,7 @@ const awardingRouter = require('./routes/awardings');
const requestRouter = require('./routes/request'); const requestRouter = require('./routes/request');
const signatureRouter = require('./routes/signatures'); const signatureRouter = require('./routes/signatures');
const commandRouter = require('./routes/command'); const commandRouter = require('./routes/command');
const warRouter = require('./routes/war'); const warRouter = require('./routes/wars');
// Configuration *********************************** // Configuration ***********************************
// mongoose promise setup // mongoose promise setup

View File

@ -17,4 +17,4 @@ while IFS= read -r line; do
echo "$line" echo "$line"
echo "" echo ""
fi fi
done < <(grep -A 200 Scoreboard ${FILE} ) done < <(grep -A 100 Scoreboard ${FILE} )

View File

@ -21,6 +21,18 @@
<li routerLinkActive="active"> <li routerLinkActive="active">
<a routerLink='/cc-overview' class="link">Armeeübersicht</a> <a routerLink='/cc-overview' class="link">Armeeübersicht</a>
</li> </li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
aria-expanded="false">
Schlacht Statistik
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li *ngFor="let war of wars">
<a [routerLink]="['/cc-wars/' + war._id]">{{war.title}} <small>{{war.date | date: 'dd.MM.yy'}}</small></a>
</li>
</ul>
</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='/cc-users' class="link">Teilnehmer</a>
</li> </li>

View File

@ -7,6 +7,8 @@ import {
import {LoginService} from './services/login-service/login-service'; import {LoginService} from './services/login-service/login-service';
import {Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import {AUTH_ENABLED} from './app.tokens'; import {AUTH_ENABLED} from './app.tokens';
import {WarService} from "./services/war-service/war.service";
import {War} from "./models/model-interfaces";
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -17,8 +19,11 @@ export class AppComponent {
defaultTitle: string; defaultTitle: string;
wars: War[] = [];
constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled, constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled,
private loginService: LoginService, private loginService: LoginService,
private warService: WarService,
private activatedRoute: ActivatedRoute, private activatedRoute: ActivatedRoute,
private router: Router, private router: Router,
private titleService: Title) { private titleService: Title) {
@ -31,7 +36,11 @@ export class AppComponent {
.filter(event => event instanceof NavigationEnd) .filter(event => event instanceof NavigationEnd)
.subscribe(event => { .subscribe(event => {
this.setBrowserTitle(); this.setBrowserTitle();
});
this.warService.getAllWars().subscribe((wars) => {
this.wars = wars;
}) })
} }
setBrowserTitle() { setBrowserTitle() {

View File

@ -29,6 +29,7 @@ export interface Player {
} }
export interface War { export interface War {
_id?: string; _id?: string;
title?: string;
date?: Date; date?: Date;
ptBlufor?: number; ptBlufor?: number;
ptOpfor?: number; ptOpfor?: number;

View File

@ -1,7 +1,7 @@
<div class="overview" xmlns="http://www.w3.org/1999/html"> <div class="overview" xmlns="http://www.w3.org/1999/html">
<div style="margin-left: 5%"> <div style="margin-left: 5%">
<h2>Schlacht vom {{war.date | date: 'dd.MM.yyyy'}}</h2> <h2>{{war.title}} - Schlacht vom {{war.date | date: 'dd.MM.yyyy'}}</h2>
<h3 class="pull-left"> <h3 class="pull-left">
<h4>Endpunktestand:</h4> <h4>Endpunktestand:</h4>
<span class="text-blufor" style="font-weight: bold; margin-right: 10px">NATO {{war.ptBlufor}}</span> <span class="text-blufor" style="font-weight: bold; margin-right: 10px">NATO {{war.ptBlufor}}</span>
@ -9,7 +9,8 @@
<span class="text-opfor" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} CSAT</span> <span class="text-opfor" style="font-weight: bold; margin-left: 10px;">{{war.ptOpfor}} CSAT</span>
</h3> </h3>
<div style="margin-left: 50%; margin-top:5%"> <div style="margin-left: 50%; margin-top:1%">
<a class="btn btn-default btn-" style="margin: 20px" target="_blank" href="resource/logs/{{war._id}}/clean.log">Logfile anzeigen</a>
<form class="form-group"> <form class="form-group">
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" <input type="radio" name="fractSelect"