mirror of
https://github.com/ansible/awx.git
synced 2026-05-16 05:47:38 -02:30
fixed inv vars on UI
This commit is contained in:
@@ -424,44 +424,19 @@ export function InventoriesAdd($scope, $rootScope, $compile, $location, $log, $r
|
|||||||
|
|
||||||
data = {};
|
data = {};
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (fld !== 'variables') {
|
if (form.fields[fld].realName) {
|
||||||
if (form.fields[fld].realName) {
|
data[form.fields[fld].realName] = $scope[fld];
|
||||||
data[form.fields[fld].realName] = $scope[fld];
|
} else {
|
||||||
} else {
|
data[fld] = $scope[fld];
|
||||||
data[fld] = $scope[fld];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.removeUpdateInventoryVariables) {
|
|
||||||
$scope.removeUpdateInventoryVariables();
|
|
||||||
}
|
|
||||||
$scope.removeUpdateInventoryVariables = $scope.$on('UpdateInventoryVariables', function(e, data) {
|
|
||||||
var inventory_id = data.id;
|
|
||||||
var vars_to_send = {"variables": json_data};
|
|
||||||
Rest.setUrl(data.related.variable_data);
|
|
||||||
Rest.put(vars_to_send)
|
|
||||||
.success(function () {
|
|
||||||
Wait('stop');
|
|
||||||
$location.path('/inventories/' + inventory_id + '/manage');
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors( $scope, data, status, null, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to update inventory varaibles. PUT returned status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
var inventory_id = data.id;
|
var inventory_id = data.id;
|
||||||
if ($scope.variables) {
|
Wait('stop');
|
||||||
$scope.$emit('UpdateInventoryVariables', data);
|
$location.path('/inventories/' + inventory_id + '/');
|
||||||
} else {
|
|
||||||
Wait('stop');
|
|
||||||
$location.path('/inventories/' + inventory_id + '/');
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors( $scope, data, status, form, { hdr: 'Error!',
|
ProcessErrors( $scope, data, status, form, { hdr: 'Error!',
|
||||||
@@ -597,40 +572,18 @@ export function InventoriesEdit($scope, $rootScope, $compile, $location, $log, $
|
|||||||
|
|
||||||
data = {};
|
data = {};
|
||||||
for (fld in form.fields) {
|
for (fld in form.fields) {
|
||||||
if (fld !== 'variables') {
|
if (form.fields[fld].realName) {
|
||||||
if (form.fields[fld].realName) {
|
data[form.fields[fld].realName] = $scope[fld];
|
||||||
data[form.fields[fld].realName] = $scope[fld];
|
} else {
|
||||||
} else {
|
data[fld] = $scope[fld];
|
||||||
data[fld] = $scope[fld];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($scope.removeUpdateInventoryVariables) {
|
|
||||||
$scope.removeUpdateInventoryVariables();
|
|
||||||
}
|
|
||||||
$scope.removeUpdateInventoryVariables = $scope.$on('UpdateInventoryVariables', function(e, data) {
|
|
||||||
Rest.setUrl(data.related.variable_data);
|
|
||||||
Rest.put(json_data)
|
|
||||||
.success(function () {
|
|
||||||
Wait('stop');
|
|
||||||
$location.path('/inventories/');
|
|
||||||
})
|
|
||||||
.error(function (data, status) {
|
|
||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
|
||||||
msg: 'Failed to update inventory varaibles. PUT returned status: ' + status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
Rest.setUrl(defaultUrl + inventory_id + '/');
|
Rest.setUrl(defaultUrl + inventory_id + '/');
|
||||||
Rest.put(data)
|
Rest.put(data)
|
||||||
.success(function (data) {
|
.success(function () {
|
||||||
if ($scope.variables) {
|
Wait('stop');
|
||||||
$scope.$emit('UpdateInventoryVariables', data);
|
$location.path('/inventories/');
|
||||||
} else {
|
|
||||||
$location.path('/inventories/');
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.error(function (data, status) {
|
.error(function (data, status) {
|
||||||
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
ProcessErrors($scope, data, status, form, { hdr: 'Error!',
|
||||||
|
|||||||
Reference in New Issue
Block a user