salix/front/core/services/report.js

27 lines
765 B
JavaScript

import ngModule from '../module';
class Report {
constructor($httpParamSerializer, vnToken) {
this.$httpParamSerializer = $httpParamSerializer;
this.vnToken = vnToken;
}
/**
* Shows a report in another window, automatically adds the authorization
* token to params.
*
* @param {String} path The report name
* @param {Object} params The report parameters
*/
show(path, params) {
params = Object.assign({
access_token: this.vnToken.token
}, params);
const serializedParams = this.$httpParamSerializer(params);
window.open(`api/${path}?${serializedParams}`);
}
}
Report.$inject = ['$httpParamSerializer', 'vnToken'];
ngModule.service('vnReport', Report);