diff --git a/app/config/config.example.js b/app/config/config.example.js index 41d5db9e2..8759ee437 100755 --- a/app/config/config.example.js +++ b/app/config/config.example.js @@ -13,11 +13,12 @@ //Do not modify the structure of this window.__env = { // View Editor Version - version: '4.0.1', + version: '4.0.2', // API url apiUrl: 'http://localhost:8080', // Base url baseUrl: '', + printUrl: 'http://localhost:8080/convert', enableDebug: true, // Configuration for the banner below the login modal (only visible at login) loginBanner: { diff --git a/app/js/mms/app.js b/app/js/mms/app.js index f3e157758..31b060f27 100644 --- a/app/js/mms/app.js +++ b/app/js/mms/app.js @@ -61,7 +61,9 @@ angular.module('mmsApp', ['mms', 'mms.directives', 'app.tpls', 'fa.directive.bor var mmsHost = window.location.protocol + '//' + window.location.host; URLServiceProvider.setMmsUrl(mmsHost); } - + if (window.__env.printUrl) { + URLServiceProvider.setPrintUrl(window.__env.printUrl); + } diff --git a/app/js/mms/controllers/controller.utils.js b/app/js/mms/controllers/controller.utils.js index b7196956f..855fd9613 100644 --- a/app/js/mms/controllers/controller.utils.js +++ b/app/js/mms/controllers/controller.utils.js @@ -256,11 +256,14 @@ function MmsAppUtils($q, $uibModal, $timeout, $location, $window, growl, if (result.tof != '') htmlArr.push(result.tof); htmlArr.push(result.contents, ''); var htmlString = htmlArr.join(''); + growl.info('Generating, please wait...', {ttl: -1}); UtilsService.exportHtmlAs(mode, {htmlString: htmlString, name: viewOrDocOb.name, projectId: viewOrDocOb._projectId, refId: viewOrDocOb._refId, css: css}) .then(function(result) { + growl.success('File Downloaded', {ttl: -1}); deferred.resolve(result); }, function(reason){ deferred.reject(reason); + growl.error('Generation Failed'); }); } } else { diff --git a/app/js/mms/controllers/fulldoc.controller.js b/app/js/mms/controllers/fulldoc.controller.js index f3300d733..faae3adb4 100644 --- a/app/js/mms/controllers/fulldoc.controller.js +++ b/app/js/mms/controllers/fulldoc.controller.js @@ -57,6 +57,7 @@ function($scope, $state, $anchorScroll, $location, $timeout, $http, FullDocument $scope.bbApi.addButton(UxService.getButtonBarButton('print')); var exportButtons = UxService.getButtonBarButton('export'); exportButtons.dropdown_buttons.push(UxService.getButtonBarButton("convert-pdf")); + //exportButtons.dropdown_buttons.push(UxService.getButtonBarButton("word")); $scope.bbApi.addButton(exportButtons); $scope.bbApi.setToggleState('show-comments', rootScopeSvc.veCommentsOn()); $scope.bbApi.setToggleState('show-elements', rootScopeSvc.veElementsOn()); @@ -172,9 +173,9 @@ function($scope, $state, $anchorScroll, $location, $timeout, $http, FullDocument fullDocumentService.loadRemainingViews(function() { MmsAppUtils.printModal(documentOb, refOb, true, 3) .then(function(ob) { - growl.info('Exporting as PDF file. Please wait for a completion email.',{ttl: -1}); + //growl.info('Exporting as PDF file. Please wait for a completion email.',{ttl: -1}); }, function(reason){ - growl.error("Exporting as PDF file Failed: " + reason.message); + //growl.error("Exporting as PDF file Failed: " + reason.message); }); }); })); @@ -189,9 +190,9 @@ function($scope, $state, $anchorScroll, $location, $timeout, $http, FullDocument fullDocumentService.loadRemainingViews(function() { MmsAppUtils.printModal(documentOb, refOb, true, 2) .then(function(ob) { - growl.info('Exporting as Word file. Please wait for a completion email.',{ttl: -1}); + //growl.info('Exporting as Word file. Please wait for a completion email.',{ttl: -1}); }, function(reason){ - growl.error("Exporting as Word file Failed: " + reason.message); + //growl.error("Exporting as Word file Failed: " + reason.message); }); }); })); diff --git a/app/js/mms/controllers/view.controller.js b/app/js/mms/controllers/view.controller.js index f43d4671c..1a50625fb 100644 --- a/app/js/mms/controllers/view.controller.js +++ b/app/js/mms/controllers/view.controller.js @@ -246,9 +246,9 @@ angular.module('mmsApp') return; MmsAppUtils.printModal(viewOb, refOb, false, 3) .then(function(ob) { - growl.info('Exporting as PDF file. Please wait for a completion email.',{ttl: -1}); + // growl.info('Exporting as PDF file. Please wait for a completion email.',{ttl: -1}); }, function(reason){ - growl.error("Exporting as PDF file Failed: " + reason.message); + //growl.error("Exporting as PDF file Failed: " + reason.message); }); })); @@ -263,9 +263,9 @@ angular.module('mmsApp') return; MmsAppUtils.printModal(viewOb, refOb, false, 2) .then(function(ob) { - growl.info('Exporting as Word file. Please wait for a completion email.',{ttl: -1}); + //growl.info('Exporting as Word file. Please wait for a completion email.',{ttl: -1}); }, function(reason){ - growl.error("Exporting as Word file Failed: " + reason.message); + //growl.error("Exporting as Word file Failed: " + reason.message); }); })); diff --git a/app/partials/mms/printConfirm.html b/app/partials/mms/printConfirm.html index 923f91fe1..d9c4cdc4e 100644 --- a/app/partials/mms/printConfirm.html +++ b/app/partials/mms/printConfirm.html @@ -16,10 +16,10 @@

{{action}} {{type | lowercase}}

- Click on {{action | uppercase}} to generate a {{label}} of this view (it will not include table of contents or cover pages). You will receive an email with subject line "HTML to {{label}} generation completed" with a link to the generated {{label | uppercase}}. If you want the full document instead, please click on GO TO FULL DOCUMENT. + Click on {{action | uppercase}} to generate a {{label}} of this view (it will not include table of contents or cover pages). If you want the full document instead, please click on GO TO FULL DOCUMENT. - Please wait until the full document appears in this pane before continuing. You will receive an email with subject line "HTML to {{label}} generation completed" with a link to the generated {{label}}. + Please wait until the full document appears in this pane before continuing.

diff --git a/src/services/URLService.js b/src/services/URLService.js index 7dadea383..338175d19 100644 --- a/src/services/URLService.js +++ b/src/services/URLService.js @@ -4,14 +4,18 @@ angular.module('mms') .provider('URLService', function URLServiceProvider() { var baseUrl = '/api'; var mmsUrl = 'localhost:8080'; + var printUrl = 'http://localhost:8080/convert'; this.setBaseUrl = function (base) { baseUrl = base; }; this.setMmsUrl = function (mms) { mmsUrl = mms; }; + this.setPrintUrl = function (print) { + printUrl = print; + }; this.$get = [function URLServiceFactory() { - return urlService(baseUrl, mmsUrl); + return urlService(baseUrl, mmsUrl, printUrl); }]; }); @@ -37,9 +41,8 @@ angular.module('mms') * (You may run into problems like cross origin security policy that prevents it from * actually getting the resources from a different server, solution TBD) */ -function urlService(baseUrl, mmsUrl) { +function urlService(baseUrl, mmsUrl, printUrl) { var root = mmsUrl + baseUrl; - var jobsRoot = 'https://cae-pma-int:8443/'; var token; var getRoot = function() { @@ -149,9 +152,8 @@ function urlService(baseUrl, mmsUrl) { * @param {string} refId id of the ref * @returns {string} The url */ - var getExportHtmlUrl = function(projectId, refId) { - return root + "/projects/" + projectId + - "/refs/" + refId + '/convert'; + var getExportHtmlUrl = function() { + return printUrl; }; diff --git a/src/services/UtilsService.js b/src/services/UtilsService.js index 2285b9967..0e30d9191 100644 --- a/src/services/UtilsService.js +++ b/src/services/UtilsService.js @@ -1324,14 +1324,21 @@ function UtilsService($q, $http, CacheService, URLService, ApplicationService, _ accept = 'application/pdf'; } var deferred = $q.defer(); - $http.post(URLService.getExportHtmlUrl(data.projectId, data.refId), { - 'Content-Type' : 'text/html', - 'Accepts' : accept, - 'body': data.htmlString, - 'name': data.name, - 'css': data.css + $http.post(URLService.getExportHtmlUrl(), { + 'html': data.htmlString, + 'css': data.css, + 'format': exportType == 2 ? 'docx' : 'pdf' + }, { + responseType: 'blob' }) - .then(function() { + .then(function(data2) { + var blob = new Blob([data2.data], {type: accept}); + var a = window.document.createElement('a'); + var url = window.URL.createObjectURL(blob); + a.href = url; + a.download = data.name + (exportType == 2 ? '.docx' : '.pdf'); + a.click(); + window.URL.revokeObjectURL(url); deferred.resolve('ok'); }, function(error) { URLService.handleHttpStatus(error.data, error.status, error.headers, error.config, deferred);