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.
|
|
|
|
*
|
|
|
|
* @param {String} report The report name
|
|
|
|
* @param {Object} params The report parameters
|
|
|
|
*/
|
|
|
|
show(report, params) {
|
|
|
|
params = Object.assign({
|
|
|
|
authorization: this.vnToken.token
|
|
|
|
}, params);
|
|
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
|
|
window.open(`api/report/${report}?${serializedParams}`);
|
|
|
|
}
|
2021-10-01 10:41:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a report in another window, automatically adds the authorization
|
|
|
|
* token to params.
|
|
|
|
*
|
|
|
|
* @param {String} report The report name
|
|
|
|
* @param {Object} params The report parameters
|
|
|
|
*/
|
|
|
|
showCSV(report, params) {
|
|
|
|
params = Object.assign({
|
|
|
|
authorization: this.vnToken.token
|
|
|
|
}, params);
|
|
|
|
const serializedParams = this.$httpParamSerializer(params);
|
|
|
|
window.open(`api/csv/${report}/download?${serializedParams}`);
|
|
|
|
}
|
2020-06-12 12:28:29 +00:00
|
|
|
}
|
|
|
|
Report.$inject = ['$httpParamSerializer', 'vnToken'];
|
|
|
|
|
|
|
|
ngModule.service('vnReport', Report);
|