commit
675f319993
13 changed files with 3950 additions and 2376 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -2,6 +2,16 @@
|
||||||
|
|
||||||
# Next Release
|
# Next Release
|
||||||
|
|
||||||
|
# v0.1.4
|
||||||
|
|
||||||
|
* Amended category list on transaction submission
|
||||||
|
* Added budget view for weekly breakdown of spend by category
|
||||||
|
* Added flag to make purchases essential
|
||||||
|
* Fixed budget view issues and amended it to show essential purchases that week
|
||||||
|
* Added ability to make purchases recurring
|
||||||
|
* Updated Moment dependency due to security issue
|
||||||
|
* Fixed category uploading in upload
|
||||||
|
|
||||||
# v0.1.3
|
# v0.1.3
|
||||||
|
|
||||||
* Made fix to Travis config
|
* Made fix to Travis config
|
||||||
|
|
5864
package-lock.json
generated
5864
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "localloop-web",
|
"name": "localloop-web",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"description": "LocalLoop Web - Web interface for LocalLoop app",
|
"description": "LocalLoop Web - Web interface for LocalLoop app",
|
||||||
"author": "",
|
"author": "",
|
||||||
"url": "http://www.peartrade.org",
|
"url": "http://www.peartrade.org",
|
||||||
|
@ -32,19 +32,18 @@
|
||||||
"chart.js": "2.7.1",
|
"chart.js": "2.7.1",
|
||||||
"core-js": "2.5.1",
|
"core-js": "2.5.1",
|
||||||
"js-marker-clusterer": "1.0.0",
|
"js-marker-clusterer": "1.0.0",
|
||||||
"moment": "^2.19.2",
|
"moment": "^2.21.0",
|
||||||
"ng2-charts": "1.6.0",
|
"ng2-charts": "1.6.0",
|
||||||
"ng2-validation-manager": "0.5.3",
|
"ng2-validation-manager": "0.5.3",
|
||||||
"ngx-bootstrap": "2.0.0-beta.8",
|
"ngx-bootstrap": "2.0.0-beta.8",
|
||||||
"ngx-pagination": "3.0.3",
|
"ngx-pagination": "3.0.3",
|
||||||
"rxjs": "5.5.6",
|
"rxjs": "5.5.6",
|
||||||
"ts-helpers": "1.1.2",
|
"ts-helpers": "1.1.2",
|
||||||
"webpack": "3.8.1",
|
"webpack-dev-server": "3.1.0",
|
||||||
"webpack-dev-server": "2.9.4",
|
|
||||||
"zone.js": "0.8.18"
|
"zone.js": "0.8.18"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@angular/cli": "1.6.4",
|
"@angular/cli": "1.7.3",
|
||||||
"@angular/compiler-cli": "5.2.0",
|
"@angular/compiler-cli": "5.2.0",
|
||||||
"@types/jasmine": "2.8.2",
|
"@types/jasmine": "2.8.2",
|
||||||
"@types/jasminewd2": "2.0.3",
|
"@types/jasminewd2": "2.0.3",
|
||||||
|
|
|
@ -25,17 +25,77 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-md-3 form-control-label" for="text-input">Category</label>
|
<label class="col-md-3 form-control-label" for="text-input">Essential Purchase</label>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<select type="text" class="form-control" [(ngModel)]="categoryId" size="6">
|
<input type="checkbox" class="mr-auto" [(ngModel)]="essentialPurchase" (ngModelChange)="transactionFormValidate()">
|
||||||
<option value="">Uncategorised</option>
|
|
||||||
<option *ngFor="let category of categoryIdList, let i=index" [ngValue]="category" >
|
|
||||||
{{ categoryNameList[i] }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<span class="help-block"><strong>Optional:</strong> Choose the relevant Category for the purchase.</span>
|
<span class="help-block">Tick if the purchase is deemed an essential purchase for budgeting purposes.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-3 form-control-label" for="text-input">Recurring Purchase</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="checkbox" class="mr-auto" [(ngModel)]="recurringPurchase" (ngModelChange)="transactionFormValidate()">
|
||||||
|
</div>
|
||||||
|
<span class="help-block">Tick if the purchase frequently recurs, such as monthly.</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="recurringPurchase" class="form-group row">
|
||||||
|
<label class="col-md-3 form-control-label" for="text-input"><strong>Recurring Period</strong></label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div>
|
||||||
|
<input value="daily" type="radio" name="daily" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
|
||||||
|
<label>Daily</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input value="weekly" type="radio" name="weekly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
|
||||||
|
<label>Weekly</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input value="fortnightly" type="radio" name="fortnightly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
|
||||||
|
<label>Fortnightly</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div>
|
||||||
|
<input value="monthly" type="radio" name="monthly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
|
||||||
|
<label>Monthly</label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<input value="quarterly" type="radio" name="quarterly" [(ngModel)]="recurringType" (ngModelChange)="transactionFormValidate()">
|
||||||
|
<label>Quarterly</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="help-block">Please give the period of time the purchase will recur from "Time of Transaction".</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group row">
|
||||||
|
<label class="col-md-3 form-control-label" for="text-input">Budget Type</label>
|
||||||
|
<div class="col-md-9">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div>
|
||||||
|
<input value="" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
|
<label>Uncategorised</label>
|
||||||
|
</div>
|
||||||
|
<div class="radio" *ngFor="let category of leftCategoryIdList, let i=index">
|
||||||
|
<input [value]="category" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
|
<label>{{ categoryNameList[i] }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="radio" *ngFor="let category2 of rightCategoryIdList, let i=index">
|
||||||
|
<input [value]="category2" type="radio" name="radios" [(ngModel)]="categoryId">
|
||||||
|
<label>{{ categoryNameList[category2 - 1] }}</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<span class="help-block"><strong>Optional:</strong> Choose the Budget Type for the majority of the purchase.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
|
|
|
@ -32,6 +32,9 @@ export class AddDataComponent implements OnInit {
|
||||||
amount: number;
|
amount: number;
|
||||||
// Assumes Groceries is 1st category
|
// Assumes Groceries is 1st category
|
||||||
categoryId: number = 1;
|
categoryId: number = 1;
|
||||||
|
essentialPurchase = false;
|
||||||
|
recurringPurchase = false;
|
||||||
|
recurringType: string;
|
||||||
transactionAdditionType = 1;
|
transactionAdditionType = 1;
|
||||||
storeList = [];
|
storeList = [];
|
||||||
showAddStore = false;
|
showAddStore = false;
|
||||||
|
@ -39,7 +42,8 @@ export class AddDataComponent implements OnInit {
|
||||||
transactionFormInvalid = true;
|
transactionFormInvalid = true;
|
||||||
myDate: any;
|
myDate: any;
|
||||||
minDate: any;
|
minDate: any;
|
||||||
categoryIdList: number[] = [];
|
leftCategoryIdList: number[] = [];
|
||||||
|
rightCategoryIdList: number[] = [];
|
||||||
categoryNameList: string[] = [];
|
categoryNameList: string[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -85,8 +89,11 @@ export class AddDataComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setCategoryList(data: any) {
|
private setCategoryList(data: any) {
|
||||||
this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
let categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
||||||
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
||||||
|
let halfLength = Math.floor(categoryIdList.length / 2);
|
||||||
|
this.leftCategoryIdList = categoryIdList.splice(0, halfLength);
|
||||||
|
this.rightCategoryIdList = categoryIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
getMinDate() {
|
getMinDate() {
|
||||||
|
@ -169,7 +176,9 @@ export class AddDataComponent implements OnInit {
|
||||||
transactionFormValidate() {
|
transactionFormValidate() {
|
||||||
if (this.submitOrg.name.length === 0 ||
|
if (this.submitOrg.name.length === 0 ||
|
||||||
this.submitOrg.town.length === 0 ||
|
this.submitOrg.town.length === 0 ||
|
||||||
this.amount === 0 ) {
|
this.amount === 0 ||
|
||||||
|
this.recurringPurchase &&
|
||||||
|
!this.recurringType) {
|
||||||
this.transactionFormInvalid = true;
|
this.transactionFormInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
this.transactionFormInvalid = false;
|
this.transactionFormInvalid = false;
|
||||||
|
@ -189,6 +198,8 @@ export class AddDataComponent implements OnInit {
|
||||||
purchase_time : purchaseTime,
|
purchase_time : purchaseTime,
|
||||||
organisation_id : this.organisationId,
|
organisation_id : this.organisationId,
|
||||||
category : this.categoryId,
|
category : this.categoryId,
|
||||||
|
essential : this.essentialPurchase,
|
||||||
|
recurring : this.recurringType,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -198,6 +209,8 @@ export class AddDataComponent implements OnInit {
|
||||||
purchase_time : purchaseTime,
|
purchase_time : purchaseTime,
|
||||||
organisation_id : this.organisationId,
|
organisation_id : this.organisationId,
|
||||||
category : this.categoryId,
|
category : this.categoryId,
|
||||||
|
essential : this.essentialPurchase,
|
||||||
|
recurring : this.recurringType,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -210,6 +223,8 @@ export class AddDataComponent implements OnInit {
|
||||||
town : this.submitOrg.town,
|
town : this.submitOrg.town,
|
||||||
postcode : this.submitOrg.postcode,
|
postcode : this.submitOrg.postcode,
|
||||||
category : this.categoryId,
|
category : this.categoryId,
|
||||||
|
essential : this.essentialPurchase,
|
||||||
|
recurring : this.recurringType,
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -260,6 +275,9 @@ export class AddDataComponent implements OnInit {
|
||||||
this.amount = null;
|
this.amount = null;
|
||||||
this.transactionFormInvalid = true;
|
this.transactionFormInvalid = true;
|
||||||
this.showAddStore = false;
|
this.showAddStore = false;
|
||||||
|
this.essentialPurchase = false;
|
||||||
|
this.recurringPurchase = false;
|
||||||
|
this.recurringType = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmitPayroll() {
|
onSubmitPayroll() {
|
||||||
|
|
172
src/app/dashboard/category-month.component.html
Normal file
172
src/app/dashboard/category-month.component.html
Normal file
|
@ -0,0 +1,172 @@
|
||||||
|
<div class="animated fadeIn">
|
||||||
|
<div class=row>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-block">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h4 class="card-title float-left mb-0">Purchases Last Week</h4>
|
||||||
|
</div><!--/.col-->
|
||||||
|
</div><!--/.row-->
|
||||||
|
<div class="chart-wrapper">
|
||||||
|
<ul *ngIf="weekList1" class="horizontal-bars type-2">
|
||||||
|
<li *ngIf="weekEssential1">
|
||||||
|
<span class="title">Essential Purchases</span>
|
||||||
|
<span class="value">{{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (weekEssential1.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(weekEssential1.value || 0 ) / weekListValueSum1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li *ngFor="let categoryEntry of weekList1 | slice:0:categoryLimit1; let i=index;">
|
||||||
|
<span class="title">{{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }}</span>
|
||||||
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div *ngIf="weekList1">
|
||||||
|
<li *ngIf="weekList1.length > categoryLimit1 && disableCategoryButton1 == false" class="divider text-center">
|
||||||
|
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore1()"><i class="icon-options"></i></button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!--/.col-->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-block">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h4 class="card-title float-left mb-0">Purchases 1 Week Ago</h4>
|
||||||
|
</div><!--/.col-->
|
||||||
|
</div><!--/.row-->
|
||||||
|
<div class="chart-wrapper">
|
||||||
|
<ul *ngIf="weekList2" class="horizontal-bars type-2">
|
||||||
|
<li *ngIf="weekEssential2">
|
||||||
|
<span class="title">Essential Purchases</span>
|
||||||
|
<span class="value">{{ ( weekEssential2.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (weekEssential2.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(weekEssential2.value || 0 ) / weekListValueSum2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li *ngFor="let categoryEntry of weekList2 | slice:0:categoryLimit2; let i=index;">
|
||||||
|
<span class="title">{{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }}</span>
|
||||||
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div *ngIf="weekList2">
|
||||||
|
<li *ngIf="weekList2.length > categoryLimit2 && disableCategoryButtonFirst == false" class="divider text-center">
|
||||||
|
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore2()"><i class="icon-options"></i></button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!--/.col-->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-block">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h4 class="card-title float-left mb-0">Purchases 2 Weeks Ago</h4>
|
||||||
|
</div><!--/.col-->
|
||||||
|
</div><!--/.row-->
|
||||||
|
<div class="chart-wrapper">
|
||||||
|
<ul *ngIf="weekList3" class="horizontal-bars type-2">
|
||||||
|
<li *ngIf="weekEssential3">
|
||||||
|
<span class="title">Essential Purchases</span>
|
||||||
|
<span class="value">{{ ( weekEssential1.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (weekEssential3.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(weekEssential3.value || 0 ) / weekListValueSum3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li *ngFor="let categoryEntry of weekList3 | slice:0:categoryLimit3; let i=index;">
|
||||||
|
<span class="title">{{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }}</span>
|
||||||
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div *ngIf="weekList3">
|
||||||
|
<li *ngIf="weekList3.length > categoryLimit3 && disableCategoryButtonFirst == false" class="divider text-center">
|
||||||
|
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore3()"><i class="icon-options"></i></button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!--/.col-->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-block">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h4 class="card-title float-left mb-0">Purchases 3 Weeks Ago</h4>
|
||||||
|
</div><!--/.col-->
|
||||||
|
</div><!--/.row-->
|
||||||
|
<div class="chart-wrapper">
|
||||||
|
<ul *ngIf="weekList4" class="horizontal-bars type-2">
|
||||||
|
<li *ngIf="weekEssential4">
|
||||||
|
<span class="title">Essential Purchases</span>
|
||||||
|
<span class="value">{{ ( weekEssential4.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (weekEssential4.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(weekEssential4.value || 0 ) / weekListValueSum4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li *ngFor="let categoryEntry of weekList4 | slice:0:categoryLimit4; let i=index;">
|
||||||
|
<span class="title">{{ categoryNameList[categoryEntry.category - 1] || 'Uncategorised' }}</span>
|
||||||
|
<span class="value">{{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} <span class="text-muted small">
|
||||||
|
({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }})</span></span>
|
||||||
|
<div class="bars">
|
||||||
|
<div class="progress" style="height: 6px;">
|
||||||
|
<div class="progress-bar bg-success" role="progressbar"
|
||||||
|
[style.width]="(categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0'" aria-valuemin="0" aria-valuemax="100"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<div *ngIf="weekList4">
|
||||||
|
<li *ngIf="weekList4.length > categoryLimit4 && disableCategoryButtonFirst == false" class="divider text-center">
|
||||||
|
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore4()"><i class="icon-options"></i></button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div><!--/.col-->
|
||||||
|
</div><!--/.row-->
|
||||||
|
</div>
|
136
src/app/dashboard/category-month.component.ts
Normal file
136
src/app/dashboard/category-month.component.ts
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
import { Directive, Component, OnInit } from '@angular/core';
|
||||||
|
import { ApiService } from '../providers/api-service';
|
||||||
|
import { DataType } from '../shared/data-types.enum';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: 'category-month.component.html'
|
||||||
|
})
|
||||||
|
export class CategoryMonthComponent implements OnInit {
|
||||||
|
|
||||||
|
disableCategoryButton1: boolean = false;
|
||||||
|
disableCategoryButton2: boolean = false;
|
||||||
|
disableCategoryButton3: boolean = false;
|
||||||
|
disableCategoryButton4: boolean = false;
|
||||||
|
|
||||||
|
weekPurchaseList = {
|
||||||
|
first: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
weekList1 = [];
|
||||||
|
weekList2 = [];
|
||||||
|
weekList3 = [];
|
||||||
|
weekList4 = [];
|
||||||
|
weekListValueSum1: number = 0;
|
||||||
|
weekListValueSum2: number = 0;
|
||||||
|
weekListValueSum3: number = 0;
|
||||||
|
weekListValueSum4: number = 0;
|
||||||
|
weekEssential1: number = 0;
|
||||||
|
weekEssential2: number = 0;
|
||||||
|
weekEssential3: number = 0;
|
||||||
|
weekEssential4: number = 0;
|
||||||
|
|
||||||
|
categoryList: number[] = [];
|
||||||
|
dayList: any[] = [];
|
||||||
|
valueList: number[] = [];
|
||||||
|
myWeek1: any;
|
||||||
|
myWeek2: any;
|
||||||
|
myWeek3: any;
|
||||||
|
myWeek4: any;
|
||||||
|
categoryIdList: number[] = [];
|
||||||
|
categoryNameList: string[] = [];
|
||||||
|
categoryLimit1: number = 6;
|
||||||
|
categoryLimit2: number = 6;
|
||||||
|
categoryLimit3: number = 6;
|
||||||
|
categoryLimit4: number = 6;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private api: ApiService,
|
||||||
|
) {
|
||||||
|
this.setDate();
|
||||||
|
this.api.categoryList().subscribe(
|
||||||
|
result => {
|
||||||
|
this.setCategoryList(result.categories);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log('Retrieval Error');
|
||||||
|
console.log( error._body );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
this.api.categoryTransactionList().subscribe(
|
||||||
|
result => {
|
||||||
|
this.setData(result);
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.log('Retrieval Error');
|
||||||
|
console.log( error._body );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
}
|
||||||
|
|
||||||
|
private setCategoryList(data: any) {
|
||||||
|
this.categoryIdList = Object.keys(data.ids).map(key => data.ids[key]);
|
||||||
|
this.categoryNameList = Object.keys(data.names).map(key => data.names[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setDate () {
|
||||||
|
this.myWeek1 = moment().startOf('isoWeek').format('YYYY-MM-DD');
|
||||||
|
this.myWeek2 = moment(this.myWeek1).subtract(1, 'weeks').format('YYYY-MM-DD');
|
||||||
|
this.myWeek3 = moment(this.myWeek2).subtract(1, 'weeks').format('YYYY-MM-DD');
|
||||||
|
this.myWeek4 = moment(this.myWeek3).subtract(1, 'weeks').format('YYYY-MM-DD');
|
||||||
|
}
|
||||||
|
|
||||||
|
private setData (data: any) {
|
||||||
|
function prop<T, K extends keyof T>(obj: T, key: K) {
|
||||||
|
return obj[key];
|
||||||
|
}
|
||||||
|
this.weekList1 = prop(data.data.categories, this.myWeek1);
|
||||||
|
this.weekList2 = prop(data.data.categories, this.myWeek2);
|
||||||
|
this.weekList3 = prop(data.data.categories, this.myWeek3);
|
||||||
|
this.weekList4 = prop(data.data.categories, this.myWeek4);
|
||||||
|
this.getMaxValue(this.weekList1, this.weekList2, this.weekList3, this.weekList4);
|
||||||
|
this.weekEssential1 = prop(data.data.essentials, this.myWeek1);
|
||||||
|
this.weekEssential2 = prop(data.data.essentials, this.myWeek2);
|
||||||
|
this.weekEssential3 = prop(data.data.essentials, this.myWeek3);
|
||||||
|
this.weekEssential4 = prop(data.data.essentials, this.myWeek4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getMaxValue (data1: any,
|
||||||
|
data2: any,
|
||||||
|
data3: any,
|
||||||
|
data4: any) {
|
||||||
|
if (data1) {
|
||||||
|
this.weekListValueSum1 = data1.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
|
}
|
||||||
|
if (data2) {
|
||||||
|
this.weekListValueSum2 = data2.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
|
}
|
||||||
|
if (data3) {
|
||||||
|
this.weekListValueSum3 = data3.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
|
}
|
||||||
|
if (data4) {
|
||||||
|
this.weekListValueSum4 = data4.reduce(function (s, a) {return s + a.value;}, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadMore1 () {
|
||||||
|
this.disableCategoryButton1 = true;
|
||||||
|
this.categoryLimit1 = 20;
|
||||||
|
}
|
||||||
|
private loadMore2 () {
|
||||||
|
this.disableCategoryButton2 = true;
|
||||||
|
this.categoryLimit2 = 20;
|
||||||
|
}
|
||||||
|
private loadMore3 () {
|
||||||
|
this.disableCategoryButton3 = true;
|
||||||
|
this.categoryLimit3 = 20;
|
||||||
|
}
|
||||||
|
private loadMore4 () {
|
||||||
|
this.disableCategoryButton4 = true;
|
||||||
|
this.categoryLimit4 = 20;
|
||||||
|
}
|
||||||
|
}
|
|
@ -94,7 +94,7 @@
|
||||||
<strong>{{ sectorPurchases[i] || 'N/A' }}</strong>
|
<strong>{{ sectorPurchases[i] || 'N/A' }}</strong>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li *ngIf="sectorLetters.length > 10 && disableSectorButton == false" class="divider text-center">
|
<li *ngIf="sectorLetters.length > sectorLimit && disableSectorButton == false" class="divider text-center">
|
||||||
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore()"><i class="icon-options"></i></button>
|
<button type="button" class="btn btn-sm btn-link text-muted" (click)="loadMore()"><i class="icon-options"></i></button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -168,7 +168,7 @@ export class DashboardCustomerComponent implements OnInit {
|
||||||
this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]);
|
this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public loadMore () {
|
private loadMore () {
|
||||||
this.disableSectorButton = true;
|
this.disableSectorButton = true;
|
||||||
this.sectorLimit = 22;
|
this.sectorLimit = 22;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { AccountEditComponent } from './account-edit.component';
|
||||||
import { AddDataComponent } from './add-data.component';
|
import { AddDataComponent } from './add-data.component';
|
||||||
import { FeedbackComponent } from './feedback.component';
|
import { FeedbackComponent } from './feedback.component';
|
||||||
import { TransactionLogComponent } from './transaction-log.component';
|
import { TransactionLogComponent } from './transaction-log.component';
|
||||||
|
import { CategoryMonthComponent } from './category-month.component';
|
||||||
import { PayrollLogComponent } from './payroll-log.component';
|
import { PayrollLogComponent } from './payroll-log.component';
|
||||||
import { LeaderboardComponent } from './leaderboard.component';
|
import { LeaderboardComponent } from './leaderboard.component';
|
||||||
import { MapComponent } from './map.component';
|
import { MapComponent } from './map.component';
|
||||||
|
@ -61,6 +62,7 @@ import { environment } from '../../environments/environment';
|
||||||
OrgResultComponent,
|
OrgResultComponent,
|
||||||
OrgTableComponent,
|
OrgTableComponent,
|
||||||
TransactionLogComponent,
|
TransactionLogComponent,
|
||||||
|
CategoryMonthComponent,
|
||||||
TransactionResultComponent,
|
TransactionResultComponent,
|
||||||
PayrollLogComponent,
|
PayrollLogComponent,
|
||||||
PayrollResultComponent,
|
PayrollResultComponent,
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { AccountEditComponent } from './account-edit.component';
|
||||||
import { AddDataComponent } from './add-data.component';
|
import { AddDataComponent } from './add-data.component';
|
||||||
import { FeedbackComponent } from './feedback.component';
|
import { FeedbackComponent } from './feedback.component';
|
||||||
import { TransactionLogComponent } from './transaction-log.component';
|
import { TransactionLogComponent } from './transaction-log.component';
|
||||||
|
import { CategoryMonthComponent } from './category-month.component';
|
||||||
import { PayrollLogComponent } from './payroll-log.component';
|
import { PayrollLogComponent } from './payroll-log.component';
|
||||||
import { LeaderboardComponent } from './leaderboard.component';
|
import { LeaderboardComponent } from './leaderboard.component';
|
||||||
import { MapComponent } from './map.component';
|
import { MapComponent } from './map.component';
|
||||||
|
@ -58,6 +59,11 @@ const routes: Routes = [
|
||||||
component: TransactionLogComponent,
|
component: TransactionLogComponent,
|
||||||
data: { title: 'Transaction Log' },
|
data: { title: 'Transaction Log' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'category-month',
|
||||||
|
component: CategoryMonthComponent,
|
||||||
|
data: { title: 'Budget' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: 'map',
|
path: 'map',
|
||||||
component: MapComponent,
|
component: MapComponent,
|
||||||
|
|
|
@ -81,6 +81,14 @@
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" routerLinkActive="active" [routerLink]="['/category-month']">
|
||||||
|
<div class="row no-gutters align-items-center">
|
||||||
|
<div class="col-2"><i class="icon-basket"></i></div>
|
||||||
|
<div class="col-10">Budget</div>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
<li *ngIf="accountType == 'organisation'" class="nav-item">
|
<li *ngIf="accountType == 'organisation'" class="nav-item">
|
||||||
<a class="nav-link" routerLinkActive="active" [routerLink]="['/payroll-log']">
|
<a class="nav-link" routerLinkActive="active" [routerLink]="['/payroll-log']">
|
||||||
<div class="row no-gutters align-items-center">
|
<div class="row no-gutters align-items-center">
|
||||||
|
|
|
@ -127,6 +127,17 @@ export class ApiService {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Basic Customer User stats API
|
||||||
|
public categoryTransactionList() {
|
||||||
|
const key = this.sessionKey;
|
||||||
|
return this.http.post<any>(
|
||||||
|
this.apiUrl + '/stats/category',
|
||||||
|
{
|
||||||
|
session_key : key,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Searches organisations used for transaction submission
|
// Searches organisations used for transaction submission
|
||||||
|
|
||||||
public search(data) {
|
public search(data) {
|
||||||
|
|
Reference in a new issue