From d866399bee230941c080d78f2fcb03686b653786 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Fri, 22 Oct 2010 09:41:34 -0400 Subject: [PATCH] dns work without the details change including changes from Reviewboard https://fedorahosted.org/reviewboard/r/96/ Fixed pages that use unspecified (krb ticket policy, config) Facet name comes out of the facet, not hard coded. --- install/static/entity.js | 205 +++++++++++++-------- install/static/policy.js | 380 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 507 insertions(+), 78 deletions(-) diff --git a/install/static/entity.js b/install/static/entity.js index 9f3149bd5..f63296421 100644 --- a/install/static/entity.js +++ b/install/static/entity.js @@ -28,6 +28,13 @@ var ipa_entity_add_list = {}; //var ipa_entity_details_list = {}; var ipa_entity_association_list = {}; +var ipa_entity_facet_list = {}; + +function ipa_facet(spec){ + return spec; +}; + + /* use this to track individual changes between two hashchange events */ var window_hash_cache = {}; @@ -59,49 +66,75 @@ function ipa_entity_set_association_definition(obj_name, data) } +function ipa_entity_set_facet_definition(obj_name, data) +{ + function facet(spec){ + return spec; + } + + ipa_entity_facet_list[obj_name] = data; +} + + function ipa_details_only_setup(container){ ipa_entity_setup(container, 'details'); } function ipa_entity_setup(container, unspecified) { - var id = container.attr('id'); + var id = container.attr('id'); var state = id + '-facet'; var facet = $.bbq.getState(state, true) || unspecified || 'search'; var last_facet = window_hash_cache[state]; + var facet_renders = { + search : function(){ + state = id + '-filter'; + var filter = $.bbq.getState(state, true); + var last_filter = window_hash_cache[state]; + if (filter == last_filter) return; + _ipa_entity_setup(container); + window_hash_cache[state] = filter; + + }, + details : function (){ + state = id + '-pkey'; + var pkey = $.bbq.getState(state, true); + var last_pkey = window_hash_cache[state]; + if (pkey == last_pkey) return; + _ipa_entity_setup(container); + window_hash_cache[state] = pkey; + }, + associate : function () { + state = id + '-enroll'; + var enroll = $.bbq.getState(state, true); + var last_enroll = window_hash_cache[state]; + if (enroll == last_enroll) return; + _ipa_entity_setup(container); + window_hash_cache[state] = enroll; + }, + records : function () { + state = id + '-record'; + var records = $.bbq.getState(state, true); + var last_records = window_hash_cache[state]; + if (records == last_records) return; + _ipa_entity_setup(container); + window_hash_cache[state] = record; + } + }; + if (facet != last_facet) { _ipa_entity_setup(container,unspecified); window_hash_cache[state] = facet; - - } else if (facet == 'search') { - state = id + '-filter'; - var filter = $.bbq.getState(state, true); - var last_filter = window_hash_cache[state]; - if (filter == last_filter) return; - - _ipa_entity_setup(container); - window_hash_cache[state] = filter; - - } else if (facet == 'details') { - state = id + '-pkey'; - var pkey = $.bbq.getState(state, true); - var last_pkey = window_hash_cache[state]; - if (pkey == last_pkey) return; - - _ipa_entity_setup(container); - window_hash_cache[state] = pkey; - - } else if (facet == 'associate') { - state = id + '-enroll'; - var enroll = $.bbq.getState(state, true); - var last_enroll = window_hash_cache[state]; - if (enroll == last_enroll) return; - - _ipa_entity_setup(container); - window_hash_cache[state] = enroll; + } else{ + var render = facet_renders[facet]; + if (render) { + render(); + } + //TODO handle error. } + } function _ipa_entity_setup(container, unspecified) { @@ -127,7 +160,9 @@ function _ipa_entity_setup(container, unspecified) { function switch_view() { var enroll_obj_name = $(this).attr('title'); var state = {}; - if (enroll_obj_name != 'search' && enroll_obj_name != 'details') { + if (enroll_obj_name != 'search' && + enroll_obj_name != 'details' && + enroll_obj_name != 'records') { state[obj_name + '-facet'] = 'associate'; state[obj_name + '-enroll'] = enroll_obj_name; } else { @@ -137,65 +172,65 @@ function _ipa_entity_setup(container, unspecified) { $.bbq.pushState(state); } - function setup_search_facet() { - var filter = $.bbq.getState(obj_name + '-filter', true) || ''; - search_create(obj_name, ipa_entity_search_list[obj_name], container); + var facet_setups = { + search : function (unspecified) { + var filter = $.bbq.getState(obj_name + '-filter', true) || ''; + search_create(obj_name, ipa_entity_search_list[obj_name], container); + ipa_make_button( 'ui-icon-plus',ipa_messages.button.add). + click(new_on_click). + appendTo($( "div#" + obj_name + " > div.search-controls")) + search_load(container, filter); + }, - ipa_make_button( 'ui-icon-plus',ipa_messages.button.add). - click(new_on_click). - appendTo($( "div#" + obj_name + " > div.search-controls")) - - search_load(container, filter, null, null); - } - - function setup_details_facet(unspecified) { - var pkey = $.bbq.getState(obj_name + '-pkey', true); - ipa_entity_generate_views(obj_name, container, switch_view); - var sections = ipa_entity_get_details_sections(obj_name); - ipa_details_create(container, sections); - container.find('.details-reset').click(reset_on_click); - container.find('.details-update').click(update_on_click); - - if (pkey||unspecified){ - ipa_details_load(container, pkey, null, null); - } - } - - function setup_associate_facet() { - var pkey = $.bbq.getState(obj_name + '-pkey', true) || ''; - var enroll_obj_name = $.bbq.getState(obj_name + '-enroll', true) || ''; - var attr = ipa_get_member_attribute(obj_name, enroll_obj_name); - var columns = [ - { - title: ipa_objs[enroll_obj_name].label, - column: attr + '_' + enroll_obj_name + details : function(unspecified) { + var pkey = $.bbq.getState(obj_name + '-pkey', true); + ipa_entity_generate_views(obj_name, container, switch_view); + var sections = ipa_entity_get_details_sections(obj_name); + ipa_details_create(container, sections); + container.find('.details-reset').click(reset_on_click); + container.find('.details-update').click(update_on_click); + if (pkey||unspecified){ + ipa_details_load(container, pkey, null, null); } - ]; + }, - var association = ipa_entity_association_list[obj_name]; - var association_config = association ? association[enroll_obj_name] : null; - var associator = association_config ? association_config.associator : null; - var method = association_config ? association_config.method : null; - - var frm = new AssociationList( + associate : function facet(unspecified) { + var pkey = $.bbq.getState(obj_name + '-pkey', true) || ''; + var enroll_obj_name = $.bbq.getState(obj_name + '-enroll', true) || ''; + var attr = ipa_get_member_attribute(obj_name, enroll_obj_name); + var columns = [ + { + title: ipa_objs[enroll_obj_name].label, + column: attr + '_' + enroll_obj_name + } + ]; + var association = ipa_entity_association_list[obj_name]; + var association_config = association ? association[enroll_obj_name] : null; + var associator = association_config ? association_config.associator : null; + var method = association_config ? association_config.method : null; + var frm = new AssociationList( obj_name, pkey, enroll_obj_name, columns, container, associator, method - ); + ); + ipa_entity_generate_views(obj_name, container, switch_view); + frm.setup(); + }, + + records: function(unspecified) { + records_facet.setup(obj_name, container, switch_view ); + } - ipa_entity_generate_views(obj_name, container, switch_view); - frm.setup(); } + container.empty(); - var facet = $.bbq.getState(obj_name + '-facet', true) || + var facet = $.bbq.getState(obj_name + '-facet', true) || unspecified || 'search'; - if (facet == 'search') { - setup_search_facet(); - } else if (facet == 'details') { - setup_details_facet(unspecified); - } else if (facet == 'associate') { - setup_associate_facet(); + + var facet_setup_function = facet_setups[facet]; + if (facet_setup_function){ + facet_setup_function(unspecified); } } @@ -203,7 +238,7 @@ function ipa_entity_generate_views(obj_name, container, switch_view) { var ul = $('', {'class': 'entity-views'}); - //TODO replace the plus image with the correct image for each facet + //TODO for single instance entites, don't display search ul.append($('
  • ', { title: 'search', text: 'Search', @@ -231,6 +266,20 @@ function ipa_entity_generate_views(obj_name, container, switch_view) } } + //TODO Additional facets go here + + var facets = ipa_entity_facet_list[obj_name]; + if (facets){ + for (var f = 0; f < facets.length; f += 1){ + var facet = facets[f]; + ul.append($('
  • ', { + text: facet.name, + title: facet.name, + click: switch_view + }).prepend('| ')); + } + } + container.append(ul); } diff --git a/install/static/policy.js b/install/static/policy.js index 9d55e1cf0..4d30c5732 100644 --- a/install/static/policy.js +++ b/install/static/policy.js @@ -53,6 +53,7 @@ ipa_entity_set_search_definition('dns', [ ['quick_links', 'Quick Links', ipa_entity_quick_links] ]); + ipa_entity_set_add_definition('dns', [ 'dialog-add-dns', 'Add New Zone', [ ['idnsname', 'Name', null], @@ -82,6 +83,385 @@ ipa_entity_set_association_definition('dns', { }); +ipa_entity_set_facet_definition('dns', [ + ipa_facet({name:'records'})] +); + +function create_records_facet(){ + + var that = {}; + + var record_types =[ 'a', 'aaaa', 'dname', 'cname', 'mx', 'ns', 'ptr', + 'srv', 'txt', 'a6', 'afsdb', 'cert', 'ds', 'hinfo', + 'key', 'kx', 'loc', 'md', 'minfo', 'naptr', 'nsec', + 'nxt', 'rrsig', 'sshfp']; + + function create_type_select(id,add_none) { + var type_select = $(''))); + dl.append('
    Type
    '); + dl.append( $('
    ').append(create_type_select('dns-record-type'))); + dl.append('
    Data
    '); + dl.append($('
    ').append($('