<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<template>
    <type>DQL</type>
    <!--
        Meta description of the templates, that anybody
        knows what the template is doing
    -->
    <meta>
        <parameter name="name">Default hostgroup summary template</parameter>
        <parameter name="description">Displays the summary of hostgroups</parameter>
        <parameter name="author">icinga-web developers</parameter>
    </meta>

    <!--
        Options for the template. Change layout and view style to fit the type you
        want to display
    -->
    <option>

        <!--
            Some layout modes:
                - default: full featured view
                - minimal: reduce space consumption (e.g. filters, pagers, ...)
        -->
        <parameter name="mode">default</parameter>
        <parameter name="layout">CronkGridTemplateAjaxGridLayout</parameter>


        <parameter name="rowEvents">
            <!-- Hosts in hostgroup -->
            <parameter>
                <parameter name="title">Icinga</parameter>
                <parameter name="menuid">icinga</parameter>
                <parameter name="items">

                    <!-- Hosts in hostgroup -->
                    <parameter>
                        <parameter name="target">sub</parameter>

                        <parameter name="handler">
                            <parameter name="click">Cronk.grid.handler.Grid.openTemplateGrid</parameter>
                        </parameter>

                        <parameter name="handlerArguments">
                            <parameter name="template">icinga-host-template</parameter>
                            <parameter name="labelField">hostgroup_name</parameter>
                            <parameter name="idPrefix">hosts_subgrid_hostgroup</parameter>
                            <parameter name="titlePrefix">Hosts for</parameter>
                            <parameter name="filterMap">
                                <parameter name="hostgroup_name">hostgroup_name</parameter>
                            </parameter>
                        </parameter>

                        <parameter name="model"></parameter>

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">host_hostgroup_link</parameter>
                        <parameter name="iconCls">icinga-icon-host</parameter>
                        <parameter name="tooltip">Hosts in hostgroup</parameter>
                        <parameter name="text">Hosts</parameter>
                    </parameter>

                    <!-- Services in hostgroup -->
                    <parameter>
                        <parameter name="target">sub</parameter>

                        <parameter name="handler">
                            <parameter name="click">Cronk.grid.handler.Grid.openTemplateGrid</parameter>
                        </parameter>

                        <parameter name="handlerArguments">
                            <parameter name="template">icinga-service-template</parameter>
                            <parameter name="labelField">hostgroup_name</parameter>
                            <parameter name="idPrefix">services_subgrid_hostgroup</parameter>
                            <parameter name="titlePrefix">Services for</parameter>
                            <parameter name="filterMap">
                                <parameter name="hostgroup_name">hostgroup_name</parameter>
                            </parameter>
                        </parameter>

                        <parameter name="model"></parameter>

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">service_hostgroup_link</parameter>
                        <parameter name="iconCls">icinga-icon-service</parameter>
                        <parameter name="tooltip">Services in hostgroup</parameter>
                        <parameter name="text">Services</parameter>
                    </parameter>
                </parameter>
            </parameter>
        </parameter>


        <!-- Special config for the EXTJS grid view (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.GridView) -->
        <parameter name="Ext.grid.GridView">
            <parameter name="headersDisabled">true</parameter>
        </parameter>

        <!-- Special config for the EXTJS grid panel (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.GridPanel) -->
        <!--
            !!! Attention: this options goes to the main grid panel, only change layout attributes, all other
            will corrupt the auto build of the GridPanel
        -->
        <!-- <parameter name="Ext.grid.GridPanel">
            <parameter name="disable">true</parameter>
            <parameter name="hidden">false</parameter>
        </parameter> -->

        <!--
            Selection model of rows (checkbox/row). This is needed for
            commands and maybe other user things ...
        -->
        <parameter name="selection_model">checkbox</parameter>

        <!--
            Enable/disable commands and specify which of type you'll need
        -->
        <parameter name="commands">
            <!--
                Generally enabled od disabled
            -->
            <parameter name="enabled">true</parameter>

            <!--
                Sourcefieldmapping
                * Which field content comes from the template data source
            -->
            <parameter name="source">
                <parameter name="IcingaApiConstants::COMMAND_HOSTGROUP">hostgroup_name</parameter>
                <parameter name="IcingaApiConstants::COMMAND_INSTANCE">instance_name</parameter>
            </parameter>

            <parameter name="predefined">
                <parameter name="IcingaApiConstants::COMMAND_AUTHOR">${xmlfn.author}</parameter>
            <parameter name="IcingaApiConstants::COMMAND_FIXED">1</parameter>
            </parameter>

            <!--
                Which commands are available in this template and can charged
                with template data
            -->
            <parameter name="items">
                <parameter name="SCHEDULE_HOSTGROUP_HOST_DOWNTIME">
                    <parameter name="title">Schedule downtime for all hosts in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-downtime</parameter>
                </parameter>
                <parameter name="SCHEDULE_HOSTGROUP_SVC_DOWNTIME">
                    <parameter name="title">Schedule downtime for all services in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-downtime</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_HOSTGROUP_HOST_NOTIFICATIONS">
                    <parameter name="title">Enable notifications for all hosts in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-notify</parameter>
                </parameter>
                <parameter name="DISABLE_HOSTGROUP_HOST_NOTIFICATIONS">
                    <parameter name="title">Disable notifications for all hosts in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-notify-disabled</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_HOSTGROUP_SVC_NOTIFICATIONS">
                    <parameter name="title">Enable notifications for all services in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-notify</parameter>
                </parameter>
                <parameter name="DISABLE_HOSTGROUP_SVC_NOTIFICATIONS">
                    <parameter name="title">Disable notifications for all services in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-notify-disabled</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_HOSTGROUP_SVC_CHECKS">
                    <parameter name="title">Enable active checks of all services in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-arrow-out</parameter>
                </parameter>
                <parameter name="DISABLE_HOSTGROUP_SVC_CHECKS">
                    <parameter name="title">Disable active checks of all services in this hostgroup</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                </parameter>
            </parameter>

        </parameter>
<!--
        <parameter name="filter">
            <paramter name="hostgroup_alias">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">Alias</parameter>

                 Operator type is needed because we don't know which type returned
                <parameter name="operator_type">text</parameter>

                <parameter name="api_target">hostgroup</parameter>
                <parameter name="api_keyfield">HOSTGROUP_ALIAS</parameter>
                <parameter name="api_valuefield">HOSTGROUP_ALIAS</parameter>

            </paramter>
            <paramter name="hostgroup_alias">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">Alias</parameter>

                 Operator type is needed because we don't know which type returned
                <parameter name="operator_type">text</parameter>

                <parameter name="api_target">hostgroup</parameter>
                <parameter name="api_keyfield">HOSTGROUP_ALIAS</parameter>
                <parameter name="api_valuefield">HOSTGROUP_ALIAS</parameter>

            </paramter>
        </parameter>-->
    </option>

    <!--
        What data to display? Define icinga data targets and countfields
    -->
    <datasource>
        <parameter name="target">TARGET_HOSTGROUP_SUMMARY</parameter>
        <parameter name="countmode">field</parameter>

    </datasource>

    <!--
        Paging record on its result
    -->
    <pager>
        <parameter name="enabled">true</parameter>
        <parameter name="start">0</parameter>
    </pager>

    <grouping>
        <parameter name="enabled">true</parameter>
        <parameter name="field">hostgroup_name</parameter>

        <!-- GroupingView options (http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.GroupingView) -->
        <parameter name="Ext.grid.GroupingView">
            <parameter name="hideGroupedColumn">true</parameter>
            <parameter name="startCollapsed">false</parameter>
        </parameter>

        <!-- Options for the store (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.GroupingStore) -->
        <!-- <parameter name="Ext.data.GroupingStore">

        </parameter> -->
    </grouping>

    <!--
        Field decleration: What to display and how
    -->
    <fields>
        <field name="instance_name">
            <datasource>
                <parameter name="field">INSTANCE_NAME</parameter>
            </datasource>

            <display>
                <parameter name="visible">false</parameter>
                <parameter name="label">Instance</parameter>

                <parameter name="width">60</parameter>

                <parameter name="Ext.grid.Column">
                    <parameter name="fixed">false</parameter>
                </parameter>
            </display>

            <filter>
                <parameter name="enabled">true</parameter>

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>

                <!-- Operator type is needed because we don't know which type returned-->
                <parameter name="operator_type">text</parameter>

                <parameter name="api_target">instance</parameter>
                <parameter name="api_keyfield">INSTANCE_NAME</parameter>
                <parameter name="api_valuefield">INSTANCE_NAME</parameter>
            </filter>

            <order>
                <parameter name="enabled">false</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

        <field name="hostgroup_id">
            <datasource>
                <parameter name="field">HOSTGROUP_ID</parameter>
            </datasource>

            <display>
                <parameter name="visible">false</parameter>
                <parameter name="label">ID</parameter>
            </display>

            <filter>
                <parameter name="enabled">false</parameter>
            </filter>

            <order>
                <parameter name="enabled">false</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

        <field name="hostgroup_name">
            <datasource>
                <parameter name="field">HOSTGROUP_NAME</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Hostgroup</parameter>
            </display>

            <filter>
                <parameter name="enabled">false</parameter>
            </filter>

            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">true</parameter>
            </order>
        </field>

        <field name="hostgroup_alias">
            <datasource>
                <parameter name="field">HOSTGROUP_ALIAS</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Alias</parameter>
                <parameter name="width">200</parameter>
            </display>



            <filter>
                <parameter name="enabled">true</parameter>

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>

                <!-- Operator type is needed because we don't know which type returned-->
                <parameter name="operator_type">text</parameter>

                <parameter name="api_target">hostgroup</parameter>
                <parameter name="api_keyfield">HOSTGROUP_ALIAS</parameter>
                <parameter name="api_valuefield">HOSTGROUP_ALIAS</parameter>
            </filter>


            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

        <field name="host_status">
            <datasource>
                <parameter name="field">HOST_CURRENT_STATE</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Status</parameter>
                <parameter name="width">200</parameter>

                <!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
                <parameter name="Ext.grid.Column">
                    <parameter name="fixed">true</parameter>
                </parameter>

                <parameter name="jsFunc">
                    <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                    <parameter name="function">hostStatus</parameter>

                    <!-- renderer/gridevent[cellclick|celldblclick|...] -->
                    <parameter name="type">renderer</parameter>
                </parameter>
            </display>


            <filter>
                <parameter name="enabled">true</parameter>

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.hoststatus</parameter>

                <parameter name="no_operator">false</parameter>
            </filter>

            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">true</parameter>
            </order>
        </field>

        <field name="host_status_count">
            <datasource>
                <parameter name="field">HOSTGROUP_SUMMARY_COUNT</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Count</parameter>
            </display>

           <filter>
                <parameter name="enabled">false</parameter>


            </filter>


            <order>
                <parameter name="enabled">false</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

    </fields>

</template>
