mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 01:17:37 -02:30
Improves pagination unrolling based on jmcdermott's feedback
* Fixes pagination and fsm-diff * Removes unused Array.extend
This commit is contained in:
@@ -244,19 +244,34 @@ var NetworkUIController = function($scope,
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.for_each_page = function(url, callback, limit) {
|
||||||
|
|
||||||
|
function rec(url, rec_limit) {
|
||||||
|
if (rec_limit <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$http.get(url)
|
||||||
|
.then(function(response) {
|
||||||
|
callback(response.data.results);
|
||||||
|
if (response.data.next) {
|
||||||
|
rec(response.data.next, rec_limit-1);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(({data, status}) => {
|
||||||
|
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get host data: ' + status });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
rec(url, limit);
|
||||||
|
};
|
||||||
|
|
||||||
//Inventory Toolbox Setup
|
//Inventory Toolbox Setup
|
||||||
$scope.inventory_toolbox = new models.ToolBox(0, 'Inventory', 'device', 0, toolboxTopMargin, 200, toolboxHeight);
|
$scope.inventory_toolbox = new models.ToolBox(0, 'Inventory', 'device', 0, toolboxTopMargin, 200, toolboxHeight);
|
||||||
if (!$scope.disconnected) {
|
if (!$scope.disconnected) {
|
||||||
$http.get('/api/v2/inventories/' + $scope.inventory_id + '/hosts/')
|
$scope.for_each_page('/api/v2/inventories/' + $scope.inventory_id + '/hosts/',
|
||||||
.then(function(response) {
|
function(all_results) {
|
||||||
var devices_by_name = {};
|
let hosts = all_results;
|
||||||
var i = 0;
|
|
||||||
for (i = 0; i < $scope.devices.length; i++) {
|
|
||||||
devices_by_name[$scope.devices[i].name] = $scope.devices[i];
|
|
||||||
}
|
|
||||||
let hosts = response.data.results;
|
|
||||||
console.log(hosts.length);
|
console.log(hosts.length);
|
||||||
for(i = 0; i<hosts.length; i++) {
|
for(var i = 0; i<hosts.length; i++) {
|
||||||
console.log(i);
|
console.log(i);
|
||||||
try {
|
try {
|
||||||
let device_type = null;
|
let device_type = null;
|
||||||
@@ -282,7 +297,7 @@ var NetworkUIController = function($scope,
|
|||||||
|
|
||||||
$scope.update_links_in_vars_by_device(device_name, host.data);
|
$scope.update_links_in_vars_by_device(device_name, host.data);
|
||||||
}
|
}
|
||||||
if (devices_by_name[device_name] === undefined) {
|
if ($scope.devices_by_name[device_name] === undefined) {
|
||||||
console.log(['adding', device_name]);
|
console.log(['adding', device_name]);
|
||||||
device = new models.Device(0, device_name, 0, 0, device_type, host.id);
|
device = new models.Device(0, device_name, 0, 0, device_type, host.id);
|
||||||
device.icon = true;
|
device.icon = true;
|
||||||
@@ -293,10 +308,7 @@ var NetworkUIController = function($scope,
|
|||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}, 100);
|
||||||
.catch(({data, status}) => {
|
|
||||||
ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get host data: ' + status });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
$scope.inventory_toolbox.spacing = 150;
|
$scope.inventory_toolbox.spacing = 150;
|
||||||
$scope.inventory_toolbox.enabled = true;
|
$scope.inventory_toolbox.enabled = true;
|
||||||
@@ -919,8 +931,7 @@ var NetworkUIController = function($scope,
|
|||||||
$scope.test_channel.send("EnableTest", new messages.EnableTest());
|
$scope.test_channel.send("EnableTest", new messages.EnableTest());
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.all_buttons = [];
|
$scope.all_buttons = $scope.context_menu_buttons;
|
||||||
$scope.all_buttons.extend($scope.context_menu_buttons);
|
|
||||||
|
|
||||||
$scope.onDeviceCreate = function(data) {
|
$scope.onDeviceCreate = function(data) {
|
||||||
$scope.create_device(data);
|
$scope.create_device(data);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ def main(args=None):
|
|||||||
with open(parsed_args['<design>']) as f:
|
with open(parsed_args['<design>']) as f:
|
||||||
a = yaml.load(f.read())
|
a = yaml.load(f.read())
|
||||||
|
|
||||||
data = fsm_diff.cli.fsm_diff(a, b)
|
data = fsm_diff.cli.fsm_diff(parsed_args['<design>'], parsed_args['<implementation>'], a, b)
|
||||||
data = transform_fsm.transform_fsm(data)
|
data = transform_fsm.transform_fsm(data)
|
||||||
|
|
||||||
env = Environment(loader=FileSystemLoader("templates"))
|
env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
/* Copyright (c) 2017 Red Hat, Inc. */
|
/* Copyright (c) 2017 Red Hat, Inc. */
|
||||||
Array.prototype.extend = function (other_array) {
|
|
||||||
/* you should include a test to check whether other_array really is an array */
|
|
||||||
var i = 0;
|
|
||||||
for (i = 0; i < other_array.length; i++) {
|
|
||||||
this.push(other_array[i]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var math = require('mathjs');
|
var math = require('mathjs');
|
||||||
|
|
||||||
function noop () {
|
function noop () {
|
||||||
|
|||||||
Reference in New Issue
Block a user