From 0a9e80fc97076d9ecf40c80f56e6363acc9569ea Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 20 Oct 2017 13:21:49 +0100 Subject: [PATCH 01/18] Fixed transaction submission --- package-lock.json | 18 +++++++++--------- src/app/dashboard/add-data.component.html | 2 +- src/app/dashboard/add-data.component.ts | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index b3325ee..655bc51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "localloop-web", - "version": "0.0.1", + "version": "0.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -7979,14 +7979,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -7997,6 +7989,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 3a78b96..948f868 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -31,7 +31,7 @@ Enter the name of the organisation money was spent. Choose existing ones from below or if not found, enter the details below. - +
diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 359c294..13589c7 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -32,7 +32,7 @@ export class AddDataComponent implements OnInit { organisationPostcode: string; amount: number; transactionAdditionType = 1; - storeList; + storeList = []; showAddStore = false; submitReceipt = false; transactionFormInvalid = true; @@ -108,7 +108,7 @@ export class AddDataComponent implements OnInit { } // handle the case when the storelist is empty if (this.storeList.length < 1) { - this.storeList = null; + this.storeList = []; this.showAddStore = true; this.transactionAdditionType = 3; } @@ -135,7 +135,7 @@ export class AddDataComponent implements OnInit { const val = ev.target.value; // Filter the store list so search seems quicker - if (val && val.trim() !== '' && this.storeList !== null) { + if (val && val.trim() !== '' && this.storeList.length > 0) { this.storeList = this.storeList.filter( (item) => { return ( item.name.toLowerCase().indexOf( val.toLowerCase() ) > -1 ); From 0a54cdc0918c642b01a95cb0237936f79d0e81ff Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 10 Nov 2017 14:13:28 +0000 Subject: [PATCH 02/18] fixed register name in place --- src/app/auth/register.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/auth/register.component.html b/src/app/auth/register.component.html index 1a0c868..34c50ca 100644 --- a/src/app/auth/register.component.html +++ b/src/app/auth/register.component.html @@ -40,7 +40,7 @@
From 0b2c9c20f82f08b893b78c2f25aa7ead6781f045 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 10 Nov 2017 14:14:11 +0000 Subject: [PATCH 03/18] Unusable password reset button disabled --- src/app/auth/login.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/auth/login.component.html b/src/app/auth/login.component.html index 5c02b96..db5b7c8 100644 --- a/src/app/auth/login.component.html +++ b/src/app/auth/login.component.html @@ -30,9 +30,9 @@
-
+
From f5239a3822ef1e9748a814c122233d920ee6f90f Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 10 Nov 2017 15:20:48 +0000 Subject: [PATCH 04/18] Added password reset placeholder --- src/app/auth/login.component.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/auth/login.component.html b/src/app/auth/login.component.html index db5b7c8..d1992f5 100644 --- a/src/app/auth/login.component.html +++ b/src/app/auth/login.component.html @@ -30,9 +30,10 @@
- +
+ +
+ From 8a5236ad3a0e3102177fd7361d92d16f22811be2 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 10 Nov 2017 17:15:11 +0000 Subject: [PATCH 05/18] Leaderboard pages added and routing sorted --- src/app/dashboard/dashboard.module.ts | 4 + src/app/dashboard/dashboard.routing.ts | 7 +- src/app/dashboard/leaderboard.component.html | 59 +++++++++ src/app/dashboard/leaderboard.component.ts | 113 ++++++++++++++++++ src/app/layouts/full-layout.component.html | 7 +- src/app/providers/api-service.ts | 9 +- .../shared/leaderboard-result.component.html | 3 + .../shared/leaderboard-result.component.ts | 19 +++ 8 files changed, 216 insertions(+), 5 deletions(-) create mode 100644 src/app/dashboard/leaderboard.component.html create mode 100644 src/app/dashboard/leaderboard.component.ts create mode 100644 src/app/shared/leaderboard-result.component.html create mode 100644 src/app/shared/leaderboard-result.component.ts diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index a8c59b0..941f8ab 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -15,6 +15,7 @@ import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; import { TransactionLogComponent } from './transaction-log.component'; import { PayrollLogComponent } from './payroll-log.component'; +import { LeaderboardComponent } from './leaderboard.component'; import { MapComponent } from './map.component'; import { GraphWidget } from '../widgets/graph-widget.component'; @@ -26,6 +27,7 @@ import { OrgResultComponent } from '../shared/org-result.component'; import { OrgTableComponent } from '../shared/org-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; +import { LeaderboardResultComponent } from '../shared/leaderboard-result.component'; // API key env variable import import { environment } from '../../environments/environment'; @@ -55,6 +57,8 @@ import { environment } from '../../environments/environment'; TransactionResultComponent, PayrollLogComponent, PayrollResultComponent, + LeaderboardComponent, + LeaderboardResultComponent, MapComponent, FeedbackComponent, GraphWidget, diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index f28c65e..ba776f2 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -38,13 +38,18 @@ const routes: Routes = [ { path: 'account-edit', component: AccountEditComponent, - data: { title: 'Leaderboards' }, + data: { title: 'Edit Account' }, }, { path: 'add-data', component: AddDataComponent, data: { title: 'Add Transaction' }, }, + { + path: 'leaderboard', + component: LeaderboardComponent, + data: { title: 'Leaderboards' }, + }, { path: 'transaction-log', component: TransactionLogComponent, diff --git a/src/app/dashboard/leaderboard.component.html b/src/app/dashboard/leaderboard.component.html new file mode 100644 index 0000000..7eee607 --- /dev/null +++ b/src/app/dashboard/leaderboard.component.html @@ -0,0 +1,59 @@ +
+
+
+
+
+ Leaderboard + By default this loads the page with your position. +
+
+ + + + + + + + + + + + +
PositionValuePurchase Time
+ + + +
+
+ No Leaderboard available. +
+
+
+
+
diff --git a/src/app/dashboard/leaderboard.component.ts b/src/app/dashboard/leaderboard.component.ts new file mode 100644 index 0000000..7940056 --- /dev/null +++ b/src/app/dashboard/leaderboard.component.ts @@ -0,0 +1,113 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import { ApiService } from '../providers/api-service'; +// import { PaginatePipe } from 'ngx-pagination'; +import {PaginationInstance} from 'ngx-pagination'; +// import { PaginationControlsComponent } from 'ngx-pagination'; +// import { PaginationControlsDirective } from 'ngx-pagination'; +// import { TransactionResultComponent } from '../shared/transaction-result.component'; +import 'rxjs/add/operator/map'; + +@Component({ + templateUrl: 'leaderboard-log.component.html', +}) +export class LeaderboardComponent implements OnInit { + + transactionList; + noLeaderboardList = false; + public p: any; + + leaderboardData: Array; + currentPos: number; + listType: any = 'weekly_total'; + + public paginateConfig: PaginationInstance = { + id: 'leadpaginate', + itemsPerPage: 10, + currentPage: 1, + totalItems: 0 + }; + + constructor( + private http: Http, + private api: ApiService, + ) { + this.myDate = moment().format('YYYY-MM-DD[T]HH:mm'); + // this.myDate = new Date().toISOString().slice(0, 16); + } + + ngOnInit(): void { + this.loadLeaderboard(0); + } + + // private fetchLeaderboard() { + // this.peopleService.leaderboard(this.listType) + // .subscribe( + // result => { + // this.leaderboardData = result.leaderboard; + // this.currentPos = result.user_position; + // } + // ); + // } + + public changeLeaderboard(event) { + this.loadLeaderboard(); + } + + + loadLeaderboard(leadPage: number) { + console.log(leadPage, listType); + this.api.leaderboard_fetch(listType,leadPage).subscribe( + result => { + if (result.transactions.length > 0) { + this.transactionList = result.transactions; + // TODO Rename in server + this.paginateConfig.totalItems = result.page_no; + this.paginateConfig.currentPage = result.page; + this.noLeaderboardList = false; + } else { + // handle the case when the transactionList is empty + this.leaderboardList = null; + this.noLeaderboardList = true; + } + }, + error => { + console.log(error); + } + ); + } + + // // dynamically changes the row style based on player's position + // // for instance, top three player and the player him/herself should + // // be hightlighted + // public getClass(item) { + // if( item.position < 4 ) { + // return "topThree"; + // } else if( item.position == this.currentPos ) { + // return "user"; + // } + // return "otherUsers"; + // } + // + // // show changes by using icon, trending up and trending down or no trend. + // public getTrendIcon(item){ + // if( item.trend < 0 ){ + // return "md-trending-up"; + // } else if( item.trend > 0 ){ + // return "md-trending-down"; + // } + // return "md-remove"; + // } + // + // // need to merge this function with getIcon + // // this function shows different icon color based on the direction of the position shifted + // public getTrendIconColor(item){ + // if( item.trend < 0 ) { + // return "secondary"; + // } else if( item.trend > 0 ){ + // return "danger"; + // } + // return "dark"; + // } + +} diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index 4fc7f4c..5dc056b 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -40,11 +40,16 @@ Enter Feedback - + - -