From b3ef28000ba297cc41ac9a1f3b9d00a258f5b529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Comte?= Date: Wed, 25 May 2022 08:09:57 +0200 Subject: [PATCH] SED-1022 Disabling 'Import all entities' per default and implementing progress bar on import/export screens --- .../src/main/resources/webapp/js/app.js | 22 ++++++++----------- .../webapp/js/controllers/functions.js | 6 ++--- .../webapp/js/controllers/parameters.js | 4 ++-- .../webapp/js/controllers/planEditor.js | 2 +- .../resources/webapp/js/controllers/plans.js | 6 ++--- .../src/main/resources/webapp/js/export.js | 13 ++++++----- .../webapp/partials/exportDialog.html | 1 + .../webapp/partials/importDialog.html | 1 + 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/app.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/app.js index 9cfc389e1..9dd35dd7e 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/app.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/app.js @@ -625,7 +625,7 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) .factory('ImportDialogs', function ($rootScope, $uibModal, EntityRegistry,$sce) { var dialogs = {}; - dialogs.displayImportDialog = function(title,path,importAll,overwrite) { + dialogs.displayImportDialog = function(title,path) { var modalInstance = $uibModal.open({ backdrop: 'static', templateUrl: 'partials/importDialog.html', @@ -633,8 +633,8 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) resolve: { title: function() {return title;}, path: function() {return path;}, - importAll: function() {return importAll;}, - overwrite: function() {return overwrite;}} + importAll: function() {return false;}, + overwrite: function() {return false;}} }); return modalInstance.result; } @@ -651,6 +651,7 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) $scope.save = function() { if($scope.resourcePath) { + $scope.importing = true; $http({url:"rest/import/" + path,method:"POST",params:{path:$scope.resourcePath,importAll:$scope.importAll,overwrite:$scope.overwrite}}).then(function(response) { $uibModalInstance.close(response.data); if (response.data && response.data.length > 0) { @@ -670,7 +671,7 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) .factory('ExportDialogs', function ($rootScope, $uibModal, EntityRegistry,$sce) { var dialogs = {}; - dialogs.displayExportDialog = function(title, path, filename, recursively, parameters) { + dialogs.displayExportDialog = function(title, path, filename) { var modalInstance = $uibModal.open({ backdrop: 'static', templateUrl: 'partials/exportDialog.html', @@ -679,8 +680,8 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) title: function() {return title;}, path: function() {return path;}, filename: function() {return filename;}, - recursively: function() {return recursively;}, - parameters: function() {return parameters;}} + recursively: function() {return false;}, + parameters: function() {return false;}} }); return modalInstance.result; } @@ -696,18 +697,13 @@ angular.module('step',['ngStorage','ngCookies','angularResizable']) $scope.parameters = parameters; $scope.save = function() { + $scope.exporting = true; if($scope.filename) { urlParams = "?recursively=" + $scope.recursively + "&filename=" + $scope.filename; if ($scope.parameters) { urlParams += "&additionalEntities=parameters" } - ExportService.get("rest/export/" + $scope.path + urlParams); - $uibModalInstance.close(); - - - /* $http({url:"rest/import/" + path,method:"POST",params:{path:$scope.resourcePath,importAll:$scope.importAll,overwrite:$scope.overwrite}}).then(function(response) { - $uibModalInstance.close(response.data); - })*/ + ExportService.get("rest/export/" + $scope.path + urlParams, () => $uibModalInstance.close()); } else { Dialogs.showErrorMsg("Upload not completed."); } diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/functions.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/functions.js index 21a8bf0b8..9b8a5cafe 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/functions.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/functions.js @@ -193,17 +193,17 @@ angular.module('functionsControllers',['step']) } $scope.importFunctions = function() { - ImportDialogs.displayImportDialog('Keyword import','functions', true).then(function () { + ImportDialogs.displayImportDialog('Keyword import','functions').then(function () { reload(); }); } $scope.exportFunction = function(id, name) { - ExportDialogs.displayExportDialog('Keywords export','functions/' + id, name + '.sta', true).then(function () {}) + ExportDialogs.displayExportDialog('Keywords export','functions/' + id, name + '.sta').then(function () {}) } $scope.exportFunctions = function() { - ExportDialogs.displayExportDialog('Keywords export','functions', 'allKeywords.sta', true).then(function () {}) + ExportDialogs.displayExportDialog('Keywords export','functions', 'allKeywords.sta').then(function () {}) } $scope.lookUp = function(id) { diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/parameters.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/parameters.js index 7abebf5f1..bdf625b4b 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/parameters.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/parameters.js @@ -61,13 +61,13 @@ angular.module('parametersControllers',['tables','step','screenConfigurationCont } $scope.importParameters = function() { - ImportDialogs.displayImportDialog('Parameters import','parameters',true).then(function () { + ImportDialogs.displayImportDialog('Parameters import','parameters').then(function () { reload(); }); } $scope.exportParameters = function() { - ExportDialogs.displayExportDialog('Parameters export','parameters', 'allParameters.sta', true).then(function () {}) + ExportDialogs.displayExportDialog('Parameters export','parameters', 'allParameters.sta').then(function () {}) } $scope.$on("parameter.edited",function(evt,data){ diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/planEditor.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/planEditor.js index 8068bf7ba..fc9836608 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/planEditor.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/planEditor.js @@ -86,7 +86,7 @@ angular.module('planEditor',['step','artefacts','reportTable','dynamicForms','ex }); $scope.exportPlan = function() { - ExportDialogs.displayExportDialog('Plans export','plans/'+$scope.planId, $scope.model.plan.attributes.name+'.sta', true, false).then(function () {}) + ExportDialogs.displayExportDialog('Plans export','plans/'+$scope.planId, $scope.model.plan.attributes.name+'.sta').then(function () {}) } $scope.clonePlan = function() { diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/plans.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/plans.js index 789c72330..80f212450 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/plans.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/controllers/plans.js @@ -111,17 +111,17 @@ angular.module('plans',['tables','step','screenConfigurationControllers']) } $scope.importPlans = function() { - ImportDialogs.displayImportDialog('Plans import','plans', true, false).then(function () { + ImportDialogs.displayImportDialog('Plans import','plans').then(function () { reload(); }); } $scope.exportPlans = function() { - ExportDialogs.displayExportDialog('Plans export','plans', 'allPlans.sta', true, false).then(function () {}) + ExportDialogs.displayExportDialog('Plans export','plans', 'allPlans.sta').then(function () {}) } $scope.exportPlan = function(id, name) { - ExportDialogs.displayExportDialog('Plans export','plans/'+id, name+'.sta', true, false).then(function () {}) + ExportDialogs.displayExportDialog('Plans export','plans/'+id, name+'.sta').then(function () {}) } $scope.lookUp = function(id) { diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/export.js b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/export.js index b853724d1..6dae35be4 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/export.js +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/js/export.js @@ -21,13 +21,16 @@ angular.module('export',[]) .factory('ExportService', function($http,$timeout, Dialogs) { var factory = {}; - factory.pollUrl = function(exportUrl) { + factory.pollUrl = function(exportUrl, callback) { var pollCount = 0; (function poll() { $http.get(exportUrl).then(function (response) { pollCount++; var status = response.data; if(status.ready) { + if(callback) { + callback(); + } var attachmentID = status.attachmentID; if (status.warnings !== undefined && status.warnings !== null && status.warnings.length > 0) { @@ -63,14 +66,14 @@ angular.module('export',[]) .fail(function () { alert('File download failed!'); }); } - factory.poll = function(exportId) { - factory.pollUrl('rest/export/'+exportId+'/status'); + factory.poll = function(exportId, callback) { + factory.pollUrl('rest/export/'+exportId+'/status', callback); } - factory.get = function (exportUrl) { + factory.get = function (exportUrl, callback) { $http.get(exportUrl).then(function(response){ var exportStatus = response.data; - factory.poll(exportStatus.id); + factory.poll(exportStatus.id, callback); }) }; diff --git a/step-controller/step-controller-server-webapp/src/main/resources/webapp/partials/exportDialog.html b/step-controller/step-controller-server-webapp/src/main/resources/webapp/partials/exportDialog.html index f38be9faf..bb94cf27e 100644 --- a/step-controller/step-controller-server-webapp/src/main/resources/webapp/partials/exportDialog.html +++ b/step-controller/step-controller-server-webapp/src/main/resources/webapp/partials/exportDialog.html @@ -3,6 +3,7 @@