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.tokenMultimedia }, params); const serializedParams = this.$httpParamSerializer(params); const query = serializedParams ? `?${serializedParams}` : ''; window.open(`api/${path}${query}`); } } Report.$inject = ['$httpParamSerializer', 'vnToken']; ngModule.service('vnReport', Report);