* TspInfo module added

This commit is contained in:
Dávid Danyi 2017-09-06 18:53:31 +02:00
parent c61d1c8f13
commit 7e82c57b0e
41 changed files with 625 additions and 1 deletions

View File

@ -4,6 +4,7 @@ import { NgModule } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { KanbanModule } from './kanban/kanban.module';
import { TspInfoModule } from "./tsp-info/tsp-info.module";
@NgModule({
declarations: [
@ -12,7 +13,8 @@ import { KanbanModule } from './kanban/kanban.module';
imports: [
BrowserModule,
AppRoutingModule,
KanbanModule
KanbanModule,
TspInfoModule
],
providers: [],
bootstrap: [AppComponent]

View File

@ -0,0 +1,3 @@
<p>
animgif works!
</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { AnimgifComponent } from './animgif.component';
describe('AnimgifComponent', () => {
let component: AnimgifComponent;
let fixture: ComponentFixture<AnimgifComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ AnimgifComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(AnimgifComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,21 @@
import { Component, OnInit } from '@angular/core';
import {InfoBoxComponent} from "../info-box/info-box.component";
@Component({
selector: 'app-animgif',
templateUrl: './animgif.component.html',
styleUrls: [
'../info-box/info-box.component.css',
'./animgif.component.css'
]
})
export class AnimgifComponent extends InfoBoxComponent implements OnInit {
constructor() {
super();
}
ngOnInit() {
}
}

View File

@ -0,0 +1,4 @@
<h1>{{title}}</h1>
<h2>{{data.all}}</h2>
<h3>{{data.unassigned}}</h3>
<p>unassigned</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ExpeditesComponent } from './expedites.component';
describe('ExpeditesComponent', () => {
let component: ExpeditesComponent;
let fixture: ComponentFixture<ExpeditesComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ExpeditesComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ExpeditesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,23 @@
import {Component, Input, OnInit} from '@angular/core';
import {InfoBoxComponent} from "../info-box/info-box.component";
import {ExpediteInfo} from "../shared/expedite-info.model";
@Component({
selector: 'app-expedites',
templateUrl: './expedites.component.html',
styleUrls: [
'../info-box/info-box.component.css',
'./expedites.component.css'
]
})
export class ExpeditesComponent extends InfoBoxComponent implements OnInit {
@Input() data: ExpediteInfo;
constructor() {
super();
}
ngOnInit() {}
}

View File

@ -0,0 +1,5 @@
:host {
display: inline-block;
padding: 1.25em;
background-color: #0E566C;
}

View File

@ -0,0 +1,3 @@
<p>
info-box works!
</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { InfoBoxComponent } from './info-box.component';
describe('InfoBoxComponent', () => {
let component: InfoBoxComponent;
let fixture: ComponentFixture<InfoBoxComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InfoBoxComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(InfoBoxComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,18 @@
import {Component, Input, OnInit} from '@angular/core';
@Component({
selector: 'app-info-box',
templateUrl: './info-box.component.html',
styleUrls: ['./info-box.component.css']
})
export class InfoBoxComponent implements OnInit {
@Input() title = '';
@Input() data: any;
constructor() { }
ngOnInit() {
}
}

View File

@ -0,0 +1,17 @@
<p>
<app-tr-progress
title="OVERDUE PROGRESS INFOS (DAYS)"
[data]="tspInfo.trProgressInfo"></app-tr-progress>
<app-tr-flow-errors
title="TR FLOW ERRORS"
[data]="tspInfo.trFlowErrors"></app-tr-flow-errors>
<app-pra-goals
title="PRA TR GOALS(A,B,C PRIO)"
[data]="tspInfo.praGoals"></app-pra-goals>
<app-expedites
title="NUMBER OF EXPEDITES (W/O PA)"
[data]="tspInfo.expedites"></app-expedites>
<app-animgif
title=""
[data]="tspInfo.animGifs"></app-animgif>
</p>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { InfoPageComponent } from './info-page.component';
describe('InfoPageComponent', () => {
let component: InfoPageComponent;
let fixture: ComponentFixture<InfoPageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InfoPageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(InfoPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,34 @@
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from "@angular/router";
import {Title} from "@angular/platform-browser";
import {
TspInfo,
TspInfoService,
} from "../shared";
@Component({
selector: 'app-info-page',
templateUrl: './info-page.component.html',
styleUrls: ['./info-page.component.css']
})
export class InfoPageComponent implements OnInit {
constructor(private titleService: Title,
private route: ActivatedRoute,
private tspInfoService: TspInfoService) {
}
ngOnInit() {
this.titleService.setTitle('TaurusXFT : TSP INFO');
this.route.data.subscribe((data: { tspInfo: TspInfo }) => this.tspInfo = data.tspInfo);
}
get tspInfo(): TspInfo {
return this.tspInfoService.tspInfo;
}
set tspInfo(tspInfo: TspInfo) {
this.tspInfoService.tspInfo = tspInfo;
}
}

View File

@ -0,0 +1,24 @@
<h1>{{title}}</h1>
<p>
<span class="heading">CORE</span>
<span class="heading">SIG</span>
<span class="heading">TADE</span>
</p>
<p>
<span class="heading">{{data.core.A}}</span>
<span class="heading">{{data.sig.A}}</span>
<span class="heading">{{data.tade.A}}</span>
</p>
<h2>{{sumA}}</h2>
<p>
<span class="heading">{{data.core.B}}</span>
<span class="heading">{{data.sig.B}}</span>
<span class="heading">{{data.tade.B}}</span>
</p>
<h2>{{sumB}}</h2>
<p>
<span class="heading">{{data.core.C}}</span>
<span class="heading">{{data.sig.C}}</span>
<span class="heading">{{data.tade.C}}</span>
</p>
<h2>{{sumC}}</h2>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PraGoalsComponent } from './pra-goals.component';
describe('PraGoalsComponent', () => {
let component: PraGoalsComponent;
let fixture: ComponentFixture<PraGoalsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PraGoalsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PraGoalsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,43 @@
import {Component, Input, OnInit} from '@angular/core';
import {InfoBoxComponent} from "../info-box/info-box.component";
import {PrioValues} from "../shared/prio-values.model";
@Component({
selector: 'app-pra-goals',
templateUrl: './pra-goals.component.html',
styleUrls: [
'../info-box/info-box.component.css',
'./pra-goals.component.css'
]
})
export class PraGoalsComponent extends InfoBoxComponent implements OnInit {
@Input() data: {
core: PrioValues,
sig: PrioValues,
tade: PrioValues
};
constructor() {
super();
}
ngOnInit() {
}
get sumA(): number {
return this.sum('A');
}
get sumB(): number {
return this.sum('B');
}
get sumC(): number {
return this.sum('C');
}
public sum(prio: string) {
return ['core', 'sig', 'tade'].reduce((sum,unit) => sum + this.data[unit][prio], 0);
}
}

View File

@ -0,0 +1,4 @@
export class AnimGif {
public url: string;
public label: string;
}

View File

@ -0,0 +1,4 @@
export class ExpediteInfo {
public unassigned: number;
public all: number;
}

View File

@ -0,0 +1,9 @@
export * from './anim-gif.model';
export * from './expedite-info.model';
export * from './lab-temperature.model';
export * from './tr-flow-error.model';
export * from './prio-values.model';
export * from './tr-progress.model';
export * from './tsp-info.model';
export * from './tsp-info.service';

View File

@ -0,0 +1,2 @@
export class LabTemperature {
}

View File

@ -0,0 +1,5 @@
export class PrioValues {
public A: number = 0;
public B: number = 0;
public C: number = 0;
}

View File

@ -0,0 +1,4 @@
export class TrFlowError {
public label: string = '';
public value: number = 0;
}

View File

@ -0,0 +1,6 @@
export class TrProgress {
public eriref: string = '';
public heading: string = '';
public prio: string = '';
public lastProgressInDays: number = 0;
}

View File

@ -0,0 +1,31 @@
import {
AnimGif,
ExpediteInfo,
LabTemperature,
PrioValues,
TrProgress,
TrFlowError
} from ".";
export class TspInfo {
public cameraMovieUrls: Array<string> = [];
public animGifs: Array<AnimGif> = [];
public praGoals: {
core: PrioValues,
sig: PrioValues,
tade: PrioValues
};
public trProgressInfo: Array<TrProgress> = [];
public trFlowErrors: Array<TrFlowError> = [];
public expedites: ExpediteInfo = {
unassigned: 0,
all: 0
};
public isVacationSoon: boolean = false;
public labTemperature: LabTemperature = {
back_right: 0,
back_middle: 0,
back_left: 0
};
}

View File

@ -0,0 +1,15 @@
import { TestBed, inject } from '@angular/core/testing';
import { TspInfoService } from './tsp-info.service';
describe('TspInfoService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [TspInfoService]
});
});
it('should be created', inject([TspInfoService], (service: TspInfoService) => {
expect(service).toBeTruthy();
}));
});

View File

@ -0,0 +1,54 @@
import {Injectable} from '@angular/core';
import {Http, Headers} from "@angular/http";
import 'rxjs/Rx';
import {Router, Resolve, ActivatedRouteSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable';
import {environment} from '../../../environments/environment';
import {
TspInfo
} from '.';
@Injectable()
export class TspInfoService {
private url = environment.apiUri + '/api/tsp-info';
private cachedTspInfo: TspInfo = new TspInfo();
constructor(private httpService: Http) {}
/**
* Returns an observable instance to the kanban board api
*
* @returns {Observable<TspInfo>}
*/
public getList(): Observable<TspInfo> {
return this.httpService.get(this.url).map(res => <TspInfo>res.json());
}
/**
* Route preload resolver
*
* @param {ActivatedRouteSnapshot} route
* @returns {Promise<TspInfo>}
*/
public resolve(route: ActivatedRouteSnapshot): Promise<TspInfo> {
return this.getList().toPromise().then(result => result ? result : false);
}
/**
* Reload the board
*/
public reload() {
this.getList().subscribe(result => this.cachedTspInfo = result);
}
get tspInfo(): TspInfo {
return this.cachedTspInfo;
}
set tspInfo(tspInfo: TspInfo) {
this.cachedTspInfo = tspInfo;
}
}

View File

@ -0,0 +1,7 @@
<h1>{{title}} ({{errorSum}})</h1>
<ul>
<li *ngFor="let flowError of data">
<span class="label">{{flowError.label}}</span>
<span class="value">{{flowError.value}}</span>
</li>
</ul>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TrFlowErrorsComponent } from './tr-flow-errors.component';
describe('TrFlowErrorsComponent', () => {
let component: TrFlowErrorsComponent;
let fixture: ComponentFixture<TrFlowErrorsComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TrFlowErrorsComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TrFlowErrorsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,27 @@
import {Component, Input, OnInit} from '@angular/core';
import {InfoBoxComponent} from "../info-box/info-box.component";
import {TrFlowError} from "../shared/tr-flow-error.model";
@Component({
selector: 'app-tr-flow-errors',
templateUrl: './tr-flow-errors.component.html',
styleUrls: [
'../info-box/info-box.component.css',
'./tr-flow-errors.component.css'
]
})
export class TrFlowErrorsComponent extends InfoBoxComponent implements OnInit {
@Input() data: Array<TrFlowError> = [];
constructor() {
super();
}
ngOnInit() {
}
get errorSum(): number {
return this.data.reduce((sum: number, flowError: TrFlowError) => sum + flowError.value, 0);
}
}

View File

@ -0,0 +1,7 @@
<h1>THE MOST OVERDUE PROGRESS INFOS (DAYS)</h1>
<ul>
<li *ngFor="let progress of data">
<span class="label">{{progress.eriref}} {{progress.heading}}</span>
<span class="value">{{progress.lastProgressInDays}}</span>
</li>
</ul>

View File

@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { TrProgressComponent } from './tr-progress.component';
describe('TrProgressComponent', () => {
let component: TrProgressComponent;
let fixture: ComponentFixture<TrProgressComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TrProgressComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(TrProgressComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should be created', () => {
expect(component).toBeTruthy();
});
});

View File

@ -0,0 +1,24 @@
import {Component, Input, OnInit} from '@angular/core';
import {InfoBoxComponent} from "../info-box/info-box.component";
import {TrProgress} from "../shared/tr-progress.model";
@Component({
selector: 'app-tr-progress',
templateUrl: './tr-progress.component.html',
styleUrls: [
'../info-box/info-box.component.css',
'./tr-progress.component.css'
]
})
export class TrProgressComponent extends InfoBoxComponent implements OnInit {
@Input() data: Array<TrProgress> = [];
constructor() {
super();
}
ngOnInit() {
}
}

View File

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { InfoPageComponent } from "./info-page/info-page.component";
import { TspInfoService } from "./shared/tsp-info.service";
const routes: Routes = [
{
path: 'tsp-info-page',
children: [],
component: InfoPageComponent,
resolve: {
tspInfo: TspInfoService,
},
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class TspInfoRoutingModule { }

View File

@ -0,0 +1,32 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { TspInfoRoutingModule } from './tsp-info-routing.module';
import { InfoBoxComponent } from './info-box/info-box.component';
import { TrProgressComponent } from './tr-progress/tr-progress.component';
import { ExpeditesComponent } from './expedites/expedites.component';
import { TrFlowErrorsComponent } from './tr-flow-errors/tr-flow-errors.component';
import { PraGoalsComponent } from './pra-goals/pra-goals.component';
import { InfoPageComponent } from './info-page/info-page.component';
import { AnimgifComponent } from './animgif/animgif.component';
import { TspInfoService } from './shared/tsp-info.service';
import { HttpModule } from "@angular/http";
@NgModule({
imports: [
CommonModule,
HttpModule,
TspInfoRoutingModule
],
declarations: [
InfoBoxComponent,
TrProgressComponent,
ExpeditesComponent,
TrFlowErrorsComponent,
PraGoalsComponent,
InfoPageComponent,
AnimgifComponent
],
providers: [TspInfoService]
})
export class TspInfoModule { }