| .. | .. |
|---|
| 2 | 2 | import { Observable } from 'rxjs/Rx'; |
|---|
| 3 | 3 | import { Injectable } from '@angular/core'; |
|---|
| 4 | 4 | import { Http, RequestOptions, ResponseContentType, Response } from '@angular/http'; |
|---|
| 5 | +import { Locker } from 'angular-safeguard'; |
|---|
| 5 | 6 | import { SeCurisResourceServices } from './base'; |
|---|
| 6 | 7 | import { saveAs } from "file-saver"; |
|---|
| 7 | 8 | |
|---|
| .. | .. |
|---|
| 78 | 79 | |
|---|
| 79 | 80 | @Injectable() |
|---|
| 80 | 81 | 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'); |
|---|
| 84 | 84 | } |
|---|
| 85 | 85 | |
|---|
| 86 | 86 | public getByPack(packId: number) { |
|---|
| 87 | 87 | 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()); |
|---|
| 89 | 89 | } |
|---|
| 90 | 90 | |
|---|
| 91 | 91 | public activate(id: number) { |
|---|
| .. | .. |
|---|
| 114 | 114 | |
|---|
| 115 | 115 | public download(id: number) { |
|---|
| 116 | 116 | 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)); |
|---|
| 123 | 125 | } |
|---|
| 124 | 126 | |
|---|
| 125 | 127 | public isActionAvailable(action:string, lic:any) { |
|---|