Fix indentation in api-service

This commit is contained in:
Tom Bloor 2017-08-16 16:12:40 +01:00
parent 59693df214
commit ddadae9a07

View file

@ -5,7 +5,7 @@ import { environment } from '../../environments/environment';
import 'rxjs/add/operator/map'; import 'rxjs/add/operator/map';
/* this provider handles the interaction between server and client */ /* this provider handles the interaction between server and client */
@Injectable() @Injectable()
export class ApiService { export class ApiService {
private apiUrl = environment.apiUrl; private apiUrl = environment.apiUrl;
@ -17,26 +17,26 @@ export class ApiService {
this.sessionKey = localStorage.getItem('sessionKey'); this.sessionKey = localStorage.getItem('sessionKey');
} }
} }
// Login API // Login API
private getSessionKey() { private getSessionKey() {
console.log('get key'); console.log('get key');
return this.sessionKey; return this.sessionKey;
} }
private setSessionKey(key) { private setSessionKey(key) {
console.log('set key'); console.log('set key');
this.sessionKey = key; this.sessionKey = key;
localStorage.setItem('sessionKey', this.sessionKey); localStorage.setItem('sessionKey', this.sessionKey);
} }
private removeSessionKey() { private removeSessionKey() {
console.log('remove key'); console.log('remove key');
this.sessionKey = null; this.sessionKey = null;
localStorage.removeItem('sessionKey'); localStorage.removeItem('sessionKey');
} }
public register(data) { public register(data) {
return this.http.post( return this.http.post(
this.apiUrl + '/register', this.apiUrl + '/register',
@ -50,8 +50,8 @@ export class ApiService {
data data
).map( response => response.json() ); ).map( response => response.json() );
login_event.subscribe( login_event.subscribe(
result => { result => {
this.setSessionKey(result.session_key); this.setSessionKey(result.session_key);
this.setUserInfo( this.setUserInfo(
data.email, data.email,
result.display_name, result.display_name,
@ -60,7 +60,7 @@ export class ApiService {
); );
return login_event; return login_event;
} }
public logout() { public logout() {
console.log(this.sessionKey); console.log(this.sessionKey);
return this.http.post( return this.http.post(
@ -78,9 +78,9 @@ export class ApiService {
data data
).map( response => response.json() ); ).map( response => response.json() );
} }
// Handles user data interaction // Handles user data interaction
// Checks for login status // Checks for login status
public hasLoggedIn() { public hasLoggedIn() {
@ -96,9 +96,9 @@ export class ApiService {
localStorage.setItem('email',email); localStorage.setItem('email',email);
localStorage.setItem('displayname',display_name); localStorage.setItem('displayname',display_name);
} }
// Used for getting account details and updating // Used for getting account details and updating
public accountFullLoad() { public accountFullLoad() {
let key = this.sessionKey; let key = this.sessionKey;
return this.http.post( return this.http.post(
@ -106,7 +106,7 @@ export class ApiService {
{ session_key : key }, { session_key : key },
).map( response => response.json() ); ).map( response => response.json() );
} }
public accountEditUpdate(data) { public accountEditUpdate(data) {
data.session_key = this.sessionKey; data.session_key = this.sessionKey;
return this.http.post( return this.http.post(
@ -147,9 +147,9 @@ export class ApiService {
console.log("get email"); console.log("get email");
localStorage.getItem('email'); localStorage.getItem('email');
} }
// Leaderboard Api // Leaderboard Api
public leaderboard_fetch(data) { public leaderboard_fetch(data) {
return this.http.post( return this.http.post(
this.apiUrl + '/stats/leaderboard', this.apiUrl + '/stats/leaderboard',
@ -159,9 +159,9 @@ export class ApiService {
} }
).map( response => response.json() ); ).map( response => response.json() );
} }
// Fake Breadcrumb data // Fake Breadcrumb data
public breadcrumb_data(data) { public breadcrumb_data(data) {
return Observable.of( return Observable.of(
{ {
@ -172,9 +172,9 @@ export class ApiService {
} }
) )
} }
// Fake chart data to mimic // Fake chart data to mimic
public graph_data(data) { public graph_data(data) {
return Observable.of( return Observable.of(
{ {
@ -236,7 +236,7 @@ export class ApiService {
returningcustomerno : [3,2,4,2,1,1,1,6,4,8,5,12], returningcustomerno : [3,2,4,2,1,1,1,6,4,8,5,12],
}, },
// If the number is potential or actual customers in their sector has yet to be determined // If the number is potential or actual customers in their sector has yet to be determined
"customersinsector" : "customersinsector" :
{ {
percent : 76, percent : 76,
customerno : 34000, customerno : 34000,
@ -257,7 +257,7 @@ export class ApiService {
percentsinglecompetitorlocal : 65, percentsinglecompetitorlocal : 65,
}, },
}, },
} }
) )
} }
} }