From 20ad8fe1ba9b4a0f8ca9e365ac782895f6698c71 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 9 Nov 2011 18:48:04 -0600 Subject: Removed develop.js. The develop.js is no longer necessary because the code in it has been merged into the main code. An empty extension.js has been added to provide a place for UI customization. Ticket #2099 --- freeipa.spec.in | 4 ++++ install/ui/Makefile.am | 1 + install/ui/aci.js | 12 ++++++++++ install/ui/details.js | 9 ++++---- install/ui/develop.js | 13 ----------- install/ui/extension.js | 0 install/ui/host.js | 12 ++++++++++ install/ui/index.html | 1 - install/ui/ipa.js | 44 +++++++++++++------------------------ install/ui/jsl.conf | 1 - install/ui/test/aci_tests.js | 11 ++++------ install/ui/test/details_tests.js | 11 ++++------ install/ui/test/entity_tests.js | 11 +++++----- install/ui/test/ipa_tests.js | 11 +++++----- install/ui/test/navigation_tests.js | 11 ++++------ install/ui/test/widget_tests.js | 11 ++++------ install/ui/webui.js | 8 ++++--- 17 files changed, 80 insertions(+), 91 deletions(-) create mode 100644 install/ui/extension.js diff --git a/freeipa.spec.in b/freeipa.spec.in index 828d308e1..6531cf5dd 100644 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -516,6 +516,7 @@ fi %{_usr}/share/ipa/ui/*.svg %{_usr}/share/ipa/ui/*.ttf %{_usr}/share/ipa/ui/*.woff +%config(noreplace) %{_usr}/share/ipa/ui/extension.js %dir %{_usr}/share/ipa/ui/images %{_usr}/share/ipa/ui/images/*.png %{_usr}/share/ipa/ui/images/*.gif @@ -617,6 +618,9 @@ fi %ghost %attr(0644,root,apache) %config(noreplace) %{_sysconfdir}/ipa/default.conf %changelog +* Wed Nov 14 2011 Endi S. Dewata - 2.99.0-11 +- Make sure changes to extension.js are not removed. + * Wed Oct 26 2011 Endi S. Dewata - 2.99.0-10 - Moved UI images into install/ui/images diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index 8e1ec46fb..2ec047c34 100644 --- a/install/ui/Makefile.am +++ b/install/ui/Makefile.am @@ -18,6 +18,7 @@ app_DATA = \ dns.js \ entitle.js \ entity.js \ + extension.js \ facet.js \ favicon.ico \ group.js \ diff --git a/install/ui/aci.js b/install/ui/aci.js index cae067040..b63660da3 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -36,6 +36,7 @@ IPA.aci.permission_entity = function(spec) { columns: [ 'cn' ] }). details_facet({ + factory: IPA.aci.permission_details_facet, sections: [ { name: 'identity', @@ -90,6 +91,17 @@ IPA.aci.permission_entity = function(spec) { return that; }; +IPA.aci.permission_details_facet = function(spec) { + + var that = IPA.details_facet(spec); + + that.get_refresh_command_name = function() { + return that.entity.name+'_show_'+that.pkey; + }; + + return that; +}; + IPA.aci.privilege_entity = function(spec) { var that = IPA.entity(spec); diff --git a/install/ui/details.js b/install/ui/details.js index fd3570e1c..440a9b7d9 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -800,20 +800,21 @@ IPA.details_facet = function(spec) { command.execute(); }; + that.get_refresh_command_name = function() { + return that.entity.name+'_show'; + }; + that.refresh = function() { that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var command = IPA.command({ + name: that.get_refresh_command_name(), entity: that.entity.name, method: 'show', options: { all: true, rights: true } }); - if (IPA.details_refresh_devel_hook) { - IPA.details_refresh_devel_hook(that.entity.name, command, that.pkey); - } - if (that.pkey) { command.args = that.get_primary_key(true); diff --git a/install/ui/develop.js b/install/ui/develop.js index 9f0c8dd5a..e69de29bb 100644 --- a/install/ui/develop.js +++ b/install/ui/develop.js @@ -1,13 +0,0 @@ -/*jsl:import ipa.js */ - -if (window.location.protocol == 'file:') { - IPA.json_url = "test/data"; - IPA.use_static_files = true; - - IPA.details_refresh_devel_hook = function(entity_name,command,pkey){ - if ((entity_name === 'host')||(entity_name === 'permission')){ - command.name = entity_name+'_show_'+pkey; - command.method = entity_name+'_show'; - } - }; -} diff --git a/install/ui/extension.js b/install/ui/extension.js new file mode 100644 index 000000000..e69de29bb diff --git a/install/ui/host.js b/install/ui/host.js index 857f85434..ab33892c6 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -43,6 +43,7 @@ IPA.host.entity = function(spec) { ] }). details_facet({ + factory: IPA.host.details_facet, sections: [ { name: 'details', @@ -176,6 +177,17 @@ IPA.host.entity = function(spec) { return that; }; +IPA.host.details_facet = function(spec) { + + var that = IPA.details_facet(spec); + + that.get_refresh_command_name = function() { + return that.entity.name+'_show_'+that.pkey; + }; + + return that; +}; + IPA.host_fqdn_section = function(spec) { spec = spec || {}; diff --git a/install/ui/index.html b/install/ui/index.html index cb014815b..25e910ed0 100644 --- a/install/ui/index.html +++ b/install/ui/index.html @@ -39,7 +39,6 @@ - diff --git a/install/ui/ipa.js b/install/ui/ipa.js index 4dd627ff2..c6d39478a 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -31,11 +31,8 @@ var IPA = function() { jsonrpc_id: 0 }; - that.use_static_files = false; - that.json_url = '/ipa/json'; - if (that.use_static_files){ - that.json_url = 'test/data'; - } + // live server path + that.url = '/ipa/ui/'; that.ajax_options = { type: 'POST', @@ -54,16 +51,15 @@ var IPA = function() { that.network_call_count = 0; - /* initialize the IPA JSON-RPC helper - * arguments: - * url - JSON-RPC URL to use (optional) */ - that.init = function (url, use_static_files, on_success, on_error) { - if (url) { - that.json_url = url; - } + /* initialize the IPA JSON-RPC helper */ + that.init = function(params) { - if (use_static_files) { - that.use_static_files = use_static_files; + // if current path matches live server path, use live data + if (that.url && window.location.pathname.substring(0, that.url.length) === that.url) { + that.json_url = params.url || '/ipa/json'; + + } else { // otherwise use fixtures + that.json_path = params.url || "test/data"; } $.ajaxSetup(that.ajax_options); @@ -75,7 +71,6 @@ var IPA = function() { methodname: 'all' }, on_success: function(data, text_status, xhr) { - if(!that.metadata) that.metadata = {}; that.metadata.methods = data.result.methods; } }); @@ -87,7 +82,6 @@ var IPA = function() { objname: 'all' }, on_success: function(data, text_status, xhr) { - if(!that.metadata) that.metadata = {}; that.metadata.objects = data.result.objects; } }); @@ -97,7 +91,7 @@ var IPA = function() { methods, objects ], - on_success: on_success + on_success: params.on_success }); var batch = IPA.batch_command({ @@ -125,8 +119,8 @@ var IPA = function() { dialog.on_cancel = function() { dialog.close(); - if (on_error) { - on_error.call(ajax, xhr, text_status, error_thrown); + if (params.on_error) { + params.on_error.call(ajax, xhr, text_status, error_thrown); } }; @@ -446,21 +440,13 @@ IPA.command = function(spec) { } } - var url = IPA.json_url; - - var command = that.get_command(); - - if (IPA.use_static_files) { - url += '/' + (that.name ? that.name : command) + '.json'; - } - var data = { - method: command, + method: that.get_command(), params: [that.args, that.options] }; var request = { - url: url, + url: IPA.json_url || IPA.json_path + '/' + (that.name || data.method) + '.json', data: JSON.stringify(data), success: success_handler, error: error_handler diff --git a/install/ui/jsl.conf b/install/ui/jsl.conf index 675e4b6c1..a49279263 100644 --- a/install/ui/jsl.conf +++ b/install/ui/jsl.conf @@ -150,7 +150,6 @@ +process sudo.js +process policy.js +process aci.js -+process develop.js +process dns.js +process automount.js +process webui.js diff --git a/install/ui/test/aci_tests.js b/install/ui/test/aci_tests.js index 2ff1acddd..b050b7476 100644 --- a/install/ui/test/aci_tests.js +++ b/install/ui/test/aci_tests.js @@ -26,15 +26,12 @@ var entity = {name:'bogus'}; module('aci',{ setup: function() { IPA.ajax_options.async = false; - IPA.init( - "data", - true, - function(data, text_status, xhr) { - }, - function(xhr, text_status, error_thrown) { + IPA.init({ + url: 'data', + on_error: function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } - ); + }); target_container = $('
').appendTo(document.body); target_section = IPA.permission_target_section({ diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 122234e78..c6a55cda9 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -25,15 +25,12 @@ module('details', { setup: function() { IPA.ajax_options.async = false; - IPA.init( - "data", - true, - function(data, text_status, xhr) { - }, - function(xhr, text_status, error_thrown) { + IPA.init({ + url: 'data', + on_error: function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } - ); + }); IPA.nav = {}; diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index 12a1fcae2..84a5e28fe 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -27,10 +27,9 @@ module('entity',{ IPA.ajax_options.async = false; - IPA.init( - "data", - true, - function(data, text_status, xhr) { + IPA.init({ + url: 'data', + on_success: function(data, text_status, xhr) { IPA.entity_factories.user = function(){ return IPA. @@ -41,10 +40,10 @@ module('entity',{ build(); }; }, - function(xhr, text_status, error_thrown) { + on_error: function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } - ); + }); entities_container = $('
').appendTo(document.body); diff --git a/install/ui/test/ipa_tests.js b/install/ui/test/ipa_tests.js index 8b3efc708..372f76879 100644 --- a/install/ui/test/ipa_tests.js +++ b/install/ui/test/ipa_tests.js @@ -26,16 +26,15 @@ test("Testing ipa_init().", function() { IPA.ajax_options.async = false; - IPA.init( - "data", - true, - function(data, text_status, xhr) { + IPA.init({ + url: 'data', + on_success: function(data, text_status, xhr) { ok(true, "ipa_init() succeeded."); }, - function(xhr, text_status, error_thrown) { + on_error: function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } - ); + }); }); test("Testing IPA.get_entity_param().", function() { diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js index 6df1926c3..92a23eebe 100644 --- a/install/ui/test/navigation_tests.js +++ b/install/ui/test/navigation_tests.js @@ -23,15 +23,12 @@ module('navigation', { setup: function() { IPA.ajax_options.async = false; - IPA.init( - 'data', - true, - function(data, text_status, xhr) { - }, - function(xhr, text_status, error_thrown) { + IPA.init({ + url: 'data', + on_error: function(xhr, text_status, error_thrown) { ok(false, 'ipa_init() failed: '+error_thrown); } - ); + }); } }); diff --git a/install/ui/test/widget_tests.js b/install/ui/test/widget_tests.js index 50a5f7d6f..4549d5a94 100644 --- a/install/ui/test/widget_tests.js +++ b/install/ui/test/widget_tests.js @@ -28,15 +28,12 @@ var spec; module('widget',{ setup: function() { IPA.ajax_options.async = false; - IPA.init( - "data", - true, - function(data, text_status, xhr) { - }, - function(xhr, text_status, error_thrown) { + IPA.init({ + url: 'data', + on_error: function(xhr, text_status, error_thrown) { ok(false, "ipa_init() failed: "+error_thrown); } - ); + }); widget_container = $('
').appendTo(document.body); widget = null; diff --git a/install/ui/webui.js b/install/ui/webui.js index daa22b22a..6490a446f 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -153,7 +153,7 @@ $(function() { } - function init_on_win(data, text_status, xhr) { + function init_on_success(data, text_status, xhr) { $(window).bind('hashchange', window_hashchange); var whoami = IPA.whoami; @@ -176,6 +176,8 @@ $(function() { container.append('

'+error_thrown.message+'

'); } - IPA.init(null, null, init_on_win, init_on_error); - + IPA.init({ + on_success: init_on_success, + on_error: init_on_error + }); }); -- cgit