diff --git a/package.json b/package.json index 9a74bd2..ec4f66a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "private": true, "scripts": { diff --git a/static/src/app/app.component.css b/static/src/app/app.component.css index 23acb46..1bf8f81 100644 --- a/static/src/app/app.component.css +++ b/static/src/app/app.component.css @@ -28,3 +28,30 @@ li { max-height: 200px; overflow-x: hidden; } + +.unprocessed { + -webkit-animation-name: color-blink; /* Safari 4.0 - 8.0 */ + -webkit-animation-duration: 4s; /* Safari 4.0 - 8.0 */ + animation-name: color-blink; + animation-duration: 4s; + animation-iteration-count: infinite; +} + +.unprocessed-child { + background-color: orange; +} + +unprocessed-child:hover { + background-color: orange; +} + +/* Safari 4.0 - 8.0 */ +@-webkit-keyframes color-blink { + from {background-color: #222222;} + to {background-color: orange;} +} + +@keyframes color-blink { + from {background-color: #222222;} + to {background-color: orange;} +} diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html index 5a58439..6c18a40 100644 --- a/static/src/app/app.component.html +++ b/static/src/app/app.component.html @@ -67,17 +67,17 @@ diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index 820b6b5..2712b94 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -1,14 +1,11 @@ import {Component, Inject, Optional} from '@angular/core'; -import { - Router, - NavigationEnd, - ActivatedRoute, -} from '@angular/router'; +import {Router} from '@angular/router'; import {LoginService} from './services/login-service/login-service'; -import {Title} from '@angular/platform-browser'; import {AUTH_ENABLED} from './app.tokens'; import {WarService} from "./services/war-service/war.service"; import {War} from "./models/model-interfaces"; +import {PromotionService} from "./services/promotion-service/promotion.service"; +import {AwardingService} from "./services/awarding-service/awarding.service"; @Component({ selector: 'app-root', @@ -17,41 +14,34 @@ import {War} from "./models/model-interfaces"; }) export class AppComponent { - defaultTitle: string; - wars: War[] = []; constructor(@Optional() @Inject(AUTH_ENABLED) public authEnabled, private loginService: LoginService, private warService: WarService, - private activatedRoute: ActivatedRoute, - private router: Router, - private titleService: Title) { + private promotionService: PromotionService, + private awardingService: AwardingService, + private router: Router) { } ngOnInit() { - this.defaultTitle = this.titleService.getTitle(); - this.router.events - .filter(event => event instanceof NavigationEnd) - .subscribe(event => { - this.setBrowserTitle(); - }); this.warService.getAllWars().subscribe((wars) => { this.wars = wars; - }) - - } - - setBrowserTitle() { - let title = this.defaultTitle; - let route = this.activatedRoute; - // firstChild gibt die Haupt-Kindroute der übergebenen Route zurück - while (route.firstChild) { - route = route.firstChild; - title = route.snapshot.data['title'] || title; + }); + if (this.loginService.hasPermission(2)) { + const fraction = this.loginService.getCurrentUser().squad.fraction; + this.promotionService.getUnconfirmedPromotions(fraction).subscribe((items) => { + if (items.length > 0) { + this.promotionService.hasUnprocessedPromotion = true; + } + }); + this.awardingService.getUnconfirmedAwards(fraction).subscribe((items) => { + if (items.length > 0) { + this.awardingService.hasUnprocessedAwards = true; + } + }) } - this.titleService.setTitle(title); } logout() { diff --git a/static/src/app/request/confirm-award/confirm-award.component.ts b/static/src/app/request/confirm-award/confirm-award.component.ts index 6c4a282..f213abe 100644 --- a/static/src/app/request/confirm-award/confirm-award.component.ts +++ b/static/src/app/request/confirm-award/confirm-award.component.ts @@ -1,5 +1,4 @@ import {Component} from "@angular/core"; -import {ActivatedRoute, Router} from "@angular/router"; import {Award} from "../../models/model-interfaces"; import {AwardingService} from "../../services/awarding-service/awarding.service"; @@ -14,9 +13,7 @@ export class ConfirmAwardComponent { showSuccessLabel = false; - constructor(private router: Router, - private route: ActivatedRoute, - private awardingService: AwardingService) { + constructor(private awardingService: AwardingService) { } ngOnInit() { @@ -37,6 +34,9 @@ export class ConfirmAwardComponent { let currentUser = JSON.parse(localStorage.getItem('currentUser')); this.awardingService.getUnconfirmedAwards(currentUser.squad.fraction).subscribe(awards => { this.awards = awards; + if (awards.length < 1) { + this.awardingService.hasUnprocessedAwards = false; + } this.showSuccessLabel = true; setTimeout(() => { this.showSuccessLabel = false; diff --git a/static/src/app/request/confirm-promotion/confirm-promotion.component.ts b/static/src/app/request/confirm-promotion/confirm-promotion.component.ts index 543daaa..6975821 100644 --- a/static/src/app/request/confirm-promotion/confirm-promotion.component.ts +++ b/static/src/app/request/confirm-promotion/confirm-promotion.component.ts @@ -17,9 +17,7 @@ export class ConfirmPromotionComponent { promotions: Promotion[]; - constructor(private router: Router, - private route: ActivatedRoute, - private rankService: RankService, + constructor(private rankService: RankService, private promotionService: PromotionService) { } @@ -45,6 +43,9 @@ export class ConfirmPromotionComponent { let currentUser = JSON.parse(localStorage.getItem('currentUser')); this.promotionService.getUnconfirmedPromotions(currentUser.squad.fraction).subscribe(promotions => { this.promotions = promotions; + if (promotions.length < 1) { + this.promotionService.hasUnprocessedPromotion = false; + } this.showSuccessLabel = true; setTimeout(() => { this.showSuccessLabel = false; diff --git a/static/src/app/services/awarding-service/awarding.service.ts b/static/src/app/services/awarding-service/awarding.service.ts index a8e03f8..0b7d953 100644 --- a/static/src/app/services/awarding-service/awarding.service.ts +++ b/static/src/app/services/awarding-service/awarding.service.ts @@ -1,13 +1,13 @@ import {Injectable} from "@angular/core"; -import {Award, User} from "../../models/model-interfaces"; -import {Headers, Http} from "@angular/http"; -import {Observable} from "rxjs/Observable"; +import {Award} from "../../models/model-interfaces"; import {AppConfig} from "../../app.config"; import {HttpClient} from "../http-client"; @Injectable() export class AwardingService { + hasUnprocessedAwards = false; + constructor(private http: HttpClient, private config: AppConfig) { } diff --git a/static/src/app/services/login-service/login-service.ts b/static/src/app/services/login-service/login-service.ts index 4ee2460..f7a4e7a 100644 --- a/static/src/app/services/login-service/login-service.ts +++ b/static/src/app/services/login-service/login-service.ts @@ -4,6 +4,7 @@ import "rxjs/add/operator/map"; import {AppConfig} from "../../app.config"; import {AUTH_ENABLED} from "../../app.tokens"; +import {AppUser} from "../../models/model-interfaces"; @Injectable() export class LoginService { @@ -45,6 +46,10 @@ export class LoginService { return this.isLoggedIn() && currentUser.permission >= level; } + getCurrentUser() :AppUser { + return JSON.parse(localStorage.getItem('currentUser')); + } + hasSquad() { let currentUser = JSON.parse(localStorage.getItem('currentUser')); return currentUser.squad != null; diff --git a/static/src/app/services/promotion-service/promotion.service.ts b/static/src/app/services/promotion-service/promotion.service.ts index 994f74f..3580e0a 100644 --- a/static/src/app/services/promotion-service/promotion.service.ts +++ b/static/src/app/services/promotion-service/promotion.service.ts @@ -6,6 +6,8 @@ import {Promotion} from "../../models/model-interfaces"; @Injectable() export class PromotionService { + hasUnprocessedPromotion = false; + constructor(private http: HttpClient, private config: AppConfig) { }