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.

Updated commit to catch a few things that had been left out, including
sampledata handling and updateing Makefile.am
This commit is contained in:
Adam Young 2010-08-19 20:48:21 -04:00
parent 9a16027535
commit 12ee9365a7
11 changed files with 216 additions and 166 deletions

View File

@ -11,7 +11,6 @@ app_DATA = \
ipa.css \
jquery.js \
group.js \
group-details.inc \
host.js \
hostgroup.js \
index.xhtml \
@ -23,7 +22,6 @@ app_DATA = \
details.js \
user.js \
user-add.inc \
user-details.inc \
ipalogo.png \
gray-fade-line.png \
Mainnav-background.png \

View File

@ -39,7 +39,7 @@ var _ipa_load_on_fail_callback = null;
var ipa_details_cache = null;
function ipa_details_load(pkey, on_win, on_fail)
function ipa_details_load(pkey, on_win, on_fail,sampleData)
{
if (!pkey)
return;
@ -49,8 +49,7 @@ function ipa_details_load(pkey, on_win, on_fail)
ipa_cmd(
'show', [pkey], {all: true}, _ipa_load_on_win, _ipa_load_on_fail,
_ipa_obj_name
);
_ipa_obj_name, sampleData );
}
function _ipa_load_on_win(data, text_status, xhr)
@ -171,7 +170,9 @@ function ipa_details_create(dls, container)
for (var i = 0; i < dls.length; ++i) {
var d = dls[i];
ipa_generate_dl(container.children('hr').last(), d[0], d[1], d[2]);
ipa_generate_dl($('#detail-lists hr').last(), d[0], d[1], d[2]);
// ipa_generate_dl($("#detail-lists"), d[0], d[1], d[2]);
}
}
@ -188,7 +189,6 @@ function ipa_generate_dl(jobj, id, name, dts)
jobj = jobj.next();
jobj.after(_ipa_dl_template.replace('I', id));
jobj = jobj.next();
jobj.after('<hr />');
for (var i = 0; i < dts.length; ++i) {
var label = '';
@ -203,6 +203,7 @@ function ipa_generate_dl(jobj, id, name, dts)
_ipa_dt_template.replace('T', dts[i][0]).replace('N', label)
);
}
jobj.after('<hr />');
}
/* HTML templates for ipa_details_display() */

View File

@ -1,32 +0,0 @@
<script type="text/javascript">
$(document).ready(function(){
load_object($('body'),'group');
});
</script>
<h1>Managing group:</h1>
<div id="buttons">
<a href="dummy"><img id="butreset" src="but-reset.png" alt="Reset" /></a>
<a href="dummy"><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="" />
Personal Details
</li>
<li>
<img src="but-unselected.png" alt="" />
<a href="memberof?pkey=${pkey}">Memberships</a>
</li>
</ul>
<hr />
<h2 onclick="h2_on_click(this)">&#8722; Group Details</h2>
<dl id="identity" class="entryattrs">
<dt title="cn">Group Name:</dt>
<dt title="description">Description:</dt>
<dt title="gidnumber">GID</dt>
</dl>
<hr />

View File

@ -68,29 +68,60 @@ function setupAddGroup(){
}
function setupGroupDetails(){
var group_details_list =
[['identity', 'Group Details', [
['cn', 'Group Name'],
['description', 'Description'],
['gidnumber', 'Group ID']]]];
$('#search').css("visibility","hidden");
$('#content').css("visibility","visible");
$('#content').load("group-details.inc");
sampleData = "sampledata/groupshow.json";
function setupGroupDetails(group){
window.location.hash="#tab=user&facet=details&pkey="+group;
//re initialize global parse of parameters
qs = ipa_parse_qs();
//TODO make this work for more than just user details
user_details_lists;
showDetails();
ipa_details_init('group');
ipa_details_create(group_details_list, $('#details'));
ipa_details_load(qs['pkey'], on_win, null, "sampledata/groupshow.json");
$('h1').text('Managing group: ' + group);
}
function renderGroupDetails(group)
{
}
function renderGroupDetailColumn(current,cell){
$("<a/>",{
href:"#tab=group&facet=details&pkey="+current.cn,
html: ""+ current[this.column],
click: function(){ setupGroupDetails(current.cn)},
}).appendTo(cell);
}
function setupGroupSearch(){
var columns = [
{title:"Group Name", column:"cn",render: function(current,cell){
renderDetailColumn(current,cell,current[this.column],"group");
}},
{title:"Group Name", column:"cn",render: renderGroupDetailColumn},
{title:"GID", column:"gidnumber",render: renderSimpleColumn},
{title:"Description", column:"description",render: renderSimpleColumn}
];
var groupSearchForm = new SearchForm("group", "find", columns);
var groupSearchForm = new SearchForm("group", "find", columns,"sampledata/grouplist.json");
$("#query").unbind();
$("#query").click(function(){
sampleData = "sampledata/grouplist.json";
executeSearch(groupSearchForm);
});
$("#new").unbind();

View File

@ -16,7 +16,6 @@
</script>
<script type="text/javascript" src="ipa.js" />
<script type="text/javascript" src="pageparams.js" />
<script type="text/javascript" src="navigation.js" />
<script type="text/javascript" src="sampledata/develop.js" />
@ -34,7 +33,7 @@
$(document).ready(function(){
if (useSampleData)
ipa_init(sampleData, buildNavigation);
ipa_init("sampledata/metadata.json", buildNavigation);
else
ipa_init(null, buildNavigation);
});
@ -56,10 +55,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="search" style="visibility:hidden">
<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>
<div id="detail-lists">
<hr />
</div>
<div id="backtotop">
<a href="#viewtype">Back to Top</a>
</div>
</div>
<div id="search" style="display:none">
<div class="searchControls" >
<span class="filter" >
<input id="queryFilter" type="text"/>

View File

@ -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;
}

View File

@ -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)
@ -65,12 +71,23 @@ function _ipa_load_objs(data, textStatus, xhr)
* win_callback - function to call if the JSON request succeeds
* fail_callback - function to call if the JSON request fails
* objname - name of an IPA object (optional) */
function ipa_cmd(name, args, options, win_callback, fail_callback, objname)
function ipa_cmd(name, args, options, win_callback, fail_callback, objname,sampleData)
{
id = ipa_jsonrpc_id++;
if (objname)
name = objname + '_' + name;
if (useSampleData && sampleData){
var ajax_options = {
url: sampleData,
type: 'POST',
contentType: 'application/json',
dataType: 'json',
processData: false,
};
$.ajaxSetup(ajax_options);
}
var data = {
method: name,
params: [args, options],
@ -96,7 +113,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('&');

View File

@ -16,7 +16,7 @@ function unimplemented(facet){
}
function buildNavigation(){
params= getPageParams();
params= ipa_parse_qs();
var tab = params["tab"];
if (!tab){
@ -107,10 +107,9 @@ function buildNavigation(){
currentMain.setup(facet);
}
sampleData = "sampledata/whoami.json";
var whoami = $.cookie("whoami");
if (whoami == null){
ipa_cmd( 'whoami', [], {}, whoamiSuccess);
ipa_cmd( 'whoami', [], {}, whoamiSuccess, null,null, "sampledata/whoami.json");
}else{
setLoggedInText(whoami);
}
@ -145,14 +144,49 @@ 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
$('.entryattrs dd').remove();
$('#detail-lists').html("<hr/>");
}
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");
}

View File

@ -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,15 +25,16 @@ 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);
}
function SearchForm(obj, method, cols){
function SearchForm(obj, method, cols, searchSampleData){
this.buildColumnHeaders = function (){
var columnHeaders = document.createElement("tr");
@ -96,35 +70,55 @@ 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, form.searchSampleData);
}
this.obj = obj;
this.method = method;
this.columns = cols;
this.searchSampleData = searchSampleData;
showSearch();
$('#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);
}

View File

@ -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>

View File

@ -1,5 +1,4 @@
var qs = ipa_parse_qs();
var user_details_lists = [
['identity', 'Identity Details', [
@ -79,41 +78,46 @@ function addAnotherUser(){
function addEditUser(){
addUser(function (response){
location.href="index.xhtml?tab=user&facet=details&pkey="+$("#login").val();
setupUserDetails($("#login").val());
});
}
function setupAddUser(){
showContent();
$('#content').load("user-add.inc");
}
function setupUserDetails(user){
function setupUserDetails(){
showContent();
sampleData = "sampledata/usershow.json";
$('#content').load("user-details.inc", [], renderUserDetails);
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;
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(
'find', [], {'krbprincipalname': qs['principal']},
on_win_find, null, 'user'
);
on_win_find, null, 'user', "sampledata/usershow.json");
return;
}
if (!qs['pkey'])
return;
ipa_details_load(qs['pkey'], on_win);
ipa_details_load(qs['pkey'], on_win, null, "sampledata/usershow.json");
$('h1').text('Managing user: ' + qs['pkey']);
}
@ -126,24 +130,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 +155,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},
@ -166,7 +174,7 @@ var columns = [
];
function setupUserSearch(){
var userSearchForm = new SearchForm("user", "find", columns);
var userSearchForm = new SearchForm("user", "find", columns, "sampledata/userlist.json");
$("#query").unbind();
$("#query").click(function(){
@ -184,8 +192,6 @@ function populateUserGroupFailure(){
alert("Can't find user");
}
function setupUserGroupEnrollmentSearch(pkey){
sampleData = "sampledata/usershow.json";
showContent();
@ -224,7 +230,7 @@ function enrollUserInNextGroup(){
ipa_cmd( 'add_member',args, options ,
enrollUserInGroupSuccess,
enrollUserInGroupFailure, 'group' );
enrollUserInGroupFailure );
}else{
setupUserGroupMembership();
}
@ -259,8 +265,7 @@ function initializeUserGroupEnrollments(){
});
$("#query").click(function(){
sampleData="sampledata/grouplist.json";
ipa_cmd( 'find', [], {}, populateUserGroupSearch, populateUserGroupFailure, 'group' );
ipa_cmd( 'find', [], {}, populateUserGroupSearch, populateUserGroupFailure, 'group', "sampledata/grouplist.json" );
});