Joaquín Reñé
18 hours ago 78b085815b9873acdf178b2e9c9598d065fd40c0
securis/src/main/webapp/src/app/resources/licenses.ts
....@@ -2,6 +2,7 @@
22 import { Observable } from 'rxjs/Rx';
33 import { Injectable } from '@angular/core';
44 import { Http, RequestOptions, ResponseContentType, Response } from '@angular/http';
5
+import { Locker } from 'angular-safeguard';
56 import { SeCurisResourceServices } from './base';
67 import { saveAs } from "file-saver";
78
....@@ -78,14 +79,13 @@
7879
7980 @Injectable()
8081 export class LicensesService extends SeCurisResourceServices {
81
- constructor(http: Http,
82
- $L: LocaleService) {
83
- super($L, http, 'license');
82
+ constructor(http: Http, $L: LocaleService, store: Locker) {
83
+ super($L, http, store, 'license');
8484 }
8585
8686 public getByPack(packId: number) {
8787 let url = `${this.resource}?packId=${packId}`;
88
- return this.http.get(url).map(response => response.json());
88
+ return this.http.get(url, this.getAuthHeaders()).map(response => response.json());
8989 }
9090
9191 public activate(id: number) {
....@@ -114,12 +114,14 @@
114114
115115 public download(id: number) {
116116 let url = `${this.resource}/${id}/download`;
117
- return this.http.get(url).map((response : Response) => {
118
- let filename = JSON.parse(response.headers.get('Content-Disposition').match(/".*"$/g)[0]);
119
- let content = JSON.stringify(response.json(), null, 2);
120
- saveAs( new Blob([ content ], { type : 'application/octet-stream' }), filename);
121
- return Observable.of(true);
122
- }).catch(err => super.processErrorResponse(err));
117
+ return this.http.get(url, this.getAuthHeaders())
118
+ .map((response: Response) => {
119
+ let filename = JSON.parse(response.headers.get('Content-Disposition').match(/".*"$/g)[0]);
120
+ let content = JSON.stringify(response.json(), null, 2);
121
+ saveAs(new Blob([content], { type: 'application/octet-stream' }), filename);
122
+ return Observable.of(true);
123
+ })
124
+ .catch(err => super.processErrorResponse(err));
123125 }
124126
125127 public isActionAvailable(action:string, lic:any) {