summaryrefslogtreecommitdiffstats
path: root/install/static/host.js
blob: 3ea609b13b4acd3a31031099de7bdc27a3e8a168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function setupHost(facet){
    if (facet == "details"){
	setupHostDetails();
    }else{
	setupHostSearch();
    }
}

function setupHostDetails(host){
    hostDetailsForm.setup(host);    
}


var host_details_list =
    [['identity', 'Host Details', [
        ['fqdn', 'Fully Qualified Domain Name'],
        ['"krbprincipalname', 'Kerberos Principal'],
	['serverhostname', 'Host Name']]]];


function DetailsForm(obj, details_list, pkeyCol, sampleData   ){

    this.obj = obj;
    this.details_list = details_list;
    this.sampleData = sampleData;
    this.pkeyCol = pkeyCol;

    this.setup= function(key){
	window.location.hash="#tab="+this.obj+"user&facet=details&pkey="+key;
	
	//re initialize global parse of parameters
	qs = ipa_parse_qs();
	
	showDetails();
	$('h1').text(":RESET:key");
	
	ipa_details_init(this.obj);
	ipa_details_create(this.details_list, $('#details'));
	ipa_details_load(key, on_win, null, this.sampleData);
    }

}

var hostDetailsForm = new DetailsForm("host",host_details_list,"fqdn","sampledata/hostgroup.json") ;

function renderDetailColumn(form,current,cell){
    $("<a/>",{
	href:"#tab="+this.obj+"&facet=details&pkey="+current.fqdn,
	html:  "" +current[form.pkeyCol],
	click: function(){ form.setup(current[form.pkeyCol])},
    }).appendTo(cell);
}

function setupHostSearch(){
    var columns = [
	{title:"Host",column:"fqdn",render: function(current,cell){
	    renderDetailColumn(hostDetailsForm, current,cell);
	}},
	{title:"Comment",   column: "description", render: renderSimpleColumn},
	{title:"Enrolled?",  render: renderUnknownColumn},
	{title:"Manages?",   render: renderUnknownColumn}
    ];

    var hostSearchForm = new SearchForm("host", "find", columns, "sampledata/hostlist.json");

    $("#query").unbind();
    $("#query").click(function(){
	executeSearch(hostSearchForm);
    });

    $("#new").unbind();
    $("#new").click( function() {
	alert("New Host...");
    });
}