Joaquín Reñé
18 hours ago 78b085815b9873acdf178b2e9c9598d065fd40c0
securis/src/main/webapp/src/app/resources/packs.ts
....@@ -1,6 +1,7 @@
11 import { Observable } from 'rxjs/Rx';
22 import { Injectable } from '@angular/core';
33 import { Http, RequestOptions } from '@angular/http';
4
+import { Locker } from 'angular-safeguard';
45 import { SeCurisResourceServices, MySearchParams } from './base';
56 import { LocaleService } from '../common/i18n';
67
....@@ -82,19 +83,21 @@
8283
8384 @Injectable()
8485 export class PacksService extends SeCurisResourceServices {
85
- constructor(http: Http, $L: LocaleService) {
86
- super($L, http, 'pack');
86
+ constructor(http: Http, $L: LocaleService, store: Locker) {
87
+ super($L, http, store, 'pack');
8788 }
8889
8990 public get(filter?: PacksFilter | number | string) {
90
- if (!filter || typeof filter === "number" || typeof filter === "string") {
91
- return super.get(filter);
92
- }
93
- let searchParams = new MySearchParams(filter);
94
- let url = `${this.resource}/?${searchParams}`;
95
- return this.http.get(url).map(response => response.json()).catch(err => super.processErrorResponse(err));
96
- }
97
-
91
+ if (!filter || typeof filter === "number" || typeof filter === "string") {
92
+ return super.get(filter);
93
+ }
94
+ const searchParams = new MySearchParams(filter);
95
+ const url = `${this.resource}/?${searchParams}`;
96
+ // Añade las cabeceras usando el método de la base
97
+ return this.http.get(url, this.getAuthHeaders())
98
+ .map(response => response.json())
99
+ .catch(err => super.processErrorResponse(err));
100
+ }
98101
99102 public activate(id: number) {
100103 return super.action(id, "activate");
....@@ -108,12 +111,12 @@
108111 return super.action(id, "putonhold");
109112 }
110113 public nextLicCode(id: number) {
111
- let url = `pack/${id}/next_license_code`
112
- return this.http.get(url).map(response => response.text());
114
+ const url = `api/pack/${id}/next_license_code`;
115
+ return this.http.get(url, this.getAuthHeaders())
116
+ .map(response => response.text());
113117 }
114
-
115
-
116
- public isActionAvailable(action:string, pack:any) {
118
+
119
+ public isActionAvailable(action:string, pack:any) {
117120 var validStatuses = PACK_ACTIONS_BY_STATUS[action];
118121 return pack && validStatuses && validStatuses.indexOf(pack.status) !== -1;
119122 }