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({
|
@Component({
|
||||||
templateUrl: 'login.component.html',
|
templateUrl: 'login.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class LoginComponent implements OnInit {
|
export class LoginComponent implements OnInit {
|
||||||
signin: FormGroup;
|
signin: FormGroup;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'register.component.html',
|
templateUrl: 'register.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export class RegisterComponent {
|
export class RegisterComponent {
|
||||||
|
@ -134,4 +133,4 @@ export class RegisterComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'account-edit.component.html',
|
templateUrl: 'account-edit.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class AccountEditComponent implements OnInit {
|
export class AccountEditComponent implements OnInit {
|
||||||
settingForm: FormGroup;
|
settingForm: FormGroup;
|
||||||
|
|
|
@ -8,7 +8,6 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'add-data.component.html',
|
templateUrl: 'add-data.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class AddDataComponent {
|
export class AddDataComponent {
|
||||||
payrollForm: FormGroup;
|
payrollForm: FormGroup;
|
||||||
|
|
|
@ -6,7 +6,6 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'feedback.component.html',
|
templateUrl: 'feedback.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class FeedbackComponent {
|
export class FeedbackComponent {
|
||||||
feedbackForm: FormGroup;
|
feedbackForm: FormGroup;
|
||||||
|
|
|
@ -11,7 +11,6 @@ import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: 'transaction-log.component.html',
|
templateUrl: 'transaction-log.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class TransactionLogComponent {
|
export class TransactionLogComponent {
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { Router } from '@angular/router';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dashboard',
|
selector: 'app-dashboard',
|
||||||
templateUrl: './full-layout.component.html',
|
templateUrl: './full-layout.component.html',
|
||||||
providers: [ApiService]
|
|
||||||
})
|
})
|
||||||
export class FullLayoutComponent implements OnInit {
|
export class FullLayoutComponent implements OnInit {
|
||||||
displayName: any;
|
displayName: any;
|
||||||
|
|
|
@ -19,9 +19,7 @@ export class ApiService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public post(url: string, data: any = {}) {
|
public post(url: string, data: any = {}) {
|
||||||
if ( this.sessionKey != null ) {
|
data.session_key = this.sessionKey;
|
||||||
data.session_key = this.sessionKey;
|
|
||||||
}
|
|
||||||
return this.http.post(
|
return this.http.post(
|
||||||
this.apiUrl + url,
|
this.apiUrl + url,
|
||||||
data
|
data
|
||||||
|
@ -77,12 +75,18 @@ export class ApiService {
|
||||||
public logout() {
|
public logout() {
|
||||||
console.log(this.sessionKey);
|
console.log(this.sessionKey);
|
||||||
const key = this.sessionKey;
|
const key = this.sessionKey;
|
||||||
return this.http.post(
|
return this.http
|
||||||
this.apiUrl + '/logout',
|
.post(
|
||||||
{
|
this.apiUrl + '/logout',
|
||||||
session_key : key,
|
{ session_key : key },
|
||||||
}
|
)
|
||||||
).map( response => { this.removeSessionKey(); return response.json(); } );
|
.map(
|
||||||
|
response => {
|
||||||
|
localStorage.clear();
|
||||||
|
this.sessionKey = null;
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submits feedback
|
// Submits feedback
|
||||||
|
|
Reference in a new issue