Merge pull request #82 from Pear-Trading/v0.1.11

v0.1.11 release
This commit is contained in:
Finn 2018-06-06 14:15:53 +01:00 committed by GitHub
commit 8510c539f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 6384 additions and 4182 deletions

View file

@ -1,59 +0,0 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"version": "1.0.0-alpha.4",
"name": "coreui-angular"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": ["assets"],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"scripts": [
"../node_modules/moment/min/moment.min.js"
],
"styles": [
"scss/style.scss"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.dev.ts",
"prod": "environments/environment.prod.ts",
"local": "environments/environment.local.ts",
"ci": "environments/environment.ci.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json"
},
{
"project": "src/tsconfig.spec.json"
},
{
"project": "e2e/tsconfig.e2e.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"prefixInterfaces": false
}
}

View file

@ -2,6 +2,13 @@
# Next Release # Next Release
# 0.1.11
* Bumped Angular to version 6 and upgraded packages to match
* Converted RxJS 5 syntax to RxJS 6
* Removed extraneous console logs
* Changed dashboard sector list to category all time list & tweaked layout
# 0.1.10 # 0.1.10
* Allowed for creation of yearly recurring transactions * Allowed for creation of yearly recurring transactions

189
angular.json Normal file
View file

@ -0,0 +1,189 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"localloop-web": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets"
],
"styles": [
"src/scss/style.scss"
],
"scripts": [
"node_modules/moment/min/moment.min.js"
]
},
"configurations": {
"dev": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.dev.ts"
}
]
},
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"local": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
]
},
"ci": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.ci.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "localloop-web:build"
},
"configurations": {
"dev": {
"browserTarget": "localloop-web:build:dev"
},
"production": {
"browserTarget": "localloop-web:build:production"
},
"local": {
"browserTarget": "localloop-web:build:local"
},
"ci": {
"browserTarget": "localloop-web:build:ci"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "localloop-web:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
"node_modules/moment/min/moment.min.js"
],
"styles": [
"src/scss/style.scss"
],
"assets": [
"src/assets"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": []
}
}
}
},
"localloop-web-e2e": {
"root": "",
"sourceRoot": "",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "localloop-web:serve"
},
"configurations": {
"local": {
"devServerTarget": "localloop-web:serve:local"
},
"ci": {
"devServerTarget": "localloop-web:serve:ci"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": []
}
}
}
}
},
"defaultProject": "localloop-web",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "scss"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}

View file

@ -4,28 +4,28 @@
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
basePath: '', basePath: '',
frameworks: ['jasmine', '@angular/cli'], frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [ plugins: [
require('karma-jasmine'), require('karma-jasmine'),
require('karma-chrome-launcher'), require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'), require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'), require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma') require('@angular-devkit/build-angular/plugins/karma')
], ],
client:{ client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
files: [ files: [
{ pattern: './src/test.ts', watched: false }
], ],
preprocessors: { preprocessors: {
'./src/test.ts': ['@angular/cli']
}, },
mime: { mime: {
'text/x-typescript': ['ts','tsx'] 'text/x-typescript': ['ts','tsx']
}, },
coverageIstanbulReporter: { coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ], dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true fixWebpackSourcePaths: true
}, },
angularCli: { angularCli: {

9889
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "localloop-web", "name": "localloop-web",
"version": "0.1.9", "version": "0.1.11",
"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",
@ -10,56 +10,59 @@
"start": "ng serve", "start": "ng serve",
"build": "ng build", "build": "ng build",
"test": "ng test", "test": "ng test",
"test:ci": "ng test --watch=false --env=ci", "test:ci": "ng test --watch=false",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e", "e2e": "ng e2e",
"e2e:ci": "ng e2e --env=ci", "e2e:ci": "ng e2e --configuration=ci",
"ci": "npm run test:ci && npm run e2e:ci" "ci": "npm run test:ci && npm run e2e:ci"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@agm/core": "1.0.0-beta.2", "@agm/core": "1.0.0-beta.3",
"@agm/js-marker-clusterer": "1.0.0-beta.2", "@agm/js-marker-clusterer": "1.0.0-beta.3",
"@angular/common": "5.2.0", "@angular/common": "6.0.3",
"@angular/compiler": "5.2.0", "@angular/compiler": "6.0.3",
"@angular/core": "5.2.0", "@angular/core": "6.0.3",
"@angular/forms": "5.2.0", "@angular/forms": "6.0.3",
"@angular/platform-browser": "5.2.0", "@angular/platform-browser": "6.0.3",
"@angular/platform-browser-dynamic": "5.2.0", "@angular/platform-browser-dynamic": "6.0.3",
"@angular/router": "5.2.0", "@angular/router": "6.0.3",
"@angular/upgrade": "5.2.0", "@angular/upgrade": "6.0.3",
"@types/moment": "2.13.0", "@types/moment": "2.13.0",
"chart.js": "2.7.1", "chart.js": "^2.7.2",
"core-js": "2.5.1", "core-js": "^2.5.7",
"jasmine": "^3.1.0",
"js-marker-clusterer": "1.0.0", "js-marker-clusterer": "1.0.0",
"moment": "^2.21.0", "moment": "^2.22.2",
"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-rc.1", "ngx-bootstrap": "^2.0.5",
"ngx-pagination": "3.0.3", "ngx-pagination": "^3.1.1",
"rxjs": "5.5.6", "rxjs": "6.2.0",
"rxjs-compat": "^6.2.0",
"ts-helpers": "1.1.2", "ts-helpers": "1.1.2",
"webpack-dev-server": "3.1.0", "webpack-dev-server": "^3.1.4",
"zone.js": "0.8.18" "zone.js": "0.8.26"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "1.7.3", "@angular-devkit/build-angular": "~0.6.6",
"@angular/compiler-cli": "5.2.0", "@angular/cli": "^6.0.7",
"@angular/compiler-cli": "6.0.3",
"@types/jasmine": "2.8.2", "@types/jasmine": "2.8.2",
"@types/jasminewd2": "2.0.3", "@types/jasminewd2": "2.0.3",
"@types/node": "8.0.52", "@types/node": "8.0.52",
"codelyzer": "4.0.1", "codelyzer": "^4.3.0",
"jasmine-core": "2.8.0", "jasmine-core": "^3.1.0",
"jasmine-spec-reporter": "4.2.1", "jasmine-spec-reporter": "4.2.1",
"karma": "1.7.1", "karma": "^2.0.2",
"karma-chrome-launcher": "2.2.0", "karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1", "karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0", "karma-coverage-istanbul-reporter": "^2.0.1",
"karma-jasmine": "1.1.0", "karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "0.2.2", "karma-jasmine-html-reporter": "^1.1.0",
"protractor": "5.2.0", "protractor": "^5.3.2",
"ts-node": "3.3.0", "ts-node": "^6.1.0",
"tslint": "5.8.0", "tslint": "^5.10.0",
"typescript": "2.6.x" "typescript": "2.7.2"
} }
} }

View file

@ -8,13 +8,11 @@ export class AuthGuard implements CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (localStorage.getItem('sessionKey')) { if (localStorage.getItem('sessionKey')) {
console.log('session key found');
// logged in so return true // logged in so return true
return true; return true;
} }
// not logged in so redirect to login page with the return url // not logged in so redirect to login page with the return url
console.log('no session key found');
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }}); this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
return false; return false;
} }

View file

@ -8,11 +8,9 @@ export class CustomerGuard implements CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (localStorage.getItem('usertype') === 'customer') { if (localStorage.getItem('usertype') === 'customer') {
console.log('Customer logged in');
// customer logged in so return true // customer logged in so return true
return true; return true;
} else if (localStorage.getItem('usertype') === 'organisation') { } else if (localStorage.getItem('usertype') === 'organisation') {
console.log('not an customer');
this.router.navigate(['/dashboard']); this.router.navigate(['/dashboard']);
return false; return false;
} }

View file

@ -8,11 +8,9 @@ export class OrgGuard implements CanActivate {
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
if (localStorage.getItem('usertype') === 'organisation') { if (localStorage.getItem('usertype') === 'organisation') {
console.log('Organisation logged in');
// org logged in so return true // org logged in so return true
return true; return true;
} else if (localStorage.getItem('usertype') === 'customer') { } else if (localStorage.getItem('usertype') === 'customer') {
console.log('not an organisation');
this.router.navigate(['/dashboard-customer']); this.router.navigate(['/dashboard-customer']);
return false; return false;
} }

View file

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms'; import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import { Router, ActivatedRoute } from '@angular/router'; import { Router, ActivatedRoute } from '@angular/router';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'login.component.html', templateUrl: 'login.component.html',

View file

@ -3,7 +3,7 @@ import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ValidationManager } from 'ng2-validation-manager'; import { ValidationManager } from 'ng2-validation-manager';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import {Router } from '@angular/router'; import {Router } from '@angular/router';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'register.component.html', templateUrl: 'register.component.html',

View file

@ -1,7 +1,7 @@
import { Component, OnInit, ViewChild } from '@angular/core'; import { Component, OnInit, ViewChild } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms'; import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'account-edit.component.html', templateUrl: 'account-edit.component.html',

View file

@ -3,7 +3,7 @@ import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import { OrgTableComponent } from '../shared/org-table.component'; import { OrgTableComponent } from '../shared/org-table.component';
import * as moment from 'moment'; import * as moment from 'moment';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'add-data.component.html', templateUrl: 'add-data.component.html',
@ -174,6 +174,7 @@ export class AddDataComponent implements OnInit {
} }
transactionFormValidate() { transactionFormValidate() {
this.transactionFormStatus = null;
if (this.submitOrg.name.length && if (this.submitOrg.name.length &&
this.amount && this.amount &&
(this.recurringPurchase && (this.recurringPurchase &&

View file

@ -2,7 +2,7 @@ import { Directive, Component, OnInit } from '@angular/core';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
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 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'category-month.component.html' templateUrl: 'category-month.component.html'

View file

@ -11,10 +11,10 @@
</div><!--/.col--> </div><!--/.col-->
</div><!--/.row--> </div><!--/.row-->
<div class=row> <div class=row>
<div class="col-xl-4 col-md-6"> <div class="col-xl-6">
<panel-pie></panel-pie> <panel-pie></panel-pie>
</div><!--/.col--> </div><!--/.col-->
<div *ngIf="showCategoryDoughnutChart" class="col-xl-4 col-md-6"> <div *ngIf="showCategoryDoughnutChart" class="col-xl-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
@ -26,7 +26,7 @@
<canvas baseChart class="chart" <canvas baseChart class="chart"
[datasets]="doughnutChartDataCategory" [datasets]="doughnutChartDataCategory"
[labels]="doughnutChartLabelsCategory" [labels]="doughnutChartLabelsCategory"
[options]="doughtnutChartOptionsCategory" [options]="doughnutChartOptionsCategory"
[legend]="chartLegend" [legend]="chartLegend"
[chartType]="chartType" [chartType]="chartType"
(chartHover)="chartHovered($event)" (chartHover)="chartHovered($event)"
@ -35,7 +35,7 @@
</div> </div>
</div> </div>
</div><!--/.col--> </div><!--/.col-->
<div *ngIf="showEssentialBarChart" class="col-xl-4 col-md-6"> <div *ngIf="showEssentialBarChart" class="col-xl-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
@ -55,7 +55,7 @@
</div> </div>
</div> </div>
</div><!--/.col--> </div><!--/.col-->
<div *ngIf="showCategoryBarChart" class="col-xl-4 col-md-6"> <div *ngIf="showCategoryBarChart" class="col-xl-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
@ -76,7 +76,7 @@
</div> </div>
</div> </div>
</div><!--/.col--> </div><!--/.col-->
<div class="col-xl-4 col-md-6"> <div class="col-xl-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
@ -135,29 +135,29 @@
</div> </div>
</div> </div>
</div><!--/.col--> </div><!--/.col-->
<div class="col-xl-4"> <div class="col-xl-6">
<div class="card"> <div class="card">
<div class="card-block"> <div class="card-block">
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<h4 class="card-title float-left mb-0">Purchases by Sector</h4> <h4 class="card-title float-left mb-0">All Purchases by Category</h4>
</div><!--/.col--> </div><!--/.col-->
</div><!--/.row--> </div><!--/.row-->
<div class="chart-wrapper"> <div class="chart-wrapper">
<ul class="icons-list"> <ul class="icons-list">
<!-- New loop --> <!-- New loop -->
<li *ngFor="let sector of sectorLetters | slice:0:sectorLimit; let i=index"> <li *ngFor="let category of totalCategoryList | slice:0:totalCategoryLimit; let i=index">
<i [ngClass]="[sectorIcons [sector] || 'icon-question', sectorClasses [sector] || 'bg-info']"></i> <i [ngClass]="[ 'icon-question', 'bg-info']"></i>
<div class="desc"> <div class="desc">
<div class="title">{{ sectorNames [sector] || 'N/A' }}</div> <div class="title">{{ category.category || 'N/A' }}</div>
</div> </div>
<div class="value"> <div class="value">
<div class="small text-muted">Bought</div> <div class="small text-muted">Bought</div>
<strong>{{ sectorPurchases[i] || 'N/A' }}</strong> <strong>{{ category.value || 'N/A' }}</strong>
</div> </div>
</li> </li>
<li *ngIf="sectorLetters.length > sectorLimit && disableSectorButton == false" class="divider text-center"> <li *ngIf="totalCategoryList.length > totalCategoryLimit && disableCategoryButton == 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)="categoryLoadMore()"><i class="icon-options"></i></button>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -7,7 +7,7 @@ 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 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'dashboard-customer.component.html' templateUrl: 'dashboard-customer.component.html'
@ -23,14 +23,14 @@ export class DashboardCustomerComponent implements OnInit {
username: any; username: any;
maxPurchase: number = 0; maxPurchase: number = 0;
disableSectorButton: boolean = false; disableCategoryButton: boolean = false;
public chartType = 'doughnut'; public chartType = 'doughnut';
public chartLegend = true; public chartLegend = true;
public doughnutChartDataCategory: any[] = []; public doughnutChartDataCategory: any[] = [];
public doughnutChartLabelsCategory: string[] = []; public doughnutChartLabelsCategory: string[] = [];
public doughtnutChartOptionsCategory:any = { public doughnutChartOptionsCategory:any = {
tooltips: { tooltips: {
callbacks: { callbacks: {
label: (tooltip, data) => { label: (tooltip, data) => {
@ -100,83 +100,9 @@ export class DashboardCustomerComponent implements OnInit {
count: 0, count: 0,
}; };
sectorNames = { showTotalCategoryList: boolean = false;
A: 'Agriculture, Forestry & Fishing', totalCategoryLimit: number = 10;
B: 'Mining & Quarrying', totalCategoryList: any[]=[];
C: 'Manufacturing',
D: 'Electricity, Gas, Steam & Air Conditioning',
E: 'Water & Waste Management',
F: 'Construction',
G: 'Wholesale & Retail Trade',
H: 'Transportation & Storage',
I: 'Accomodation & Food Services',
J: 'Information & Communication',
K: 'Financial & Insurance Activities',
L: 'Real Estate',
M: 'Professional, Scientfic & Technical',
N: 'Administrative & Support Services',
O: 'Public Administration, Defence & Social Security',
P: 'Education',
Q: 'Human Health & Social Work',
R: 'Arts, Entertainment & Recreation',
S: 'Other Service Activities',
T: 'Household Domestic Business',
U: 'Extraterritorial Organisations and Bodies'
}
sectorIcons = {
A: 'icon-drop',
B: 'icon-diamond',
C: 'icon-settings',
D: 'icon-energy',
E: 'icon-trash',
F: 'icon-wrench',
G: 'icon-tag',
H: 'icon-speedometer',
I: 'icon-cup',
J: 'icon-feed',
K: 'icon-credit-card',
L: 'icon-graph',
M: 'icon-chemistry',
N: 'icon-drawer',
O: 'icon-pie-chart',
P: 'icon-graduation',
Q: 'icon-support',
R: 'icon-film',
S: 'icon-calendar',
T: 'icon-home',
U: 'icon-globe',
}
sectorClasses = {
A: 'bg-primary',
B: 'bg-success',
C: 'bg-danger',
D: 'bg-warning',
E: 'bg-info',
F: 'bg-primary',
G: 'bg-success',
H: 'bg-danger',
I: 'bg-warning',
J: 'bg-info',
K: 'bg-primary',
L: 'bg-success',
M: 'bg-danger',
N: 'bg-warning',
O: 'bg-info',
P: 'bg-primary',
Q: 'bg-success',
R: 'bg-danger',
S: 'bg-warning',
T: 'bg-info',
U: 'bg-primary',
}
sectorLetters: string[] = [];
sectorPurchases: number[] = [];
sectorLimit: number = 10;
sectorList: any;
// Graph widgets // Graph widgets
public widgetList = [ public widgetList = [
@ -216,9 +142,10 @@ export class DashboardCustomerComponent implements OnInit {
this.api.customerStats().subscribe( this.api.customerStats().subscribe(
result => { result => {
this.setWeekPurchaseList(result.weeks); this.setWeekPurchaseList(result.weeks);
this.setSectorList(result.sectors);
this.setWeekData(result); this.setWeekData(result);
this.setChartData(result.data.cat_total); this.setChartData(result.data.cat_total);
this.totalCategoryList = result.data.cat_list;
this.showTotalCategoryList = true;
this.purchaseEssential = result.data.essentials.purchase_no_essential_total; this.purchaseEssential = result.data.essentials.purchase_no_essential_total;
this.purchaseNotEssential = result.data.essentials.purchase_no_total - this.purchaseEssential; this.purchaseNotEssential = result.data.essentials.purchase_no_total - this.purchaseEssential;
this.barChartDataEssential = [ this.barChartDataEssential = [
@ -273,14 +200,9 @@ export class DashboardCustomerComponent implements OnInit {
}; };
} }
public setSectorList (data: any) { private categoryLoadMore () {
this.sectorLetters = Object.keys(data.sectors).map(key => data.sectors[key]); this.disableCategoryButton = true;
this.sectorPurchases = Object.keys(data.purchases).map(key => data.purchases[key]); this.totalCategoryLimit = 30;
}
private loadMore () {
this.disableSectorButton = true;
this.sectorLimit = 22;
} }
public convertHex(hex: string, opacity: number) { public convertHex(hex: string, opacity: number) {

View file

@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms'; import { Validators, FormBuilder, FormGroup } from '@angular/forms';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'feedback.component.html', templateUrl: 'feedback.component.html',

View file

@ -5,7 +5,7 @@ import {PaginationInstance} from 'ngx-pagination';
// import { PaginationControlsComponent } from 'ngx-pagination'; // import { PaginationControlsComponent } from 'ngx-pagination';
// import { PaginationControlsDirective } from 'ngx-pagination'; // import { PaginationControlsDirective } from 'ngx-pagination';
// import { TransactionResultComponent } from '../shared/transaction-result.component'; // import { TransactionResultComponent } from '../shared/transaction-result.component';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'leaderboard.component.html', templateUrl: 'leaderboard.component.html',

View file

@ -3,7 +3,7 @@ import { ApiService } from '../providers/api-service';
import { AgmCoreModule } from '@agm/core'; import { AgmCoreModule } from '@agm/core';
import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'map.component.html', templateUrl: 'map.component.html',

View file

@ -6,7 +6,7 @@ import {PaginationInstance} from 'ngx-pagination';
// import { PaginationControlsDirective } from 'ngx-pagination'; // import { PaginationControlsDirective } from 'ngx-pagination';
// import { TransactionResultComponent } from '../shared/transaction-result.component'; // import { TransactionResultComponent } from '../shared/transaction-result.component';
import * as moment from 'moment'; import * as moment from 'moment';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'payroll-log.component.html', templateUrl: 'payroll-log.component.html',

View file

@ -3,7 +3,7 @@ import { ApiService } from '../providers/api-service';
import { AgmCoreModule } from '@agm/core'; import { AgmCoreModule } from '@agm/core';
import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal'; import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'trail-map.component.html', templateUrl: 'trail-map.component.html',

View file

@ -4,7 +4,7 @@ import { BsModalService, ModalDirective } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service'; import { BsModalRef } from 'ngx-bootstrap/modal/bs-modal-ref.service';
import { PaginationInstance } from 'ngx-pagination'; import { PaginationInstance } from 'ngx-pagination';
import * as moment from 'moment'; import * as moment from 'moment';
import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'transaction-log.component.html', templateUrl: 'transaction-log.component.html',

View file

@ -3,7 +3,7 @@ import { ApiService } from '../providers/api-service';
import { CustPiesService } from '../providers/cust-pies.service'; import { CustPiesService } from '../providers/cust-pies.service';
import { DataType } from '../shared/data-types.enum'; import { DataType } from '../shared/data-types.enum';
import { ChartData } from '../_interfaces/chart-data'; import { ChartData } from '../_interfaces/chart-data';
import 'rxjs/add/operator/map';
@Component({ @Component({
selector: 'panel-pie', selector: 'panel-pie',

View file

@ -1,8 +1,8 @@
import { map } from 'rxjs/operators';
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Rx';
import { environment } from '../../environments/environment'; import { environment } from '../../environments/environment';
import 'rxjs/add/operator/map';
/* this provider handles the interaction between server and client */ /* this provider handles the interaction between server and client */
@ -29,18 +29,15 @@ export class ApiService {
// Login API // Login API
public getSessionKey() { public getSessionKey() {
console.log('get key');
return this.sessionKey; return this.sessionKey;
} }
public setSessionKey(key) { public setSessionKey(key) {
console.log('set key');
this.sessionKey = key; this.sessionKey = key;
localStorage.setItem('sessionKey', this.sessionKey); localStorage.setItem('sessionKey', this.sessionKey);
} }
public removeSessionKey() { public removeSessionKey() {
console.log('remove key');
this.sessionKey = null; this.sessionKey = null;
localStorage.removeItem('sessionKey'); localStorage.removeItem('sessionKey');
} }
@ -57,8 +54,8 @@ export class ApiService {
.post<any>( .post<any>(
this.apiUrl + '/login', this.apiUrl + '/login',
data data
) ).pipe(
.map( map(
result => { result => {
const json = result; const json = result;
this.setSessionKey(json.session_key); this.setSessionKey(json.session_key);
@ -69,24 +66,23 @@ export class ApiService {
this.setUserType(json.user_type); this.setUserType(json.user_type);
return json; return json;
} }
); ));
} }
public logout() { public logout() {
console.log(this.sessionKey);
const key = this.sessionKey; const key = this.sessionKey;
return this.http return this.http
.post<any>( .post<any>(
this.apiUrl + '/logout', this.apiUrl + '/logout',
{ session_key : key }, { session_key : key },
) ).pipe(
.map( map(
response => { response => {
localStorage.clear(); localStorage.clear();
this.sessionKey = null; this.sessionKey = null;
return response; return response;
} }
); ));
} }
// Submits feedback // Submits feedback
@ -96,7 +92,6 @@ export class ApiService {
data.package_name = 'Foodloop Web'; data.package_name = 'Foodloop Web';
data.version_code = 'dev'; data.version_code = 'dev';
data.version_number = 'dev'; data.version_number = 'dev';
console.log(data);
return this.http.post<any>( return this.http.post<any>(
this.apiUrl + '/feedback', this.apiUrl + '/feedback',
data data
@ -230,7 +225,6 @@ export class ApiService {
public setUserInfo( public setUserInfo(
email: string, email: string,
display_name: string) { display_name: string) {
console.log('set UserInfo');
localStorage.setItem('email', email); localStorage.setItem('email', email);
localStorage.setItem('displayname', display_name); localStorage.setItem('displayname', display_name);
} }
@ -238,7 +232,6 @@ export class ApiService {
// Sets usertype // Sets usertype
public setUserType(user_type: string) { public setUserType(user_type: string) {
console.log('set UserType');
localStorage.setItem('usertype', user_type); localStorage.setItem('usertype', user_type);
} }
@ -263,33 +256,27 @@ export class ApiService {
// Deletes account details on logout // Deletes account details on logout
public removeUserInfo() { public removeUserInfo() {
console.log('remove UserInfo');
localStorage.removeItem('email'); localStorage.removeItem('email');
localStorage.removeItem('displayname'); localStorage.removeItem('displayname');
} }
public getFullName() { public getFullName() {
console.log('get Full Name');
localStorage.getItem('fullname'); localStorage.getItem('fullname');
} }
public getDisplayName() { public getDisplayName() {
console.log('get Display Name');
localStorage.getItem('displayname'); localStorage.getItem('displayname');
} }
public getPostcode() { public getPostcode() {
console.log('get Postcode');
localStorage.getItem('postcode'); localStorage.getItem('postcode');
} }
public getYearOfBirth() { public getYearOfBirth() {
console.log('get Year of Birth');
localStorage.getItem('yearofbirth'); localStorage.getItem('yearofbirth');
} }
public getEmail() { public getEmail() {
console.log('get email');
localStorage.getItem('email'); localStorage.getItem('email');
} }

View file

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ApiService } from './api-service'; import { ApiService } from './api-service';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs';
@Injectable() @Injectable()
export class CustPiesService { export class CustPiesService {

View file

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ApiService } from './api-service'; import { ApiService } from './api-service';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs';
@Injectable() @Injectable()
export class CustSnippetsService { export class CustSnippetsService {

View file

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { ApiService } from './api-service'; import { ApiService } from './api-service';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs';
@Injectable() @Injectable()
export class OrgSnippetsService { export class OrgSnippetsService {

View file

@ -1,6 +1,8 @@
import {filter} from 'rxjs/operators';
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; import { Router, ActivatedRoute, NavigationEnd } from '@angular/router';
import 'rxjs/add/operator/filter';
@Component({ @Component({
selector: 'app-breadcrumbs', selector: 'app-breadcrumbs',
@ -18,7 +20,7 @@ export class BreadcrumbsComponent implements OnInit {
breadcrumbs: Array<Object>; breadcrumbs: Array<Object>;
constructor(private router: Router, private route: ActivatedRoute) {} constructor(private router: Router, private route: ActivatedRoute) {}
ngOnInit(): void { ngOnInit(): void {
this.router.events.filter(event => event instanceof NavigationEnd).subscribe(event => { this.router.events.pipe(filter(event => event instanceof NavigationEnd)).subscribe(event => {
this.breadcrumbs = []; this.breadcrumbs = [];
let currentRoute = this.route.root, let currentRoute = this.route.root,
url = ''; url = '';

View file

@ -11,7 +11,8 @@
] ]
}, },
"files": [ "files": [
"test.ts" "test.ts",
"polyfills.ts"
], ],
"include": [ "include": [
"**/*.spec.ts", "**/*.spec.ts",

View file

@ -12,7 +12,7 @@
"curly": true, "curly": true,
"eofline": true, "eofline": true,
"forin": true, "forin": true,
"import-blacklist": [true, "rxjs"], "import-blacklist": [true],
"import-spacing": true, "import-spacing": true,
"indent": [ "indent": [
true, true,