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-09-22 06:48:29 +00:00
|
|
|
window.open(`api/${path}?${serializedParams}`);
|
2020-06-12 12:28:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Report.$inject = ['$httpParamSerializer', 'vnToken'];
|
|
|
|
|
|
|
|
ngModule.service('vnReport', Report);
|