Skip to content

Commit

Permalink
SED-1022 Disabling 'Import all entities' per default and implementing…
Browse files Browse the repository at this point in the history
… progress bar on import/export screens
  • Loading branch information
jeromecomte committed May 25, 2022
1 parent 92710a5 commit b3ef280
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -625,16 +625,16 @@ 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',
controller: 'importModalCtrl',
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;
}
Expand All @@ -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) {
Expand All @@ -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',
Expand All @@ -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;
}
Expand All @@ -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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
})
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ <h3 class="modal-title">{{title}}</h3>
</div>

<div class="modal-body">
<div ng-if="exporting" class="alert alert-info ">Exporting, please wait...</div>
<div class="section">
<div class="section-content section-highlight">
<div class="form-group form-group-sm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ <h3 class="modal-title">{{title}}</h3>
</div>

<div class="modal-body">
<div ng-if="importing" class="alert alert-info ">Importing, please wait...</div>
<div class="section">
<div class="section-content section-highlight">
<div class="form-group form-group-sm">
Expand Down

0 comments on commit b3ef280

Please sign in to comment.