Stop using multiple apiService instances

This commit is contained in:
Tom Bloor 2017-09-08 15:22:15 +01:00
parent 7d637e84e4
commit cf1980d768
8 changed files with 14 additions and 17 deletions

View file

@ -7,7 +7,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'login.component.html',
providers: [ApiService]
})
export class LoginComponent implements OnInit {
signin: FormGroup;

View file

@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'register.component.html',
providers: [ApiService]
})
export class RegisterComponent {
@ -134,4 +133,4 @@ export class RegisterComponent {
}
}
}

View file

@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'account-edit.component.html',
providers: [ApiService]
})
export class AccountEditComponent implements OnInit {
settingForm: FormGroup;

View file

@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'add-data.component.html',
providers: [ApiService]
})
export class AddDataComponent {
payrollForm: FormGroup;

View file

@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'feedback.component.html',
providers: [ApiService]
})
export class FeedbackComponent {
feedbackForm: FormGroup;

View file

@ -11,7 +11,6 @@ import 'rxjs/add/operator/map';
@Component({
templateUrl: 'transaction-log.component.html',
providers: [ApiService]
})
export class TransactionLogComponent {

View file

@ -5,7 +5,6 @@ import { Router } from '@angular/router';
@Component({
selector: 'app-dashboard',
templateUrl: './full-layout.component.html',
providers: [ApiService]
})
export class FullLayoutComponent implements OnInit {
displayName: any;

View file

@ -19,9 +19,7 @@ export class ApiService {
}
public post(url: string, data: any = {}) {
if ( this.sessionKey != null ) {
data.session_key = this.sessionKey;
}
data.session_key = this.sessionKey;
return this.http.post(
this.apiUrl + url,
data
@ -77,12 +75,18 @@ export class ApiService {
public logout() {
console.log(this.sessionKey);
const key = this.sessionKey;
return this.http.post(
this.apiUrl + '/logout',
{
session_key : key,
}
).map( response => { this.removeSessionKey(); return response.json(); } );
return this.http
.post(
this.apiUrl + '/logout',
{ session_key : key },
)
.map(
response => {
localStorage.clear();
this.sessionKey = null;
return response.json();
}
);
}
// Submits feedback