summaryrefslogtreecommitdiffstats
path: root/install/static/hostgroup.js
blob: 3872d125d34c2318f7fc36da75811c090ea561db (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
76
77
78
79
80
81
82

function setupHostgroup(facet){
        hostgroupForms.setup(facet);
}

var hostgroup_details_list =
    [['identity', 'Hostgroup Details', [
        ['cn', 'Hostgroup Name'],
        ['description', 'Description']]]];

var hostgroupFacets = ["details","hosts","assignhosts"];



var hostgroupForms = new HostgroupsForms();

function HostgroupsForms(){

    this.setup = function(facet){
        if (this[facet]){
            this[facet].setup();
        }else{
            this.unspecified.setup();
        }
    }


/**
*  used to initialize the search
*/
    this.hostgroupSearchColumns = [
        {
            title:"Hostgroup",
            column:"cn",
            render:  function(current,cell){
                renderPkeyColumn2('hostgroup', 'cn', current,cell);
            }
        },
        {title:"Description", column:"description",render: renderSimpleColumn}];

    this.hostgroupAddProperties =
    [{title: 'Hostgroup Name', id: 'pkey', type: 'text'},
     {title: 'Description', id: 'description', type: 'text'}];


    /**
       Facets
    */
    this.hostListColumns = [ {title:"host",column:"member_host" }];
    this.obj="hostgroup";
    this.hosts = new AssociationList(
        this.obj,
        "hosts",
        "assignhosts",
        this.hostListColumns, hostgroupFacets );

    this.assignhosts = new AssociationForm(
        this.obj,
        "host",
        "assignhosts",
        hostgroupFacets,
        "fqdn",
        function(){
            return 'Add Hosts to to  hostgroup : '  + qs['pkey'] ;
        },
        BulkAssociator);

    this.details = new DetailsForm("hostgroup",hostgroup_details_list,"cn",hostgroupFacets) ;

    this.add = new EntityBuilder("hostgroup",this.hostgroupAddProperties);

    this.add.getOptions = function() {
        var options = {
            name: $('#pkey').val(),
            description: $('#description').val()
        };
        return options;
    }

    this.search = new SearchForm("hostgroup", "find", this.hostgroupSearchColumns);
    this.unspecified = this.search;
}