diff --git a/awx/ui/static/lib/ansible/TreeSelector.js.backup b/awx/ui/static/lib/ansible/TreeSelector.js.backup deleted file mode 100644 index b979af57ba..0000000000 --- a/awx/ui/static/lib/ansible/TreeSelector.js.backup +++ /dev/null @@ -1,279 +0,0 @@ - -/************************************ - * - * Copyright (c) 2013 AnsibleWorks, Inc. - * - * TreeSelector.js - * - */ - -angular.module('TreeSelector', ['Utilities', 'RestServices']) - .factory('BuildTree', ['Rest', 'GetBasePath', 'ProcessErrors', '$compile', '$rootScope', 'Wait', 'SortNodes', - function(Rest, GetBasePath, ProcessErrors, $compile, $rootScope, Wait, SortNodes) { - return function(params) { - - var scope = params.scope; - var inventory_id = params.inventory_id; - var emit_on_select = params.emit_on_select; - var target_id = params.target_id; - var refresh_tree = (params.refresh == undefined || params.refresh == false) ? false : true; - - var html = ''; - var toolTip = 'Hosts have failed jobs?'; - var idx = 0; - var level = 0; - - function refresh(parent) { - var group, title; - var id = parent.attr('id'); - if (parent.attr('data-group-id')) { - group = parent.attr('data-group-id'); - title = parent.attr('data-name'); - } - else { - group = null; - title = 'All Hosts' - } - // The following will trigger the host list to load. See Inventory.js controller. - scope.$emit(emit_on_select, id, group, title); - } - - function activate(e) { - /* Set the clicked node as active */ - var elm = angular.element(e.target); // - var parent = angular.element(e.target.parentNode.parentNode); //
  • - $('.search-tree .active').removeClass('active'); - elm.addClass('active'); - refresh(parent); - } - - function toggle(e) { - var id, parent, elm, icon; - - if (e.target.tagName == 'I') { - id = e.target.parentNode.parentNode.parentNode.attributes.id.value; - parent = angular.element(e.target.parentNode.parentNode.parentNode); //
  • - elm = angular.element(e.target.parentNode); // - } - else { - id = e.target.parentNode.parentNode.attributes.id.value; - parent = angular.element(e.target.parentNode.parentNode); - elm = angular.element(e.target); - } - - var sibling = angular.element(parent.children()[2]); // - var state = parent.attr('data-state'); - var icon = angular.element(elm.children()[0]); - - if (state == 'closed') { - // expand the elment - var childlists = parent.find('ul'); - if (childlists && childlists.length > 0) { - // has childen - for (var i=0; i < childlists.length; i++) { - var listChild = angular.element(childlists[i]); - var listParent = angular.element(listChild.parent()); - if (listParent.attr('id') == id) { - angular.element(childlists[i]).removeClass('hidden'); - } - } - } - parent.attr('data-state','open'); - icon.removeClass('icon-caret-right').addClass('icon-caret-down'); - } - else { - // close the element - parent.attr('data-state','closed'); - icon.removeClass('icon-caret-down').addClass('icon-caret-right'); - var childlists = parent.find('ul'); - if (childlists && childlists.length > 0) { - // has childen - for (var i=0; i < childlists.length; i++) { - angular.element(childlists[i]).addClass('hidden'); - } - } - /* When the active node's parent is closed, activate the parent */ - if ($(parent).find('.active').length > 0) { - $(parent).find('.active').removeClass('active'); - sibling.addClass('active'); - refresh(parent); - } - } - } - - // The HTML is ready. Insert it into the view. - if (scope.searchTreeReadyRemove) { - scope.searchTreeReadyRemove(); - } - scope.searchTreeReadyRemove = scope.$on('searchTreeReady', function(e, html) { - var container = angular.element(document.getElementById(target_id)); - container.empty(); - var compiled = $compile(html)(scope); - container.append(compiled); - var links = container.find('a'); - for (var i=0; i < links.length; i++) { - var link = angular.element(links[i]); - if (link.hasClass('expand')) { - link.unbind('click', toggle); - link.bind('click', toggle); - } - if (link.hasClass('activate')) { - link.unbind('click', activate); - link.bind('click', activate); - //link.parent().parent().draggable({ containment: target_id }); - } - } - - $('#inventory-tree').sortable(); - - // Attempt to stop the title from dropping to the next - // line - $(container).find('.title-container').each(function(idx) { - var parent = $(this).parent(); - if ($(this).width() >= parent.width()) { - $(this).css('width','80%'); - } - }); - - Wait('stop'); - }); - - function buildHTML(data) { - //var sorted = SortNodes(tree_data); - var node; - for (var i=0; i < data.length; i++) { - node = data[i]; - html += "
  • " + - "
    " + - "
    " + node.name + "
    " + - "
  • \n"; - idx++; - if (node.children.length > 0) { - level++; - buildHTML(node.children); - } - else { - level=1; - } - } - } - - // Build the HTML for our tree - if (scope.buildAllGroupsRemove) { - scope.buildAllGroupsRemove(); - } - scope.buildAllGroupsRemove = scope.$on('buildAllGroups', function(e, inventory_name, inventory_tree) { - Rest.setUrl(inventory_tree); - Rest.get() - .success( function(data, status, headers, config) { - level=1; - buildHTML(data); - scope.$emit('searchTreeReady', html + "\n"); - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Failed to get inventory tree for: ' + inventory_id + '. GET returned: ' + status }); - }); - }); - - // Builds scope.inventory_groups, used by the group picker on Hosts view to build the list of potential groups - // that can be added to a host. <<<< Should probably be moved to /helpers/Hosts.js - if (scope.buildGroupListRemove) { - scope.buildGroupListRemove(); - } - scope.buildGroupListRemove = scope.$on('buildAllGroups', function(e, inventory_name, inventory_tree, groups_url) { - scope.inventory_groups = []; - Rest.setUrl(groups_url); - Rest.get() - .success( function(data, status, headers, config) { - var groups = []; - for (var i=0; i < data.results.length; i++) { - groups.push({ - id: data.results[i].id, - description: data.results[i].description, - name: data.results[i].name }); - } - scope.inventory_groups = SortNodes(groups); - }) - .error( function(data, status, headers, config) { - ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Failed to get groups for inventory: ' + inventory_id + '. GET returned: ' + status }); - }); - }); - - Wait('start'); - - // Load the inventory root node - Rest.setUrl (GetBasePath('inventory') + inventory_id + '/'); - Rest.get() - .success( function(data, status, headers, config) { - html += "
    Group Selector:
    \n" + - "