fix: asynchronous expand path was not handled correctly

This commit is contained in:
ziirish 2016-09-14 09:06:00 +02:00
parent 284c171151
commit 06f4964015
2 changed files with 26 additions and 21 deletions

View file

@ -126,10 +126,10 @@ var errorsHandler = function(json) {
} catch(err) {
message = Array();
if (typeof(json.message) == 'string') {
message.push([2, json.message]);
message.push([NOTIF_ERROR, json.message]);
} else {
for (field in json.message) {
message.push([2, field+': '+json.message[field]]);
message.push([NOTIF_ERROR, field+': '+json.message[field]]);
}
}
}

View file

@ -351,26 +351,31 @@ app.controller('ConfigCtrl', ['$scope', '$http', '$scrollspy', function($scope,
api = '{{ url_for("api.path_expander", server=server, source=conf) }}';
{% endif -%}
$scope.inc_invalid = {};
$.ajax({
url: api,
type: 'GET',
data: {'path': path},
headers: { 'X-From-UI': true },
})
.fail(myFail)
.done(function(data) {
/* The server answered correctly but some errors may have occurred server
* side so we display them */
if (data.notif) {
notifAll(data.notif)
$scope.inc_invalid[index] = true;
} else if (data.result) {
$scope.paths[index] = [];
$.each(data.result, function(i, p) {
$scope.paths[index].push(p);
});
$http.get(
api,
{
headers: { 'X-From-UI': true },
params: { 'path': path },
}
).then(
function(response) {
data = response.data;
/* The server answered correctly but some errors may have occurred server
* side so we display them */
if (data.notif) {
notifAll(data.notif)
$scope.inc_invalid[index] = true;
} else if (data.result) {
$scope.paths[index] = [];
$.each(data.result, function(i, p) {
$scope.paths[index].push(p);
});
}
},
function(response) {
errorsHandler(response.data);
}
});
);
};
$scope.getClientsList = function() {
api = '{{ url_for("api.clients_list", server=server) }}';