Просмотр исходного кода

starting to do monthly performance

tags/2.037
Patrick Sun 4 лет назад
Родитель
Сommit
2e5c4de226
16 измененных файлов: 301 добавлений и 21 удалений
  1. +2
    -1
      src/app/app.component.ts
  2. +5
    -1
      src/app/app.module.ts
  3. +16
    -0
      src/app/chart-amount-of-loans/chart-amount-of-loans.component.html
  4. +0
    -0
      src/app/chart-amount-of-loans/chart-amount-of-loans.component.scss
  5. +25
    -0
      src/app/chart-amount-of-loans/chart-amount-of-loans.component.spec.ts
  6. +52
    -0
      src/app/chart-amount-of-loans/chart-amount-of-loans.component.ts
  7. +14
    -0
      src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.html
  8. +0
    -0
      src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.scss
  9. +25
    -0
      src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.spec.ts
  10. +58
    -0
      src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.ts
  11. +19
    -0
      src/app/chart-type-of-loans/chart-type-of-loans.component.html
  12. +0
    -0
      src/app/chart-type-of-loans/chart-type-of-loans.component.scss
  13. +25
    -0
      src/app/chart-type-of-loans/chart-type-of-loans.component.spec.ts
  14. +45
    -0
      src/app/chart-type-of-loans/chart-type-of-loans.component.ts
  15. +11
    -17
      src/app/dashboard/dashboard.component.html
  16. +4
    -2
      src/app/models/type-of-loans.model.ts

+ 2
- 1
src/app/app.component.ts Просмотреть файл

@@ -66,7 +66,8 @@ export class AppComponent implements OnInit , OnDestroy {

setTimeout(() => {
const specialCommand = 'send dummy string for 500 times';
this.wsService.sendMessage(specialCommand);
this.wsService.sendMessage(specialCommand + " cancelled");

}, 2000);
}


+ 5
- 1
src/app/app.module.ts Просмотреть файл

@@ -46,6 +46,8 @@ import { TransTailsComponent } from './trans-details/trans-tails/trans-tails.com
import {AuthHttpInterceptor} from './auth/auth-http-interceptor.service';
import {WebSocketService} from './websocket';
import { ChartTypeOfLoansComponent } from './chart-type-of-loans/chart-type-of-loans.component';
import { ChartAmountOfLoansComponent } from './chart-amount-of-loans/chart-amount-of-loans.component';
import { ChartPastYearMonthlyPerformanceComponent } from './chart-past-year-monthly-performance/chart-past-year-monthly-performance.component';



@@ -64,7 +66,9 @@ import { ChartTypeOfLoansComponent } from './chart-type-of-loans/chart-type-of-l
RatingComponent,
TransDetailsComponent,
TransTailsComponent,
ChartTypeOfLoansComponent
ChartTypeOfLoansComponent,
ChartAmountOfLoansComponent,
ChartPastYearMonthlyPerformanceComponent
],
imports: [
BrowserModule,

+ 16
- 0
src/app/chart-amount-of-loans/chart-amount-of-loans.component.html Просмотреть файл

@@ -0,0 +1,16 @@

<kendo-chart>
<kendo-chart-title text="Gross value of Loans (Million AUD)"></kendo-chart-title>
<kendo-chart-category-axis>
<kendo-chart-category-axis-item [categories]="label">
</kendo-chart-category-axis-item>
</kendo-chart-category-axis>
<kendo-chart-series>
<kendo-chart-series-item type="bar" [gap]="2" [spacing]=".25" [data]="amount">
</kendo-chart-series-item>
<!-- <kendo-chart-series-item type="bar" [data]="share">-->
<!-- </kendo-chart-series-item>-->
<!-- <kendo-chart-series-item type="bar" [data]="count">-->
<!-- </kendo-chart-series-item>-->
</kendo-chart-series>
</kendo-chart>

+ 0
- 0
src/app/chart-amount-of-loans/chart-amount-of-loans.component.scss Просмотреть файл


+ 25
- 0
src/app/chart-amount-of-loans/chart-amount-of-loans.component.spec.ts Просмотреть файл

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ChartAmountOfLoansComponent } from './chart-amount-of-loans.component';

describe('ChartAmountOfLoansComponent', () => {
let component: ChartAmountOfLoansComponent;
let fixture: ComponentFixture<ChartAmountOfLoansComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ChartAmountOfLoansComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ChartAmountOfLoansComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

+ 52
- 0
src/app/chart-amount-of-loans/chart-amount-of-loans.component.ts Просмотреть файл

@@ -0,0 +1,52 @@
import { Component, OnInit } from '@angular/core';
import {Observable} from 'rxjs';
import {TypeOfLoansModel} from '../models/type-of-loans.model';
import {AuthService} from '../service/auth.service';
import {HttpClient} from '@angular/common/http';

@Component({
selector: 'app-chart-amount-of-loans',
templateUrl: './chart-amount-of-loans.component.html',
styleUrls: ['./chart-amount-of-loans.component.scss']
})
export class ChartAmountOfLoansComponent implements OnInit {

public autoFit = true;
public data: Observable<TypeOfLoansModel[]>;

public label = ['Q1', 'Q2', 'Q3', 'Q4'];
public amount = [87, 154, 210, 215];
public share = [87, 154, 210, 215];
public count = [87, 154, 210, 215];

constructor(private auth: AuthService, private http: HttpClient) { }

ngOnInit(): void {
this.getAmountOfLoans();
}


// tslint:disable-next-line:typedef
public getAmountOfLoans() {
this.http.get<TypeOfLoansModel[]>(this.auth.getUrl('chart/amount-of-loans')).subscribe(
resp => {
this.buildChart(resp);
}
);
}

// tslint:disable-next-line:typedef
public buildChart(items: TypeOfLoansModel[]) {
this.amount =[];
this.share = [];
this.label = [];
this.count = [];
items.forEach( (value, index) =>{
this.label.push(value.Kind);
this.amount.push(value.Amount / 1000000);
this.share.push(value.Share);
this.count.push(value.Count);
});
}

}

+ 14
- 0
src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.html Просмотреть файл

@@ -0,0 +1,14 @@
<kendo-chart [title]="{ text: 'Monthly Loan Value' }">
<kendo-chart-series>
<kendo-chart-series-item type="waterfall"
[data]="cashFlowData" [color]="pointColor"
field="amount" categoryField="period" summaryField="summary">
<kendo-chart-series-item-labels format="C0" position="insideEnd">
</kendo-chart-series-item-labels>
</kendo-chart-series-item>
</kendo-chart-series>
<kendo-chart-value-axis>
<kendo-chart-value-axis-item [labels]="{ format: 'C0' }">
</kendo-chart-value-axis-item>
</kendo-chart-value-axis>
</kendo-chart>

+ 0
- 0
src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.scss Просмотреть файл


+ 25
- 0
src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.spec.ts Просмотреть файл

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ChartPastYearMontnlyPerformanceComponent } from './chart-past-year-monthly-performance.component';

describe('ChartPastYearMontnlyPerformanceComponent', () => {
let component: ChartPastYearMontnlyPerformanceComponent;
let fixture: ComponentFixture<ChartPastYearMontnlyPerformanceComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ChartPastYearMontnlyPerformanceComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ChartPastYearMontnlyPerformanceComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

+ 58
- 0
src/app/chart-past-year-monthly-performance/chart-past-year-monthly-performance.component.ts Просмотреть файл

@@ -0,0 +1,58 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-chart-past-year-monthly-performance',
templateUrl: './chart-past-year-monthly-performance.component.html',
styleUrls: ['./chart-past-year-monthly-performance.component.scss']
})
export class ChartPastYearMonthlyPerformanceComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}
public cashFlowData = [{
period: 'beginning',
amount: 50000
}, {
period: 'Jan',
amount: 17000
}, {
period: 'Feb',
amount: 14000
}, {
period: 'Mar',
amount: -12000
}, {
period: 'Q1',
summary: 'runningTotal'
}, {
period: 'Apr',
amount: -22000
}, {
period: 'May',
amount: -18000
}, {
period: 'Jun',
amount: 10000
}, {
period: 'Q2',
summary: 'runningTotal'
}, {
period: 'Ending',
summary: 'total'
}];

public pointColor(point: any): string {
const summary = point.dataItem.summary;
if (summary) {
return summary === 'total' ? '#555' : 'gray';
}

if (point.value > 0) {
return 'green';
} else {
return 'red';
}
}
}

+ 19
- 0
src/app/chart-type-of-loans/chart-type-of-loans.component.html Просмотреть файл

@@ -0,0 +1,19 @@

<kendo-chart [transitions]="true">
<kendo-chart-title text="Stages of Loans"></kendo-chart-title>
<kendo-chart-series>
<kendo-chart-series-item
[autoFit]="autoFit"
type="donut" [data]="data | async"
categoryField="Kind" field="Share">
<kendo-chart-series-item-labels
position="outsideEnd"
color="#000"
[content]="labelContent">
</kendo-chart-series-item-labels>
</kendo-chart-series-item>
</kendo-chart-series>
<kendo-chart-legend [visible]="false"></kendo-chart-legend>
</kendo-chart>



+ 0
- 0
src/app/chart-type-of-loans/chart-type-of-loans.component.scss Просмотреть файл


+ 25
- 0
src/app/chart-type-of-loans/chart-type-of-loans.component.spec.ts Просмотреть файл

@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ChartTypeOfLoansComponent } from './chart-type-of-loans.component';

describe('ChartTypeOfLoansComponent', () => {
let component: ChartTypeOfLoansComponent;
let fixture: ComponentFixture<ChartTypeOfLoansComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ChartTypeOfLoansComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ChartTypeOfLoansComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});

+ 45
- 0
src/app/chart-type-of-loans/chart-type-of-loans.component.ts Просмотреть файл

@@ -0,0 +1,45 @@
import { Component, OnInit } from '@angular/core';
import {Observable} from 'rxjs';
import {TypeOfLoansModel} from '../models/type-of-loans.model';
import {HttpClient} from '@angular/common/http';
import {AuthService} from '../service/auth.service';
import {map} from 'rxjs/operators';

@Component({
selector: 'app-chart-type-of-loans',
templateUrl: './chart-type-of-loans.component.html',
styleUrls: ['./chart-type-of-loans.component.scss']
})
export class ChartTypeOfLoansComponent implements OnInit {
public autoFit = true;
public data: Observable<TypeOfLoansModel[]>;

constructor(private auth: AuthService, private http: HttpClient) { }

ngOnInit(): void {
this.data = this.getTypeOfLoans();
}

public labelContent(e: any): string {
return e.category;
}

public getTypeOfLoans(): Observable<TypeOfLoansModel[]> {
return this.http.get<TypeOfLoansModel[]>(this.auth.getUrl('chart/type-of-loans')).pipe(
map(
input => {
let ret = [];
input.forEach( (value, index) =>{
ret.push({
Kind: value.Kind + ' ' + (value.Share * 100) + '%',
Count: value.Count,
Share: value.Share,
Amount: value.Amount
}); });
return ret;
}
)
);
}

}

+ 11
- 17
src/app/dashboard/dashboard.component.html Просмотреть файл

@@ -2,7 +2,7 @@
<div class="container inner">
<bkp-divider-shadow-bottom></bkp-divider-shadow-bottom>
<bkp-divider>
<kendo-icon [name]="'ascx'" > </kendo-icon> &nbsp; Daily summary
<kendo-icon [name]="'ascx'" > </kendo-icon> &nbsp; Loan overview
</bkp-divider>

<div class="row">
@@ -10,24 +10,18 @@
<app-chart-type-of-loans></app-chart-type-of-loans>
</div>
<div class="col-sm-6">
<kendo-chart>
<kendo-chart-title text="Units sold"></kendo-chart-title>
<app-chart-amount-of-loans></app-chart-amount-of-loans>
</div>
</div>

<kendo-chart-category-axis>
<kendo-chart-category-axis-item [categories]="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul']"
[title]="{ text: 'type' }">
</kendo-chart-category-axis-item>
</kendo-chart-category-axis>
<bkp-divider-shadow-bottom></bkp-divider-shadow-bottom>
<bkp-divider>
<kendo-icon [name]="'ascx'" > </kendo-icon> &nbsp; Past 12 Month Performance
</bkp-divider>

<kendo-chart-series>
<kendo-chart-series-item type="bar" [data]="[123, 276, 310, 212, 240, 156, 98]">
</kendo-chart-series-item>
<kendo-chart-series-item type="bar" [data]="[165, 210, 287, 144, 190, 167, 212]">
</kendo-chart-series-item>
<kendo-chart-series-item type="bar" [data]="[56, 140, 195, 46, 123, 78, 95]">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
<div class="row">
<div class="col-sm-12">
<app-chart-past-year-monthly-performance></app-chart-past-year-monthly-performance>
</div>
</div>
<bkp-divider-shadow-bottom></bkp-divider-shadow-bottom>

+ 4
- 2
src/app/models/type-of-loans.model.ts Просмотреть файл

@@ -1,6 +1,8 @@


export class TypeOfLoansModel{
kind: string;
share: number;
Kind: string;
Count: number;
Amount: number;
Share: number;
}

Загрузка…
Отмена
Сохранить