From 07dbbc106c0b0f797c8286f63bd0407975b9f316 Mon Sep 17 00:00:00 2001 From: Florian Hartwich Date: Sun, 8 Oct 2017 12:17:21 +0200 Subject: [PATCH] OPTIMIZE - fix prod build validations; remove manual minify --- minify.sh | 15 --- package.json | 4 +- static/src/app/app.component.ts | 2 +- .../decoration-list.component.html | 14 +-- .../decoration-list.component.ts | 4 +- static/src/app/models/app-validators.ts | 114 ------------------ .../ranks/rank-list/rank-list.component.html | 10 +- .../ranks/rank-list/rank-list.component.ts | 2 +- .../squad-list/squad-list.component.html | 10 +- .../squads/squad-list/squad-list.component.ts | 2 +- .../war-detail/war-detail.component.ts | 2 +- .../statistic/war-list/war-item.component.ts | 2 +- .../statistic/war-list/war-list.component.ts | 2 +- .../war-submit/war-submit.component.ts | 2 +- .../users/user-list/user-list.component.html | 12 +- .../users/user-list/user-list.component.ts | 2 +- 16 files changed, 35 insertions(+), 164 deletions(-) delete mode 100755 minify.sh delete mode 100644 static/src/app/models/app-validators.ts diff --git a/minify.sh b/minify.sh deleted file mode 100755 index 2b47016..0000000 --- a/minify.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -# execute script in its location folder -cd $(dirname $0) - -# array of files to minify -FILES=(inline.bundle main.bundle polyfills.bundle scripts.bundle styles.bundle vendor.bundle admin.module.chunk common.chunk decoration.module.chunk ranks.module.chunk request.module.chunk squads.module.chunk stats.module.chunk users.module.chunk) -OPTIONS="-c toplevel,dead_code=true,unused=true" - -for i in "${FILES[@]}" -do - echo "minify ${i} ..." - $(npm bin)/uglifyjs public/${i}.js ${OPTIONS} -o public/${i}.js - rm -f public/${i}.js.map -done diff --git a/package.json b/package.json index 1e1a860..e0598a5 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "opt-cc", - "version": "1.5.2", + "version": "1.5.3", "license": "MIT", "private": true, "scripts": { "start": "npm run deploy-static-prod && npm start --prefix ./api", "dev": "npm run deploy-static && npm run dev --prefix ./api", "deploy-static": "cd ./static && $(npm bin)/ng build && ln -s ../api/resource/ ../public/resource", - "deploy-static-prod": "cd ./static && $(npm bin)/ng build --env=prod && ln -s ../api/resource/ ../public/resource && .././minify.sh", + "deploy-static-prod": "cd ./static && $(npm bin)/ng build --prod --aot && ln -s ../api/resource/ ../public/resource", "postinstall": "npm install --prefix ./static && npm install --prefix ./api", "mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data", "test": "npm test --prefix ./api", diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index 3211123..855a37d 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -16,7 +16,7 @@ export class AppComponent { loading: boolean = false; - constructor(private loginService: LoginService, + constructor(public loginService: LoginService, private promotionService: PromotionService, private awardingService: AwardingService, private router: Router) { 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 7fe14fe..f06c42b 100644 --- a/static/src/app/decorations/decoration-list/decoration-list.component.html +++ b/static/src/app/decorations/decoration-list/decoration-list.component.html @@ -4,28 +4,28 @@ Alle + (change)="filterDecorations(query.value, '')">Alle
- + Auszeichnung hinzufügen @@ -33,11 +33,11 @@
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 817992e..fbb9999 100644 --- a/static/src/app/decorations/decoration-list/decoration-list.component.ts +++ b/static/src/app/decorations/decoration-list/decoration-list.component.ts @@ -47,7 +47,7 @@ export class DecorationListComponent implements OnInit { } - openNewSquadForm() { + openNewDecorationForm() { this.selectedDecorationId = null; this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route}); } @@ -69,7 +69,7 @@ export class DecorationListComponent implements OnInit { } } - filterSquadsByFraction(query = '', fractionFilter) { + filterDecorations(query, fractionFilter) { this.decorations$ = this.decorationService.findDecorations(query, fractionFilter); } diff --git a/static/src/app/models/app-validators.ts b/static/src/app/models/app-validators.ts deleted file mode 100644 index dc5734a..0000000 --- a/static/src/app/models/app-validators.ts +++ /dev/null @@ -1,114 +0,0 @@ -import {Directive, forwardRef} from '@angular/core'; -import {AbstractControl, FormControl, NG_ASYNC_VALIDATORS, NG_VALIDATORS} from '@angular/forms'; -import {UserService} from "../services/user-service/user.service"; - -export function asyncIfNotBacklogThenAssignee(control): Promise { - const promise = new Promise((resolve, reject) => { - setTimeout(() => { - resolve(ifNotBacklogThanAssignee(control)); - }, 500); - }); - return promise; -} - -export function ifNotBacklogThanAssignee(formGroup: FormControl): { [key: string]: any } { - const nameControl = formGroup.get('assignee.name'); - const stateControl = formGroup.get('state'); - if (!nameControl || !stateControl) { - return null; - } - if (stateControl.value !== 'BACKLOG' && - (!nameControl.value || nameControl.value === '')) { - return {'assigneeRequired': true}; - } - return null; -} - -@Directive({ - selector: '[ifNotBacklogThanAssignee]', - providers: [ - { - provide: NG_VALIDATORS, - useExisting: IfNotBacklogThanAssigneeValidatorDirective, multi: true - }] -}) -export class IfNotBacklogThanAssigneeValidatorDirective { - - public validate(formGroup: AbstractControl): { [key: string]: any } { - const nameControl = formGroup.get('assignee.name'); - const stateControl = formGroup.get('state'); - if (!nameControl || !stateControl) { - return null; - } - if (stateControl.value !== 'BACKLOG' && - (!nameControl.value || nameControl.value === '')) { - return {'assigneeRequired': true}; - } - return null; - } -} - -@Directive({ - selector: '[emailValidator]', - providers: [{ - provide: NG_VALIDATORS, - useExisting: EmailValidatorDirective, multi: true - }] -}) -export class EmailValidatorDirective { - validate(control: AbstractControl): { [key: string]: any } { - const re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; - if (!control.value || control.value === '' || re.test(control.value)) { - return null; - } else { - return {'invalidEMail': true}; - } - } -} - -export function emailValidator(control): { [key: string]: any } { - return new EmailValidatorDirective().validate(control); -} - -export function emailValidator2(control): { [key: string]: any } { - const re = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; - if (!control.value || control.value === '' || re.test(control.value)) { - return null; - } else { - return {'invalidEMail': true}; - } -} - -@Directive({ - selector: '[pjmUserExistsValidator]', - providers: [ - { - provide: NG_ASYNC_VALIDATORS, - useExisting: forwardRef(() => UserExistsValidatorDirective), multi: true - } - ] -}) -export class UserExistsValidatorDirective { - constructor(private userService: UserService) { - } - - // validate(control: AbstractControl): Observable { - // return this.userService.checkUserExists(control.value) - // .map(userExists => { - // return (userExists === false) ? {userNotFound: true} : null; - // }); - // } -} - -@Directive({ - selector: '[emailValidator]', - providers: [ - {provide: NG_VALIDATORS, useValue: emailValidator, multi: true} - ] -}) -export class EmailValidatorWithFunctionDirective { -} - - -export const APPLICATION_VALIDATORS = [IfNotBacklogThanAssigneeValidatorDirective, - EmailValidatorDirective]; diff --git a/static/src/app/ranks/rank-list/rank-list.component.html b/static/src/app/ranks/rank-list/rank-list.component.html index 9f090ec..3d46d08 100644 --- a/static/src/app/ranks/rank-list/rank-list.component.html +++ b/static/src/app/ranks/rank-list/rank-list.component.html @@ -5,19 +5,19 @@ Alle + (change)="filterRanks(query.value, '')">Alle @@ -28,11 +28,11 @@
diff --git a/static/src/app/ranks/rank-list/rank-list.component.ts b/static/src/app/ranks/rank-list/rank-list.component.ts index 63644cd..74a06ab 100644 --- a/static/src/app/ranks/rank-list/rank-list.component.ts +++ b/static/src/app/ranks/rank-list/rank-list.component.ts @@ -57,7 +57,7 @@ export class RankListComponent implements OnInit { this.router.navigate([{outlets: {'right': ['edit', rankId]}}], {relativeTo: this.route}); } - filterRanksByFraction(query = '', fractionFilter) { + filterRanks(query, fractionFilter) { this.ranks$ = this.rankService.findRanks(query, fractionFilter); } 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 5354021..470ce78 100644 --- a/static/src/app/squads/squad-list/squad-list.component.html +++ b/static/src/app/squads/squad-list/squad-list.component.html @@ -4,19 +4,19 @@ Alle + (change)="filterSquads(query.value, '')">Alle Squad hinzufügen @@ -26,11 +26,11 @@