OPTIMIZE - fix prod build validations; remove manual minify

pull/13/head
Florian Hartwich 2017-10-08 12:17:21 +02:00
parent 8799a1cdcd
commit 07dbbc106c
16 changed files with 35 additions and 164 deletions

View File

@ -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

View File

@ -1,13 +1,13 @@
{ {
"name": "opt-cc", "name": "opt-cc",
"version": "1.5.2", "version": "1.5.3",
"license": "MIT", "license": "MIT",
"private": true, "private": true,
"scripts": { "scripts": {
"start": "npm run deploy-static-prod && npm start --prefix ./api", "start": "npm run deploy-static-prod && npm start --prefix ./api",
"dev": "npm run deploy-static && npm run dev --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": "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", "postinstall": "npm install --prefix ./static && npm install --prefix ./api",
"mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data", "mongodb": "mkdir -p mongodb-data && mongod --dbpath ./mongodb-data",
"test": "npm test --prefix ./api", "test": "npm test --prefix ./api",

View File

@ -16,7 +16,7 @@ export class AppComponent {
loading: boolean = false; loading: boolean = false;
constructor(private loginService: LoginService, constructor(public loginService: LoginService,
private promotionService: PromotionService, private promotionService: PromotionService,
private awardingService: AwardingService, private awardingService: AwardingService,
private router: Router) { private router: Router) {

View File

@ -4,28 +4,28 @@
<input type="radio" name="fractSelect" <input type="radio" name="fractSelect"
[checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'" [checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
(change)="filterSquadsByFraction(query.value)">Alle (change)="filterDecorations(query.value, '')">Alle
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="blufor" <input type="radio" name="fractSelect" value="blufor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioBufor #fractRadioBufor
(change)="filterSquadsByFraction(query.value, fractRadioBufor.value)">NATO (change)="filterDecorations(query.value, fractRadioBufor.value)">NATO
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="opfor" <input type="radio" name="fractSelect" value="opfor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioOpfor #fractRadioOpfor
(change)="filterSquadsByFraction(query.value, fractRadioOpfor.value)">CSAT (change)="filterDecorations(query.value, fractRadioOpfor.value)">CSAT
</label> </label>
<br> <br>
<label class="radio-inline" style="padding-top: 8px;"> <label class="radio-inline" style="padding-top: 8px;">
<input type="radio" name="fractSelect" value="global" <input type="radio" name="fractSelect" value="global"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioGlobal #fractRadioGlobal
(change)="filterSquadsByFraction(query.value, fractRadioGlobal.value)">Global (change)="filterDecorations(query.value, fractRadioGlobal.value)">Global
</label> </label>
<a class="pull-right btn btn-success" (click)="openNewSquadForm()"> <a class="pull-right btn btn-success" (click)="openNewDecorationForm()">
Auszeichnung hinzufügen Auszeichnung hinzufügen
</a> </a>
</div> </div>
@ -33,11 +33,11 @@
<div class="input-group list-header"> <div class="input-group list-header">
<input id="search-tasks" <input id="search-tasks"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="findSquads(query.value)" (keyup.enter)="filterDecorations(query.value, fractionRadioSelect)"
[formControl]="searchTerm"> [formControl]="searchTerm">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" <button class="btn btn-default" type="button"
(click)="findSquads(query.value)"> (click)="filterDecorations(query.value, fractionRadioSelect)">
Suchen Suchen
</button> </button>
</span> </span>

View File

@ -47,7 +47,7 @@ export class DecorationListComponent implements OnInit {
} }
openNewSquadForm() { openNewDecorationForm() {
this.selectedDecorationId = null; this.selectedDecorationId = null;
this.router.navigate([{outlets: {'right': ['new']}}], {relativeTo: this.route}); 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); this.decorations$ = this.decorationService.findDecorations(query, fractionFilter);
} }

View File

@ -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<any> {
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<any> {
// 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];

View File

@ -5,19 +5,19 @@
<input type="radio" name="fractSelect" <input type="radio" name="fractSelect"
[checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'" [checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
(change)="filterRanksByFraction(query.value)">Alle (change)="filterRanks(query.value, '')">Alle
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="blufor" <input type="radio" name="fractSelect" value="blufor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioBufor #fractRadioBufor
(change)="filterRanksByFraction(query.value, fractRadioBufor.value)">NATO (change)="filterRanks(query.value, fractRadioBufor.value)">NATO
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="opfor" <input type="radio" name="fractSelect" value="opfor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioOpfor #fractRadioOpfor
(change)="filterRanksByFraction(query.value, fractRadioOpfor.value)">CSAT (change)="filterRanks(query.value, fractRadioOpfor.value)">CSAT
</label> </label>
</form> </form>
<a class="pull-right btn btn-success" (click)="openNewRankForm()"> <a class="pull-right btn btn-success" (click)="openNewRankForm()">
@ -28,11 +28,11 @@
<div class="input-group list-header"> <div class="input-group list-header">
<input id="search-tasks" <input id="search-tasks"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="findRanks(query.value)" (keyup.enter)="filterRanks(query.value, fractionRadioSelect)"
[formControl]="searchTerm"> [formControl]="searchTerm">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" <button class="btn btn-default" type="button"
(click)="findRanks(query.value)"> (click)="filterRanks(query.value, fractionRadioSelect)">
Suchen Suchen
</button> </button>
</span> </span>

View File

@ -57,7 +57,7 @@ export class RankListComponent implements OnInit {
this.router.navigate([{outlets: {'right': ['edit', rankId]}}], {relativeTo: this.route}); this.router.navigate([{outlets: {'right': ['edit', rankId]}}], {relativeTo: this.route});
} }
filterRanksByFraction(query = '', fractionFilter) { filterRanks(query, fractionFilter) {
this.ranks$ = this.rankService.findRanks(query, fractionFilter); this.ranks$ = this.rankService.findRanks(query, fractionFilter);
} }

View File

@ -4,19 +4,19 @@
<input type="radio" name="fractSelect" <input type="radio" name="fractSelect"
[checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'" [checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
(change)="filterSquadsByFraction(query.value)">Alle (change)="filterSquads(query.value, '')">Alle
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="blufor" <input type="radio" name="fractSelect" value="blufor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioBufor #fractRadioBufor
(change)="filterSquadsByFraction(query.value, fractRadioBufor.value)">NATO (change)="filterSquads(query.value, fractRadioBufor.value)">NATO
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="opfor" <input type="radio" name="fractSelect" value="opfor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioOpfor #fractRadioOpfor
(change)="filterSquadsByFraction(query.value, fractRadioOpfor.value)">CSAT (change)="filterSquads(query.value, fractRadioOpfor.value)">CSAT
</label> </label>
<a class="pull-right btn btn-success" (click)="openNewSquadForm()"> <a class="pull-right btn btn-success" (click)="openNewSquadForm()">
Squad hinzufügen Squad hinzufügen
@ -26,11 +26,11 @@
<div class="input-group search-bar" style="padding-top: 0;"> <div class="input-group search-bar" style="padding-top: 0;">
<input id="search-tasks" <input id="search-tasks"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="findSquads(query.value)" (keyup.enter)="filterSquads(query.value, fractionRadioSelect)"
[formControl]="searchTerm"> [formControl]="searchTerm">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" <button class="btn btn-default" type="button"
(click)="findSquads(query.value)"> (click)="filterSquads(query.value, fractionRadioSelect)">
Suchen Suchen
</button> </button>
</span> </span>

View File

@ -66,7 +66,7 @@ export class SquadListComponent implements OnInit {
} }
} }
filterSquadsByFraction(query = '', fractionFilter) { filterSquads(query = '', fractionFilter) {
this.squads$ = this.squadService.findSquads(query, fractionFilter); this.squads$ = this.squadService.findSquads(query, fractionFilter);
} }

View File

@ -55,7 +55,7 @@ export class WarDetailComponent {
}); });
} }
filterPlayersByFraction(fraction: string) { filterPlayersByFraction(fraction?: string) {
if (fraction) { if (fraction) {
this.rows = this.war.players.filter((player) => { this.rows = this.war.players.filter((player) => {
return player.fraction === fraction; return player.fraction === fraction;

View File

@ -20,7 +20,7 @@ export class WarItemComponent {
warDelete = new EventEmitter(); warDelete = new EventEmitter();
constructor(private loginService: LoginService) { constructor(public loginService: LoginService) {
} }
ngOnInit() { ngOnInit() {

View File

@ -19,7 +19,7 @@ export class WarListComponent implements OnInit {
constructor(private warService: WarService, constructor(private warService: WarService,
private campaignService: CampaignService, private campaignService: CampaignService,
private loginService: LoginService, public loginService: LoginService,
private router: Router, private router: Router,
private route: ActivatedRoute) { private route: ActivatedRoute) {
} }

View File

@ -31,7 +31,7 @@ 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) { public campaignService: CampaignService) {
} }
fileChange(event) { fileChange(event) {

View File

@ -4,26 +4,26 @@
<input type="radio" name="fractSelect" <input type="radio" name="fractSelect"
[checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'" [checked]="(fractionRadioSelect == undefined) ? 'true' : 'false'"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
(change)="filterUsersByFraction(query.value)">Alle (change)="filterUser(query.value, '')">Alle
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="blufor" <input type="radio" name="fractSelect" value="blufor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioBufor #fractRadioBufor
(change)="filterUsersByFraction(query.value, fractRadioBufor.value)">NATO (change)="filterUser(query.value, fractRadioBufor.value)">NATO
</label> </label>
<label class="radio-inline"> <label class="radio-inline">
<input type="radio" name="fractSelect" value="opfor" <input type="radio" name="fractSelect" value="opfor"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioOpfor #fractRadioOpfor
(change)="filterUsersByFraction(query.value, fractRadioOpfor.value)">CSAT (change)="filterUser(query.value, fractRadioOpfor.value)">CSAT
</label> </label>
<br> <br>
<label class="radio-inline" style="padding-top: 8px;"> <label class="radio-inline" style="padding-top: 8px;">
<input type="radio" name="fractSelect" value="unassigned" <input type="radio" name="fractSelect" value="unassigned"
[(ngModel)]="fractionRadioSelect" [(ngModel)]="fractionRadioSelect"
#fractRadioUnassigned #fractRadioUnassigned
(change)="filterUsersByFraction(query.value, fractRadioUnassigned.value)">Ohne Squad (change)="filterUser(query.value, fractRadioUnassigned.value)">Ohne Squad
</label> </label>
<a class="pull-right btn btn-success" (click)="openNewUserForm()"> <a class="pull-right btn btn-success" (click)="openNewUserForm()">
Teilnehmer hinzufügen Teilnehmer hinzufügen
@ -33,11 +33,11 @@
<div class="input-group list-header"> <div class="input-group list-header">
<input id="search-tasks" <input id="search-tasks"
type="text" #query class="form-control" type="text" #query class="form-control"
(keyup.enter)="findUsers(query.value)" (keyup.enter)="filterUser(query.value, fractionRadioSelect)"
[formControl]="searchTerm"> [formControl]="searchTerm">
<span class="input-group-btn"> <span class="input-group-btn">
<button class="btn btn-default" type="button" <button class="btn btn-default" type="button"
(click)="findUsers(query.value)"> (click)="filterUser(query.value, fractionRadioSelect)">
Suchen Suchen
</button> </button>
</span> </span>

View File

@ -70,7 +70,7 @@ export class UserListComponent implements OnInit {
} }
} }
filterUsersByFraction(query = '', fractionFilter) { filterUser(query, fractionFilter) {
this.users$ = this.userService.findUsers(query, fractionFilter); this.users$ = this.userService.findUsers(query, fractionFilter);
} }