On 08/17/2010 09:23 AM, Pavel Zuna wrote:
On 08/12/2010 08:36 PM, Adam Young wrote:
I'll try to use a patch naming structure similar to what Pavel's using:


This patch fixes https://fedorahosted.org/freeipa/ticket/135.

Instead of HTML Params starting with '?' we use the Hash '#' as the
startgin point. This keeps the broswer from sending addition http
requests to the server whenever we need to update the URL.

Sorry for a late review. I can't get this patch to apply, probably because of some other patches that were pushed in between. Please add me to CC on your patches, so they end up in my Inbox and I'll make sure to review them faster.

Pavel


Here is an updated version. It applies on top of the pzuna patches that were pushed earlier.


>From ae87e878d9a5e4b4c815cc5bd4823c6b07ac3eb1 Mon Sep 17 00:00:00 2001
From: Adam Young <ayo...@redhat.com>
Date: Tue, 17 Aug 2010 17:42:38 -0400
Subject: [PATCH] Hash Params

Changes the URL parsing from standard HTML params ( starting with ?)
 to hash params ( starting with # ).  User Details are now part of
index.xhtml, ao one more .inc file has been removed.
---
 install/static/index.xhtml      |   34 +++++++++++++++-
 install/static/ipa.css          |   14 +++---
 install/static/ipa.js           |    8 +++-
 install/static/navigation.js    |   40 +++++++++++++++++-
 install/static/search.js        |   83 ++++++++++++++++++---------------------
 install/static/user-details.inc |   27 -------------
 install/static/user.js          |   39 +++++++++++++------
 7 files changed, 148 insertions(+), 97 deletions(-)
 delete mode 100644 install/static/user-details.inc

diff --git a/install/static/index.xhtml b/install/static/index.xhtml
index e94e6d1..8cde161 100644
--- a/install/static/index.xhtml
+++ b/install/static/index.xhtml
@@ -56,10 +56,40 @@
       <div id="sub-nav">Edit: </div>
     </div>
 
-    <div id="content" border="1"  style="visibility:hidden" >
+    <div id="content" border="1"  style="display:none" >
+    </div>
+    
+    <div id="details" style="display:none" >      
+      <h1>Managing user:</h1>
+      <div id="buttons">
+	<a href="jslink" onclick="return (reset_on_click(this));">
+          <img id="butreset" src="but-reset.png" alt="Reset" />
+	</a>
+	<a href="jslink" onclick="return (update_on_click(this));">
+          <img id="butupdate" src="but-update.png" alt="Update" />
+	</a>
+      </div>
+      
+      <ul id="viewtype">
+	<li id="viewcaption">View:</li>
+	<li>
+          <img src="but-selected.png" alt="" />
+          Identity Details
+	</li>
+	<li>
+          <img src="but-unselected.png" alt="" />
+          <a href="memberof?pkey=${pkey}">Memberships</a>
+	</li>
+      </ul>
+      <hr />
+
+      <div id="backtotop">
+	<a href="#viewtype">Back to Top</a>
+      </div>
+      
     </div>
 
-    <div id="search"  style="visibility:hidden">
+    <div id="search"  style="display:none">
       <div class="searchControls" >
 	<span class="filter"  >
 	  <input id="queryFilter" type="text"/>
diff --git a/install/static/ipa.css b/install/static/ipa.css
index 54b29c7..0a40839 100644
--- a/install/static/ipa.css
+++ b/install/static/ipa.css
@@ -83,17 +83,17 @@ h1 {
     margin-top: 18px;
 }
 
-div#content {
+div#details {
     float: left;
     width: 100%;
 }
 
 
-div#content ul#viewtype {
+div#details ul#viewtype {
     padding-left: 20px;
 }
 
-div#content ul#viewtype li {
+div#details ul#viewtype li {
     color: #656565;
     display: inline;
     font-weight: bold;
@@ -106,20 +106,20 @@ div#content ul#viewtype li#viewcaption {
     padding-right: 10px;
 }
 
-div#content ul#viewtype li img {
+div#details ul#viewtype li img {
     vertical-align: middle;
 }
 
-div#content ul#viewtype li a {
+div#details ul#viewtype li a {
     font-weight: normal;
 }
 
-div#content div#buttons {
+div#details div#buttons {
     float: right;
     margin-right: 15px;
 }
 
-div#content div#buttons img {
+div#details div#buttons img {
     border: 0;
 }
 
diff --git a/install/static/ipa.js b/install/static/ipa.js
index d1f9fe5..95deccb 100644
--- a/install/static/ipa.js
+++ b/install/static/ipa.js
@@ -30,6 +30,12 @@ var _ipa_init_on_win_callback = null;
 /* initialize the IPA JSON-RPC helper
  * arguments:
  *   url - JSON-RPC URL to use (optional) */
+
+/*Query String*/
+var qs;
+
+
+
 function ipa_init(url, on_win)
 {
     if (!url)
@@ -96,7 +102,7 @@ function ipa_parse_qs(qs)
     var dict = {};
 
     if (!qs)
-	qs = location.search.substring(1, location.search.length);
+	qs = location.hash.substring(1);
     qs = qs.replace(/\+/g, ' ');
 
     var args = qs.split('&');
diff --git a/install/static/navigation.js b/install/static/navigation.js
index 10c1681..de2e2d2 100644
--- a/install/static/navigation.js
+++ b/install/static/navigation.js
@@ -145,14 +145,48 @@ function setActiveSubtab(){
 	netgroup:setupNetgroup,
 };
 
-
-
-
     var subtabName = this.id.substring("subtab-".length);
     $(".sub-nav-on").removeClass('sub-nav-on').addClass("sub-nav-off")
     var active = "#span-subtab-"+subtabName;
     $(active).removeClass('sub-nav-off').addClass("sub-nav-on")
 
     setupFunctions[subtabName]();
+}
+
+function clearOld(){
+    $('#searchResultsTable thead').html("");
+    $('#searchResultsTable tfoot').html("");
+    $('#searchResultsTable tbody').find("tr").remove();
+    $("#searchButtons").html("");
+
+    $('#content').html("");
+
+    //remove old details
+    $('#detail-lists').html("<hr/>");
+    //$('.entryattrs dd').remove();
+}
+
+
+
+function showSearch(){
+    $('#content').css("display","none");
+    $('#details').css("display","none");
+    clearOld();
+    $('#search').css("display","block");
+    $("#filter").css("display","block");
+}
+
+function showContent(){
+    $('#search').css("display","none");
+    $('#details').css("display","none");
+    clearOld();
+    $('#content').css("display","block");
+}
+
 
+function showDetails(){
+    $('#search').css("display","none");
+    $('#content').css("display","none");
+    clearOld();
+    $('#details').css("display","block");
 }
diff --git a/install/static/search.js b/install/static/search.js
index de11f2e..3589a85 100644
--- a/install/static/search.js
+++ b/install/static/search.js
@@ -2,33 +2,6 @@
 var sampleData;
 
 
-function clearOld(){
-    $('#searchResultsTable thead').html("");
-    $('#searchResultsTable tfoot').html("");
-    $('#searchResultsTable tbody').find("tr").remove();
-    $('#content').html("");
-}
-
-function showSearch(){
-    clearOld();
-    $('#search').css("visibility","visible");
-    $('#content').css("visibility","hidden");
-    $('#search').css("display","block");
-    $('#content').css("display","none");
-    $("#filter").css("display","block");
-    $("#searchButtons").html("");
-    
-
-}
-
-function showContent(){
-    clearOld();
-    $('#search').css("visibility","hidden");
-    $('#content').css("visibility","visible");
-    $('#search').css("display","none");
-    $('#content').css("display","block");
-}
-
 //Columns is an array of items in the form
 // {title, column,  render}
 //title: the the value that goes at the head of the column
@@ -52,10 +25,11 @@ function  renderUnknownColumn(current,cell){
 }
 
 function renderDetailColumn(current,cell,pkey,obj){
-    link = document.createElement("a");
-    link.href= "?tab=" +obj+"&facet=details&pkey="+pkey;
-    link.innerHTML = pkey;
-    cell.appendChild(link);
+    $("<a/>",{
+	href:"#tab=user&facet=details&pkey="+pkey,
+	html:  ""+ current[this.column],
+	click: function(){ setupUserDetails(current.uid)},
+    }).appendTo(cell);
 }
 
 
@@ -96,6 +70,29 @@ function SearchForm(obj, method, cols){
 	}
     }
 
+    this.searchWithFilter = function(queryFilter){    
+	var form = this;
+	window.location.hash="#tab="
+	+this.obj
+	    +"&facet=search&criteria="
+	    +queryFilter;
+	
+	$('#searchResultsTable tbody').html("");
+	$('#searchResultsTable tbody').html("");
+	$('#searchResultsTable tfoot').html("");
+	
+	ipa_cmd(this.method,
+		[queryFilter],
+		{"all":"true"},
+		function(json){
+		    form.searchSuccess(json);
+		},
+		function(json){
+		    alert("Search Failed");
+		},form.obj);
+	
+    }
+    
     this.obj = obj;
     this.method = method;
     this.columns = cols;
@@ -104,27 +101,23 @@ function SearchForm(obj, method, cols){
 
     $('#searchResultsTable thead').html("");
     $('#searchResultsTable tbody').html("");
+    $('#searchResultsTable tfoot').html("");
+
     $("#new").click(function(){
-	location.href="?tab="+obj+"&facet=add";
+	location.href="#tab="+obj+"&facet=add";
     });
     this.buildColumnHeaders();
+
+    var params = ipa_parse_qs();
+    
+    if (params["criteria"]){
+	this.searchWithFilter(params["criteria"]);
+    }
 }
 
 
 executeSearch = function(searchForm){
     var queryFilter = $("#queryFilter").val();
-
-    $('#searchResultsTable tbody').html("");
-
-    ipa_cmd(searchForm.method,
-	    [queryFilter],
-	    {"all":"true"},
-	    function(json){
-		searchForm.searchSuccess(json);
-	    },
-	    function(json){
-		alert("Search Failed");
-	    },searchForm.obj);
-
+    searchForm.searchWithFilter(queryFilter);
 }
 
diff --git a/install/static/user-details.inc b/install/static/user-details.inc
deleted file mode 100644
index 08b8be1..0000000
--- a/install/static/user-details.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<h1>Managing user:</h1>
-<div id="buttons">
-    <a href="jslink" onclick="return (reset_on_click(this));">
-        <img id="butreset" src="but-reset.png" alt="Reset" />
-    </a>
-    <a href="jslink" onclick="return (update_on_click(this));">
-        <img id="butupdate" src="but-update.png" alt="Update" />
-    </a>
-</div>
-
-<ul id="viewtype">
-    <li id="viewcaption">View:</li>
-    <li>
-        <img src="but-selected.png" alt="" />
-        Identity Details
-    </li>
-    <li>
-        <img src="but-unselected.png" alt="" />
-        <a href="memberof?pkey=${pkey}">Memberships</a>
-    </li>
-</ul>
-<hr />
-
-<div id="backtotop">
-    <a href="#viewtype">Back to Top</a>
-</div>
-
diff --git a/install/static/user.js b/install/static/user.js
index 9a58e31..fc084c7 100644
--- a/install/static/user.js
+++ b/install/static/user.js
@@ -1,5 +1,4 @@
 
-var qs = ipa_parse_qs();
 
 var user_details_lists = [
     ['identity', 'Identity Details', [
@@ -90,17 +89,29 @@ function setupAddUser(){
     $('#content').load("user-add.inc");
 }
 
+function setupUserDetails(user){
 
-function setupUserDetails(){
-    showContent();
+    window.location.hash="#tab=user&facet=details&pkey="+user;
+
+    //re initialize global parse of parameters
+    qs = ipa_parse_qs();
+
+    //TODO make this work for more than just user details
+    details_lists =  user_details_lists;    
+
+
+    //showContent();
     sampleData = "sampledata/usershow.json";
-    $('#content').load("user-details.inc", [], renderUserDetails);
+    //$('#content').load("user-details.inc", [], renderUserDetails);
+
+    showDetails();
+    renderUserDetails();
 }
 
 function renderUserDetails()
 {
     ipa_details_init('user');
-    ipa_details_create(user_details_lists, $('#content'));
+    ipa_details_create(user_details_lists, $('#details'));
 
     if (qs['principal']) {
         ipa_cmd(
@@ -126,24 +137,24 @@ function renderUserLinks(current, cell){
 	cell.appendChild(link);
 
     $("<a/>",{
-	href:"?tab=user&facet=details&pkey="+current.uid,
+	href:"#tab=user&facet=details&pkey="+current.uid,
 	html:  "[D]",
-	click:setupUserDetails,
+	click: function(){ setupUserDetails(current.uid)},
     }).appendTo(cell);
 
     $("<a/>",{
-	href: "#tab=user&facet=details&pkey="+current.uid,
+	href: "#tab=user&facet=group&pkey="+current.uid,
 	click:setupUserGroupMembership,
 	html: "[G]"
     }).appendTo(cell);
 
     $("<a/>",{
-	href:"?tab=user&facet=netgroup&pkey="+current.uid,
+	href:"#tab=user&facet=netgroup&pkey="+current.uid,
 	html: "[N]"
     }).appendTo(cell);
 
     $("<a/>",{
-	href:"?tab=user&facet=role&pkey="+current.uid,
+	href:"#tab=user&facet=role&pkey="+current.uid,
 	html:"[R]"
     }).appendTo(cell);
 }
@@ -151,9 +162,13 @@ function renderUserLinks(current, cell){
 
 
 function renderUserDetailColumn(current,cell){
-    renderDetailColumn(current,cell,current[this.column],"user");
-}
 
+    $("<a/>",{
+	href:"#tab=user&facet=details&pkey="+current.uid,
+	html:  ""+ current[this.column],
+	click: function(){ setupUserDetails(current.uid)},
+    }).appendTo(cell);
+}
 
 var columns  = [
     {title:"Name",     column:"cn",             render: renderSimpleColumn},
-- 
1.7.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to