diff --git a/.gitattributes b/.gitattributes index bdb0cab..60dd516 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,3 +15,9 @@ *.PDF diff=astextplain *.rtf diff=astextplain *.RTF diff=astextplain + +# ensures font files are loaded as binary not text +*.ttf binary +*.eot binary +*.woff binary +*.woff2 binary diff --git a/.travis.yml b/.travis.yml index f0c1c52..428a222 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +# Force sudo due to issue in travis +sudo: required addons: chrome: stable language: node_js diff --git a/CHANGELOG.md b/CHANGELOG.md index 7923872..74408eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,19 @@ # Next Release +* Amended category list on transaction submission +* Added budget view for weekly breakdown of spend by category + +# v0.1.3 + +* Made fix to Travis config + +# v0.1.2 + +* Removed unused button +* Added ability to choose category for transaction +* Added version bump on Angular + # v0.1.1 * Redid layout on circle customer view diff --git a/package-lock.json b/package-lock.json index cb1c91b..3e727f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "localloop-web", - "version": "0.1.1", + "version": "0.1.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 11398d1..4439085 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "localloop-web", - "version": "0.1.1", + "version": "0.1.3", "description": "LocalLoop Web - Web interface for LocalLoop app", "author": "", "url": "http://www.peartrade.org", diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index edcb5e2..c413237 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -25,17 +25,33 @@
- +
-
- +
+
+
+ +
+
+ +
+
+
+
+ +
+
- Optional: Choose the relevant Category for the purchase. + Optional: Choose the Budget Type for the majority of the purchase.
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 6d64ca8..48622bf 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -39,7 +39,8 @@ export class AddDataComponent implements OnInit { transactionFormInvalid = true; myDate: any; minDate: any; - categoryIdList: number[] = []; + leftCategoryIdList: number[] = []; + rightCategoryIdList: number[] = []; categoryNameList: string[] = []; constructor( @@ -85,8 +86,14 @@ export class AddDataComponent implements OnInit { } 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]); + console.log(categoryIdList); + let halfLength = Math.floor(categoryIdList.length / 2); + this.leftCategoryIdList = categoryIdList.splice(0, halfLength); + console.log(this.leftCategoryIdList); + this.rightCategoryIdList = categoryIdList; + console.log(this.rightCategoryIdList); } getMinDate() { diff --git a/src/app/dashboard/category-month.component.html b/src/app/dashboard/category-month.component.html new file mode 100644 index 0000000..0a7c91f --- /dev/null +++ b/src/app/dashboard/category-month.component.html @@ -0,0 +1,128 @@ +
+
+
+
+
+
+
+

Purchases Last Week

+
+
+
+
    +
  • + {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} + {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ (categoryEntry.value || 0 ) / weekListValueSum1 | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
    +
  • + +
  • +
    +
+
+
+
+
+
+
+
+
+
+

Purchases 1 Week Ago

+
+
+
+
    +
  • + {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} + {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ (categoryEntry.value || 0 ) / weekListValueSum2 | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
    +
  • + +
  • +
    +
+
+
+
+
+
+
+
+
+
+

Purchases 2 Weeks Ago

+
+
+
+
    +
  • + {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} + {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ (categoryEntry.value || 0 ) / weekListValueSum3 | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
    +
  • + +
  • +
    +
+
+
+
+
+
+
+
+
+
+

Purchases 3 Weeks Ago

+
+
+
+
    +
  • + {{ categoryNameList[categoryEntry.category] || 'Uncategorised' }} + {{ ( categoryEntry.value || 0 ) | currency:'GBP':'symbol':'1.2-2' }} + ({{ (categoryEntry.value || 0 ) / weekListValueSum4 | percent:'1.0-0' }}) +
    +
    +
    +
    +
    +
  • +
    +
  • + +
  • +
    +
+
+
+
+
+
+
diff --git a/src/app/dashboard/category-month.component.ts b/src/app/dashboard/category-month.component.ts new file mode 100644 index 0000000..1356a3f --- /dev/null +++ b/src/app/dashboard/category-month.component.ts @@ -0,0 +1,128 @@ +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; + + 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(obj: T, key: K) { + return obj[key]; + } + this.weekList1 = prop(data.data, this.myWeek1); + this.weekList2 = prop(data.data, this.myWeek2); + this.weekList3 = prop(data.data, this.myWeek3); + this.weekList4 = prop(data.data, this.myWeek4); + this.getMaxValue(this.weekList1, this.weekList2, this.weekList3, this.weekList4); + } + + 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; + } +} diff --git a/src/app/dashboard/dashboard-customer.component.html b/src/app/dashboard/dashboard-customer.component.html index f94704b..809bac1 100644 --- a/src/app/dashboard/dashboard-customer.component.html +++ b/src/app/dashboard/dashboard-customer.component.html @@ -94,7 +94,7 @@ {{ sectorPurchases[i] || 'N/A' }}
-
  • +
  • diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index 54867f2..55f1b6a 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -168,7 +168,7 @@ export class DashboardCustomerComponent implements OnInit { this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]); } - public loadMore () { + private loadMore () { this.disableSectorButton = true; this.sectorLimit = 22; } diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index d44e4ae..e41c4ea 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -16,6 +16,7 @@ import { AccountEditComponent } from './account-edit.component'; import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; import { TransactionLogComponent } from './transaction-log.component'; +import { CategoryMonthComponent } from './category-month.component'; import { PayrollLogComponent } from './payroll-log.component'; import { LeaderboardComponent } from './leaderboard.component'; import { MapComponent } from './map.component'; @@ -67,6 +68,7 @@ import { NgPipesModule } from 'ngx-pipes'; OrgResultComponent, OrgTableComponent, TransactionLogComponent, + CategoryMonthComponent, TransactionResultComponent, PayrollLogComponent, PayrollResultComponent, diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index 3e137a6..d222386 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -12,6 +12,7 @@ import { AccountEditComponent } from './account-edit.component'; import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; import { TransactionLogComponent } from './transaction-log.component'; +import { CategoryMonthComponent } from './category-month.component'; import { PayrollLogComponent } from './payroll-log.component'; import { LeaderboardComponent } from './leaderboard.component'; import { MapComponent } from './map.component'; @@ -59,6 +60,11 @@ const routes: Routes = [ component: TransactionLogComponent, data: { title: 'Transaction Log' }, }, + { + path: 'category-month', + component: CategoryMonthComponent, + data: { title: 'Budget' }, + }, { path: 'map', component: MapComponent, diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index b9b7cae..94ecad1 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -81,6 +81,14 @@
    +