Merge pull request #20 from Pear-Trading/TBSliver/Lint-Errors

Tb sliver/lint errors
This commit is contained in:
Tom Bloor 2017-09-19 15:31:03 +01:00 committed by GitHub
commit f70d3945b6
15 changed files with 194 additions and 193 deletions

View file

@ -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;
}

View file

@ -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);
}
);

View file

@ -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);
}
);

View file

@ -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);
}
);

View file

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

View file

@ -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);
}
);

View file

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

View file

@ -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);
}

View file

@ -7,9 +7,9 @@
<h4 class="pt-3">Oops! You're lost.</h4>
<p class="text-muted">The page you are looking for was not found.</p>
</div>
<span class="input-group-btn">
<button class="btn btn-primary btn-lg" type="button"(click)="goBack()">Go Back</button>
</span>
<span class="input-group-btn">
<button class="btn btn-primary btn-lg" type="button"(click)="goBack()">Go Back</button>
</span>
</div>
</div>
</div>

View file

@ -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();
}
}

View file

@ -8,8 +8,8 @@
<p class="text-muted">The page you are looking for is temporarily unavailable.</p>
</div>
<span class="input-group-btn">
<button class="btn btn-primary btn-lg" type="button"(click)="goBack()">Go Back</button>
</span>
<button class="btn btn-primary btn-lg" type="button"(click)="goBack()">Go Back</button>
</span>
</div>
</div>
</div>

View file

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

View file

@ -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
)
);
}
}

View file

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

View file

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