Automatic lint

This commit is contained in:
Ben Goldsworthy 2021-03-20 23:47:48 +00:00
parent 9bbf6af75c
commit 06dfb7947b
16 changed files with 272 additions and 273 deletions

View file

@ -1,5 +1,5 @@
import { LoginPageObject } from './login.po'; import { LoginPageObject } from './login.po';
import { browser } from "protractor"; import { browser } from 'protractor';
describe('Login Page', () => { describe('Login Page', () => {
let page: LoginPageObject; let page: LoginPageObject;

View file

@ -91,7 +91,7 @@ export class AddDataComponent implements OnInit {
} }
private setCategoryList(data: any) { private setCategoryList(data: any) {
let halfLength = Math.floor(data.length / 2); const halfLength = Math.floor(data.length / 2);
this.leftCategoryList = data.splice(0, halfLength); this.leftCategoryList = data.splice(0, halfLength);
this.rightCategoryList = data; this.rightCategoryList = data;
} }

View file

@ -9,10 +9,10 @@ import * as moment from 'moment';
}) })
export class CategoryMonthComponent implements OnInit { export class CategoryMonthComponent implements OnInit {
disableCategoryButton1: boolean = false; disableCategoryButton1 = false;
disableCategoryButton2: boolean = false; disableCategoryButton2 = false;
disableCategoryButton3: boolean = false; disableCategoryButton3 = false;
disableCategoryButton4: boolean = false; disableCategoryButton4 = false;
weekPurchaseList = { weekPurchaseList = {
first: 0, first: 0,
@ -22,14 +22,14 @@ export class CategoryMonthComponent implements OnInit {
weekList2 = []; weekList2 = [];
weekList3 = []; weekList3 = [];
weekList4 = []; weekList4 = [];
weekListValueSum1: number = 0; weekListValueSum1 = 0;
weekListValueSum2: number = 0; weekListValueSum2 = 0;
weekListValueSum3: number = 0; weekListValueSum3 = 0;
weekListValueSum4: number = 0; weekListValueSum4 = 0;
weekEssential1: number = 0; weekEssential1 = 0;
weekEssential2: number = 0; weekEssential2 = 0;
weekEssential3: number = 0; weekEssential3 = 0;
weekEssential4: number = 0; weekEssential4 = 0;
dayList: any[] = []; dayList: any[] = [];
valueList: number[] = []; valueList: number[] = [];
@ -37,10 +37,10 @@ export class CategoryMonthComponent implements OnInit {
myWeek2: any; myWeek2: any;
myWeek3: any; myWeek3: any;
myWeek4: any; myWeek4: any;
categoryLimit1: number = 6; categoryLimit1 = 6;
categoryLimit2: number = 6; categoryLimit2 = 6;
categoryLimit3: number = 6; categoryLimit3 = 6;
categoryLimit4: number = 6; categoryLimit4 = 6;
constructor( constructor(
private api: ApiService, private api: ApiService,
@ -87,16 +87,16 @@ export class CategoryMonthComponent implements OnInit {
data3: any, data3: any,
data4: any) { data4: any) {
if (data1) { if (data1) {
this.weekListValueSum1 = data1.reduce(function (s, a) {return s + a.value;}, 0); this.weekListValueSum1 = data1.reduce(function (s, a) {return s + a.value; }, 0);
} }
if (data2) { if (data2) {
this.weekListValueSum2 = data2.reduce(function (s, a) {return s + a.value;}, 0); this.weekListValueSum2 = data2.reduce(function (s, a) {return s + a.value; }, 0);
} }
if (data3) { if (data3) {
this.weekListValueSum3 = data3.reduce(function (s, a) {return s + a.value;}, 0); this.weekListValueSum3 = data3.reduce(function (s, a) {return s + a.value; }, 0);
} }
if (data4) { if (data4) {
this.weekListValueSum4 = data4.reduce(function (s, a) {return s + a.value;}, 0); this.weekListValueSum4 = data4.reduce(function (s, a) {return s + a.value; }, 0);
} }
} }

View file

@ -9,11 +9,11 @@ import { CustBarSnippetComponent } from '../snippets/cust-snippet-bar.component'
import { PiePanel } from '../panels/pie-panel.component'; import { PiePanel } from '../panels/pie-panel.component';
import { DataType } from '../shared/data-types.enum'; import { DataType } from '../shared/data-types.enum';
import * as moment from 'moment'; import * as moment from 'moment';
//import { MoreStuffComponent } from '../dashboard/more-graphs-and-tables.component'; // import { MoreStuffComponent } from '../dashboard/more-graphs-and-tables.component';
// import { StackedBarChartComponent } from '../panels/stacked-bar.component'; // import { StackedBarChartComponent } from '../panels/stacked-bar.component';
interface SuppliersComponent { interface SuppliersComponent {
name : string; name: string;
} }
@Component({ @Component({
@ -28,9 +28,9 @@ export class DashboardCustomerComponent implements OnInit {
trends: any; trends: any;
myRank: any; myRank: any;
username: any; username: any;
maxPurchase: number = 0; maxPurchase = 0;
disableCategoryButton: boolean = false; disableCategoryButton = false;
public bootstrapColours: string[] = ['bg-primary', 'bg-secondary', 'bg-success', public bootstrapColours: string[] = ['bg-primary', 'bg-secondary', 'bg-success',
'bg-danger', 'bg-warning', 'bg-info']; 'bg-danger', 'bg-warning', 'bg-info'];
@ -41,7 +41,7 @@ export class DashboardCustomerComponent implements OnInit {
public doughnutChartLabelsCategory: string[] = []; public doughnutChartLabelsCategory: string[] = [];
public doughnutChartColoursCategory: any[] = [ public doughnutChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor: [
'#ffa1b5', '#ffa1b5',
'#3cde52', '#3cde52',
'#52afed', '#52afed',
@ -56,7 +56,7 @@ export class DashboardCustomerComponent implements OnInit {
] ]
}]; }];
public doughnutChartOptionsCategory:any = { public doughnutChartOptionsCategory: any = {
tooltips: { tooltips: {
callbacks: { callbacks: {
label: (tooltip, data) => { label: (tooltip, data) => {
@ -76,26 +76,26 @@ export class DashboardCustomerComponent implements OnInit {
public showCategoryBarChart = false; public showCategoryBarChart = false;
public showCategoryDoughnutChart = false; public showCategoryDoughnutChart = false;
public barChartDataEssential:any[]=[ public barChartDataEssential: any[] = [
{data: 0, label: 'Essential', stack: '1'}, {data: 0, label: 'Essential', stack: '1'},
{data: 0, label: 'Non-Essential', stack: '1'}, {data: 0, label: 'Non-Essential', stack: '1'},
]; ];
public barChartLabelsEssential:string[] = ['All Purchases']; public barChartLabelsEssential: string[] = ['All Purchases'];
public barChartOptionsEssential:any = { public barChartOptionsEssential: any = {
responsive: true, responsive: true,
scales:{ scales: {
xAxes:[{ xAxes: [{
scaleLabel: { scaleLabel: {
display:true, display: true,
}, },
stacked:true, stacked: true,
}], }],
} }
}; };
public barChartTypeEssential:string = 'horizontalBar'; public barChartTypeEssential = 'horizontalBar';
public barChartOptionsCategory:any = { public barChartOptionsCategory: any = {
scaleShowVerticalLines: false, scaleShowVerticalLines: false,
responsive: true, responsive: true,
scales: { scales: {
@ -114,13 +114,13 @@ export class DashboardCustomerComponent implements OnInit {
}, },
}, },
}; };
public barChartTypeCategory:string = 'bar'; public barChartTypeCategory = 'bar';
public barChartLegendCategory:boolean = false; public barChartLegendCategory = false;
public barChartDataCategory:any[]=[]; public barChartDataCategory: any[] = [];
public barChartLabelsCategory:string[] = []; public barChartLabelsCategory: string[] = [];
public barChartColoursCategory: any[] = [ public barChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor: [
'#ffa1b5', '#ffa1b5',
'#3cde52', '#3cde52',
'#52afed', '#52afed',
@ -144,9 +144,9 @@ export class DashboardCustomerComponent implements OnInit {
count: 0, count: 0,
}; };
showTotalCategoryList: boolean = false; showTotalCategoryList = false;
totalCategoryLimit: number = 10; totalCategoryLimit = 10;
totalCategoryList: any[]=[]; totalCategoryList: any[] = [];
// Graph widgets // Graph widgets
@ -212,18 +212,18 @@ export class DashboardCustomerComponent implements OnInit {
private setChartData(dataCat: any) { private setChartData(dataCat: any) {
this.barChartLabelsCategory = Object.keys(dataCat); this.barChartLabelsCategory = Object.keys(dataCat);
let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]); const barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]);
this.barChartDataCategory = [ this.barChartDataCategory = [
{data: barChartDataCategoryInitial, label: 'Series A'}, {data: barChartDataCategoryInitial, label: 'Series A'},
]; ];
this.showCategoryBarChart = true; this.showCategoryBarChart = true;
if (this.weekList1) { if (this.weekList1) {
let doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value;}); const doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value; });
this.doughnutChartDataCategory = [ this.doughnutChartDataCategory = [
{data: doughnutChartDataCategoryInitial, label: 'Series A'}, {data: doughnutChartDataCategoryInitial, label: 'Series A'},
]; ];
// setTimeout is currently a workaround for ng2-charts labels // setTimeout is currently a workaround for ng2-charts labels
setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category; }), 0);
this.showCategoryDoughnutChart = true; this.showCategoryDoughnutChart = true;
} }
} }
@ -269,8 +269,8 @@ export class DashboardCustomerComponent implements OnInit {
} }
private tooltipLabelCallback(tooltipItem: any, data: any) { private tooltipLabelCallback(tooltipItem: any, data: any) {
var dataset = data.datasets[tooltipItem.datasetIndex]; const dataset = data.datasets[tooltipItem.datasetIndex];
var value = dataset.data[tooltipItem.index]; const value = dataset.data[tooltipItem.index];
return this.currencyPipe.transform(value, 'GBP', 'symbol', '1.2-2'); return this.currencyPipe.transform(value, 'GBP', 'symbol', '1.2-2');
} }

View file

@ -1,5 +1,5 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Router, NavigationEnd } from "@angular/router"; import { Router, NavigationEnd } from '@angular/router';
import { CurrencyPipe } from '@angular/common'; import { CurrencyPipe } from '@angular/common';
import { ChartOptions, ChartType, ChartDataSets } from 'chart.js'; import { ChartOptions, ChartType, ChartDataSets } from 'chart.js';
import { Color, Label } from 'ng2-charts'; import { Color, Label } from 'ng2-charts';
@ -75,7 +75,7 @@ export class DashboardComponent {
*/ */
]; ];
disableCategoryButton: boolean = false; disableCategoryButton = false;
public bootstrapColours: string[] = ['bg-primary', 'bg-secondary', 'bg-success', public bootstrapColours: string[] = ['bg-primary', 'bg-secondary', 'bg-success',
'bg-danger', 'bg-warning', 'bg-info']; 'bg-danger', 'bg-warning', 'bg-info'];
@ -86,7 +86,7 @@ export class DashboardComponent {
public doughnutChartLabelsCategory: string[] = []; public doughnutChartLabelsCategory: string[] = [];
public doughnutChartColoursCategory: any[] = [ public doughnutChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor: [
'#ffa1b5', '#ffa1b5',
'#3cde52', '#3cde52',
'#52afed', '#52afed',
@ -102,7 +102,7 @@ export class DashboardComponent {
}]; }];
public doughnutChartOptionsCategory:any = { public doughnutChartOptionsCategory: any = {
tooltips: { tooltips: {
callbacks: { callbacks: {
label: (tooltip, data) => { label: (tooltip, data) => {
@ -118,7 +118,7 @@ export class DashboardComponent {
public purchaseNotEssential: number; public purchaseNotEssential: number;
public purchaseEssential: number; public purchaseEssential: number;
public showEssentialBarChart:boolean = false; public showEssentialBarChart = false;
public showCategoryBarChart = false; public showCategoryBarChart = false;
public showCategoryDoughnutChart = false; public showCategoryDoughnutChart = false;
@ -126,22 +126,22 @@ export class DashboardComponent {
{data: [0], label: 'Essential', stack: '1'}, {data: [0], label: 'Essential', stack: '1'},
{data: [0], label: 'Non-Essential', stack: '1'}, {data: [0], label: 'Non-Essential', stack: '1'},
]; ];
public barChartLabelsEssential:string[] = ['All Purchases']; public barChartLabelsEssential: string[] = ['All Purchases'];
public barChartOptionsEssential:any = { public barChartOptionsEssential: any = {
responsive: true, responsive: true,
scales:{ scales: {
xAxes:[{ xAxes: [{
stacked:true stacked: true
}], }],
yAxes:[{ yAxes: [{
stacked:true stacked: true
}] }]
} }
}; };
public barChartTypeEssential:string = 'horizontalBar'; public barChartTypeEssential = 'horizontalBar';
public barChartColoursCategory: any[] = [ public barChartColoursCategory: any[] = [
{ {
backgroundColor:[ backgroundColor: [
'#ffa1b5', '#ffa1b5',
'#3cde52', '#3cde52',
'#52afed', '#52afed',
@ -156,7 +156,7 @@ export class DashboardComponent {
] ]
}]; }];
public barChartOptionsCategory:any = { public barChartOptionsCategory: any = {
scaleShowVerticalLines: false, scaleShowVerticalLines: false,
responsive: true, responsive: true,
scales: { scales: {
@ -175,15 +175,15 @@ export class DashboardComponent {
}, },
}, },
}; };
public barChartTypeCategory:string = 'bar'; public barChartTypeCategory = 'bar';
public barChartLegendCategory:boolean = false; public barChartLegendCategory = false;
public barChartDataCategory:any[]=[]; public barChartDataCategory: any[] = [];
public barChartLabelsCategory:string[] = []; public barChartLabelsCategory: string[] = [];
public lineChartDataSector: ChartDataSets[] = [ public lineChartDataSector: ChartDataSets[] = [
{ data: [], label: '' }, { data: [], label: '' },
]; ];
public lineChartLabelsSector: Label[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July','August','September','October','November','December']; public lineChartLabelsSector: Label[] = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
public lineChartOptionsSector: (ChartOptions & { annotation: any }) = { public lineChartOptionsSector: (ChartOptions & { annotation: any }) = {
responsive: true, responsive: true,
scales: { scales: {
@ -246,9 +246,9 @@ export class DashboardComponent {
count: 0, count: 0,
}; };
showTotalCategoryList: boolean = false; showTotalCategoryList = false;
totalCategoryLimit: number = 10; totalCategoryLimit = 10;
totalCategoryList: any[]=[]; totalCategoryList: any[] = [];
constructor( constructor(
private router: Router, private router: Router,
@ -296,18 +296,18 @@ export class DashboardComponent {
private setChartDataCat(dataCat: any) { private setChartDataCat(dataCat: any) {
this.barChartLabelsCategory = Object.keys(dataCat); this.barChartLabelsCategory = Object.keys(dataCat);
let barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]); const barChartDataCategoryInitial = Object.keys(dataCat).map(key => dataCat[key]);
this.barChartDataCategory = [ this.barChartDataCategory = [
{data: barChartDataCategoryInitial, label: 'Series A'}, {data: barChartDataCategoryInitial, label: 'Series A'},
]; ];
this.showCategoryBarChart = true; this.showCategoryBarChart = true;
if (this.weekList1) { if (this.weekList1) {
let doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value;}); const doughnutChartDataCategoryInitial = this.weekList1.map(function(a) {return a.value; });
this.doughnutChartDataCategory = [ this.doughnutChartDataCategory = [
{data: doughnutChartDataCategoryInitial, label: 'Series A'}, {data: doughnutChartDataCategoryInitial, label: 'Series A'},
]; ];
// setTimeout is currently a workaround for ng2-charts labels // setTimeout is currently a workaround for ng2-charts labels
setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category;}), 0); setTimeout(() => this.doughnutChartLabelsCategory = this.weekList1.map(function(a) {return a.category; }), 0);
this.showCategoryDoughnutChart = true; this.showCategoryDoughnutChart = true;
} }
} }
@ -357,8 +357,8 @@ export class DashboardComponent {
} }
private tooltipLabelCallback(tooltipItem: any, data: any) { private tooltipLabelCallback(tooltipItem: any, data: any) {
var dataset = data.datasets[tooltipItem.datasetIndex]; const dataset = data.datasets[tooltipItem.datasetIndex];
var value = dataset.data[tooltipItem.index]; const value = dataset.data[tooltipItem.index];
return this.currencyPipe.transform(value, 'GBP', 'symbol', '1.2-2'); return this.currencyPipe.transform(value, 'GBP', 'symbol', '1.2-2');
} }

View file

@ -26,6 +26,7 @@ export class LeaderboardComponent implements OnInit {
currentPage: 1, currentPage: 1,
totalItems: 0 totalItems: 0
}; };
org
constructor( constructor(
private api: ApiService, private api: ApiService,
@ -52,7 +53,7 @@ export class LeaderboardComponent implements OnInit {
loadLeaderboard(leadPage: number) { loadLeaderboard(leadPage: number) {
console.log(leadPage, this.listType); console.log(leadPage, this.listType);
this.api.leaderboard_fetch(this.listType,leadPage).subscribe( this.api.leaderboard_fetch(this.listType, leadPage).subscribe(
result => { result => {
if (result.leaderboard.length > 0) { if (result.leaderboard.length > 0) {
this.leaderboardList = result.leaderboard; this.leaderboardList = result.leaderboard;
@ -70,8 +71,7 @@ export class LeaderboardComponent implements OnInit {
console.log(error); console.log(error);
} }
); );
}org }
// // dynamically changes the row style based on player's position // // dynamically changes the row style based on player's position
// // for instance, top three player and the player him/herself should // // for instance, top three player and the player him/herself should
// // be hightlighted // // be hightlighted

View file

@ -10,13 +10,13 @@ import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
}) })
export class MapComponent implements OnInit, AfterViewInit { export class MapComponent implements OnInit, AfterViewInit {
@ViewChild('statusModal', { static: true }) myStatusModal: ModalDirective; @ViewChild('statusModal', { static: true }) myStatusModal: ModalDirective;
lat: number = 54.0466; lat = 54.0466;
lng: number = -2.8007; lng = -2.8007;
zoom: number = 12; zoom = 12;
public modalRef: BsModalRef; public modalRef: BsModalRef;
clickedMarker: any; clickedMarker: any;
dataReceived: string = 'loading'; dataReceived = 'loading';
markers: Array<{latitude: number, longitude: number, name: string}>; markers: Array<{latitude: number, longitude: number, name: string}>;
@ -48,9 +48,9 @@ export class MapComponent implements OnInit, AfterViewInit {
} }
public viewBoundsChanged() { public viewBoundsChanged() {
console.log("finding bounds"); console.log('finding bounds');
const resp = this.map.getBounds(); const resp = this.map.getBounds();
console.log("found bounds"); console.log('found bounds');
console.log(resp.getNorthEast().lat()); console.log(resp.getNorthEast().lat());
console.log(resp.getNorthEast().lng()); console.log(resp.getNorthEast().lng());
console.log(resp.getSouthWest().lat()); console.log(resp.getSouthWest().lat());

View file

@ -2,7 +2,7 @@ import {Component, OnInit, Input, Output, EventEmitter, ViewChild} from '@angula
import {ApiService} from '../providers/api-service'; import {ApiService} from '../providers/api-service';
import {BaseChartDirective} from 'ng2-charts'; import {BaseChartDirective} from 'ng2-charts';
import {CurrencyPipe} from '@angular/common'; import {CurrencyPipe} from '@angular/common';
import {ChartType} from "chart.js"; import {ChartType} from 'chart.js';
import * as moment from 'moment'; import * as moment from 'moment';
@Component({ @Component({
@ -16,75 +16,20 @@ export class MoreStuffComponent implements OnInit {
filterFrom: any; filterFrom: any;
filterTo: any; filterTo: any;
isBubbleChartLoaded: boolean = false; isBubbleChartLoaded = false;
isSupplierChartLoaded: boolean = false; isSupplierChartLoaded = false;
wardList: any; wardList: any;
wardListAvailable = false; wardListAvailable = false;
metaTypeList: any; metaTypeList: any;
metaTypeListAvailable = false; metaTypeListAvailable = false;
constructor(
private api: ApiService,
private currencyPipe: CurrencyPipe,
) {
let now = moment();
this.filterTo = now.format('YYYY-MM-DD');
now.subtract(1, 'months');
this.filterFrom = now.format('YYYY-MM-DD');
this.tableSummary();
}
ngOnInit(): void {
this.loadData();
}
public loadData() {
this.tableSummary();
this.loadYearSpend();
this.loadSupplierBubble();
this.loadSupplierHistory();
}
public showLegend = true; public showLegend = true;
/*
* Supplier Bubble Chart Setup
*/
private formatGraphData(data: any): any[] {
let graph_data = [];
data.data.map(item => {
graph_data.push({
t: item.date,
r: item.value > 1000000 ? (item.value / 200000) : (item.value / 100000) + 5,
supplier: item.seller,
y: item.count,
value: item.value,
count: item.count,
});
});
return graph_data;
}
private loadSupplierBubble() {
this.api.loadMiscUrl('organisation/external/supplier_count', {
from: this.filterFrom,
to: this.filterTo,
}).subscribe(
result => {
this.supplierBubbleChartData[0].data = this.formatGraphData(result);
this.isBubbleChartLoaded = true;
}
)
}
public supplierBubbleChartType: ChartType = 'bubble'; public supplierBubbleChartType: ChartType = 'bubble';
public supplierBubbleChartData: any[] = [ public supplierBubbleChartData: any[] = [
{ {
data: [], data: [],
label: ["Spend"], label: ['Spend'],
borderColor: 'blue', borderColor: 'blue',
hoverBorderColor: 'black', hoverBorderColor: 'black',
radius: 5, radius: 5,
@ -120,9 +65,160 @@ export class MoreStuffComponent implements OnInit {
}, },
}; };
public yearSpendChartData: any[] = [
{
data: [],
label: ['Value £'],
fill: false,
borderColor: 'red',
hoverBackgroundColor: '#ffa1b5',
hoverBorderColor: 'red',
yAxisID: 'y-value',
},
{
data: [],
label: ['Count'],
fill: false,
borderColor: 'blue',
hoverBackgroundColor: '#52afed',
hoverBorderColor: 'blue',
yAxisID: 'y-count',
},
];
public yearSpendChartOptions: any = {
elements: {line: {tension: 0}},
responsive: true,
scales: {
xAxes: [{
type: 'time',
time: {
unit: 'month'
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [
{id: 'y-value', position: 'left', beginAtZero: true, type: 'linear'},
{id: 'y-count', position: 'right', beginAtZero: true, type: 'linear'},
]
},
};
public yearSpendChartLabels: string[] = [];
public yearSpendChartType: ChartType = 'line';
@ViewChild('supplierChart', { read: BaseChartDirective }) supplierChart: BaseChartDirective;
private _supplierHistoryData: any[];
private _supplierHistoryPerPage = 15;
public _supplierHistoryPage = 1;
public _supplierHistoryPages = 1;
public supplierMonthChartData: any[] = [
{
data: [],
label: ['3 Month'],
fill: false,
borderColor: 'red',
hoverBorderColor: 'red',
hoverBackgroundColor: 'red',
},
{
data: [],
label: ['6 Month'],
fill: false,
borderColor: 'blue',
hoverBorderColor: 'blue',
hoverBackgroundColor: 'blue',
},
{
data: [],
label: ['12 Month'],
fill: false,
borderColor: 'orange',
hoverBorderColor: 'orange',
hoverBackgroundColor: 'orange',
},
];
public supplierMonthChartOptions: any = {
// maintainAspectRatio: false,
responsive: true,
scales: {
xAxes: [{
scaleLabel: {
display: true,
labelString: 'Spend amount £'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Supplier Names'
}
}]
},
};
public supplierMonthChartLabels: string[] = [];
public supplierMonthChartType: ChartType = 'horizontalBar';
constructor(
private api: ApiService,
private currencyPipe: CurrencyPipe,
) {
const now = moment();
this.filterTo = now.format('YYYY-MM-DD');
now.subtract(1, 'months');
this.filterFrom = now.format('YYYY-MM-DD');
this.tableSummary();
}
ngOnInit(): void {
this.loadData();
}
public loadData() {
this.tableSummary();
this.loadYearSpend();
this.loadSupplierBubble();
this.loadSupplierHistory();
}
/*
* Supplier Bubble Chart Setup
*/
private formatGraphData(data: any): any[] {
const graph_data = [];
data.data.map(item => {
graph_data.push({
t: item.date,
r: item.value > 1000000 ? (item.value / 200000) : (item.value / 100000) + 5,
supplier: item.seller,
y: item.count,
value: item.value,
count: item.count,
});
});
return graph_data;
}
private loadSupplierBubble() {
this.api.loadMiscUrl('organisation/external/supplier_count', {
from: this.filterFrom,
to: this.filterTo,
}).subscribe(
result => {
this.supplierBubbleChartData[0].data = this.formatGraphData(result);
this.isBubbleChartLoaded = true;
}
)
}
private bubbleTooltipCallback(tooltipItem: any, data: any) { private bubbleTooltipCallback(tooltipItem: any, data: any) {
let dataset = data.datasets[tooltipItem.datasetIndex]; const dataset = data.datasets[tooltipItem.datasetIndex];
let value = dataset.data[tooltipItem.index]; const value = dataset.data[tooltipItem.index];
return `${value.supplier}: ${this.currencyPipe.transform(value.value, 'GBP', 'symbol', '1.2-2')} over ${value.count} purchases`; return `${value.supplier}: ${this.currencyPipe.transform(value.value, 'GBP', 'symbol', '1.2-2')} over ${value.count} purchases`;
} }
@ -154,8 +250,8 @@ export class MoreStuffComponent implements OnInit {
to: this.filterTo, to: this.filterTo,
}).subscribe( }).subscribe(
result => { result => {
let value_data = []; const value_data = [];
let count_data = []; const count_data = [];
result.data.map(item => { result.data.map(item => {
value_data.push({ value_data.push({
@ -175,49 +271,6 @@ export class MoreStuffComponent implements OnInit {
) )
} }
public yearSpendChartData: any[] = [
{
data: [],
label: ["Value £"],
fill: false,
borderColor: 'red',
hoverBackgroundColor: '#ffa1b5',
hoverBorderColor: 'red',
yAxisID: 'y-value',
},
{
data: [],
label: ["Count"],
fill: false,
borderColor: 'blue',
hoverBackgroundColor: '#52afed',
hoverBorderColor: 'blue',
yAxisID: 'y-count',
},
];
public yearSpendChartOptions: any = {
elements: {line: {tension: 0}},
responsive: true,
scales: {
xAxes: [{
type: 'time',
time: {
unit: 'month'
},
scaleLabel: {
display: true,
labelString: 'Date'
}
}],
yAxes: [
{id: 'y-value', position: 'left', beginAtZero: true, type: 'linear'},
{id: 'y-count', position: 'right', beginAtZero: true, type: 'linear'},
]
},
};
public yearSpendChartLabels: string[] = [];
public yearSpendChartType: ChartType = 'line';
randomData() { randomData() {
return Math.random(); return Math.random();
} }
@ -227,8 +280,6 @@ export class MoreStuffComponent implements OnInit {
} }
@ViewChild('supplierChart', { read: BaseChartDirective }) supplierChart: BaseChartDirective;
private loadSupplierHistory() { private loadSupplierHistory() {
this.api.loadMiscUrl('organisation/external/supplier_history').subscribe( this.api.loadMiscUrl('organisation/external/supplier_history').subscribe(
result => { result => {
@ -251,10 +302,10 @@ export class MoreStuffComponent implements OnInit {
const pageData = this._supplierHistoryData.slice(firstResult, lastResult); const pageData = this._supplierHistoryData.slice(firstResult, lastResult);
console.log(pageData); console.log(pageData);
let labels = []; const labels = [];
let year = []; const year = [];
let half = []; const half = [];
let quarter = []; const quarter = [];
pageData.map(item => { pageData.map(item => {
labels.push(item.name); labels.push(item.name);
year.push(item.year_total); year.push(item.year_total);
@ -281,55 +332,4 @@ export class MoreStuffComponent implements OnInit {
} }
this.updateSupplierHistoryData(); this.updateSupplierHistoryData();
} }
private _supplierHistoryData: any[];
private _supplierHistoryPerPage: number = 15;
public _supplierHistoryPage: number = 1;
public _supplierHistoryPages: number = 1;
public supplierMonthChartData: any[] = [
{
data: [],
label: ["3 Month"],
fill: false,
borderColor: 'red',
hoverBorderColor: 'red',
hoverBackgroundColor: 'red',
},
{
data: [],
label: ["6 Month"],
fill: false,
borderColor: 'blue',
hoverBorderColor: 'blue',
hoverBackgroundColor: 'blue',
},
{
data: [],
label: ["12 Month"],
fill: false,
borderColor: 'orange',
hoverBorderColor: 'orange',
hoverBackgroundColor: 'orange',
},
];
public supplierMonthChartOptions: any = {
//maintainAspectRatio: false,
responsive: true,
scales: {
xAxes: [{
scaleLabel: {
display: true,
labelString: 'Spend amount £'
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: 'Supplier Names'
}
}]
},
};
public supplierMonthChartLabels: string[] = [];
public supplierMonthChartType: ChartType = 'horizontalBar';
} }

View file

@ -37,12 +37,12 @@ export class PayrollLogComponent implements OnInit {
this.loadPayrolls(1); this.loadPayrolls(1);
} }
getMinDate(){ getMinDate() {
// gets the April 1st date of the current year // gets the April 1st date of the current year
let aprilDate = moment().month(3).date(1); const aprilDate = moment().month(3).date(1);
let now = moment(); const now = moment();
// Checks if current time is before April 1st, if so returns true // Checks if current time is before April 1st, if so returns true
let beforeApril = now.isBefore(aprilDate); const beforeApril = now.isBefore(aprilDate);
if ( beforeApril == true ) { if ( beforeApril == true ) {
this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD');
} else { } else {
@ -54,9 +54,9 @@ export class PayrollLogComponent implements OnInit {
console.log(logPage); console.log(logPage);
this.api.payrollList(logPage).subscribe( this.api.payrollList(logPage).subscribe(
result => { result => {
if(result.payrolls.length > 0) { if (result.payrolls.length > 0) {
this.payrollList = result.payrolls; this.payrollList = result.payrolls;
//TODO Rename in server // TODO Rename in server
this.paginateConfig.totalItems = result.page_no; this.paginateConfig.totalItems = result.page_no;
this.paginateConfig.currentPage = logPage; this.paginateConfig.currentPage = logPage;
this.noPayrollList = false; this.noPayrollList = false;

View file

@ -23,11 +23,11 @@ export class SendPushNotificationComponent implements OnInit {
this.topicList = result.topics; this.topicList = result.topics;
this.topicIdList = Object.keys(this.topicList); this.topicIdList = Object.keys(this.topicList);
} else { } else {
console.warn("No topics returned from server"); console.warn('No topics returned from server');
} }
}, },
error => { error => {
console.error("Couldn't get topics"); console.error('Couldn\'t get topics');
console.error(error._body); console.error(error._body);
} }
); );

View file

@ -11,7 +11,7 @@ import { FilterPipeModule } from 'ngx-filter-pipe';
export class SuppliersComponent implements OnInit, AfterViewInit { export class SuppliersComponent implements OnInit, AfterViewInit {
@Output() public onClick = new EventEmitter(); @Output() public onClick = new EventEmitter();
@Input() public categories: any; @Input() public categories: any;
public perPage: number = 10; public perPage = 10;
searchText: string; searchText: string;

View file

@ -10,16 +10,16 @@ import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
}) })
export class TrailMapComponent implements OnInit, AfterViewInit { export class TrailMapComponent implements OnInit, AfterViewInit {
@ViewChild('statusModal', { static: true }) myStatusModal: ModalDirective; @ViewChild('statusModal', { static: true }) myStatusModal: ModalDirective;
lat: number = 54.0466; lat = 54.0466;
lng: number = -2.8007; lng = -2.8007;
zoom: number = 12; zoom = 12;
public modalRef: BsModalRef; public modalRef: BsModalRef;
public modalRef2: BsModalRef; public modalRef2: BsModalRef;
clickedMarker: any; clickedMarker: any;
assocMap = 'lis'; assocMap = 'lis';
assocLogo: string; assocLogo: string;
dataReceived: string = 'loading'; dataReceived = 'loading';
markers: Array<{latitude: number, longitude: number, name: string}>; markers: Array<{latitude: number, longitude: number, name: string}>;
@ -57,9 +57,9 @@ export class TrailMapComponent implements OnInit, AfterViewInit {
} }
public viewBoundsChanged() { public viewBoundsChanged() {
console.log("finding bounds"); console.log('finding bounds');
const resp = this.map.getBounds(); const resp = this.map.getBounds();
console.log("found bounds"); console.log('found bounds');
console.log(resp.getNorthEast().lat()); console.log(resp.getNorthEast().lat());
console.log(resp.getNorthEast().lng()); console.log(resp.getNorthEast().lng());
console.log(resp.getSouthWest().lat()); console.log(resp.getSouthWest().lat());

View file

@ -102,9 +102,9 @@ export class TransactionLogComponent implements OnInit {
} }
editRecurringTransaction() { editRecurringTransaction() {
let updatedTimeSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); const updatedTimeSubmit = moment(this.updatedTime, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ');
this.clickedRecur.display_time = moment(this.updatedTime).format('llll'); this.clickedRecur.display_time = moment(this.updatedTime).format('llll');
let myParams = { const myParams = {
category: (this.clickedRecur.category == 0 ? undefined : this.clickedRecur.category), category: (this.clickedRecur.category == 0 ? undefined : this.clickedRecur.category),
essential: this.clickedRecur.essential, essential: this.clickedRecur.essential,
id: this.clickedRecur.id, id: this.clickedRecur.id,
@ -138,7 +138,7 @@ export class TransactionLogComponent implements OnInit {
} }
deleteRecurringTransaction() { deleteRecurringTransaction() {
let myParams = { const myParams = {
id: this.clickedRecur.id, id: this.clickedRecur.id,
}; };
this.api this.api

View file

@ -17,7 +17,7 @@ export class OrgPiePanel implements OnInit {
public doughnutChartDataLocal: number[] = []; public doughnutChartDataLocal: number[] = [];
public doughnutChartColors: any[] = [ public doughnutChartColors: any[] = [
{ {
backgroundColor:[ backgroundColor: [
'#ffa1b5', '#ffa1b5',
'#3cde52', '#3cde52',
'#52afed', '#52afed',

View file

@ -31,7 +31,7 @@ export class PiePanel implements OnInit {
'#2d4fcc' '#2d4fcc'
] ]
}, },
{ borderColor:[ { borderColor: [
'red', 'red',
'green', 'green',
'blue', 'blue',

View file

@ -36,8 +36,7 @@ export class MessagingService {
this.angularFireMessaging.requestToken.subscribe((token) => { this.angularFireMessaging.requestToken.subscribe((token) => {
this.api.checkDeviceToken({'token': token}).subscribe( this.api.checkDeviceToken({'token': token}).subscribe(
result => { result => {
if (result.exists) { console.log('Device already registered!'); } if (result.exists) { console.log('Device already registered!'); } else {
else {
this.api.addDeviceToken({'token': token, 'email': localStorage.getItem('email')}).subscribe( this.api.addDeviceToken({'token': token, 'email': localStorage.getItem('email')}).subscribe(
result => { result => {
console.log('Device registered successfully!'); console.log('Device registered successfully!');
@ -61,7 +60,7 @@ export class MessagingService {
receiveMessage() { receiveMessage() {
this.angularFireMessaging.messages.subscribe((message) => { this.angularFireMessaging.messages.subscribe((message) => {
console.log('show message!', message); console.log('show message!', message);
let notification = new Notification(message.notification.title, { body: message.notification.body }); const notification = new Notification(message.notification.title, { body: message.notification.body });
this.currentMessage.next(message); this.currentMessage.next(message);
}); });
} }