app/assets/javascripts/katello/providers/provider_redhat.js in katello-1.5.0 vs app/assets/javascripts/katello/providers/provider_redhat.js in katello-2.2.2

- old
+ new

@@ -1,7 +1,7 @@ /** - Copyright 2013 Red Hat, Inc. + Copyright 2014 Red Hat, Inc. This software is licensed to you under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License (GPLv2) or (at your option) any later version. There is NO WARRANTY for this software, express or implied, @@ -12,46 +12,32 @@ */ $(document).ready(function() { var spinner = '<i class="icon-spinner inline-icon icon-spin"></i>'; - KT.common.jscroll_init($('.scroll-pane')); - KT.common.jscroll_resize($('.jspPane')); - - - $("#content_tabs").tabs({ cache: true, - select: function(event, ui) { - var panel = $(ui.panel); - if (panel.is(":empty")) { - panel.append(spinner); - } - }, load: function(event, ui) { KT.redhat_provider_page.init_tab($(ui.panel)); } }); - $("#ui-tabs-1").append(spinner); - $("#content_tabs").delegate('.repo_set_enable', 'change', function(){ - KT.redhat_provider_page.repoSetChange($(this), false); - }); + $("#content_tabs > .ui-tabs-panel").append(spinner); $("#content_tabs").delegate('.repo_enable', 'change', function() { KT.redhat_provider_page.repoChange($(this), false); }); $("#content_tabs").delegate('.repo_set_refresh', 'click', function(){ var icon = $(this), row = icon.parents('.repo_set').first(), - checkbox; + expanderArea; if(!icon.hasClass('disabled')){ - checkbox = row.find('.repo_set_enable'); - console.log(checkbox); - KT.redhat_provider_page.repoSetChange(checkbox, true); + expanderArea = row.find('.expander_area'); + console.log(expanderArea); + KT.redhat_provider_page.repoSetRefresh(expanderArea); } }); }); @@ -68,39 +54,43 @@ options['repo'] = "1"; } else { options['repo'] = "0"; } + options['content_id'] = checkbox.attr("data-content-id"); + options['releasever'] = checkbox.attr("data-releasever"); + options['basearch'] = checkbox.attr("data-basearch"); + $(checkbox).hide(); $('#spinner_'+id).removeClass('hidden').show(); + checkbox.parent().parent().siblings().first().find('.errors').remove(); $.ajax({ type: "PUT", url: url, data: options, cache: false, success: function(data, textStatus, jqXHR){ - KT.redhat_provider_page.checkboxHighlightRow(data['id']); + KT.redhat_provider_page.checkboxHighlightRow(checkbox.attr("data-pulp-id")); if(data['can_disable_repo_set']){ set_checkbox.removeAttr('disabled'); } else { set_checkbox.attr('disabled','disabled'); } + }, + error: function(data) { + checkbox.parent().parent().siblings().first().append(data.responseText); + $(checkbox).removeClass('hidden').show().attr('checked', false); + $('#spinner_'+id).addClass('hidden').hide(); } }); return false; }, - repoSetChange = function(checkbox, is_refresh) { - var url = checkbox.data("url"), - disable_url = checkbox.data("disable_url"), - content_id = checkbox.attr("value"); - if (checkbox.attr('checked') || is_refresh) { - refresh_repo_set(url, content_id, is_refresh); - } - else { - disable_repo_set(disable_url, content_id); - } + repoSetRefresh = function(expanderArea) { + var url = expanderArea.data('url'), + content_id = expanderArea.data('content-id'); + refresh_repo_set(url, content_id); }, disable_repo_set = function(url, content_id){ var row = $('#repo_set_' + content_id); hide_repos(content_id); row.find('.repo_set_enable').hide(); @@ -129,49 +119,40 @@ row.find('.repo_set_spinner').hide(); row.find('.repo_set_refresh').removeClass('disabled'); } }); }, - refresh_repo_set = function(url, content_id, is_refresh){ + refresh_repo_set = function(url, content_id){ var row = $('#repo_set_' + content_id); - hide_repos(content_id); row.addClass("disable"); - row.find('.repo_set_enable').hide(); + row.find('.expander').hide(); row.find('.repo_set_spinner').show(); - row.find('.repo_set_refresh').addClass('disabled'); $.ajax({ - type: "PUT", + type: "GET", url: url, data: {content_id:content_id}, cache: false, success: function(data){ row.find('table').replaceWith(data); row.removeClass("disable"); - row.find('.repo_set_enable').show(); row.find('.repo_set_spinner').hide(); row.find('.expander').show(); - show_repos(content_id); - row.find('.repo_set_refresh').removeClass('disabled').show(); - + row.find('table').show(); }, error: function(){ row.removeClass("disable"); - row.find('.repo_set_enable').show().attr('checked', is_refresh); + row.find('.expander').show(); row.find('.repo_set_spinner').hide(); - if(is_refresh){ - row.find('.repo_set_refresh').removeClass('disabled').hide(); - } } }); }, checkboxHighlightRow = function(id){ $('#repo-'+id).effect('highlight', {'color':'#390'}, 1000); $('#spinner_'+id).hide().addClass('hidden'); $('#input_repo_'+id).show(); }, on_node_show = function(a, b, c){ - $.sparkline_display_visible(); }, hide_repos = function(content_id){ var row = $('#repo_set_' + content_id); if(row.hasClass('expanded')){ row.find('.expander_area').click(); @@ -192,15 +173,12 @@ }); panel.find(".content_table").delegate('.expander_area', 'click', function(){ var area = $(this), row = area.parents('tr').first(); - if(row.hasClass("disable")){ - return; - } if(row.hasClass("collapsed")){ - area.parent().find('table').show(); + KT.redhat_provider_page.repoSetRefresh(area); row.removeClass("collapsed").addClass('expanded'); } else { area.parent().find('table').hide(); row.addClass("collapsed").removeClass('expanded'); } @@ -210,10 +188,10 @@ return { repoChange: repoChange, checkboxHighlightRow: checkboxHighlightRow, on_node_show: on_node_show, - repoSetChange: repoSetChange, + repoSetRefresh: repoSetRefresh, hide_repos: hide_repos, init_tab: init_tab }; }(jQuery));