salix/front/core/services/report.js

28 lines
823 B
JavaScript
Raw Normal View History

2020-06-12 12:28:29 +00:00
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.
*
2022-10-03 06:28:47 +00:00
* @param {String} path The report name
2020-06-12 12:28:29 +00:00
* @param {Object} params The report parameters
*/
2022-09-22 06:48:29 +00:00
show(path, params) {
2020-06-12 12:28:29 +00:00
params = Object.assign({
2022-09-19 10:59:32 +00:00
access_token: this.vnToken.token
2020-06-12 12:28:29 +00:00
}, params);
const serializedParams = this.$httpParamSerializer(params);
2022-10-04 07:21:24 +00:00
const query = serializedParams ? `?${serializedParams}` : '';
window.open(`api/${path}${query}`);
2020-06-12 12:28:29 +00:00
}
}
Report.$inject = ['$httpParamSerializer', 'vnToken'];
ngModule.service('vnReport', Report);