function setupGroup(facet){
if (facet == "details"){
setupGroupDetails();
}else if (facet == "add"){
setupAddGroup();
}else{
setupGroupSearch();
}
}
function addGroupFail(desc){
alert(desc);
}
function addGroup(on_success){
var options = {
posix: $('#isposix').is(':checked') ? 1 : 0 ,
description: $("#groupdescription").val()};
var gid = $("#groupidnumber").val();
if (gid.length > 0){
options.gidnumber = gid;
}
var params = [$("#groupname").val()];
ipa_cmd( 'add', params, options, on_success, addGroupFail, 'group' );
}
function addEditGroup(){
addGroup(function (response){
location.href="index.xhtml?tab=group&facet=details&pkey="+$("#groupname").val();
});
}
function addAnotherGroup(){
addGroup(setupAddGroup);
}
function setupAddGroup(){
showContent();
$("
Add new Group
").appendTo("#content");
$("")
.appendTo("#content");
$("").appendTo("#addGroupForm");
$("
").appendTo("#addGroupForm");
$("Name")
.appendTo("#groupProperties");
$("Description")
.appendTo("#groupProperties");
$("Is this a posix Group")
.appendTo("#groupProperties");
$("GID")
.appendTo("#groupProperties");
$("#addEdit").click(addEditGroup);
$("#addAnother").click(addAnotherGroup);
}
function setupGroupDetails(){
$('#search').css("visibility","hidden");
$('#content').css("visibility","visible");
$('#content').load("group-details.inc");
sampleData = "sampledata/groupshow.json";
}
function setupGroupSearch(){
var columns = [
{title:"Group Name", column:"cn",render: function(current,cell){
renderDetailColumn(current,cell,current[this.column],"group");
}},
{title:"GID", column:"gidnumber",render: renderSimpleColumn},
{title:"Description", column:"description",render: renderSimpleColumn}
];
var groupSearchForm = new SearchForm("group", "find", columns);
$("#query").unbind();
$("#query").click(function(){
sampleData = "sampledata/grouplist.json";
executeSearch(groupSearchForm);
});
$("#new").unbind();
$("#new").click( setupAddGroup );
}