On 11/14/2011 10:37 AM, Endi Sukma Dewata wrote:
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
Replaced the regex with a variable IPA.url for detecting live/static
site. By default the IPA.url is set to "/ipa/ui/" which is the standard
path for live deployment. If the current path matches the IPA.url the UI
will know that it's running on a live server. Otherwise it will use the
fixtures.
If the demo site needs to use the same path as the live path, the
IPA.url can be set to null in the extension.js to force the UI to use
fixtures.
--
Endi S. Dewata
From b5f0caad052d59dacf1f07f40067a261837b54d1 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <[email protected]>
Date: Wed, 9 Nov 2011 18:48:04 -0600
Subject: [PATCH] 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/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 ++++--
16 files changed, 80 insertions(+), 91 deletions(-)
create mode 100644 install/ui/extension.js
diff --git a/freeipa.spec.in b/freeipa.spec.in
index 828d308e146c9d2758edcc11e1773f920b46caba..6531cf5dde55bcbf8f57125dfdc8b1e53c7d6e3d 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 <[email protected]> - 2.99.0-11
+- Make sure changes to extension.js are not removed.
+
* Wed Oct 26 2011 Endi S. Dewata <[email protected]> - 2.99.0-10
- Moved UI images into install/ui/images
diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am
index 8e1ec46fbeccf117e5e408d7dfa13857a3549a2d..2ec047c34dd4a31ea4ce452f3a74eeaf0ba2f13a 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 cae0670405d6553951b2d5e927ef3cbda7e876e0..b63660da3f7931765e1b6791cfb8c6d03c1d5870 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 fd3570e1c79911bd62cfe2eee52ec9b4f7c7a71c..440a9b7d9618f279c5c941a51bd0bffd12f4faa6 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 9f0c8dd5ac4f60fd1fb43f3f7245702fb0b275fb..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/install/ui/host.js b/install/ui/host.js
index 857f854347d45d3e467b576ad3cb736e01e424e7..ab33892c67a35a89dde06d202e549f93605f0e51 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 cb014815b423389a9c77df3a4431b93a7c40f356..25e910ed0c60ad9ce286d54a86193f76bcda7638 100644
--- a/install/ui/index.html
+++ b/install/ui/index.html
@@ -39,7 +39,6 @@
<script type="text/javascript" src="entitle.js"></script>
<script type="text/javascript" src="extension.js"></script>
- <script type="text/javascript" src="develop.js"></script>
<script type="text/javascript" src="webui.js"></script>
<link rel="stylesheet" type="text/css" href="jquery-ui.css" />
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 4dd627ff2e2d447e56d768e68050fac310989d87..c6d39478a35b9ab8d19065572c9b469a84722d06 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 675e4b6c158431ac602fce673d39cab984b49377..a492792639f2a1942a494da40ce227a583fb93d7 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 2ff1acddd50706f69946a5e493735060879ec9e0..b050b7476ac85cc5aa79ede621010ea96e7f7ac0 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 = $('<div id="target"/>').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 122234e78b1a604411de8412233f24478fc0a6cf..c6a55cda9046fa74a8c08f646f6288972f96ae58 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 12a1fcae20d849883e089dcd0a014654facf88c3..84a5e28fea1b9ecc638906401b3ce6a56c3d5310 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 = $('<div id="entities"/>').appendTo(document.body);
diff --git a/install/ui/test/ipa_tests.js b/install/ui/test/ipa_tests.js
index 8b3efc708b9b130dc813b0adb880e9c071667e49..372f768799042f67eaae084d8f1ba8cce7afed76 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 6df1926c3efac17c0eada193e00a6dcebf0d7093..92a23eebe0eafc5ce28f39360cc5589ccd88a6cc 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 50a5f7d6f9762388b6d5a10004f72d9a05eb0852..4549d5a9407509a4bb4e28b91df2e729f77e6062 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 = $('<div id="widget"/>').appendTo(document.body);
widget = null;
diff --git a/install/ui/webui.js b/install/ui/webui.js
index daa22b22a5fb42edc7cc624715b14a911361cd07..6490a446fa8433e342003949122d0161d3c5e2b5 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('<p>'+error_thrown.message+'</p>');
}
- IPA.init(null, null, init_on_win, init_on_error);
-
+ IPA.init({
+ on_success: init_on_success,
+ on_error: init_on_error
+ });
});
--
1.7.5.1
_______________________________________________
Freeipa-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/freeipa-devel