From 7b1771b45ffb6038b503502fac7fb157715cafd7 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 15 Sep 2017 16:35:04 +0100 Subject: [PATCH 01/37] Fixed Register View on mobile --- src/app/auth/login.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/auth/login.component.html b/src/app/auth/login.component.html index 41095ff..5c02b96 100644 --- a/src/app/auth/login.component.html +++ b/src/app/auth/login.component.html @@ -37,7 +37,7 @@ -
+

Sign up

From 70be2cbc2b57aa3c4592dc71b4f21937eaab0cdf Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 15 Sep 2017 16:36:37 +0100 Subject: [PATCH 02/37] Amended changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1849098..e9124fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ # Next Release +* Fixed register box view on login page + # v0.0.1 * Added Travis Testing From f34c558d415aa80fb4f7aafa41877ecf63cf8c0a Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 15 Sep 2017 16:50:53 +0100 Subject: [PATCH 03/37] Fixes to receipt form --- CHANGELOG.md | 1 + src/app/dashboard/add-data.component.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9124fb..275665b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ # Next Release * Fixed register box view on login page +* Made the form reset properly if adding a new one # v0.0.1 diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index c121d0a..75b9a28 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -239,6 +239,7 @@ export class AddDataComponent { this.storeList = null; this.amount = null; this.transactionFormInvalid = true; + this.showAddStore = false; } onSubmitPayroll() { From 7f3e9f4fd0a6f1614734f827e0915ddbbb82ffb5 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Fri, 15 Sep 2017 17:33:34 +0100 Subject: [PATCH 04/37] Added better error messaging --- CHANGELOG.md | 1 + src/app/auth/register.component.html | 26 ++++++------- src/app/auth/register.component.ts | 37 ++++++++++++++----- src/app/dashboard/account-edit.component.html | 4 +- src/app/dashboard/account-edit.component.ts | 23 +++++++++++- 5 files changed, 65 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 275665b..84ec5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Fixed register box view on login page * Made the form reset properly if adding a new one +* Added better error messages on register and account edit # v0.0.1 diff --git a/src/app/auth/register.component.html b/src/app/auth/register.component.html index dbe0c82..1a0c868 100644 --- a/src/app/auth/register.component.html +++ b/src/app/auth/register.component.html @@ -6,7 +6,7 @@

Register

Create your account

- + - +
- +
- +
- +
@@ -137,7 +137,7 @@ Form validation failed, please ensure the form is filled correctly.
diff --git a/src/app/auth/register.component.ts b/src/app/auth/register.component.ts index ebc69d2..bdb9815 100644 --- a/src/app/auth/register.component.ts +++ b/src/app/auth/register.component.ts @@ -16,7 +16,8 @@ export class RegisterComponent { organisationForm: ValidationManager; years: Object[]; registerStatus: any; - + registerStatusError: string = 'Error received, please try again.'; + constructor( private http: Http, private formBuilder: FormBuilder, @@ -51,9 +52,9 @@ export class RegisterComponent { postcode: 'required', }); } - + onSubmitCustomer() { - + console.log(this.signupForm.isValid()); if (!this.signupForm.isValid() && !this.customerForm.isValid()) { console.log("Not Valid!"); @@ -63,7 +64,7 @@ export class RegisterComponent { } let signupForm = this.signupForm.getForm().value; let customerForm = this.customerForm.getForm().value; - + let data = { token: signupForm.token, usertype: signupForm.usertype, @@ -85,14 +86,23 @@ export class RegisterComponent { this.router.navigate(['/dashboard']); }, error => { - console.log( error._body ); + console.log('Register Error'); + console.log(error); + try { + console.log(error.error); + let jsonError = error.json(); + console.log("boop"); + this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + } catch(e) { + this.registerStatusError = 'There was a server error, please try again later.'; + } this.registerStatus = "send_failed"; - console.log(this.registerStatus) + console.log(this.registerStatus); } ); } onSubmitOrganisation() { - + console.log(this.signupForm.isValid()); if (!this.signupForm.isValid() || !this.organisationForm.isValid()) { console.log("Not Valid!"); @@ -102,7 +112,7 @@ export class RegisterComponent { } let signupForm = this.signupForm.getForm().value; let organisationForm = this.organisationForm.getForm().value; - + let data = { token: signupForm.token, usertype: signupForm.usertype, @@ -125,7 +135,16 @@ export class RegisterComponent { this.router.navigate(['/dashboard']); }, error => { - console.log( error._body ); + console.log('Register Error'); + console.log(error); + try { + console.log(error.error); + let jsonError = error.json(); + console.log("boop"); + this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + } catch(e) { + this.registerStatusError = 'There was a server error, please try again later.'; + } this.registerStatus = "send_failed"; console.log(this.registerStatus); } diff --git a/src/app/dashboard/account-edit.component.html b/src/app/dashboard/account-edit.component.html index f46aca7..5d4e7b4 100644 --- a/src/app/dashboard/account-edit.component.html +++ b/src/app/dashboard/account-edit.component.html @@ -122,7 +122,7 @@ Form validation failed, please ensure the form is filled correctly.
@@ -160,7 +160,7 @@ Form validation failed, please ensure the form is filled correctly. diff --git a/src/app/dashboard/account-edit.component.ts b/src/app/dashboard/account-edit.component.ts index eedd3ad..0cc6a51 100644 --- a/src/app/dashboard/account-edit.component.ts +++ b/src/app/dashboard/account-edit.component.ts @@ -14,6 +14,7 @@ export class AccountEditComponent implements OnInit { accountType: any; // @ViewChild('fileInput') fileInput; submitStatus: any; + submitStatusError: string = 'Error received, please try again.'; constructor( private http: Http, @@ -111,7 +112,16 @@ export class AccountEditComponent implements OnInit { console.log(this.submitStatus); }, error => { - console.log( error._body ); + console.log('Edit Error'); + console.log(error); + try { + console.log(error.error); + let jsonError = error.json(); + console.log("boop"); + this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + } catch(e) { + this.submitStatusError = 'There was a server error, please try again later.'; + } this.submitStatus = "send_failed"; console.log(this.submitStatus); } @@ -159,7 +169,16 @@ export class AccountEditComponent implements OnInit { console.log(this.submitStatus); }, error => { - console.log( error._body ); + console.log('Edit Error'); + console.log(error); + try { + console.log(error.error); + let jsonError = error.json(); + console.log("boop"); + this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; + } catch(e) { + this.submitStatusError = 'There was a server error, please try again later.'; + } this.submitStatus = "send_failed"; console.log(this.submitStatus); } From d1eb79b3948d2ace612bc86cd6bf00faefe901f9 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Mon, 18 Sep 2017 13:58:38 +0100 Subject: [PATCH 05/37] Fixed Transaction Validation --- src/app/dashboard/add-data.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index 75b9a28..f8c31e6 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -151,7 +151,8 @@ export class AddDataComponent { } transactionFormValidate() { - if( this.submitOrg.name.length == 0 && + if( this.submitOrg.name.length == 0 || + this.submitOrg.town.length == 0 || this.amount == 0 ) { this.transactionFormInvalid = true; }else{ From 10664f0da9203772e982b56ebb9ad3db145fc21b Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 10:59:08 +0100 Subject: [PATCH 06/37] Added script for automating prod and dev builds --- bin/build-releases | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 bin/build-releases diff --git a/bin/build-releases b/bin/build-releases new file mode 100755 index 0000000..0a840d2 --- /dev/null +++ b/bin/build-releases @@ -0,0 +1,23 @@ +#! /bin/bash + +VERSION=`git describe --tags` + +echo "Building releases for $VERSION" + +echo "Building Prod Release..." + +ng build --prod + +tar -czf ../LocalLoop-Web-prod-$VERSION.tar.gz dist + +echo "Building Dev Release..." + +ng build --dev + +tar -cvzf ../LocalLoop-Web-dev-$VERSION.tar.gz dist + +echo "Cleaning up build artefacts..." + +rm -rf dist + +echo "Done" From 49be004bbc1e3e821927fc244be9aa9ff79dc217 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 11:04:59 +0100 Subject: [PATCH 07/37] whitespace changes for pages 404 --- src/app/pages/404.component.html | 6 +++--- src/app/pages/404.component.ts | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app/pages/404.component.html b/src/app/pages/404.component.html index e76245d..cd46b4d 100644 --- a/src/app/pages/404.component.html +++ b/src/app/pages/404.component.html @@ -7,9 +7,9 @@

Oops! You're lost.

The page you are looking for was not found.

- - - + + + diff --git a/src/app/pages/404.component.ts b/src/app/pages/404.component.ts index 0e91023..b309577 100644 --- a/src/app/pages/404.component.ts +++ b/src/app/pages/404.component.ts @@ -7,11 +7,10 @@ import { Location } from '@angular/common'; export class P404Component { constructor( - private location: Location - ) { - } + private location: Location, + ) { } - goBack(): void { - this.location.back(); -} + goBack(): void { + this.location.back(); + } } From baf64ff4b7ee1f4f561ee76b6747eaeec6ca3443 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 11:06:41 +0100 Subject: [PATCH 08/37] whitespace changes for linter in pages 500 --- src/app/pages/500.component.html | 4 ++-- src/app/pages/500.component.ts | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/app/pages/500.component.html b/src/app/pages/500.component.html index c08396f..e09fae4 100644 --- a/src/app/pages/500.component.html +++ b/src/app/pages/500.component.html @@ -8,8 +8,8 @@

The page you are looking for is temporarily unavailable.

- - + + diff --git a/src/app/pages/500.component.ts b/src/app/pages/500.component.ts index fa459e6..a80ff31 100644 --- a/src/app/pages/500.component.ts +++ b/src/app/pages/500.component.ts @@ -7,11 +7,10 @@ import { Location } from '@angular/common'; export class P500Component { constructor( - private location: Location - ) { - } + private location: Location, + ) { } - goBack(): void { - this.location.back(); -} -} \ No newline at end of file + goBack(): void { + this.location.back(); + } +} From 8807ba6cc9c63da3bbec706b4a705496a83db691 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 11:09:30 +0100 Subject: [PATCH 09/37] linter errors in auth.guard.ts --- src/app/_guards/auth.guard.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/_guards/auth.guard.ts b/src/app/_guards/auth.guard.ts index 3e7a9fc..d267cf4 100644 --- a/src/app/_guards/auth.guard.ts +++ b/src/app/_guards/auth.guard.ts @@ -8,13 +8,13 @@ export class AuthGuard implements CanActivate { canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) { if (localStorage.getItem('sessionKey')) { - console.log('session key found') + console.log('session key found'); // logged in so return true return true; } // not logged in so redirect to login page with the return url - console.log('no session key found') + console.log('no session key found'); this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }}); return false; } From dec53b4630a1d81fed969f2cabd9bd20d6128671 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 11:10:56 +0100 Subject: [PATCH 10/37] Fix linter errors in full-layout --- src/app/layouts/full-layout.component.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/layouts/full-layout.component.ts b/src/app/layouts/full-layout.component.ts index 7007e35..af6b9bf 100644 --- a/src/app/layouts/full-layout.component.ts +++ b/src/app/layouts/full-layout.component.ts @@ -7,16 +7,15 @@ import { Router } from '@angular/router'; templateUrl: './full-layout.component.html', }) export class FullLayoutComponent implements OnInit { - displayName: any; + public displayName: string; + public disabled = false; + public status: {isopen: boolean} = {isopen: false}; constructor( private api: ApiService, private router: Router, ) {} - public disabled = false; - public status: {isopen: boolean} = {isopen: false}; - public toggled(open: boolean): void { console.log('Dropdown is now: ', open); } From 61ac856cc238dc838961a9969443b234032db189 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 14:48:22 +0100 Subject: [PATCH 11/37] fix linter errors on register component --- src/app/auth/register.component.ts | 162 ++++++++++++++--------------- 1 file changed, 81 insertions(+), 81 deletions(-) diff --git a/src/app/auth/register.component.ts b/src/app/auth/register.component.ts index bdb9815..d716340 100644 --- a/src/app/auth/register.component.ts +++ b/src/app/auth/register.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core'; import { Validators, FormBuilder, FormGroup } from '@angular/forms'; -import { ValidationManager } from "ng2-validation-manager"; +import { ValidationManager } from 'ng2-validation-manager'; import { Http, Response } from '@angular/http'; import { ApiService } from '../providers/api-service'; import {Router } from '@angular/router'; @@ -16,87 +16,87 @@ export class RegisterComponent { organisationForm: ValidationManager; years: Object[]; registerStatus: any; - registerStatusError: string = 'Error received, please try again.'; + registerStatusError = 'Error received, please try again.'; constructor( - private http: Http, - private formBuilder: FormBuilder, - private router: Router, - private api: ApiService, - ) { - this.years = []; - let max = new Date().getFullYear() - 10, - min = max - 140; + private http: Http, + private formBuilder: FormBuilder, + private router: Router, + private api: ApiService, + ) { + this.years = []; + const max = new Date().getFullYear() - 10, + min = max - 140; - for (let i = max; i>=min; i--){ - this.years.push(i); - } - this.signupForm = new ValidationManager({ - token: 'required', - usertype: 'required', - email: 'required|email', - password: 'required', - confirmpassword: 'required|equalTo:password' - }); - this.customerForm = new ValidationManager({ - display_name: 'required', - full_name: 'required', - postcode: 'required', - year_of_birth:'required', - }); - this.organisationForm = new ValidationManager({ - name: 'required', + for (let i = max; i >= min; i--) { + this.years.push(i); + } + this.signupForm = new ValidationManager({ + token: 'required', + usertype: 'required', + email: 'required|email', + password: 'required', + confirmpassword: 'required|equalTo:password' + }); + this.customerForm = new ValidationManager({ + display_name: 'required', + full_name: 'required', + postcode: 'required', + year_of_birth: 'required', + }); + this.organisationForm = new ValidationManager({ + name: 'required', sector: 'required', - street_name: 'required', - town: 'required', - postcode: 'required', - }); + street_name: 'required', + town: 'required', + postcode: 'required', + }); } onSubmitCustomer() { console.log(this.signupForm.isValid()); - if (!this.signupForm.isValid() && !this.customerForm.isValid()) { - console.log("Not Valid!"); - this.registerStatus = "validation_failed"; + if (!this.signupForm.isValid() && !this.customerForm.isValid()) { + console.log('Not Valid!'); + this.registerStatus = 'validation_failed'; console.log(this.registerStatus); - return; - } - let signupForm = this.signupForm.getForm().value; - let customerForm = this.customerForm.getForm().value; + return; + } + const signupForm = this.signupForm.getForm().value; + const customerForm = this.customerForm.getForm().value; - let data = { - token: signupForm.token, - usertype: signupForm.usertype, - email: signupForm.email, - password: signupForm.password, - display_name: customerForm.display_name, - full_name: customerForm.full_name, - postcode: customerForm.postcode, - year_of_birth:customerForm.year_of_birth, - }; - console.log(data); - this.api + const data = { + token: signupForm.token, + usertype: signupForm.usertype, + email: signupForm.email, + password: signupForm.password, + display_name: customerForm.display_name, + full_name: customerForm.full_name, + postcode: customerForm.postcode, + year_of_birth: customerForm.year_of_birth, + }; + console.log(data); + this.api .register(data) .subscribe( result => { console.log('registered!'); - this.registerStatus = "success"; + this.registerStatus = 'success'; console.log(this.registerStatus); - this.router.navigate(['/dashboard']); + this.router.navigate(['/dashboard']); }, error => { console.log('Register Error'); console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.registerStatusError = 'There was a server error, please try again later.'; } - this.registerStatus = "send_failed"; + this.registerStatus = 'send_failed'; console.log(this.registerStatus); } ); @@ -104,33 +104,33 @@ export class RegisterComponent { onSubmitOrganisation() { console.log(this.signupForm.isValid()); - if (!this.signupForm.isValid() || !this.organisationForm.isValid()) { - console.log("Not Valid!"); - this.registerStatus = "validation_failed"; + if (!this.signupForm.isValid() || !this.organisationForm.isValid()) { + console.log('Not Valid!'); + this.registerStatus = 'validation_failed'; console.log(this.registerStatus); - return; - } - let signupForm = this.signupForm.getForm().value; - let organisationForm = this.organisationForm.getForm().value; + return; + } + const signupForm = this.signupForm.getForm().value; + const organisationForm = this.organisationForm.getForm().value; - let data = { - token: signupForm.token, - usertype: signupForm.usertype, - email: signupForm.email, - password: signupForm.password, - name: organisationForm.name, + const data = { + token: signupForm.token, + usertype: signupForm.usertype, + email: signupForm.email, + password: signupForm.password, + name: organisationForm.name, sector: organisationForm.sector, - street_name: organisationForm.street_name, - town: organisationForm.town, - postcode: organisationForm.postcode, - }; - console.log(data); - this.api + street_name: organisationForm.street_name, + town: organisationForm.town, + postcode: organisationForm.postcode, + }; + console.log(data); + this.api .register(data) .subscribe( result => { console.log('registered!'); - this.registerStatus = "success"; + this.registerStatus = 'success'; console.log(this.registerStatus); this.router.navigate(['/dashboard']); }, @@ -139,13 +139,13 @@ export class RegisterComponent { console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.registerStatusError = 'There was a server error, please try again later.'; } - this.registerStatus = "send_failed"; + this.registerStatus = 'send_failed'; console.log(this.registerStatus); } ); From f6c058348132274a7e1706c86fd6d0cef5900e52 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 14:53:25 +0100 Subject: [PATCH 12/37] Fix linter errors in add-data component --- src/app/dashboard/add-data.component.ts | 100 ++++++++++++------------ 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/app/dashboard/add-data.component.ts b/src/app/dashboard/add-data.component.ts index f8c31e6..359c294 100644 --- a/src/app/dashboard/add-data.component.ts +++ b/src/app/dashboard/add-data.component.ts @@ -9,7 +9,7 @@ import 'rxjs/add/operator/map'; @Component({ templateUrl: 'add-data.component.html', }) -export class AddDataComponent { +export class AddDataComponent implements OnInit { payrollForm: FormGroup; singleSupplierForm: FormGroup; employeeForm: FormGroup; @@ -18,7 +18,7 @@ export class AddDataComponent { singleSupplierFormStatus: any; employeeFormStatus: any; transactionFormStatus: any; - transactionFormStatusError: string = 'Error received, please try again.'; + transactionFormStatusError = 'Error received, please try again.'; accountType: any; submitOrg = { @@ -41,20 +41,20 @@ export class AddDataComponent { constructor( private http: Http, - private formBuilder: FormBuilder, - private api: ApiService, - ) { + private formBuilder: FormBuilder, + private api: ApiService, + ) { this.payrollForm = this.formBuilder.group({ - entry_period: ['', [Validators.required]], - employee_amount: ['', [Validators.required]], - local_employee_amount: ['', [Validators.required]], - gross_payroll: ['', [Validators.required]], + entry_period: ['', [Validators.required]], + employee_amount: ['', [Validators.required]], + local_employee_amount: ['', [Validators.required]], + gross_payroll: ['', [Validators.required]], payroll_income_tax: ['', [Validators.required]], payroll_employee_ni: ['', [Validators.required]], payroll_employer_ni: ['', [Validators.required]], payroll_total_pension: ['', [Validators.required]], payroll_other_benefit: ['', [Validators.required]], - }); + }); this.employeeForm = this.formBuilder.group({ entry_period: ['', [Validators.required]], employee_no: ['', [Validators.required]], @@ -63,7 +63,7 @@ export class AddDataComponent { employee_ni: ['', [Validators.required]], employee_pension: ['', [Validators.required]], employee_other_benefit: ['', [Validators.required]], - }); + }); this.myDate = moment().format('YYYY-MM-DD[T]HH:mm'); // this.myDate = new Date().toISOString().slice(0, 16); } @@ -73,13 +73,13 @@ export class AddDataComponent { this.accountType = localStorage.getItem('usertype'); } - getMinDate(){ + getMinDate() { // gets the April 1st date of the current year - let aprilDate = moment().month(3).date(1); - let now = moment(); + const aprilDate = moment().month(3).date(1); + const now = moment(); // Checks if current time is before April 1st, if so returns true - let beforeApril = now.isBefore(aprilDate); - if ( beforeApril == true ) { + const beforeApril = now.isBefore(aprilDate); + if ( beforeApril === true ) { this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); } else { this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); @@ -88,16 +88,16 @@ export class AddDataComponent { initializeItems() { // Dont bother searching for an empty or undefined string - if ( this.submitOrg.name == '' ) { + if ( this.submitOrg.name === '' ) { return; } - var searchData = { + const searchData = { search_name: this.submitOrg.name, }; this.api.search(searchData).subscribe( data => { - if(data.validated.length > 0) { + if (data.validated.length > 0) { this.storeList = data.validated; this.showAddStore = false; this.transactionAdditionType = 1; @@ -107,7 +107,7 @@ export class AddDataComponent { this.transactionAdditionType = 2; } // handle the case when the storelist is empty - if(this.storeList.length < 1 ) { + if (this.storeList.length < 1) { this.storeList = null; this.showAddStore = true; this.transactionAdditionType = 3; @@ -120,7 +120,7 @@ export class AddDataComponent { } // if user select a item from the list - addStore(store){ + addStore(store) { this.submitOrg = store; this.transactionFormValidate(); this.organisationId = store.id; @@ -132,40 +132,40 @@ export class AddDataComponent { this.initializeItems(); // set val to the value of the searchbar - let val = ev.target.value; + 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 !== null) { this.storeList = this.storeList.filter( (item) => { return ( item.name.toLowerCase().indexOf( val.toLowerCase() ) > -1 ); } - ) + ); } // if nothing is found - if(!this.storeList === null){ + if (!this.storeList === null) { // display add new store button this.showAddStore = true; } } transactionFormValidate() { - if( this.submitOrg.name.length == 0 || - this.submitOrg.town.length == 0 || - this.amount == 0 ) { + if (this.submitOrg.name.length === 0 || + this.submitOrg.town.length === 0 || + this.amount === 0 ) { this.transactionFormInvalid = true; - }else{ + } else { this.transactionFormInvalid = false; } } public postTransaction() { - var myParams: any; + let myParams: any; let purchaseTime: string; purchaseTime = moment(this.myDate, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); - switch(this.transactionAdditionType){ + switch (this.transactionAdditionType) { case 1: myParams = { transaction_type : this.transactionAdditionType, @@ -200,16 +200,16 @@ export class AddDataComponent { .upload(myParams) .subscribe( result => { - if ( result.success == true ) { + if ( result.success === true ) { console.log('Successful Upload'); console.log(result); - this.transactionFormStatus = "success"; + this.transactionFormStatus = 'success'; console.log(this.transactionFormStatus); this.resetForm(); } else { console.log('Upload Error'); this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); - this.transactionFormStatus = "send_failed"; + this.transactionFormStatus = 'send_failed'; console.log(this.transactionFormStatus); } }, @@ -218,13 +218,13 @@ export class AddDataComponent { console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.transactionFormStatusError = 'There was a server error, please try again later.'; } - this.transactionFormStatus = "send_failed"; + this.transactionFormStatus = 'send_failed'; console.log(this.transactionFormStatus); } ); @@ -244,57 +244,57 @@ export class AddDataComponent { } onSubmitPayroll() { - console.log(this.payrollForm.value); + console.log(this.payrollForm.value); - this.api + this.api .orgPayroll(this.payrollForm.value) .subscribe( result => { console.log('data submitted!'); - this.payrollFormStatus = "success"; + this.payrollFormStatus = 'success'; console.log(this.payrollFormStatus); }, error => { console.log( error._body ); - this.payrollFormStatus = "send_failed"; + this.payrollFormStatus = 'send_failed'; console.log(this.payrollFormStatus); } ); } onSubmitSingleSupplier() { - console.log(this.singleSupplierForm.value); + console.log(this.singleSupplierForm.value); - this.api + this.api .orgSupplier(this.singleSupplierForm.value) .subscribe( result => { console.log('data submitted!'); - this.singleSupplierFormStatus = "success"; + this.singleSupplierFormStatus = 'success'; console.log(this.singleSupplierFormStatus); }, error => { console.log( error._body ); - this.singleSupplierFormStatus = "send_failed"; + this.singleSupplierFormStatus = 'send_failed'; console.log(this.singleSupplierFormStatus); } ); } onSubmitEmployee() { - console.log(this.employeeForm.value); + console.log(this.employeeForm.value); - this.api + this.api .orgEmployee(this.employeeForm.value) .subscribe( result => { console.log('data submitted!'); - this.employeeFormStatus = "success"; + this.employeeFormStatus = 'success'; console.log(this.employeeFormStatus); }, error => { console.log( error._body ); - this.employeeFormStatus = "send_failed"; + this.employeeFormStatus = 'send_failed'; console.log(this.employeeFormStatus); } ); From 921b25718d7905f8c0b6560737bf80203d9d8ea4 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 14:56:07 +0100 Subject: [PATCH 13/37] Linter error fixes for account-edit component --- src/app/dashboard/account-edit.component.ts | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/dashboard/account-edit.component.ts b/src/app/dashboard/account-edit.component.ts index 0cc6a51..cf5b14c 100644 --- a/src/app/dashboard/account-edit.component.ts +++ b/src/app/dashboard/account-edit.component.ts @@ -14,7 +14,7 @@ export class AccountEditComponent implements OnInit { accountType: any; // @ViewChild('fileInput') fileInput; submitStatus: any; - submitStatusError: string = 'Error received, please try again.'; + submitStatusError = 'Error received, please try again.'; constructor( private http: Http, @@ -72,7 +72,7 @@ export class AccountEditComponent implements OnInit { console.log(this.settingForm.valid); if (!this.settingForm.valid && !this.settingOrganisationForm.valid) { console.log('Not Valid!'); - this.submitStatus = "validation_failed"; + this.submitStatus = 'validation_failed'; console.log(this.submitStatus); return; } @@ -108,7 +108,7 @@ export class AccountEditComponent implements OnInit { .subscribe( result => { console.log('data submitted!'); - this.submitStatus = "success"; + this.submitStatus = 'success'; console.log(this.submitStatus); }, error => { @@ -116,13 +116,13 @@ export class AccountEditComponent implements OnInit { console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.submitStatusError = 'There was a server error, please try again later.'; } - this.submitStatus = "send_failed"; + this.submitStatus = 'send_failed'; console.log(this.submitStatus); } ); @@ -132,7 +132,7 @@ export class AccountEditComponent implements OnInit { console.log(this.settingForm.valid); if (!this.settingForm.valid && !this.settingCustomerForm.valid) { console.log('Not Valid!'); - this.submitStatus = "validation_failed"; + this.submitStatus = 'validation_failed'; console.log(this.submitStatus); return; } @@ -165,7 +165,7 @@ export class AccountEditComponent implements OnInit { .subscribe( result => { console.log('data submitted!'); - this.submitStatus = "success"; + this.submitStatus = 'success'; console.log(this.submitStatus); }, error => { @@ -173,13 +173,13 @@ export class AccountEditComponent implements OnInit { console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.submitStatusError = 'There was a server error, please try again later.'; } - this.submitStatus = "send_failed"; + this.submitStatus = 'send_failed'; console.log(this.submitStatus); } ); From 662d6be5c95b89c24fd966499ef6dcb5c9756ac3 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 14:59:19 +0100 Subject: [PATCH 14/37] Linter error fixes for feedback component --- src/app/dashboard/feedback.component.ts | 26 ++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/app/dashboard/feedback.component.ts b/src/app/dashboard/feedback.component.ts index 11d56d4..91ef375 100644 --- a/src/app/dashboard/feedback.component.ts +++ b/src/app/dashboard/feedback.component.ts @@ -7,18 +7,18 @@ import 'rxjs/add/operator/map'; @Component({ templateUrl: 'feedback.component.html', }) -export class FeedbackComponent { +export class FeedbackComponent implements OnInit { feedbackForm: FormGroup; loggedInEmail: string; - noEmail: boolean = false; + noEmail = false; username: any; feedbackFormStatus: any; - feedbackFormStatusError: string = 'Error received, please try again.'; + feedbackFormStatusError = 'Error received, please try again.'; constructor( private http: Http, - private formBuilder: FormBuilder, - private api: ApiService, + private formBuilder: FormBuilder, + private api: ApiService, ) { this.feedbackForm = this.formBuilder.group({ email: ['', [Validators.required]], @@ -28,7 +28,7 @@ export class FeedbackComponent { ngOnInit(): void { - if(localStorage.getItem('email')) { + if (localStorage.getItem('email')) { this.loggedInEmail = localStorage.getItem('email'); } console.log('loggedInEmail: ' + this.loggedInEmail); @@ -55,10 +55,10 @@ export class FeedbackComponent { .feedback(this.feedbackForm.value) .subscribe( result => { - if ( result.success == true ) { + if ( result.success === true ) { console.log('Successful Upload'); console.log(result); - this.feedbackFormStatus = "success"; + this.feedbackFormStatus = 'success'; console.log(this.feedbackFormStatus); this.feedbackForm.patchValue({ feedbacktext: '', @@ -66,7 +66,7 @@ export class FeedbackComponent { } else { console.log('Upload Error'); this.feedbackFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); - this.feedbackFormStatus = "send_failed"; + this.feedbackFormStatus = 'send_failed'; console.log(this.feedbackFormStatus); } }, @@ -75,13 +75,13 @@ export class FeedbackComponent { console.log(error); try { console.log(error.error); - let jsonError = error.json(); - console.log("boop"); + const jsonError = error.json(); + console.log('boop'); this.feedbackFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; - } catch(e) { + } catch (e) { this.feedbackFormStatusError = 'There was a server error, please try again later.'; } - this.feedbackFormStatus = "send_failed"; + this.feedbackFormStatus = 'send_failed'; console.log(this.feedbackFormStatus); } ); From 0907134ff7c339141a2f68eb31d68a301ff96153 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 15:02:48 +0100 Subject: [PATCH 15/37] Fix linter errors for transaction-log component --- .../dashboard/transaction-log.component.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/app/dashboard/transaction-log.component.ts b/src/app/dashboard/transaction-log.component.ts index f707e83..60c4e6f 100644 --- a/src/app/dashboard/transaction-log.component.ts +++ b/src/app/dashboard/transaction-log.component.ts @@ -12,12 +12,13 @@ import 'rxjs/add/operator/map'; @Component({ templateUrl: 'transaction-log.component.html', }) -export class TransactionLogComponent { +export class TransactionLogComponent implements OnInit { transactionList; noTransactionList = true; myDate: any; minDate: any; + public p: any; public paginateConfig: PaginationInstance = { id: 'transpaginate', @@ -28,8 +29,8 @@ export class TransactionLogComponent { constructor( private http: Http, - private api: ApiService, - ) { + private api: ApiService, + ) { this.myDate = moment().format('YYYY-MM-DD[T]HH:mm'); // this.myDate = new Date().toISOString().slice(0, 16); } @@ -39,13 +40,13 @@ export class TransactionLogComponent { this.loadTransactions(1); } - getMinDate(){ + getMinDate() { // gets the April 1st date of the current year - let aprilDate = moment().month(3).date(1); - let now = moment(); + const aprilDate = moment().month(3).date(1); + const now = moment(); // Checks if current time is before April 1st, if so returns true - let beforeApril = now.isBefore(aprilDate); - if ( beforeApril == true ) { + const beforeApril = now.isBefore(aprilDate); + if ( beforeApril === true ) { this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); } else { this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); @@ -56,9 +57,9 @@ export class TransactionLogComponent { console.log(logPage); this.api.transList(logPage).subscribe( result => { - if(result.transactions.length > 0) { + if (result.transactions.length > 0) { this.transactionList = result.transactions; - //TODO Rename in server + // TODO Rename in server this.paginateConfig.totalItems = result.page_no; this.paginateConfig.currentPage = logPage; this.noTransactionList = false; From a5b786a74955e0c64d8ff813440671a136d04ad5 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 15:04:49 +0100 Subject: [PATCH 16/37] Linter errors in dashboard-customer component --- src/app/dashboard/dashboard-customer.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/dashboard/dashboard-customer.component.ts b/src/app/dashboard/dashboard-customer.component.ts index dc8c9c6..09787e3 100644 --- a/src/app/dashboard/dashboard-customer.component.ts +++ b/src/app/dashboard/dashboard-customer.component.ts @@ -15,7 +15,7 @@ export class DashboardCustomerComponent implements OnInit { /* Setting up dashboard's main variables*/ name: any; - email:any; + email: any; myPearPoints: any; trends: any; myRank: any; From 8f164ca94a2979390fa7bc052a6c5b6d70d61862 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 15:19:50 +0100 Subject: [PATCH 17/37] ignore linter errors in org-result items --- src/app/shared/org-result.component.ts | 3 ++- src/app/shared/org-table.component.ts | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/shared/org-result.component.ts b/src/app/shared/org-result.component.ts index d7c599f..f22fbea 100644 --- a/src/app/shared/org-result.component.ts +++ b/src/app/shared/org-result.component.ts @@ -9,6 +9,7 @@ interface OrgData { } @Component({ + // tslint:disable-next-line selector: '[org-result]', templateUrl: 'org-result.component.html', }) @@ -19,6 +20,6 @@ export class OrgResultComponent { public orgClick(): void { this.onClick.emit( this.org - ) + ); } } diff --git a/src/app/shared/org-table.component.ts b/src/app/shared/org-table.component.ts index 8e0979d..764385c 100644 --- a/src/app/shared/org-table.component.ts +++ b/src/app/shared/org-table.component.ts @@ -10,6 +10,7 @@ interface OrgData { } @Component({ + // tslint:disable-next-line selector: 'org-table', templateUrl: 'org-table.component.html', }) From e62a46c312067fd3b442cb7cce8671f82f3980fa Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Tue, 19 Sep 2017 15:21:03 +0100 Subject: [PATCH 18/37] Ignore linter error in transaction-result component --- src/app/shared/transaction-result.component.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/shared/transaction-result.component.ts b/src/app/shared/transaction-result.component.ts index 782830a..ed76a56 100644 --- a/src/app/shared/transaction-result.component.ts +++ b/src/app/shared/transaction-result.component.ts @@ -8,6 +8,7 @@ interface TransactionData { } @Component({ + // tslint:disable-next-line selector: '[transaction-result]', templateUrl: 'transaction-result.component.html', }) From 7b03f6adffab5ac7ce264fdb615ffca8a7f4832f Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 19 Sep 2017 15:38:35 +0100 Subject: [PATCH 19/37] Initial addition of API for payroll log --- src/app/dashboard/add-data.component.html | 2 +- src/app/dashboard/payroll-log.component.html | 49 +++++++++++++ src/app/dashboard/payroll-log.component.ts | 77 ++++++++++++++++++++ src/app/providers/api-service.ts | 19 ++++- 4 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 src/app/dashboard/payroll-log.component.html create mode 100644 src/app/dashboard/payroll-log.component.ts diff --git a/src/app/dashboard/add-data.component.html b/src/app/dashboard/add-data.component.html index 91e8e42..3a78b96 100644 --- a/src/app/dashboard/add-data.component.html +++ b/src/app/dashboard/add-data.component.html @@ -72,7 +72,7 @@ -
+
Profile & Payroll Data Required Data marked in bold. diff --git a/src/app/dashboard/payroll-log.component.html b/src/app/dashboard/payroll-log.component.html new file mode 100644 index 0000000..68ec8af --- /dev/null +++ b/src/app/dashboard/payroll-log.component.html @@ -0,0 +1,49 @@ +
+
+
+
+
+ Log of Payroll submissions + Sorted descending from submission date. +
+
+ + + + + + + + + + + +
SellerValuePurchase Time
+ + + +
+
+ No Payroll data available. +
+
+
+
+
diff --git a/src/app/dashboard/payroll-log.component.ts b/src/app/dashboard/payroll-log.component.ts new file mode 100644 index 0000000..3e7a3ce --- /dev/null +++ b/src/app/dashboard/payroll-log.component.ts @@ -0,0 +1,77 @@ +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 * as moment from 'moment'; +import 'rxjs/add/operator/map'; + +@Component({ + templateUrl: 'payroll-log.component.html', +}) +export class PayrollLogComponent implements OnInit { + + payrollList; + noPayrollList = true; + myDate: any; + minDate: any; + + public paginateConfig: PaginationInstance = { + id: 'transpaginate', + 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.getMinDate(); + this.loadPayrolls(1); + } + + getMinDate(){ + // gets the April 1st date of the current year + let aprilDate = moment().month(3).date(1); + let now = moment(); + // Checks if current time is before April 1st, if so returns true + let beforeApril = now.isBefore(aprilDate); + if ( beforeApril == true ) { + this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); + } else { + this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); + } + } + + loadPayrolls(logPage: number) { + console.log(logPage); + this.api.payrollList(logPage).subscribe( + result => { + if(result.payrolls.length > 0) { + this.payrollList = result.payrolls; + //TODO Rename in server + this.paginateConfig.totalItems = result.page_no; + this.paginateConfig.currentPage = logPage; + this.noPayrollList = false; + } else { + // handle the case when the payrollList is empty + this.payrollList = null; + this.noPayrollList = true; + } + }, + error => { + console.log(error); + } + ); + } + +} diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index e0f27a2..6c6ea47 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -136,12 +136,25 @@ export class ApiService { ).map( response => response.json() ); } + // gets payroll list for log + + public payrollList(data) { + const key = this.sessionKey; + return this.http.post( + this.apiUrl + '/v1/organisation/payroll', + { + session_key : key, + page : data + } + ).map( response => response.json() ); + } + // handles Org data added public orgPayroll(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/org/payroll', + this.apiUrl + '/v1/organisation/payroll/add', data ).map( response => response.json() ); } @@ -149,7 +162,7 @@ export class ApiService { public orgSupplier(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/org/supplier', + this.apiUrl + '/v1/organisation/supplier/add', data ).map( response => response.json() ); } @@ -157,7 +170,7 @@ export class ApiService { public orgEmployee(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/org/employee', + this.apiUrl + '/v1/organisation/employee/add', data ).map( response => response.json() ); } From 089e7f7a97ead8864fc298993890a01942d863ea Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 19 Sep 2017 17:22:19 +0100 Subject: [PATCH 20/37] Functionality fully added --- CHANGELOG.md | 1 + src/app/dashboard/dashboard.module.ts | 4 ++++ src/app/dashboard/dashboard.routing.ts | 7 ++++++ src/app/dashboard/payroll-log.component.html | 8 +++---- src/app/layouts/full-layout.component.html | 5 +++++ src/app/layouts/full-layout.component.ts | 2 ++ src/app/shared/payroll-result.component.html | 3 +++ src/app/shared/payroll-result.component.ts | 22 +++++++++++++++++++ .../shared/transaction-result.component.ts | 2 +- 9 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 src/app/shared/payroll-result.component.html create mode 100644 src/app/shared/payroll-result.component.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 84ec5f1..83a368e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # Next Release +* Payroll Log Data added * Fixed register box view on login page * Made the form reset properly if adding a new one * Added better error messages on register and account edit diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 55bb110..134d8bd 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -13,6 +13,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 { PayrollLogComponent } from './payroll-log.component'; import { GraphWidget } from '../widgets/graph-widget.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; @@ -22,6 +23,7 @@ import { DashboardRoutingModule } from './dashboard.routing'; 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'; @NgModule({ imports: [ @@ -43,6 +45,8 @@ import { TransactionResultComponent } from '../shared/transaction-result.compone OrgTableComponent, TransactionLogComponent, TransactionResultComponent, + PayrollLogComponent, + PayrollResultComponent, FeedbackComponent, GraphWidget, OrgBarSnippetComponent, diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index acb81b7..c36cfb2 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 { PayrollLogComponent } from './payroll-log.component'; // Using child path to allow for FullLayout theming const routes: Routes = [ @@ -48,6 +49,12 @@ const routes: Routes = [ component: TransactionLogComponent, data: { title: 'Transaction Log' }, }, + { + path: 'payroll-log', + component: PayrollLogComponent, + data: { title: 'Payroll Log' }, + canActivate: [OrgGuard], + }, { path: 'feedback', component: FeedbackComponent, diff --git a/src/app/dashboard/payroll-log.component.html b/src/app/dashboard/payroll-log.component.html index 68ec8af..0b08ed8 100644 --- a/src/app/dashboard/payroll-log.component.html +++ b/src/app/dashboard/payroll-log.component.html @@ -10,13 +10,13 @@ - - - + + + - +
SellerValuePurchase TimeEntry PeriodGross PayrollEmployees
Transaction Log +
diff --git a/src/app/layouts/full-layout.component.ts b/src/app/layouts/full-layout.component.ts index af6b9bf..453a8df 100644 --- a/src/app/layouts/full-layout.component.ts +++ b/src/app/layouts/full-layout.component.ts @@ -8,6 +8,7 @@ import { Router } from '@angular/router'; }) export class FullLayoutComponent implements OnInit { public displayName: string; + public accountType: any; public disabled = false; public status: {isopen: boolean} = {isopen: false}; @@ -29,6 +30,7 @@ export class FullLayoutComponent implements OnInit { // getDisplayName function from api didnt work ngOnInit(): void { this.displayName = localStorage.getItem('displayname') || 'User'; + this.accountType = localStorage.getItem('usertype'); } userLogout() { diff --git a/src/app/shared/payroll-result.component.html b/src/app/shared/payroll-result.component.html new file mode 100644 index 0000000..6d891c6 --- /dev/null +++ b/src/app/shared/payroll-result.component.html @@ -0,0 +1,3 @@ +{{payrollDate}} +{{payroll.gross_payroll | currency:'GBP':true:'1.2-2' }} +{{payroll.employee_amount}} diff --git a/src/app/shared/payroll-result.component.ts b/src/app/shared/payroll-result.component.ts new file mode 100644 index 0000000..fdf3fa7 --- /dev/null +++ b/src/app/shared/payroll-result.component.ts @@ -0,0 +1,22 @@ +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import * as moment from 'moment'; + +interface PayrollData { + entry_period: string; + gross_payroll: number; + employee_amount: number; +} + +@Component({ + // tslint:disable-next-line + selector: '[payroll-result]', + templateUrl: 'payroll-result.component.html', +}) +export class PayrollResultComponent implements OnInit { + @Input() public payroll: PayrollData; + public payrollDate: string; + + ngOnInit(): void { + this.payrollDate = moment(this.payroll.entry_period).format('MMMM YYYY'); + } +} diff --git a/src/app/shared/transaction-result.component.ts b/src/app/shared/transaction-result.component.ts index ed76a56..a293b72 100644 --- a/src/app/shared/transaction-result.component.ts +++ b/src/app/shared/transaction-result.component.ts @@ -3,7 +3,7 @@ import * as moment from 'moment'; interface TransactionData { seller: number; - value: string; + value: number; purchase_time: string; } From 67bb904770897970d2ed27651230b6993d3d46a4 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 26 Sep 2017 16:22:54 +0100 Subject: [PATCH 21/37] Package added & npm updated --- package-lock.json | 9 +++++++-- package.json | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c53884..b3325ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,9 +1,14 @@ { - "name": "coreui-angular", - "version": "1.0.0-alpha.5", + "name": "localloop-web", + "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { + "@agm/core": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/@agm/core/-/core-1.0.0-beta.1.tgz", + "integrity": "sha512-IVwQGmcaE42SmYY2e5QwqOC0vrSXZCW8BhATY0Vpy3NjbiydSXi9T81hVqKLvuKaB3ves1sv3W++SB1Wj+5B6A==" + }, "@angular-devkit/build-optimizer": { "version": "0.0.13", "resolved": "https://registry.npmjs.org/@angular-devkit/build-optimizer/-/build-optimizer-0.0.13.tgz", diff --git a/package.json b/package.json index 9c56d35..1fd8e65 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ }, "private": true, "dependencies": { + "@agm/core": "^1.0.0-beta.1", "@angular/common": "4.0.3", "@angular/compiler": "4.0.3", "@angular/core": "4.0.3", From 40bd7459b5e5c683eaea3e3a7792c2746cf387ed Mon Sep 17 00:00:00 2001 From: piratefinn Date: Tue, 26 Sep 2017 17:31:40 +0100 Subject: [PATCH 22/37] Map page added with map --- src/app/dashboard/dashboard.module.ts | 9 ++++++++ src/app/dashboard/dashboard.routing.ts | 7 +++++++ src/app/dashboard/map.component.html | 19 +++++++++++++++++ src/app/dashboard/map.component.ts | 24 ++++++++++++++++++++++ src/app/layouts/full-layout.component.html | 5 +++++ src/scss/_custom.scss | 6 ++++++ 6 files changed, 70 insertions(+) create mode 100644 src/app/dashboard/map.component.html create mode 100644 src/app/dashboard/map.component.ts diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 134d8bd..f584ef4 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -4,6 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { NgxPaginationModule } from 'ngx-pagination'; +import { AgmCoreModule } from '@agm/core'; import { CurrencyPipe } from '@angular/common'; @@ -14,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 { MapComponent } from './map.component'; import { GraphWidget } from '../widgets/graph-widget.component'; import { OrgBarSnippetComponent } from '../snippets/org-snippet-bar.component'; @@ -25,6 +27,9 @@ import { OrgTableComponent } from '../shared/org-table.component'; import { TransactionResultComponent } from '../shared/transaction-result.component'; import { PayrollResultComponent } from '../shared/payroll-result.component'; +// API key env variable import +import { environment } from '../../environments/environment'; + @NgModule({ imports: [ // Angular imports @@ -32,6 +37,9 @@ import { PayrollResultComponent } from '../shared/payroll-result.component'; FormsModule, ReactiveFormsModule, ChartsModule, + AgmCoreModule.forRoot({ + apiKey: environment.mapApiKey + }), BsDropdownModule, NgxPaginationModule, DashboardRoutingModule, @@ -47,6 +55,7 @@ import { PayrollResultComponent } from '../shared/payroll-result.component'; TransactionResultComponent, PayrollLogComponent, PayrollResultComponent, + MapComponent, FeedbackComponent, GraphWidget, OrgBarSnippetComponent, diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index c36cfb2..f28c65e 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -13,6 +13,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 { MapComponent } from './map.component'; // Using child path to allow for FullLayout theming const routes: Routes = [ @@ -49,6 +50,12 @@ const routes: Routes = [ component: TransactionLogComponent, data: { title: 'Transaction Log' }, }, + { + path: 'map', + component: MapComponent, + data: { title: 'Supplier Map' }, + canActivate: [OrgGuard], + }, { path: 'payroll-log', component: PayrollLogComponent, diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html new file mode 100644 index 0000000..27ce4c7 --- /dev/null +++ b/src/app/dashboard/map.component.html @@ -0,0 +1,19 @@ +
+
+
+
+
+ Supplier Map + Required Data marked in bold. +
+
+ + + + + +
+
+
+
+
diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts new file mode 100644 index 0000000..233ad94 --- /dev/null +++ b/src/app/dashboard/map.component.ts @@ -0,0 +1,24 @@ +import { Component, OnInit } from '@angular/core'; +import { Http, Response } from '@angular/http'; +import { ApiService } from '../providers/api-service'; +import { AgmCoreModule } from '@agm/core'; +import 'rxjs/add/operator/map'; + +@Component({ + templateUrl: 'map.component.html', +}) +export class MapComponent implements OnInit { + + lat: number = 54.0466; + lng: number = 2.8007; + + constructor( + private http: Http, + private api: ApiService, + ) { } + + ngOnInit(): void { + + } + +} diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index 17f0b57..f92357c 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -40,6 +40,11 @@ Enter Feedback +
-
-
diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index 233ad94..1a05488 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -10,7 +10,7 @@ import 'rxjs/add/operator/map'; export class MapComponent implements OnInit { lat: number = 54.0466; - lng: number = 2.8007; + lng: number = -2.8007; constructor( private http: Http, diff --git a/src/scss/_custom.scss b/src/scss/_custom.scss index a47ee9f..f3e9c04 100644 --- a/src/scss/_custom.scss +++ b/src/scss/_custom.scss @@ -17,7 +17,7 @@ // Map styling agm-map { - height: 300px; + height: 75vh; } // white title font variant on type-2 as defined in _widgets.css From 64e028f0c51ec7d7675ff411983a0f6af9c4f979 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 27 Sep 2017 12:02:46 +0100 Subject: [PATCH 24/37] Added default zoom --- src/app/dashboard/map.component.html | 2 +- src/app/dashboard/map.component.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html index e7de04f..8626466 100644 --- a/src/app/dashboard/map.component.html +++ b/src/app/dashboard/map.component.html @@ -8,7 +8,7 @@ - + diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index 1a05488..e39e853 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -11,6 +11,7 @@ export class MapComponent implements OnInit { lat: number = 54.0466; lng: number = -2.8007; + zoom: number = 12; constructor( private http: Http, From 1eb79aa0474398fdb5bd75ff2a0e2ac4c67f3f16 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 27 Sep 2017 13:54:10 +0100 Subject: [PATCH 25/37] Added API and fixes --- src/app/dashboard/dashboard.module.ts | 5 ++-- src/app/dashboard/map.component.html | 25 ++++++++++++++---- src/app/dashboard/map.component.ts | 38 +++++++++++++++++++++++++-- src/app/providers/api-service.ts | 9 +++++++ 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index f584ef4..a8c59b0 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -4,7 +4,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { BsDropdownModule } from 'ngx-bootstrap/dropdown'; import { NgxPaginationModule } from 'ngx-pagination'; -import { AgmCoreModule } from '@agm/core'; +import { AgmCoreModule, GoogleMapsAPIWrapper } from '@agm/core'; import { CurrencyPipe } from '@angular/common'; @@ -62,7 +62,8 @@ import { environment } from '../../environments/environment'; GraphPanel, ], providers: [ - CurrencyPipe + CurrencyPipe, + GoogleMapsAPIWrapper, ], }) export class DashboardModule { } diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html index 8626466..646009f 100644 --- a/src/app/dashboard/map.component.html +++ b/src/app/dashboard/map.component.html @@ -6,11 +6,26 @@ Supplier Map Required Data marked in bold. - - - - - +
+
+ +
+
+ + + + + +
+
diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index e39e853..71b7274 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { Http, Response } from '@angular/http'; import { ApiService } from '../providers/api-service'; import { AgmCoreModule } from '@agm/core'; @@ -13,13 +13,47 @@ export class MapComponent implements OnInit { lng: number = -2.8007; zoom: number = 12; + dataReceived: string = 'yes'; + + map: any; + constructor( private http: Http, private api: ApiService, ) { } - ngOnInit(): void { + ngOnInit(): void { } + public onMapReady(map: any) { + this.map = map; } + public viewBoundsChanged() { + console.log("finding bounds"); + const resp = this.map.getBounds(); + console.log("found bounds"); + console.log(resp.getNorthEast().lat()); + console.log(resp.getNorthEast().lng()); + console.log(resp.getSouthWest().lat()); + console.log(resp.getSouthWest().lng()); + const mapData = { + north_east_lat: resp.getNorthEast().lat(), + north_east_lng: resp.getNorthEast().lng(), + south_west_lat: resp.getSouthWest().lat(), + south_west_lng: resp.getSouthWest().lng() + }; + this.api.getMapData(mapData).subscribe( + result => { + this.dataReceived = 'yes'; + }, + error => { + // this.dataReceived = 'no'; + console.log('Retrieval Error'); + console.log( error._body ); + } + ); + } + + + } diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 6c6ea47..4bc910d 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -264,6 +264,15 @@ export class ApiService { ).map( response => response.json() ); } + // Initial Map Data + public getMapData(data) { + data.session_key = this.sessionKey; + return this.http.post( + this.apiUrl + '/map', + data + ).map( response => response.json() ); + } + // Basic Customer User stats API public basicStats() { const key = this.sessionKey; From b59351addf2e51b88b66bda84744f77ec08f50ef Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 27 Sep 2017 14:34:46 +0100 Subject: [PATCH 26/37] made looping markers --- src/app/dashboard/map.component.html | 11 ++++++++++- src/app/dashboard/map.component.ts | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html index 646009f..04d7d73 100644 --- a/src/app/dashboard/map.component.html +++ b/src/app/dashboard/map.component.html @@ -22,7 +22,16 @@ [zoom]="zoom" [scaleControl]="true" (idle)="viewBoundsChanged($event)"> - + + + + {{m.label}} + +
diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index 71b7274..5acc512 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -15,6 +15,25 @@ export class MapComponent implements OnInit { dataReceived: string = 'yes'; + markers = [ + { + lat: 54.0466, + lng: -2.8007, + label: 'A', + + }, + { + lat: 54.0453, + lng: -2.83, + label: 'B' + }, + { + lat: 54.0563, + lng: -2.8279, + label: 'C' + } + ] + map: any; constructor( From f402d46db8d3e924ce6e25c281957b19eb1c3e04 Mon Sep 17 00:00:00 2001 From: piratefinn Date: Wed, 27 Sep 2017 17:46:25 +0100 Subject: [PATCH 27/37] Added API changes --- src/app/dashboard/map.component.html | 8 +++---- src/app/dashboard/map.component.ts | 34 +++++++++------------------- src/app/providers/api-service.ts | 2 +- 3 files changed, 16 insertions(+), 28 deletions(-) diff --git a/src/app/dashboard/map.component.html b/src/app/dashboard/map.component.html index 04d7d73..1c408a4 100644 --- a/src/app/dashboard/map.component.html +++ b/src/app/dashboard/map.component.html @@ -24,12 +24,12 @@ (idle)="viewBoundsChanged($event)"> + [latitude]="m.latitude" + [longitude]="m.longitude" + [label]="m.name[0]"> - {{m.label}} + {{m.name}} diff --git a/src/app/dashboard/map.component.ts b/src/app/dashboard/map.component.ts index 5acc512..71faed0 100644 --- a/src/app/dashboard/map.component.ts +++ b/src/app/dashboard/map.component.ts @@ -15,24 +15,7 @@ export class MapComponent implements OnInit { dataReceived: string = 'yes'; - markers = [ - { - lat: 54.0466, - lng: -2.8007, - label: 'A', - - }, - { - lat: 54.0453, - lng: -2.83, - label: 'B' - }, - { - lat: 54.0563, - lng: -2.8279, - label: 'C' - } - ] + markers: Array<{latitude: number, longitude: number, name: string}>; map: any; @@ -56,14 +39,19 @@ export class MapComponent implements OnInit { console.log(resp.getSouthWest().lat()); console.log(resp.getSouthWest().lng()); const mapData = { - north_east_lat: resp.getNorthEast().lat(), - north_east_lng: resp.getNorthEast().lng(), - south_west_lat: resp.getSouthWest().lat(), - south_west_lng: resp.getSouthWest().lng() - }; + north_east: { + latitude: resp.getNorthEast().lat(), + longitude: resp.getNorthEast().lng() + }, + south_west: { + latitude: resp.getSouthWest().lat(), + longitude: resp.getSouthWest().lng() + }, + } this.api.getMapData(mapData).subscribe( result => { this.dataReceived = 'yes'; + this.markers = result.suppliers; }, error => { // this.dataReceived = 'no'; diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 4bc910d..37919e3 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -268,7 +268,7 @@ export class ApiService { public getMapData(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/map', + this.apiUrl + '/v1/suppliers/location', data ).map( response => response.json() ); } From a622b0d87141f91903f934f7bcdef5d6a1570de1 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Thu, 28 Sep 2017 12:47:09 +0100 Subject: [PATCH 28/37] Fix issue with supplier location api url --- src/app/providers/api-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/providers/api-service.ts b/src/app/providers/api-service.ts index 37919e3..378035b 100644 --- a/src/app/providers/api-service.ts +++ b/src/app/providers/api-service.ts @@ -268,7 +268,7 @@ export class ApiService { public getMapData(data) { data.session_key = this.sessionKey; return this.http.post( - this.apiUrl + '/v1/suppliers/location', + this.apiUrl + '/v1/supplier/location', data ).map( response => response.json() ); } From 2ffe32c6f58a1f933ddc13b851562dcd4d8045f7 Mon Sep 17 00:00:00 2001 From: Tom Bloor Date: Thu, 28 Sep 2017 12:55:48 +0100 Subject: [PATCH 29/37] Change to a map icon for the Supplier Map --- src/app/layouts/full-layout.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index f92357c..4fc7f4c 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -42,7 +42,7 @@