Stop using multiple apiService instances
This commit is contained in:
parent
7d637e84e4
commit
cf1980d768
8 changed files with 14 additions and 17 deletions
|
@ -7,7 +7,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'login.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class LoginComponent implements OnInit {
|
||||
signin: FormGroup;
|
||||
|
|
|
@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'register.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
|
||||
export class RegisterComponent {
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'account-edit.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class AccountEditComponent implements OnInit {
|
||||
settingForm: FormGroup;
|
||||
|
|
|
@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'add-data.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class AddDataComponent {
|
||||
payrollForm: FormGroup;
|
||||
|
|
|
@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'feedback.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class FeedbackComponent {
|
||||
feedbackForm: FormGroup;
|
||||
|
|
|
@ -11,7 +11,6 @@ import 'rxjs/add/operator/map';
|
|||
|
||||
@Component({
|
||||
templateUrl: 'transaction-log.component.html',
|
||||
providers: [ApiService]
|
||||
})
|
||||
export class TransactionLogComponent {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -19,9 +19,7 @@ export class ApiService {
|
|||
}
|
||||
|
||||
public post(url: string, data: any = {}) {
|
||||
if ( this.sessionKey != null ) {
|
||||
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(
|
||||
return this.http
|
||||
.post(
|
||||
this.apiUrl + '/logout',
|
||||
{
|
||||
session_key : key,
|
||||
{ session_key : key },
|
||||
)
|
||||
.map(
|
||||
response => {
|
||||
localStorage.clear();
|
||||
this.sessionKey = null;
|
||||
return response.json();
|
||||
}
|
||||
).map( response => { this.removeSessionKey(); return response.json(); } );
|
||||
);
|
||||
}
|
||||
|
||||
// Submits feedback
|
||||
|
|
Reference in a new issue