Commit 2d1b3e00 authored by Samuel GAIST's avatar Samuel GAIST Committed by Flavio TARSETTI

[plotters][static][app] Fix handling of $http promise

The success/error handlers have been deprecated and removed.
This patch updates the code using them.
parent 1aff0440
Pipeline #42755 passed with stage
in 15 minutes and 16 seconds
......@@ -60,19 +60,19 @@ app.controller('plotterparameterController',['$scope', 'plotterFactory', 'plotte
function getPlottersData(user)
{
plotterFactory.getPlottersInformation(user, $scope.url_prefix)
.success(function (plottersData)
{
$scope.plotters = plottersData;
for(var init_selected_plotter in plottersData)
{
$scope.plotters.selected = init_selected_plotter.name;
}
})
.error(function (error)
{
$scope.status = 'Unable to load report data: ' + error.message;
});
plotterFactory.getPlottersInformation(user, $scope.url_prefix)
.then(
function (response) {
var plottersData = response.data;
$scope.plotters = plottersData;
for(var init_selected_plotter in plottersData) {
$scope.plotters.selected = init_selected_plotter.name;
}
},
function (error) {
$scope.status = 'Unable to load report data: ' + error.data;
}
);
$('#tabs_progress').hide();
}
......@@ -80,51 +80,51 @@ app.controller('plotterparameterController',['$scope', 'plotterFactory', 'plotte
function getPlotterParameterData(user, plotterparameter_user, plotterparameter_name, plotterparameter_version)
{
plotterparameterFactory.getPlotterParameterInformation(user, plotterparameter_user, plotterparameter_name, plotterparameter_version, $scope.url_prefix)
.success(function (plotterparameterData)
{
$scope.plotters = plotterparameterData.plotters;
for(var init_selected_plotter in plotterparameterData.plotters)
{
$scope.plotters.selected = init_selected_plotter;
}
$scope.plotterparameterData = plotterparameterData;
.then(
function (response) {
var plotterparameterData = response.data;
$scope.plotters = plotterparameterData.plotters;
for(var init_selected_plotter in plotterparameterData.plotters)
{
$scope.plotters.selected = init_selected_plotter;
}
$scope.plotterparameterData = plotterparameterData;
if(plotterparameterData.plotter != "undefined plotter")
{
//Find selected plotter
$.each(plotterparameterData.plotters, function( key, value ) {
if(plotterparameterData.plotter != "undefined plotter")
{
//Find selected plotter
$.each(plotterparameterData.plotters, function( key, value ) {
if(key == plotterparameterData.plotter)
{
$scope.plotters.selected = value;
//break
return false;
}
});
if(key == plotterparameterData.plotter)
{
$scope.plotters.selected = value;
//break
return false;
}
});
$.each($scope.plotters.selected.declaration.parameters, function( key, value ) {
//push all keys in array
$scope.textdata.push(key);
$.each($scope.plotters.selected.declaration.parameters, function( key, value ) {
//push all keys in array
$scope.textdata.push(key);
//check if already saved key/values for this plotterparameter and add
$.each($scope.plotterparameterData.data, function(keysaved, valuesaved){
if(key == keysaved)
{
$scope.plotterparams_update[keysaved] = valuesaved;
return false;
}
//check if already saved key/values for this plotterparameter and add
$.each($scope.plotterparameterData.data, function(keysaved, valuesaved){
if(key == keysaved)
{
$scope.plotterparams_update[keysaved] = valuesaved;
return false;
}
});
});
//$scope.textdata = $scope.plotters.selected.declaration.parameters;
});
});
//$scope.textdata = $scope.plotters.selected.declaration.parameters;
addParametersToEditor();
addParametersToEditor();
}
}, function (response) {
$scope.status = 'Unable to load report data: ' + response.data;
}
})
.error(function (error)
{
$scope.status = 'Unable to load report data: ' + error.message;
});
);
$('#tabs_progress').hide();
}
......
......@@ -194,14 +194,14 @@ app.directive("saveplotterparameter", function()
function updatePlotterParameter()
{
scope.plotterparameterFactory.updatePlotterParameter(scope.user, scope.plotterparameter_user, scope.plotterparameter_name, scope.plotterparameter_version, scope.plotterparameterData, scope.url_prefix)
.success(function (returnedData)
{
beat.ui.plotterparameter.plotterparameter_saved('plotterparameter_saved', scope);
})
.error(function (error)
{
scope.status = 'Unable to update plotterparameter data: ' + error.message;
});
.then(
function (response) {
beat.ui.plotterparameter.plotterparameter_saved('plotterparameter_saved', scope);
},
function (error) {
scope.status = 'Unable to update plotterparameter data: ' + error.data;
}
);
}
......@@ -241,23 +241,22 @@ app.directive("createplotterparameter", function()
function createPlotterParameter()
{
scope.plotterparams_update['version'] = 1;
scope.plotterparameterFactory.createPlotterParameter(scope.user, scope.plotterparams_update, scope.url_prefix)
.success(function (returnedData)
{
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
})
.error(function (error)
{
var error_text = "";
$.each(error, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
});
.then(
function (response) {
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
},
function (error) {
var error_text = "";
$.each(error.data, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
}
);
}
}
......@@ -304,22 +303,21 @@ app.directive("createplotterparameternewversion", function()
function createPlotterParameter()
{
scope.plotterparameterFactory.createPlotterParameter(scope.user, scope.plotterparams_newversion, scope.url_prefix)
.success(function (returnedData)
{
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
})
.error(function (error)
{
var error_text = "";
$.each(error, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
});
.then(
function (response) {
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
},
function (response) {
var error_text = "";
$.each(response.data, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
}
);
}
}
......@@ -371,22 +369,21 @@ app.directive("createplotterparameterfork", function()
function createPlotterParameter()
{
scope.plotterparameterFactory.createPlotterParameter(scope.user, scope.plotterparams_fork, scope.url_prefix)
.success(function (returnedData)
{
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
})
.error(function (error)
{
var error_text = "";
$.each(error, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
});
.then(
function (response) {
beat.ui.plotterparameter.plotterparameter_created('plotterparameter_created', scope);
},
function (response) {
var error_text = "";
$.each(response.data, function( key, value ) {
error_text += key + ": " + value;
});
scope.status = 'Unable to create plotterparameter:\n' + error_text;
alert(scope.status);
}
);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment