12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: Content-Apps
- *| (C) Copyright IBM Corp. 2018
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define([
- 'bi/commons/utils/BrowserUtils',
- 'bi/commons/utils/Downloader',
- './OutputHandler'
- ], function (BrowserUtils, Downloader, OutputHandler) {
- 'use strict';
- var _HANDLED_FORMATS = ['xlsxdata','spreadsheetml','xlwa','csv','xml'];
- var DownloadOutputHandler = OutputHandler.extend({
- /**
- * @inheritdoc
- */
- getPriority: function() {
- // a relative number to other output handlers
- return 50;
- },
- /**
- * @inheritDoc
- */
- canExecute: function(options) {
- // don't download on an iPad
- var format = !BrowserUtils.isIPad() && options && options.output && options.output.format;
- return !!(format && _HANDLED_FORMATS.indexOf(format.toLowerCase()) !== -1);
- },
- /**
- * @inheritDoc
- */
- execute: function(options) {
- return this._getDownloader({
- 'url': options.output.content + '?download=true',
- 'logger': options.glassContext.appController.logger
- }).doDownload()
- .then(function() {
- // don't need to wait to return here
- options.glassContext.getSvc('.Content').then(function(contentSvc) {
- contentSvc.addToMRU(options.report);
- });
- });
- },
- // private for unit-test mocking
- _getDownloader: function(options) {
- return new Downloader(options);
- }
- });
- return DownloadOutputHandler;
- });
|