diff --git a/awx/ui/client/src/network-ui/network.ui.controller.js b/awx/ui/client/src/network-ui/network.ui.controller.js index cd75aa6b9f..881841e13b 100644 --- a/awx/ui/client/src/network-ui/network.ui.controller.js +++ b/awx/ui/client/src/network-ui/network.ui.controller.js @@ -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 $scope.inventory_toolbox = new models.ToolBox(0, 'Inventory', 'device', 0, toolboxTopMargin, 200, toolboxHeight); if (!$scope.disconnected) { - $http.get('/api/v2/inventories/' + $scope.inventory_id + '/hosts/') - .then(function(response) { - var devices_by_name = {}; - 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; + $scope.for_each_page('/api/v2/inventories/' + $scope.inventory_id + '/hosts/', + function(all_results) { + let hosts = all_results; console.log(hosts.length); - for(i = 0; i { - ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get host data: ' + status }); - }); + }, 100); } $scope.inventory_toolbox.spacing = 150; $scope.inventory_toolbox.enabled = true; @@ -919,8 +931,7 @@ var NetworkUIController = function($scope, $scope.test_channel.send("EnableTest", new messages.EnableTest()); }; - $scope.all_buttons = []; - $scope.all_buttons.extend($scope.context_menu_buttons); + $scope.all_buttons = $scope.context_menu_buttons; $scope.onDeviceCreate = function(data) { $scope.create_device(data); diff --git a/awx/ui/client/src/network-ui/tools/fsm_generate_diffs.py b/awx/ui/client/src/network-ui/tools/fsm_generate_diffs.py index fd221a81c9..b5df78c419 100755 --- a/awx/ui/client/src/network-ui/tools/fsm_generate_diffs.py +++ b/awx/ui/client/src/network-ui/tools/fsm_generate_diffs.py @@ -49,7 +49,7 @@ def main(args=None): with open(parsed_args['']) as f: a = yaml.load(f.read()) - data = fsm_diff.cli.fsm_diff(a, b) + data = fsm_diff.cli.fsm_diff(parsed_args[''], parsed_args[''], a, b) data = transform_fsm.transform_fsm(data) env = Environment(loader=FileSystemLoader("templates")) diff --git a/awx/ui/client/src/network-ui/util.js b/awx/ui/client/src/network-ui/util.js index bf11beebb6..f732f7bcf5 100644 --- a/awx/ui/client/src/network-ui/util.js +++ b/awx/ui/client/src/network-ui/util.js @@ -1,12 +1,4 @@ /* 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'); function noop () {