From dbca2a3d937963887e817287f065a393538b679f Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Thu, 14 Sep 2017 11:47:41 +0200 Subject: [PATCH] Add campaign submit form --- .../campaign-submit.component.css | 8 ++++ .../campaign-submit.component.html | 33 ++++++++++++++ .../campaign-submit.component.ts | 44 +++++++++++++++++++ static/src/app/statistic/stats.routing.ts | 10 ++++- .../statistic/war-list/war-list.component.ts | 5 +++ .../war-submit/war-submit.component.css | 21 --------- 6 files changed, 98 insertions(+), 23 deletions(-) create mode 100644 static/src/app/statistic/campaign-submit/campaign-submit.component.css create mode 100644 static/src/app/statistic/campaign-submit/campaign-submit.component.html create mode 100644 static/src/app/statistic/campaign-submit/campaign-submit.component.ts diff --git a/static/src/app/statistic/campaign-submit/campaign-submit.component.css b/static/src/app/statistic/campaign-submit/campaign-submit.component.css new file mode 100644 index 0000000..f0ba23d --- /dev/null +++ b/static/src/app/statistic/campaign-submit/campaign-submit.component.css @@ -0,0 +1,8 @@ +.overview { + position: fixed; + width: 25%; + min-width: 300px; + padding-left: 50px; + padding-top: 70px; + margin-left: 10px; +} diff --git a/static/src/app/statistic/campaign-submit/campaign-submit.component.html b/static/src/app/statistic/campaign-submit/campaign-submit.component.html new file mode 100644 index 0000000..c4b0880 --- /dev/null +++ b/static/src/app/statistic/campaign-submit/campaign-submit.component.html @@ -0,0 +1,33 @@ +
+

Kampagne hinzufügen

+ +
+ + + + +
+ + + + + + + {{error}} + + +
diff --git a/static/src/app/statistic/campaign-submit/campaign-submit.component.ts b/static/src/app/statistic/campaign-submit/campaign-submit.component.ts new file mode 100644 index 0000000..469b968 --- /dev/null +++ b/static/src/app/statistic/campaign-submit/campaign-submit.component.ts @@ -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; + } + +} diff --git a/static/src/app/statistic/stats.routing.ts b/static/src/app/statistic/stats.routing.ts index ffc10cd..acff442 100644 --- a/static/src/app/statistic/stats.routing.ts +++ b/static/src/app/statistic/stats.routing.ts @@ -6,6 +6,7 @@ import {WarListComponent} from "./war-list/war-list.component"; import {StatisticOverviewComponent} from "./overview/stats-overview.component"; import {WarItemComponent} from "./war-list/war-item.component"; import {ModuleWithProviders} from "@angular/core"; +import {CampaignSubmitComponent} from "./campaign-submit/campaign-submit.component"; export const statsRoutes: Routes = [{ @@ -22,6 +23,11 @@ export const statsRoutes: Routes = [{ component: StatisticOverviewComponent, outlet: 'right' }, + { + path: 'new-campaign', + component: CampaignSubmitComponent, + outlet: 'right' + }, { path: 'new', component: WarSubmitComponent, @@ -35,6 +41,6 @@ export const statsRoutes: Routes = [{ export const statsRouterModule: ModuleWithProviders = RouterModule.forChild(statsRoutes); -export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, WarListComponent, - WarSubmitComponent, WarDetailComponent, WarItemComponent]; +export const statsRoutingComponents = [StatisticComponent, StatisticOverviewComponent, CampaignSubmitComponent, + WarListComponent, WarSubmitComponent, WarDetailComponent, WarItemComponent]; diff --git a/static/src/app/statistic/war-list/war-list.component.ts b/static/src/app/statistic/war-list/war-list.component.ts index db99c1a..c602849 100644 --- a/static/src/app/statistic/war-list/war-list.component.ts +++ b/static/src/app/statistic/war-list/war-list.component.ts @@ -31,6 +31,11 @@ export class WarListComponent implements OnInit { }); } + selectNewCampaign() { + this.selectedWarId = null; + this.router.navigate([{outlets: {'right': ['new-campaign']}}], {relativeTo: this.route}); + } + selectNewWar() { this.selectedWarId = null; this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route}); diff --git a/static/src/app/statistic/war-submit/war-submit.component.css b/static/src/app/statistic/war-submit/war-submit.component.css index dd7472c..f0ba23d 100644 --- a/static/src/app/statistic/war-submit/war-submit.component.css +++ b/static/src/app/statistic/war-submit/war-submit.component.css @@ -6,24 +6,3 @@ padding-top: 70px; 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); - } -}