Merge branch 'development' into finn/PayrollSubmit

This commit is contained in:
piratefinn 2017-09-19 15:37:17 +01:00
commit f1a6b1886f
16 changed files with 217 additions and 193 deletions

23
bin/build-releases Executable file
View file

@ -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"

View file

@ -8,13 +8,13 @@ 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') 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') 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

@ -1,6 +1,6 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Validators, FormBuilder, FormGroup } from '@angular/forms'; 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 { Http, Response } from '@angular/http';
import { ApiService } from '../providers/api-service'; import { ApiService } from '../providers/api-service';
import {Router } from '@angular/router'; import {Router } from '@angular/router';
@ -16,7 +16,7 @@ export class RegisterComponent {
organisationForm: ValidationManager; organisationForm: ValidationManager;
years: Object[]; years: Object[];
registerStatus: any; registerStatus: any;
registerStatusError: string = 'Error received, please try again.'; registerStatusError = 'Error received, please try again.';
constructor( constructor(
private http: Http, private http: Http,
@ -25,7 +25,7 @@ export class RegisterComponent {
private api: ApiService, private api: ApiService,
) { ) {
this.years = []; this.years = [];
let max = new Date().getFullYear() - 10, const max = new Date().getFullYear() - 10,
min = max - 140; min = max - 140;
for (let i = max; i >= min; i--) { for (let i = max; i >= min; i--) {
@ -57,15 +57,15 @@ export class RegisterComponent {
console.log(this.signupForm.isValid()); console.log(this.signupForm.isValid());
if (!this.signupForm.isValid() && !this.customerForm.isValid()) { if (!this.signupForm.isValid() && !this.customerForm.isValid()) {
console.log("Not Valid!"); console.log('Not Valid!');
this.registerStatus = "validation_failed"; this.registerStatus = 'validation_failed';
console.log(this.registerStatus); console.log(this.registerStatus);
return; return;
} }
let signupForm = this.signupForm.getForm().value; const signupForm = this.signupForm.getForm().value;
let customerForm = this.customerForm.getForm().value; const customerForm = this.customerForm.getForm().value;
let data = { const data = {
token: signupForm.token, token: signupForm.token,
usertype: signupForm.usertype, usertype: signupForm.usertype,
email: signupForm.email, email: signupForm.email,
@ -81,7 +81,7 @@ export class RegisterComponent {
.subscribe( .subscribe(
result => { result => {
console.log('registered!'); console.log('registered!');
this.registerStatus = "success"; this.registerStatus = 'success';
console.log(this.registerStatus); console.log(this.registerStatus);
this.router.navigate(['/dashboard']); this.router.navigate(['/dashboard']);
}, },
@ -90,13 +90,13 @@ export class RegisterComponent {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.registerStatusError = 'There was a server error, please try again later.'; this.registerStatusError = 'There was a server error, please try again later.';
} }
this.registerStatus = "send_failed"; this.registerStatus = 'send_failed';
console.log(this.registerStatus); console.log(this.registerStatus);
} }
); );
@ -105,15 +105,15 @@ export class RegisterComponent {
console.log(this.signupForm.isValid()); console.log(this.signupForm.isValid());
if (!this.signupForm.isValid() || !this.organisationForm.isValid()) { if (!this.signupForm.isValid() || !this.organisationForm.isValid()) {
console.log("Not Valid!"); console.log('Not Valid!');
this.registerStatus = "validation_failed"; this.registerStatus = 'validation_failed';
console.log(this.registerStatus); console.log(this.registerStatus);
return; return;
} }
let signupForm = this.signupForm.getForm().value; const signupForm = this.signupForm.getForm().value;
let organisationForm = this.organisationForm.getForm().value; const organisationForm = this.organisationForm.getForm().value;
let data = { const data = {
token: signupForm.token, token: signupForm.token,
usertype: signupForm.usertype, usertype: signupForm.usertype,
email: signupForm.email, email: signupForm.email,
@ -130,7 +130,7 @@ export class RegisterComponent {
.subscribe( .subscribe(
result => { result => {
console.log('registered!'); console.log('registered!');
this.registerStatus = "success"; this.registerStatus = 'success';
console.log(this.registerStatus); console.log(this.registerStatus);
this.router.navigate(['/dashboard']); this.router.navigate(['/dashboard']);
}, },
@ -139,13 +139,13 @@ export class RegisterComponent {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.registerStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.registerStatusError = 'There was a server error, please try again later.'; this.registerStatusError = 'There was a server error, please try again later.';
} }
this.registerStatus = "send_failed"; this.registerStatus = 'send_failed';
console.log(this.registerStatus); console.log(this.registerStatus);
} }
); );

View file

@ -14,7 +14,7 @@ export class AccountEditComponent implements OnInit {
accountType: any; accountType: any;
// @ViewChild('fileInput') fileInput; // @ViewChild('fileInput') fileInput;
submitStatus: any; submitStatus: any;
submitStatusError: string = 'Error received, please try again.'; submitStatusError = 'Error received, please try again.';
constructor( constructor(
private http: Http, private http: Http,
@ -72,7 +72,7 @@ export class AccountEditComponent implements OnInit {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingOrganisationForm.valid) { if (!this.settingForm.valid && !this.settingOrganisationForm.valid) {
console.log('Not Valid!'); console.log('Not Valid!');
this.submitStatus = "validation_failed"; this.submitStatus = 'validation_failed';
console.log(this.submitStatus); console.log(this.submitStatus);
return; return;
} }
@ -108,7 +108,7 @@ export class AccountEditComponent implements OnInit {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.submitStatus = "success"; this.submitStatus = 'success';
console.log(this.submitStatus); console.log(this.submitStatus);
}, },
error => { error => {
@ -116,13 +116,13 @@ export class AccountEditComponent implements OnInit {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.submitStatusError = 'There was a server error, please try again later.'; this.submitStatusError = 'There was a server error, please try again later.';
} }
this.submitStatus = "send_failed"; this.submitStatus = 'send_failed';
console.log(this.submitStatus); console.log(this.submitStatus);
} }
); );
@ -132,7 +132,7 @@ export class AccountEditComponent implements OnInit {
console.log(this.settingForm.valid); console.log(this.settingForm.valid);
if (!this.settingForm.valid && !this.settingCustomerForm.valid) { if (!this.settingForm.valid && !this.settingCustomerForm.valid) {
console.log('Not Valid!'); console.log('Not Valid!');
this.submitStatus = "validation_failed"; this.submitStatus = 'validation_failed';
console.log(this.submitStatus); console.log(this.submitStatus);
return; return;
} }
@ -165,7 +165,7 @@ export class AccountEditComponent implements OnInit {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.submitStatus = "success"; this.submitStatus = 'success';
console.log(this.submitStatus); console.log(this.submitStatus);
}, },
error => { error => {
@ -173,13 +173,13 @@ export class AccountEditComponent implements OnInit {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.submitStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.submitStatusError = 'There was a server error, please try again later.'; this.submitStatusError = 'There was a server error, please try again later.';
} }
this.submitStatus = "send_failed"; this.submitStatus = 'send_failed';
console.log(this.submitStatus); console.log(this.submitStatus);
} }
); );

View file

@ -9,7 +9,7 @@ import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'add-data.component.html', templateUrl: 'add-data.component.html',
}) })
export class AddDataComponent { export class AddDataComponent implements OnInit {
payrollForm: FormGroup; payrollForm: FormGroup;
singleSupplierForm: FormGroup; singleSupplierForm: FormGroup;
employeeForm: FormGroup; employeeForm: FormGroup;
@ -18,7 +18,7 @@ export class AddDataComponent {
singleSupplierFormStatus: any; singleSupplierFormStatus: any;
employeeFormStatus: any; employeeFormStatus: any;
transactionFormStatus: any; transactionFormStatus: any;
transactionFormStatusError: string = 'Error received, please try again.'; transactionFormStatusError = 'Error received, please try again.';
accountType: any; accountType: any;
submitOrg = { submitOrg = {
@ -75,11 +75,11 @@ export class AddDataComponent {
getMinDate() { getMinDate() {
// gets the April 1st date of the current year // gets the April 1st date of the current year
let aprilDate = moment().month(3).date(1); const aprilDate = moment().month(3).date(1);
let now = moment(); const now = moment();
// Checks if current time is before April 1st, if so returns true // Checks if current time is before April 1st, if so returns true
let beforeApril = now.isBefore(aprilDate); const beforeApril = now.isBefore(aprilDate);
if ( beforeApril == true ) { if ( beforeApril === true ) {
this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD');
} else { } else {
this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD');
@ -88,10 +88,10 @@ export class AddDataComponent {
initializeItems() { initializeItems() {
// Dont bother searching for an empty or undefined string // Dont bother searching for an empty or undefined string
if ( this.submitOrg.name == '' ) { if ( this.submitOrg.name === '' ) {
return; return;
} }
var searchData = { const searchData = {
search_name: this.submitOrg.name, search_name: this.submitOrg.name,
}; };
@ -132,15 +132,15 @@ export class AddDataComponent {
this.initializeItems(); this.initializeItems();
// set val to the value of the searchbar // 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 // 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( this.storeList = this.storeList.filter(
(item) => { (item) => {
return ( item.name.toLowerCase().indexOf( val.toLowerCase() ) > -1 ); return ( item.name.toLowerCase().indexOf( val.toLowerCase() ) > -1 );
} }
) );
} }
// if nothing is found // if nothing is found
@ -151,9 +151,9 @@ export class AddDataComponent {
} }
transactionFormValidate() { transactionFormValidate() {
if( this.submitOrg.name.length == 0 || if (this.submitOrg.name.length === 0 ||
this.submitOrg.town.length == 0 || this.submitOrg.town.length === 0 ||
this.amount == 0 ) { this.amount === 0 ) {
this.transactionFormInvalid = true; this.transactionFormInvalid = true;
} else { } else {
this.transactionFormInvalid = false; this.transactionFormInvalid = false;
@ -162,7 +162,7 @@ export class AddDataComponent {
public postTransaction() { public postTransaction() {
var myParams: any; let myParams: any;
let purchaseTime: string; let purchaseTime: string;
purchaseTime = moment(this.myDate, 'YYYY-MM-DD[T]HH:mm').local().format('YYYY-MM-DD[T]HH:mm:ss.SSSZ'); 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) {
@ -200,16 +200,16 @@ export class AddDataComponent {
.upload(myParams) .upload(myParams)
.subscribe( .subscribe(
result => { result => {
if ( result.success == true ) { if ( result.success === true ) {
console.log('Successful Upload'); console.log('Successful Upload');
console.log(result); console.log(result);
this.transactionFormStatus = "success"; this.transactionFormStatus = 'success';
console.log(this.transactionFormStatus); console.log(this.transactionFormStatus);
this.resetForm(); this.resetForm();
} else { } else {
console.log('Upload Error'); console.log('Upload Error');
this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); this.transactionFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message);
this.transactionFormStatus = "send_failed"; this.transactionFormStatus = 'send_failed';
console.log(this.transactionFormStatus); console.log(this.transactionFormStatus);
} }
}, },
@ -218,13 +218,13 @@ export class AddDataComponent {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.transactionFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.transactionFormStatusError = 'There was a server error, please try again later.'; this.transactionFormStatusError = 'There was a server error, please try again later.';
} }
this.transactionFormStatus = "send_failed"; this.transactionFormStatus = 'send_failed';
console.log(this.transactionFormStatus); console.log(this.transactionFormStatus);
} }
); );
@ -251,12 +251,12 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.payrollFormStatus = "success"; this.payrollFormStatus = 'success';
console.log(this.payrollFormStatus); console.log(this.payrollFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.payrollFormStatus = "send_failed"; this.payrollFormStatus = 'send_failed';
console.log(this.payrollFormStatus); console.log(this.payrollFormStatus);
} }
); );
@ -270,12 +270,12 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.singleSupplierFormStatus = "success"; this.singleSupplierFormStatus = 'success';
console.log(this.singleSupplierFormStatus); console.log(this.singleSupplierFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.singleSupplierFormStatus = "send_failed"; this.singleSupplierFormStatus = 'send_failed';
console.log(this.singleSupplierFormStatus); console.log(this.singleSupplierFormStatus);
} }
); );
@ -289,12 +289,12 @@ export class AddDataComponent {
.subscribe( .subscribe(
result => { result => {
console.log('data submitted!'); console.log('data submitted!');
this.employeeFormStatus = "success"; this.employeeFormStatus = 'success';
console.log(this.employeeFormStatus); console.log(this.employeeFormStatus);
}, },
error => { error => {
console.log( error._body ); console.log( error._body );
this.employeeFormStatus = "send_failed"; this.employeeFormStatus = 'send_failed';
console.log(this.employeeFormStatus); console.log(this.employeeFormStatus);
} }
); );

View file

@ -7,13 +7,13 @@ import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'feedback.component.html', templateUrl: 'feedback.component.html',
}) })
export class FeedbackComponent { export class FeedbackComponent implements OnInit {
feedbackForm: FormGroup; feedbackForm: FormGroup;
loggedInEmail: string; loggedInEmail: string;
noEmail: boolean = false; noEmail = false;
username: any; username: any;
feedbackFormStatus: any; feedbackFormStatus: any;
feedbackFormStatusError: string = 'Error received, please try again.'; feedbackFormStatusError = 'Error received, please try again.';
constructor( constructor(
private http: Http, private http: Http,
@ -55,10 +55,10 @@ export class FeedbackComponent {
.feedback(this.feedbackForm.value) .feedback(this.feedbackForm.value)
.subscribe( .subscribe(
result => { result => {
if ( result.success == true ) { if ( result.success === true ) {
console.log('Successful Upload'); console.log('Successful Upload');
console.log(result); console.log(result);
this.feedbackFormStatus = "success"; this.feedbackFormStatus = 'success';
console.log(this.feedbackFormStatus); console.log(this.feedbackFormStatus);
this.feedbackForm.patchValue({ this.feedbackForm.patchValue({
feedbacktext: '', feedbacktext: '',
@ -66,7 +66,7 @@ export class FeedbackComponent {
} else { } else {
console.log('Upload Error'); console.log('Upload Error');
this.feedbackFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message); this.feedbackFormStatusError = JSON.stringify(result.status) + 'Error, ' + JSON.stringify(result.message);
this.feedbackFormStatus = "send_failed"; this.feedbackFormStatus = 'send_failed';
console.log(this.feedbackFormStatus); console.log(this.feedbackFormStatus);
} }
}, },
@ -75,13 +75,13 @@ export class FeedbackComponent {
console.log(error); console.log(error);
try { try {
console.log(error.error); console.log(error.error);
let jsonError = error.json(); const jsonError = error.json();
console.log("boop"); console.log('boop');
this.feedbackFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message; this.feedbackFormStatusError = '"' + jsonError.error + '" Error, ' + jsonError.message;
} catch (e) { } catch (e) {
this.feedbackFormStatusError = 'There was a server error, please try again later.'; this.feedbackFormStatusError = 'There was a server error, please try again later.';
} }
this.feedbackFormStatus = "send_failed"; this.feedbackFormStatus = 'send_failed';
console.log(this.feedbackFormStatus); console.log(this.feedbackFormStatus);
} }
); );

View file

@ -12,12 +12,13 @@ import 'rxjs/add/operator/map';
@Component({ @Component({
templateUrl: 'transaction-log.component.html', templateUrl: 'transaction-log.component.html',
}) })
export class TransactionLogComponent { export class TransactionLogComponent implements OnInit {
transactionList; transactionList;
noTransactionList = true; noTransactionList = true;
myDate: any; myDate: any;
minDate: any; minDate: any;
public p: any;
public paginateConfig: PaginationInstance = { public paginateConfig: PaginationInstance = {
id: 'transpaginate', id: 'transpaginate',
@ -41,11 +42,11 @@ export class TransactionLogComponent {
getMinDate() { getMinDate() {
// gets the April 1st date of the current year // gets the April 1st date of the current year
let aprilDate = moment().month(3).date(1); const aprilDate = moment().month(3).date(1);
let now = moment(); const now = moment();
// Checks if current time is before April 1st, if so returns true // Checks if current time is before April 1st, if so returns true
let beforeApril = now.isBefore(aprilDate); const beforeApril = now.isBefore(aprilDate);
if ( beforeApril == true ) { if ( beforeApril === true ) {
this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD'); this.minDate = aprilDate.subtract(2, 'years').format('YYYY-MM-DD');
} else { } else {
this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD'); this.minDate = aprilDate.subtract(1, 'years').format('YYYY-MM-DD');

View file

@ -7,16 +7,15 @@ import { Router } from '@angular/router';
templateUrl: './full-layout.component.html', templateUrl: './full-layout.component.html',
}) })
export class FullLayoutComponent implements OnInit { export class FullLayoutComponent implements OnInit {
displayName: any; public displayName: string;
public disabled = false;
public status: {isopen: boolean} = {isopen: false};
constructor( constructor(
private api: ApiService, private api: ApiService,
private router: Router, private router: Router,
) {} ) {}
public disabled = false;
public status: {isopen: boolean} = {isopen: false};
public toggled(open: boolean): void { public toggled(open: boolean): void {
console.log('Dropdown is now: ', open); console.log('Dropdown is now: ', open);
} }

View file

@ -7,9 +7,8 @@ import { Location } from '@angular/common';
export class P404Component { export class P404Component {
constructor( constructor(
private location: Location private location: Location,
) { ) { }
}
goBack(): void { goBack(): void {
this.location.back(); this.location.back();

View file

@ -7,9 +7,8 @@ import { Location } from '@angular/common';
export class P500Component { export class P500Component {
constructor( constructor(
private location: Location private location: Location,
) { ) { }
}
goBack(): void { goBack(): void {
this.location.back(); this.location.back();

View file

@ -9,6 +9,7 @@ interface OrgData {
} }
@Component({ @Component({
// tslint:disable-next-line
selector: '[org-result]', selector: '[org-result]',
templateUrl: 'org-result.component.html', templateUrl: 'org-result.component.html',
}) })
@ -19,6 +20,6 @@ export class OrgResultComponent {
public orgClick(): void { public orgClick(): void {
this.onClick.emit( this.onClick.emit(
this.org this.org
) );
} }
} }

View file

@ -10,6 +10,7 @@ interface OrgData {
} }
@Component({ @Component({
// tslint:disable-next-line
selector: 'org-table', selector: 'org-table',
templateUrl: 'org-table.component.html', templateUrl: 'org-table.component.html',
}) })

View file

@ -8,6 +8,7 @@ interface TransactionData {
} }
@Component({ @Component({
// tslint:disable-next-line
selector: '[transaction-result]', selector: '[transaction-result]',
templateUrl: 'transaction-result.component.html', templateUrl: 'transaction-result.component.html',
}) })