Compare commits
2 Commits
53be9498af
...
947e8df1f7
Author | SHA1 | Date |
---|---|---|
Florian Hartwich | 947e8df1f7 | |
Florian Hartwich | dbca2a3d93 |
|
@ -13,6 +13,8 @@ const checkMT = require('../middleware/permission-check').checkMT;
|
||||||
|
|
||||||
// Mongoose Model using mongoDB
|
// Mongoose Model using mongoDB
|
||||||
const CampaignModel = require('../models/campaign');
|
const CampaignModel = require('../models/campaign');
|
||||||
|
const WarModel = require('../models/war');
|
||||||
|
|
||||||
|
|
||||||
const campaigns = express.Router();
|
const campaigns = express.Router();
|
||||||
|
|
||||||
|
@ -66,7 +68,10 @@ campaigns.route('/:id')
|
||||||
err.status = codes.notfound;
|
err.status = codes.notfound;
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
return next();
|
WarModel.find({campaign: req.params.id}).remove().exec();
|
||||||
|
|
||||||
|
res.locals.processed = true;
|
||||||
|
next();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
.overview {
|
||||||
|
position: fixed;
|
||||||
|
width: 25%;
|
||||||
|
min-width: 300px;
|
||||||
|
padding-left: 50px;
|
||||||
|
padding-top: 70px;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
<form #form="ngForm" class="overview">
|
||||||
|
<h3>Kampagne hinzufügen</h3>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="title">Titel</label>
|
||||||
|
<input type="text" class="form-control"
|
||||||
|
[(ngModel)]="campaign.title"
|
||||||
|
name="title"
|
||||||
|
id="title"
|
||||||
|
required maxlength="50"/>
|
||||||
|
|
||||||
|
<show-error text="Name" path="title"></show-error>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button id="cancel"
|
||||||
|
(click)="cancel()"
|
||||||
|
class="btn btn-default">
|
||||||
|
Abbrechen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button id="save"
|
||||||
|
(click)="saveCampaign()"
|
||||||
|
class="btn btn-default"
|
||||||
|
[disabled]="!form.valid">
|
||||||
|
Bestätigen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<span *ngIf="showErrorLabel"
|
||||||
|
class="center-block label label-danger" style="font-size: medium; padding: 2px; margin-top: 2px">
|
||||||
|
{{error}}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</form>
|
|
@ -0,0 +1,44 @@
|
||||||
|
import {Component, ViewChild} from "@angular/core";
|
||||||
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
|
import {NgForm} from "@angular/forms";
|
||||||
|
import {Campaign} from "../../models/model-interfaces";
|
||||||
|
import {CampaignService} from "../../services/campaign-service/campaign.service";
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'campaign-submit',
|
||||||
|
templateUrl: './campaign-submit.component.html',
|
||||||
|
styleUrls: ['./campaign-submit.component.css']
|
||||||
|
})
|
||||||
|
export class CampaignSubmitComponent {
|
||||||
|
|
||||||
|
campaign: Campaign = {};
|
||||||
|
|
||||||
|
showErrorLabel = false;
|
||||||
|
|
||||||
|
error;
|
||||||
|
|
||||||
|
@ViewChild(NgForm) form: NgForm;
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private router: Router,
|
||||||
|
private campaignService: CampaignService) {
|
||||||
|
}
|
||||||
|
|
||||||
|
saveCampaign() {
|
||||||
|
this.campaignService.submitCampaign(this.campaign)
|
||||||
|
.subscribe(campaign => {
|
||||||
|
this.router.navigate(['../overview/' + campaign._id], {relativeTo: this.route});
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
this.error = error._body.error.message;
|
||||||
|
this.showErrorLabel = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel() {
|
||||||
|
this.router.navigate(['..'], {relativeTo: this.route});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,6 +6,7 @@ import {WarListComponent} from "./war-list/war-list.component";
|
||||||
import {StatisticOverviewComponent} from "./overview/stats-overview.component";
|
import {StatisticOverviewComponent} from "./overview/stats-overview.component";
|
||||||
import {WarItemComponent} from "./war-list/war-item.component";
|
import {WarItemComponent} from "./war-list/war-item.component";
|
||||||
import {ModuleWithProviders} from "@angular/core";
|
import {ModuleWithProviders} from "@angular/core";
|
||||||
|
import {CampaignSubmitComponent} from "./campaign-submit/campaign-submit.component";
|
||||||
|
|
||||||
|
|
||||||
export const statsRoutes: Routes = [{
|
export const statsRoutes: Routes = [{
|
||||||
|
@ -22,6 +23,11 @@ export const statsRoutes: Routes = [{
|
||||||
component: StatisticOverviewComponent,
|
component: StatisticOverviewComponent,
|
||||||
outlet: 'right'
|
outlet: 'right'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'new-campaign',
|
||||||
|
component: CampaignSubmitComponent,
|
||||||
|
outlet: 'right'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'new',
|
path: 'new',
|
||||||
component: WarSubmitComponent,
|
component: WarSubmitComponent,
|
||||||
|
@ -35,6 +41,6 @@ export const statsRoutes: Routes = [{
|
||||||
|
|
||||||
export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes);
|
export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes);
|
||||||
|
|
||||||
export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, WarListComponent,
|
export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent,
|
||||||
WarSubmitComponent, WarDetailComponent, WarItemComponent];
|
WarListComponent, WarSubmitComponent, WarDetailComponent, WarItemComponent];
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ export class WarListComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
selectNewCampaign() {
|
||||||
|
this.selectedWarId = null;
|
||||||
|
this.router.navigate([{outlets: {'right': ['new-campaign']}}], {relativeTo: this.route});
|
||||||
|
}
|
||||||
|
|
||||||
selectNewWar() {
|
selectNewWar() {
|
||||||
this.selectedWarId = null;
|
this.selectedWarId = null;
|
||||||
this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route});
|
this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route});
|
||||||
|
|
|
@ -6,24 +6,3 @@
|
||||||
padding-top: 70px;
|
padding-top: 70px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.load-arrow {
|
|
||||||
background: url(../../../assets/loading.png) no-repeat;
|
|
||||||
display: block;
|
|
||||||
width: 120px;
|
|
||||||
height: 120px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Loading Animation */
|
|
||||||
.glyphicon-refresh-animate {
|
|
||||||
animation: spin 1.5s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes spin {
|
|
||||||
0% {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
id="campaign"
|
id="campaign"
|
||||||
[(ngModel)]="war.campaign"
|
[(ngModel)]="war.campaign"
|
||||||
required>
|
required>
|
||||||
<option *ngFor="let campaign of warService.campaigns" [ngValue]="campaign._id">
|
<option *ngFor="let campaign of campaignService.campaigns" [ngValue]="campaign._id">
|
||||||
{{campaign.title}}
|
{{campaign.title}}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {NgForm} from "@angular/forms";
|
import {NgForm} from "@angular/forms";
|
||||||
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 {CampaignService} from "../../services/campaign-service/campaign.service";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -28,7 +29,8 @@ export class WarSubmitComponent {
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private warService: WarService) {
|
private warService: WarService,
|
||||||
|
private campaignService: CampaignService) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileChange(event) {
|
fileChange(event) {
|
||||||
|
|
Loading…
Reference in New Issue