diff --git a/api/models/rank.js b/api/models/rank.js index e410873..d14cbaa 100644 --- a/api/models/rank.js +++ b/api/models/rank.js @@ -17,8 +17,6 @@ const RankSchema = new Schema({ type: Number, get: v => Math.round(v), set: v => Math.round(v), - min: 0, - max: 22, required: true } }, { diff --git a/static/src/app/app.config.ts b/static/src/app/app.config.ts index a46c463..301f4ab 100644 --- a/static/src/app/app.config.ts +++ b/static/src/app/app.config.ts @@ -12,11 +12,4 @@ export class AppConfig { public readonly apiUserPath = '/users/'; public readonly apiOverviewPath = '/overview'; - public getAuthenticationHeader() :Headers { - let currentUser = JSON.parse(localStorage.getItem('currentUser')); - let headers = new Headers(); - headers.append('x-access-token', currentUser.token); - return headers; - } - } diff --git a/static/src/app/decorations/decoration-list/decoration-item.component.css b/static/src/app/decorations/decoration-list/decoration-item.component.css index d176e8d..d74d2f7 100644 --- a/static/src/app/decorations/decoration-list/decoration-item.component.css +++ b/static/src/app/decorations/decoration-list/decoration-item.component.css @@ -1,4 +1,4 @@ -div.squad-list-entry, a.squad-list-entry { +div.decoration-list-entry, a.decoration-list-entry { padding: 8px; width: 475px; border-radius: 2px; @@ -7,6 +7,11 @@ div.squad-list-entry, a.squad-list-entry { margin-bottom: -1px; } +.decoration-list-preview { + float: left; + margin-right: 12px; +} + .marked { background: lightgrey; } @@ -25,9 +30,9 @@ small { } .trash { + float:right; padding-top: 18px; font-size: 17px; - margin-left: -10px; } .selected { diff --git a/static/src/app/decorations/decoration-list/decoration-item.component.html b/static/src/app/decorations/decoration-list/decoration-item.component.html index db49d9d..fdfe55e 100644 --- a/static/src/app/decorations/decoration-list/decoration-item.component.html +++ b/static/src/app/decorations/decoration-list/decoration-item.component.html @@ -1,7 +1,7 @@ -
+
-
+
{{decoration.name}} @@ -11,5 +11,10 @@ Global - Sortierung: {{decoration.sortingNumber}}
+ +
+ + +
diff --git a/static/src/app/decorations/decoration-list/decoration-item.component.ts b/static/src/app/decorations/decoration-list/decoration-item.component.ts index 943373c..05bbe86 100644 --- a/static/src/app/decorations/decoration-list/decoration-item.component.ts +++ b/static/src/app/decorations/decoration-list/decoration-item.component.ts @@ -8,24 +8,36 @@ import {Decoration} from "../../models/model-interfaces"; styleUrls: ['./decoration-item.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, inputs: ['decoration', 'selected'], - outputs: ['decorationSelected'], + outputs: ['decorationDelete','decorationSelected'], }) export class DecorationItemComponent { selected: boolean; decoration: Decoration; + imageSrc; + previewMargin; decorationSelected = new EventEmitter(); - + decorationDelete = new EventEmitter(); constructor(private router: Router) { + } + ngOnInit() { + this.imageSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now(); + if (!this.decoration.isMedal) { + this.previewMargin = '17px' + } } select() { this.decorationSelected.emit(this.decoration._id) } + delete() { + this.decorationDelete.emit(this.decoration); + } + ngAfterViewChecked() { //var taskId = (this.task ? this.task.id : ''); // console.log(`Task ${taskId} checked ${++this.checkCounter} times`) diff --git a/static/src/app/decorations/decoration-list/decoration-list.component.html b/static/src/app/decorations/decoration-list/decoration-list.component.html index 24cfb0a..366e2f5 100644 --- a/static/src/app/decorations/decoration-list/decoration-list.component.html +++ b/static/src/app/decorations/decoration-list/decoration-list.component.html @@ -42,6 +42,7 @@
diff --git a/static/src/app/decorations/decoration-list/decoration-list.component.ts b/static/src/app/decorations/decoration-list/decoration-list.component.ts index 62619b6..fae3837 100644 --- a/static/src/app/decorations/decoration-list/decoration-list.component.ts +++ b/static/src/app/decorations/decoration-list/decoration-list.component.ts @@ -48,12 +48,25 @@ export class DecorationListComponent implements OnInit { } openNewSquadForm() { + this.selectedDecorationId = null; this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route}); } selectDecoration(decorationId: string | number) { this.selectedDecorationId = decorationId; - this.router.navigate([{outlets: {'right': ['overview', decorationId]}}], {relativeTo: this.route}); + this.router.navigate([{outlets: {'right': ['edit', decorationId]}}], {relativeTo: this.route}); + } + + deleteDecoration(decoration) { + let fraction = 'GLOBAL'; + if (decoration.fraction === 'BLUFOR') fraction = 'NATO'; + else if (decoration.fraction === 'OPFOR') fraction = 'CSAT'; + + if (confirm('Soll die Auszeichnung "' + decoration.name + '" (' + fraction + ') wirklich gelöscht werden?')) { + this.decorationService.deleteDecoration(decoration) + .subscribe((res) => { + }) + } } filterSquadsByFraction(query = '', fractionFilter) { diff --git a/static/src/app/decorations/decoration-overview/decoration-overview.component.css b/static/src/app/decorations/decoration-overview/decoration-overview.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/static/src/app/decorations/decoration-overview/decoration-overview.component.html b/static/src/app/decorations/decoration-overview/decoration-overview.component.html deleted file mode 100644 index 451d361..0000000 --- a/static/src/app/decorations/decoration-overview/decoration-overview.component.html +++ /dev/null @@ -1,134 +0,0 @@ -
-

Auszeichnung-Details - - Erfolgreich gespeichert - -

-
-
- - -
-
-
- -
-
- {{decoration.name}} -
-
- -
- -
-
-
- -
-
- CSAT -
-
- NATO -
-
-
-
-
-
- -
-
- Orden -
-
- Ribbon -
-
-
-
-
- -
-
-
-
- -
-
- {{decoration.sortingNumber}} -
-
- -
- -
-
- -
-
-
-
- -
-
- -
- -
-
- -
-
-
-
- -
-
- -
-
- - - - Bild muss im PNG Format vorliegen - -
-
- - Bestätigen -
-
-
- -
-
-
-
- -
-
- -
- - -
-
- - -
-
-
diff --git a/static/src/app/decorations/decoration-overview/decoration-overview.component.ts b/static/src/app/decorations/decoration-overview/decoration-overview.component.ts deleted file mode 100644 index a4578e2..0000000 --- a/static/src/app/decorations/decoration-overview/decoration-overview.component.ts +++ /dev/null @@ -1,94 +0,0 @@ -import {Component} from "@angular/core"; -import {ActivatedRoute, Router} from "@angular/router"; -import {Decoration} from "../../models/model-interfaces"; -import {DecorationService} from "../../services/decoration-service/decoration.service"; - -@Component({ - templateUrl: './decoration-overview.component.html', - styleUrls: ['./decoration-overview.component.css', '../../style/overview.css'], -}) -export class DecorationOverviewComponent { - - id: string; - - showSuccessLabel = false; - - showImageError = false; - - decoration: Decoration; - - fileList: FileList; - - previewImage; - - constructor(private router: Router, - private route: ActivatedRoute, - private decorationService: DecorationService) { - } - - ngOnInit() { - this.route.params.subscribe((params) => { - this.decorationService.getDecoration(params['id']).subscribe(decoration => { - this.decoration = decoration; - this.previewImage = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now(); - }) - }) - } - - // register file change and save to fileList - fileChange(event) { - if (!event.target.files[0].name.endsWith('.png')) { - this.showImageError = true; - this.fileList = undefined; - } else { - this.showImageError = false; - this.fileList = event.target.files; - } - } - - update(attrName, inputField) { - const inputValue = inputField.value; - if (inputValue.length > 0 && (this.decoration[attrName] !== inputValue || attrName === 'description')) { - const updateObject = {_id: this.decoration._id}; - updateObject[attrName] = inputValue; - this.decorationService.submitDecoration(updateObject) - .subscribe(decoration => { - this.decoration = decoration; - if (attrName != 'description') { - inputField.value = ''; - } - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000) - }) - } - } - - updateGraphic(fileInput) { - if (this.fileList && this.fileList.length > 0) { - let file: File = this.fileList[0]; - this.decorationService.submitDecoration({_id: this.decoration._id}, file) - .subscribe((res) => { - setTimeout(() => { - this.previewImage = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now(); - }, 300); - fileInput.value = ''; - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000) - }) - } - } - - deleteDecoration(confirm) { - if (confirm.toLowerCase() === this.decoration.name.toLocaleLowerCase()) { - this.decorationService.deleteDecoration(this.decoration) - .subscribe((res) => { - this.router.navigate(['../..'], {relativeTo: this.route}); - }) - } - } - -} diff --git a/static/src/app/decorations/decoration.routing.ts b/static/src/app/decorations/decoration.routing.ts index 5805cbb..c96720a 100644 --- a/static/src/app/decorations/decoration.routing.ts +++ b/static/src/app/decorations/decoration.routing.ts @@ -2,7 +2,6 @@ import {Routes} from "@angular/router"; import {DecorationComponent} from "./decoration.component"; import {DecorationListComponent} from "./decoration-list/decoration-list.component"; import {CreateDecorationComponent} from "./new-decoration/new-decoration.component"; -import {DecorationOverviewComponent} from "./decoration-overview/decoration-overview.component"; export const decorationsRoutes: Routes = [{ path: '', component: DecorationComponent, @@ -19,10 +18,10 @@ export const decorationsRoutes: Routes = [{ outlet: 'right' }, { - path: 'overview/:id', - component: DecorationOverviewComponent, + path: 'edit/:id', + component: CreateDecorationComponent, outlet: 'right' }]; -export const decorationsRoutingComponents = [DecorationComponent, DecorationListComponent, DecorationOverviewComponent, CreateDecorationComponent]; +export const decorationsRoutingComponents = [DecorationComponent, DecorationListComponent, CreateDecorationComponent]; diff --git a/static/src/app/decorations/new-decoration/new-decoration.component.css b/static/src/app/decorations/new-decoration/new-decoration.component.css index c77d09c..0523e4c 100644 --- a/static/src/app/decorations/new-decoration/new-decoration.component.css +++ b/static/src/app/decorations/new-decoration/new-decoration.component.css @@ -1,3 +1,7 @@ +.preview-image { + margin: 10px; +} + .form-control { height: auto; } diff --git a/static/src/app/decorations/new-decoration/new-decoration.component.html b/static/src/app/decorations/new-decoration/new-decoration.component.html index 4faa9e1..a1b5eca 100644 --- a/static/src/app/decorations/new-decoration/new-decoration.component.html +++ b/static/src/app/decorations/new-decoration/new-decoration.component.html @@ -1,5 +1,6 @@
-

Neue Auszeichnung hinzufügen

+

Auszeichnung editieren

+

Neuen Auszeichnung hinzufügen

@@ -45,18 +46,21 @@ + [(ngModel)]="decoration.description">
Bild muss im PNG Format vorliegen + +
+ + + + Erfolgreich gespeichert + +
diff --git a/static/src/app/decorations/new-decoration/new-decoration.component.ts b/static/src/app/decorations/new-decoration/new-decoration.component.ts index f1afb40..370479f 100644 --- a/static/src/app/decorations/new-decoration/new-decoration.component.ts +++ b/static/src/app/decorations/new-decoration/new-decoration.component.ts @@ -1,9 +1,9 @@ import {Component, ViewChild} from "@angular/core"; import {ActivatedRoute, Router} from "@angular/router"; import {NgForm} from "@angular/forms"; -import * as model from "../../models/model-interfaces"; import {Decoration} from "../../models/model-interfaces"; import {DecorationService} from "../../services/decoration-service/decoration.service"; +import {Subscription} from "rxjs/Subscription"; @Component({ templateUrl: './new-decoration.component.html', @@ -11,6 +11,8 @@ import {DecorationService} from "../../services/decoration-service/decoration.se }) export class CreateDecorationComponent { + subscription: Subscription; + decoration: Decoration = {name: '', fraction: '', sortingNumber: 0}; fileList: FileList; @@ -19,6 +21,10 @@ export class CreateDecorationComponent { showImageError = false; + imagePreviewSrc; + + showSuccessLabel = false; + @ViewChild(NgForm) form: NgForm; constructor(private route: ActivatedRoute, @@ -27,7 +33,18 @@ export class CreateDecorationComponent { } ngOnInit() { + this.subscription = this.route.params + .map(params => params['id']) + .filter(id => id != undefined) + .flatMap(id => this.decorationService.getDecoration(id)) + .subscribe(decoration => { + this.decoration = decoration; + this.imagePreviewSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now(); + }); + } + ngOnDestroy() { + this.subscription.unsubscribe(); } fileChange(event) { @@ -40,22 +57,40 @@ export class CreateDecorationComponent { } } - saveDecoration() { - if (this.fileList) { - let file: File = this.fileList[0]; - this.decorationService.submitDecoration(this.decoration, file) - .subscribe(decoration => { - this.saved = true; - this.router.navigate(['../overview', decoration._id], {relativeTo: this.route}); - }) + saveDecoration(fileInput) { + let file: File; + if (!this.decoration._id) { + if (this.fileList) { + file = this.fileList[0]; + this.decorationService.submitDecoration(this.decoration, file) + .subscribe(rank => { + this.saved = true; + this.router.navigate(['..'], {relativeTo: this.route}); + }) + } else { + return window.alert(`Bild ist ein Pflichtfeld`); + } } else { - return window.alert(`Bild ist ein Pflichtfeld`); + if (this.fileList) { + file = this.fileList[0]; + } + delete this.decoration['__v']; + this.decorationService.submitDecoration(this.decoration, file) + .subscribe(rank => { + setTimeout(() => { + this.imagePreviewSrc = 'resource/decoration/' + this.decoration._id + '.png?' + Date.now(); + }, 300); + fileInput.value = ''; + this.showSuccessLabel = true; + setTimeout(() => { + this.showSuccessLabel = false; + }, 2000) + }) } } cancel() { - //this.location.back(); - this.router.navigate(['/cc-decorations']); + this.router.navigate([this.decoration._id ? '../..' : '..'], {relativeTo: this.route}); return false; } diff --git a/static/src/app/ranks/rank-list/rank-item.component.html b/static/src/app/ranks/rank-list/rank-item.component.html index a1c9d8a..eecc2c3 100644 --- a/static/src/app/ranks/rank-list/rank-item.component.html +++ b/static/src/app/ranks/rank-list/rank-item.component.html @@ -16,6 +16,5 @@
-
diff --git a/static/src/app/services/decoration-service/decoration.service.ts b/static/src/app/services/decoration-service/decoration.service.ts index a36a040..33f1774 100644 --- a/static/src/app/services/decoration-service/decoration.service.ts +++ b/static/src/app/services/decoration-service/decoration.service.ts @@ -63,7 +63,7 @@ export class DecorationService { if (imageFile) { body = new FormData(); Object.keys(decoration).map((objectKey) => { - if (decoration[objectKey]) { + if (decoration[objectKey] !== undefined) { body.append(objectKey, decoration[objectKey]); } }); diff --git a/static/src/app/services/squad-service/squad.service.ts b/static/src/app/services/squad-service/squad.service.ts index 867ffef..195ffe2 100644 --- a/static/src/app/services/squad-service/squad.service.ts +++ b/static/src/app/services/squad-service/squad.service.ts @@ -62,7 +62,7 @@ export class SquadService { if (imageFile) { body = new FormData(); Object.keys(squad).map((objectKey) => { - if (squad[objectKey]) { + if (squad[objectKey] !== undefined) { body.append(objectKey, squad[objectKey]); } }); diff --git a/static/src/app/squads/new-squad/new-squad.component.css b/static/src/app/squads/new-squad/new-squad.component.css index c77d09c..0523e4c 100644 --- a/static/src/app/squads/new-squad/new-squad.component.css +++ b/static/src/app/squads/new-squad/new-squad.component.css @@ -1,3 +1,7 @@ +.preview-image { + margin: 10px; +} + .form-control { height: auto; } diff --git a/static/src/app/squads/new-squad/new-squad.component.html b/static/src/app/squads/new-squad/new-squad.component.html index 1deb356..61ada09 100644 --- a/static/src/app/squads/new-squad/new-squad.component.html +++ b/static/src/app/squads/new-squad/new-squad.component.html @@ -1,5 +1,6 @@
-

Neues Squad hinzufügen

+

Squad editieren

+

Neues Squad hinzufügen

@@ -33,11 +34,14 @@
Bild muss im PNG Format vorliegen + +
- + + + + Erfolgreich gespeichert + + diff --git a/static/src/app/squads/new-squad/new-squad.component.ts b/static/src/app/squads/new-squad/new-squad.component.ts index d1e5270..ae28459 100644 --- a/static/src/app/squads/new-squad/new-squad.component.ts +++ b/static/src/app/squads/new-squad/new-squad.component.ts @@ -3,6 +3,7 @@ import {ActivatedRoute, Router} from "@angular/router"; import {NgForm} from "@angular/forms"; import {Squad} from "../../models/model-interfaces"; import {SquadService} from "../../services/squad-service/squad.service"; +import {Subscription} from "rxjs/Subscription"; @Component({ @@ -11,6 +12,8 @@ import {SquadService} from "../../services/squad-service/squad.service"; }) export class CreateSquadComponent { + subscription: Subscription; + squad: Squad = {name: '', fraction: '', sortingNumber: 0}; fileList: FileList; @@ -19,6 +22,10 @@ export class CreateSquadComponent { showImageError = false; + showSuccessLabel = false; + + imagePreviewSrc; + @ViewChild(NgForm) form: NgForm; constructor(private route: ActivatedRoute, @@ -27,7 +34,18 @@ export class CreateSquadComponent { } ngOnInit() { + this.subscription = this.route.params + .map(params => params['id']) + .filter(id => id != undefined) + .flatMap(id => this.squadService.getSquad(id)) + .subscribe(squad => { + this.squad = squad; + this.imagePreviewSrc = 'resource/squad/' + this.squad._id + '.png?' + Date.now(); + }); + } + ngOnDestroy() { + this.subscription.unsubscribe(); } fileChange(event) { @@ -40,22 +58,40 @@ export class CreateSquadComponent { } } - saveSquad() { - if (this.fileList) { - let file: File = this.fileList[0]; - this.squadService.submitSquad(this.squad, file) - .subscribe(squad => { - this.saved = true; - this.router.navigate(['../overview', squad._id], {relativeTo: this.route}); - }) + saveSquad(fileInput) { + let file: File; + if (!this.squad._id) { + if (this.fileList) { + file = this.fileList[0]; + this.squadService.submitSquad(this.squad, file) + .subscribe(rank => { + this.saved = true; + this.router.navigate(['..'], {relativeTo: this.route}); + }) + } else { + return window.alert(`Bild ist ein Pflichtfeld`); + } } else { - return window.alert(`Bild ist ein Pflichtfeld`); + if (this.fileList) { + file = this.fileList[0]; + } + delete this.squad['__v']; + this.squadService.submitSquad(this.squad, file) + .subscribe(rank => { + setTimeout(() => { + this.imagePreviewSrc = 'resource/squad/' + this.squad._id + '.png?' + Date.now(); + }, 300); + fileInput.value = ''; + this.showSuccessLabel = true; + setTimeout(() => { + this.showSuccessLabel = false; + }, 2000) + }) } } cancel() { - //this.location.back(); - this.router.navigate(['/cc-squads']); + this.router.navigate([this.squad._id ? '../..' : '..'], {relativeTo: this.route}); return false; } diff --git a/static/src/app/squads/squad-list/squad-item.component.css b/static/src/app/squads/squad-list/squad-item.component.css index d176e8d..9b05bb1 100644 --- a/static/src/app/squads/squad-list/squad-item.component.css +++ b/static/src/app/squads/squad-list/squad-item.component.css @@ -11,6 +11,11 @@ div.squad-list-entry, a.squad-list-entry { background: lightgrey; } +.squad-list-preview { + float: left; + margin-right: 12px; +} + span { cursor: pointer; } @@ -25,9 +30,9 @@ small { } .trash { + float:right; padding-top: 18px; font-size: 17px; - margin-left: -10px; } .selected { diff --git a/static/src/app/squads/squad-list/squad-item.component.html b/static/src/app/squads/squad-list/squad-item.component.html index 164d598..d6e937e 100644 --- a/static/src/app/squads/squad-list/squad-item.component.html +++ b/static/src/app/squads/squad-list/squad-item.component.html @@ -1,7 +1,7 @@
-
+
{{squad.name}} @@ -9,5 +9,10 @@ CSAT NATO
+ +
+ + +
diff --git a/static/src/app/squads/squad-list/squad-item.component.ts b/static/src/app/squads/squad-list/squad-item.component.ts index 181cfb2..7a70239 100644 --- a/static/src/app/squads/squad-list/squad-item.component.ts +++ b/static/src/app/squads/squad-list/squad-item.component.ts @@ -1,6 +1,6 @@ import {ChangeDetectionStrategy, Component, EventEmitter} from "@angular/core"; import {Router} from "@angular/router"; -import {Squad, User} from "../../models/model-interfaces"; +import {Squad} from "../../models/model-interfaces"; @Component({ selector: 'pjm-squad-item', @@ -18,8 +18,13 @@ export class SquadItemComponent { squadSelected = new EventEmitter(); squadDelete = new EventEmitter(); - constructor(private router: Router) { + imageSrc; + constructor(private router: Router) { + } + + ngOnInit() { + this.imageSrc = 'resource/squad/' + this.squad._id + '.png?' + Date.now(); } select() { diff --git a/static/src/app/squads/squad-list/squad-list.component.html b/static/src/app/squads/squad-list/squad-list.component.html index 48713ed..d992163 100644 --- a/static/src/app/squads/squad-list/squad-list.component.html +++ b/static/src/app/squads/squad-list/squad-list.component.html @@ -42,7 +42,7 @@
diff --git a/static/src/app/squads/squad-list/squad-list.component.ts b/static/src/app/squads/squad-list/squad-list.component.ts index 7ee4c19..1c7f435 100644 --- a/static/src/app/squads/squad-list/squad-list.component.ts +++ b/static/src/app/squads/squad-list/squad-list.component.ts @@ -48,12 +48,22 @@ export class SquadListComponent implements OnInit { } openNewSquadForm() { + this.selectedSquadId = null; this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route}); } selectSquad(squadId: string | number) { this.selectedSquadId = squadId; - this.router.navigate([{outlets: {'right': ['overview', squadId]}}], {relativeTo: this.route}); + this.router.navigate([{outlets: {'right': ['edit', squadId]}}], {relativeTo: this.route}); + } + + deleteSquad(squad) { + const fraction = squad.fraction === 'OPFOR' ? 'CSAT' : 'NATO'; + if (confirm('Soll das Squad "' + squad.name + '" (' + fraction + ') wirklich gelöscht werden?')) { + this.squadService.deleteSquad(squad) + .subscribe((res) => { + }) + } } filterSquadsByFraction(query = '', fractionFilter) { diff --git a/static/src/app/squads/squad-overview/squad-overview.component.css b/static/src/app/squads/squad-overview/squad-overview.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/static/src/app/squads/squad-overview/squad-overview.component.html b/static/src/app/squads/squad-overview/squad-overview.component.html deleted file mode 100644 index 5b11595..0000000 --- a/static/src/app/squads/squad-overview/squad-overview.component.html +++ /dev/null @@ -1,107 +0,0 @@ -
-

Squad-Details - - Erfolgreich gespeichert - -

-
-
- - -
-
-
- -
-
- {{squad.name}} -
-
- -
- -
-
- -
-
- CSAT -
-
- NATO -
-
-
-
- -
-
-
-
- -
-
- {{squad.sortingNumber}} -
-
- -
- -
-
- -
-
-
-
- -
-
- -
-
- - - - Bild muss im PNG Format vorliegen - -
- -
-
- -
-
-
-
- -
-
- -
-
-   -
- - -
-
- - -
-
-
diff --git a/static/src/app/squads/squad-overview/squad-overview.component.ts b/static/src/app/squads/squad-overview/squad-overview.component.ts deleted file mode 100644 index 6bf1527..0000000 --- a/static/src/app/squads/squad-overview/squad-overview.component.ts +++ /dev/null @@ -1,92 +0,0 @@ -import {Component} from "@angular/core"; -import {ActivatedRoute, Router} from "@angular/router"; -import {Squad} from "../../models/model-interfaces"; -import {SquadService} from "../../services/squad-service/squad.service"; - -@Component({ - templateUrl: './squad-overview.component.html', - styleUrls: ['./squad-overview.component.css', '../../style/overview.css'], -}) -export class SquadOverviewComponent { - - showSuccessLabel = false; - - showImageError = false; - - squad: Squad; - - fileList: FileList; - - imagePreview; - - constructor(private router: Router, - private route: ActivatedRoute, - private squadService: SquadService) { - } - - ngOnInit() { - this.route.params.subscribe((params) => { - this.squadService.getSquad(params['id']).subscribe(squad => { - this.squad = squad; - this.imagePreview = 'resource/squad/' + squad._id + '.png?' + Date.now(); - }) - }) - } - - /** - * register file change and save to fileList - */ - fileChange(event) { - if (!event.target.files[0].name.endsWith('.png')) { - this.showImageError = true; - this.fileList = undefined; - } else { - this.showImageError = false; - this.fileList = event.target.files; - } - } - - update(attrName, inputField) { - const inputValue = inputField.value; - if (inputValue.length > 0 && this.squad[attrName] !== inputValue) { - const updateObject = {_id: this.squad._id}; - updateObject[attrName] = inputValue; - this.squadService.submitSquad(updateObject) - .subscribe(squad => { - this.squad = squad; - inputField.value = ''; - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000) - }) - } - } - - updateGraphic(fileInput) { - if (this.fileList && this.fileList.length > 0) { - let file: File = this.fileList[0]; - this.squadService.submitSquad({_id: this.squad._id}, file) - .subscribe((res) => { - setTimeout(() => { - this.imagePreview = 'resource/squad/' + this.squad._id + '.png?' + Date.now(); - }, 300); - fileInput.value = ''; - this.showSuccessLabel = true; - setTimeout(() => { - this.showSuccessLabel = false; - }, 2000) - }) - } - } - - deleteSquad(confirm) { - if (confirm.toLowerCase() === this.squad.name.toLocaleLowerCase()) { - this.squadService.deleteSquad(this.squad) - .subscribe((res) => { - this.router.navigate(['../..'], {relativeTo: this.route}); - }) - } - } - -} diff --git a/static/src/app/squads/squads.routing.ts b/static/src/app/squads/squads.routing.ts index cf2dc47..95384c1 100644 --- a/static/src/app/squads/squads.routing.ts +++ b/static/src/app/squads/squads.routing.ts @@ -1,6 +1,5 @@ import {Routes} from "@angular/router"; import {SquadComponent} from "./squads.component"; -import {SquadOverviewComponent} from "./squad-overview/squad-overview.component"; import {SquadListComponent} from "./squad-list/squad-list.component"; import {CreateSquadComponent} from "./new-squad/new-squad.component"; @@ -19,10 +18,10 @@ export const squadsRoutes: Routes = [{ outlet: 'right' }, { - path: 'overview/:id', - component: SquadOverviewComponent, + path: 'edit/:id', + component: CreateSquadComponent, outlet: 'right' }]; -export const squadsRoutingComponents = [SquadComponent, SquadListComponent, SquadOverviewComponent, CreateSquadComponent]; +export const squadsRoutingComponents = [SquadComponent, SquadListComponent, CreateSquadComponent]; diff --git a/static/src/app/users/user-list/user-list.component.ts b/static/src/app/users/user-list/user-list.component.ts index a40812a..8a9a4f9 100644 --- a/static/src/app/users/user-list/user-list.component.ts +++ b/static/src/app/users/user-list/user-list.component.ts @@ -63,7 +63,7 @@ export class UserListComponent implements OnInit { } deleteUser(user: User) { - if (confirm('Soll der Teilnehmer ' + user.username + ' wirklich gelöscht werden?')) { + if (confirm('Soll der Teilnehmer "' + user.username + '" wirklich gelöscht werden?')) { this.userService.deleteUser(user) .subscribe((res) => { })