<?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">YOUR TEMPLATE NAME</parameter>
        <parameter name="description">TEMPLATE DESCRIPTION</parameter>
        <parameter name="author">YOUR</parameter>
    </meta>

    <!--
        Options for the template. Change layout and view style to fit the type you
        want to display
    -->
    <option>
        <parameter name="mode">default</parameter>
        <parameter name="layout">CronkGridTemplateAjaxGridLayout</parameter>

        <parameter name="gridEvents">
        </parameter>


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


        <parameter name="filter"></parameter>
   </option>

    <!--
        What data to display? Define icinga data targets and countfields
    -->
    <datasource>
        <parameter name="target">EXAMPLE_VIEW_HOST_IN_HOSTGROUP</parameter>
        <parameter name="countmode">field</parameter>
        <parameter name="parameters">
            <parameter name="hostgroup">'hostgroup_02','hostgroup_03'</parameter>
        </parameter>
    </datasource>

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

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

    <!--
        Field decleration: What to display and how
    -->
    <fields>

        <!--
            Create a id column which isn't displayed per default
        -->
        <field name="HOST_OBJECT_ID">
            <datasource>
                <parameter name="field">HOST_OBJECT_ID</parameter>
            </datasource>

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

            <!-- The ID has a simple numeric filter-->
            <filter>
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.number</parameter>
                <parameter name="no_operator">false</parameter>
                <parameter name="field">HOST_OBJECT_ID</parameter>
            </filter>
            <!-- We order by id per default-->
            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">true</parameter>
            </order>
        </field>

        <!--
            Add the host name
        -->
        <field name="host_name">
            <datasource>
                <parameter name="field">HOST_NAME</parameter>
            </datasource>

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

            <!--
                Allow to filter this column supported by
                icinga-api provided autocompletion
            -->
            <filter>
                <parameter name="enabled">true</parameter>

                <parameter name="type">extjs</parameter>
                <!-- provide autocompletion from the icinga-api -->
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">host</parameter>
                <parameter name="api_keyfield">HOST_NAME</parameter>
                <parameter name="api_valuefield">HOST_NAME</parameter>
            </filter>
            <!-- Allow ordering, but don't order by default -->
            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

        <field name="maintenance_admin">
            <datasource>
                <parameter name="field">MAINTENANCE_ADMIN</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Current maintenance</parameter>
            </display>

            <!--
                Ordering and filtering is disabled, as merged fields make this a
                little bit more complicated
            -->
            <filter>
                <parameter name="enabled">false</parameter>
            </filter>
            <order>
                <parameter name="enabled">false</parameter>
                <parameter name="default">false</parameter>
            </order>
        </field>

        <!--
            Diisplay the host status
            here we have a more sophisticated display section, as we
            use the AdvancedHostStatusColumnRenderer which provides
            information about the host and it's unhandled service problems
        -->
        <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">100</parameter>

                <parameter name="Ext.grid.Column">
                    <!-- use a fixed size for this column-->
                    <parameter name="fixed">true</parameter>
                </parameter>

                <!--
                    This column has a special renderer, otherwise you would only
                    see 0,1 or 2 in the status column
                -->

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

            <!--
                Hoststatus has a special filter type that maps the host status
                names (up,down,unreachable) automatically to it's numerical representations
            -->
            <filter>
                <parameter name="enabled">true</parameter>
                <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">false</parameter>
            </order>
        </field>

        <!--
            This is rather simple:
        -->
        <field name="plugin_output">
            <datasource>
                <parameter name="field">HOST_OUTPUT</parameter>
            </datasource>

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

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

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

        <!--
            This is rather simple:
        -->
        <field name="last_comment">
            <datasource>
                <parameter name="field">HOST_LAST_COMMENT</parameter>
            </datasource>

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

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

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

</template>
