<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<template>
    <type>DQL</type>

    <meta>
        <parameter name="name">Icinga services with unhandled problems</parameter>
        <parameter name="description">Displays object status information</parameter>
        <parameter name="author">icinga-web developers</parameter>
    </meta>


    <option>
        <parameter name="mode">default</parameter>
        <parameter name="layout">CronkGridTemplateAjaxGridLayout</parameter>

        <parameter name="gridEvents">

            <!-- Initialize comments -->
            <parameter>
                <parameter name="type">viewready</parameter>
                <parameter name="function">Cronk.grid.CommentColumnRenderer.init</parameter>
                <parameter name="arguments">
                    <parameter name="column_name">comments</parameter>
                    <!-- <parameter name="class">icinga-icon-comment icon-24 icinga-link icinga-notext</parameter> -->
                    <parameter name="title">Comments for {service_name}</parameter>
                </parameter>
            </parameter>

            <!-- Initialize info icons lazy -->
            <parameter>
                <parameter name="type">viewready</parameter>
                <parameter name="namespace">Cronk.grid.InfoIconColumnRenderer</parameter>
                <parameter name="function">init</parameter>

                <parameter name="arguments">
                    <parameter name="column_name">service_info_icons</parameter>
                </parameter>
            </parameter>

        </parameter>
        
        <parameter name="rowEvents">
            <parameter>
                <parameter name="title">Icinga</parameter>
                <parameter name="menuid">icinga</parameter>
                <parameter name="items">
                    
                    <!-- Service information -->
                    <parameter>
                        <parameter name="target">sub</parameter>

                        <parameter name="handler">
                            <parameter name="click">Cronk.grid.handler.Info.service</parameter>
                        </parameter>

                        <parameter name="handlerArguments">
                            <parameter name="objectid_field">service_object_id</parameter>
                        </parameter>

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

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">detail_info_service</parameter>
                        <parameter name="iconCls">icinga-icon-servicedetail</parameter>
                        <parameter name="tooltip">Detailed information</parameter>
                        <parameter name="text">Details</parameter>
                    </parameter>
                    
                    <!-- Host information -->
                    <parameter>
                        <parameter name="target">sub</parameter>

                        <parameter name="handler">
                            <parameter name="click">Cronk.grid.handler.Info.host</parameter>
                        </parameter>

                        <parameter name="handlerArguments">
                            <parameter name="objectid_field">host_object_id</parameter>
                        </parameter>

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

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">detail_info_host</parameter>
                        <parameter name="iconCls">icinga-icon-hostdetail</parameter>
                        <parameter name="tooltip">Detailed host information</parameter>
                        <parameter name="text">Host details</parameter>
                    </parameter>
                    
                    <!-- Show host for this service -->
                    <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">service_name</parameter>
                            <parameter name="idPrefix">host_subgrid_hosts</parameter>
                            <parameter name="titlePrefix">Hosts for</parameter>
                            <parameter name="filterMap">
                                <parameter name="host_object_id">host_object_id</parameter>
                            </parameter>
                        </parameter>

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

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">services_for_host</parameter>
                        <parameter name="iconCls">icinga-icon-host</parameter>
                        <parameter name="tooltip">Show host</parameter>
                        <parameter name="text">Host</parameter>
                    </parameter>
                    
                    <!-- Service history for that host -->
                    <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-history-template</parameter>
                            <parameter name="labelField">service_name</parameter>
                            <parameter name="idPrefix">servicehistory_subgrid_service</parameter>
                            <parameter name="titlePrefix">History for</parameter>
                            <parameter name="filterMap">
                                <parameter name="service_object_id">service_object_id</parameter>
                            </parameter>
                        </parameter>

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

                        <parameter name="xtype">grideventbutton</parameter>
                        <parameter name="menuid">host_history_for_host</parameter>
                        <parameter name="iconCls">icinga-icon-book</parameter>
                        <parameter name="tooltip">Show history</parameter>
                        <parameter name="text">History</parameter>
                    </parameter>
                    
                </parameter>
            </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_HOST">host_name</parameter>
                <parameter name="IcingaApiConstants::COMMAND_SERVICE">service_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_ENDTIME">now+7200</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_SVC_CHECK">
                    <parameter name="title">Schedule next service check</parameter>
                    <parameter name="icon_class">icinga-icon-cog</parameter>
                </parameter>
                <parameter name="SCHEDULE_FORCED_SVC_CHECK">
                    <parameter name="title">Schedule forced service check</parameter>
                    <parameter name="icon_class">icinga-icon-cog</parameter>
                </parameter>
                <parameter name="PROCESS_SERVICE_CHECK_RESULT">
                    <parameter name="title">Process service check result</parameter>
                    <parameter name="icon_class">icinga-icon-cog</parameter>
                </parameter>
                <parameter name="ACKNOWLEDGE_SVC_PROBLEM">
                    <parameter name="title">Acknowledge service check problem</parameter>
                    <parameter name="icon_class">icinga-icon-exclamation-white</parameter>
                </parameter>
                <parameter name="ACKNOWLEDGE_SVC_PROBLEM_EXPIRE">
                    <parameter name="title">Acknowledge service check problem with expiration time</parameter>
                    <parameter name="icon_class">icinga-icon-exclamation-clock</parameter>
                </parameter>
                <parameter name="REMOVE_SVC_ACKNOWLEDGEMENT">
                    <parameter name="title">Remove service acknowledgement</parameter>
                    <parameter name="icon_class">icinga-icon-exclamation-red</parameter>
                </parameter>
                <parameter name="SCHEDULE_SVC_DOWNTIME">
                    <parameter name="title">Schedule a service downtime</parameter>
                    <parameter name="icon_class">icinga-icon-downtime</parameter>
                </parameter>
                <parameter name="ADD_SVC_COMMENT">
                    <parameter name="title">Add a service comment</parameter>
                    <parameter name="icon_class">icinga-icon-comment</parameter>
                </parameter>
                <parameter name="SEND_CUSTOM_SVC_NOTIFICATION">
                    <parameter name="title">Send custom service notification</parameter>
                    <parameter name="icon_class">icinga-icon-notify</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_SVC_CHECK">
                    <parameter name="title">Enable active checks of this service</parameter>
                    <parameter name="icon_class">icinga-icon-arrow-out</parameter>
                </parameter>
                <parameter name="DISABLE_SVC_CHECK">
                    <parameter name="title">Disable active checks of this service</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_PASSIVE_SVC_CHECKS">
                    <parameter name="title">Start accepting passive checks for this service</parameter>
                    <parameter name="icon_class">icinga-icon-arrow-in</parameter>
                </parameter>
                <parameter name="DISABLE_PASSIVE_SVC_CHECKS">
                    <parameter name="title">Stop accepting passive checks for this service</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="START_OBSESSING_OVER_SVC">
                    <parameter name="title">Start obsessing over this service</parameter>
                    <parameter name="icon_class">icinga-icon-bricks</parameter>
                </parameter>
                <parameter name="STOP_OBSESSING_OVER_SVC">
                    <parameter name="title">Stop obsessing over this service</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_SVC_NOTIFICATIONS">
                    <parameter name="title">Enable notifications for this service</parameter>
                    <parameter name="icon_class">icinga-icon-notify</parameter>
                </parameter>
                <parameter name="DISABLE_SVC_NOTIFICATIONS">
                    <parameter name="title">Disable notifications for this service</parameter>
                    <parameter name="icon_class">icinga-icon-notify-disabled</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_SVC_EVENT_HANDLER">
                    <parameter name="title">Enable event handler for this service</parameter>
                    <parameter name="icon_class">icinga-icon-bricks</parameter>
                </parameter>
                <parameter name="DISABLE_SVC_EVENT_HANDLER">
                    <parameter name="title">Disable event handler for this service</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                    <parameter name="seperator">true</parameter>
                </parameter>
                <parameter name="ENABLE_SVC_FLAP_DETECTION">
                    <parameter name="title">Enable flap detection for this service</parameter>
                    <parameter name="icon_class">icinga-icon-flapping</parameter>
                </parameter>
                <parameter name="DISABLE_SVC_FLAP_DETECTION">
                    <parameter name="title">Disable flap detection for this service</parameter>
                    <parameter name="icon_class">icinga-icon-cross</parameter>
                </parameter>

            </parameter>
        </parameter>

        <!--
            Additional filter
            * Keep in mind to map the names in datasource.additional_filter_fields
        -->
        <parameter name="filter">
            <paramter name="customvariable_name">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">CV Name</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">customvariable</parameter>
                <parameter name="api_keyfield">CUSTOMVARIABLE_NAME</parameter>
                <parameter name="api_valuefield">CUSTOMVARIABLE_NAME</parameter>
            </paramter>
            <paramter name="customvariable_value">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">CV Val</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">customvariable</parameter>
                <parameter name="api_keyfield">CUSTOMVARIABLE_VALUE</parameter>
                <parameter name="api_valuefield">CUSTOMVARIABLE_VALUE</parameter>
                <parameter name="api_additional">CUSTOMVARIABLE_NAME</parameter>
                <parameter name="api_exttpl"><![CDATA[ {CUSTOMVARIABLE_NAME}: {CUSTOMVARIABLE_VALUE} ]]></parameter>
                <parameter name="api_id">CUSTOMVARIABLE_VALUE</parameter>
            </paramter>
            <paramter name="hostgroup_name">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">Hostgroup</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">hostgroup</parameter>
                <parameter name="api_keyfield">HOSTGROUP_NAME</parameter>
                <parameter name="api_valuefield">HOSTGROUP_NAME</parameter>
            </paramter>
            <paramter name="servicegroup_name">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="label">Servicegroup</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">servicegroup</parameter>
                <parameter name="api_keyfield">SERVICEGROUP_NAME</parameter>
                <parameter name="api_valuefield">SERVICEGROUP_NAME</parameter>
            </paramter>
            <paramter name="notifications_enabled">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.bool</parameter>
                <parameter name="label">Notifications enabled</parameter>
            </paramter>
            <paramter name="problem_acknowledged">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.bool</parameter>
                <parameter name="label">Acknowledged</parameter>
            </paramter>
            <paramter name="scheduled_downtime_depth">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.bool</parameter>
                <parameter name="label">In downtime</parameter>
            </paramter>
            <paramter name="service_is_pending">
                <parameter name="enabled">true</parameter>
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.bool</parameter>
                <parameter name="label">Is pending</parameter>
            </paramter>
        </parameter>

    </option>

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

        <parameter name="id">service_object_id</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">host_name</parameter>

        <parameter name="Ext.grid.GroupingView">
            <parameter name="hideGroupedColumn">true</parameter>
        </parameter>
    </grouping>

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

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Object image</parameter>
                <parameter name="icon">icinga-icon-image</parameter>
                <parameter name="width">25</parameter>
                <parameter name="Ext.grid.Column">
                    <parameter name="menuDisabled">true</parameter>
                    <parameter name="fixed">true</parameter>
                </parameter>
                <parameter name="jsFunc">
                    <parameter>
                        <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                        <parameter name="function">columnImage</parameter>

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

                        <parameter name="arguments">
                            <parameter name="image">
                                <![CDATA[
                                    <tpl if="service_icon == ''" />
                                        images/icons/application-monitor.png
                                    </tpl>
                                    <tpl if="service_icon != ''" />
                                        images/icinga/{service_icon}
                                    </tpl>

                                ]]>
                            </parameter>
                        </parameter>
                    </parameter>
                </parameter>
            </display>

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

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

        </field>
    <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>
                <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="host_object_id">
            <datasource>
                <parameter name="field">HOST_OBJECT_ID</parameter>
            </datasource>

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

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

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

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

        <field name="service_object_id">
            <datasource>
                <parameter name="field">SERVICE_OBJECT_ID</parameter>
            </datasource>

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

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

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

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

                <parameter name="field">SERVICE_OBJECT_ID</parameter>
            </filter>

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

        <field name="host_name">
            <datasource>
                <parameter name="field">HOST_NAME</parameter>
            </datasource>

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

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

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <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>

            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">true</parameter>
                <parameter name="direction">ASC</parameter>

                <!--  <parameter name="field">A_NEW_FIELD_TO_SORT</parameter> -->
            </order>
        </field>

        <field name="host_alias">
            <datasource>
                <parameter name="field">HOST_ALIAS</parameter>
            </datasource>

            <display>
                <parameter name="visible">false</parameter>
                <parameter name="label">Host alias</parameter>

            </display>

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

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <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_ALIAS</parameter>
                <parameter name="api_valuefield">HOST_ALIAS</parameter>
            </filter>

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

        <field name="host_display_name">
            <datasource>
                <parameter name="field">HOST_DISPLAY_NAME</parameter>
            </datasource>

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

            </display>

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

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <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_DISPLAY_NAME</parameter>
                <parameter name="api_valuefield">HOST_DISPLAY_NAME</parameter>
            </filter>

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

        <field name="service_name">
            <datasource>
                <parameter name="field">SERVICE_NAME</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Service</parameter>
                <parameter name="width">180</parameter>
            </display>

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

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">service</parameter>
                <parameter name="api_keyfield">SERVICE_NAME</parameter>
                <parameter name="api_valuefield">SERVICE_NAME</parameter>
            </filter>

            <order>
                <parameter name="enabled">true</parameter>
                <!--  <parameter name="field">A_NEW_FIELD_TO_SORT</parameter> -->
            </order>
        </field>

        <field name="service_display_name">
            <datasource>
                <parameter name="field">SERVICE_DISPLAY_NAME</parameter>
            </datasource>

            <display>
                <parameter name="visible">false</parameter>
                <parameter name="label">Display Name</parameter>
            </display>

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

                <!-- Filter configuration -->
                <parameter name="type">extjs</parameter>
                <parameter name="subtype">appkit.ext.filter.api</parameter>
                <parameter name="operator_type">text</parameter>
                <parameter name="api_target">service</parameter>
                <parameter name="api_keyfield">SERVICE_DISPLAY_NAME</parameter>
                <parameter name="api_valuefield">SERVICE_DISPLAY_NAME</parameter>
            </filter>

            <order>
                <parameter name="enabled">true</parameter>
                <!--  <parameter name="field">A_NEW_FIELD_TO_SORT</parameter> -->
            </order>
        </field>

        <field name="comments">
            <datasource>
                <parameter name="field">SERVICE_OBJECT_ID</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Comments</parameter>
                <parameter name="icon">icinga-icon-comment</parameter>

                <parameter name="width">22</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="menuDisabled">true</parameter>
                    <parameter name="fixed">true</parameter>
                </parameter>

                <parameter name="jsFunc">
                    <parameter>
                        <parameter name="namespace">Cronk.grid.CommentColumnRenderer</parameter>
                        <parameter name="function">commentColumn</parameter>

                        <!-- renderer/gridevent[cellclick|celldblclick|...] -->
                        <parameter name="type">renderer</parameter>
                        <parameter name="arguments">
                            <parameter name="target">service</parameter>
                            <parameter name="target_field">service_object_id</parameter>
                        </parameter>
                    </parameter>
                </parameter>

            </display>

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

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

        <field name="service_state_type">
            <datasource>
                <parameter name="field">SERVICE_STATE_TYPE</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">State Type</parameter>
                <parameter name="width">60</parameter>
                <parameter name="Ext.grid.Column">
                    <parameter name="fixed">true</parameter>
                </parameter>
                <parameter name="jsFunc">
                    <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                    <parameter name="function">stateType</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.statetype</parameter>
                <parameter name="no_operator">false</parameter>
                <parameter name="field">service_state_type</parameter>
            </filter>

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

        <field name="service_status">
            <datasource>
                <parameter name="field">SERVICE_CURRENT_STATE</parameter>
            </datasource>

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

                <parameter name="width">100</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">serviceStatus</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.servicestatus</parameter>

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

            <order>
                <parameter name="enabled">true</parameter>
                <parameter name="default">false</parameter>
                <parameter name="field">SERVICE_CURRENT_STATE</parameter>
            </order>
        </field>
        <field name="service_last_check">
            <datasource>
                <parameter name="field">SERVICE_LAST_CHECK</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Last check</parameter>
                <parameter name="width">120</parameter>
                
                <!-- Let the agavi translation manager transform the date -->
                <parameter name="userFunc">
                    <parameter name="model">Cronks.ColumnDisplay.Format</parameter>
                    <parameter name="method">agaviDateFormat</parameter>
                </parameter>
            </display>

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

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

        <field name="service_duration">
            <datasource>
                   <parameter name="field"><![CDATA[(CASE WHEN ss.last_state_change<='1970-01-01 00:00:00' THEN ps.program_start_time ELSE ss.last_state_change END)]]></parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Duration</parameter>
                <parameter name="width">110</parameter>
                <parameter name="jsFunc">
                    <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                    <parameter name="function">durationField</parameter>
                    <parameter name="type">renderer</parameter>
                    <parameter name="arguments">
                        <parameter name="type">service</parameter>
                    </parameter>
                </parameter>
            </display>

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

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

        <field name="service_info_icons">

            <datasource>
                <parameter name="field">SERVICE_OBJECT_ID</parameter>
            </datasource>

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

                <parameter name="width">50</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="menuDisabled">true</parameter>
                </parameter>

                <parameter name="jsFunc">
                    <parameter name="namespace">Cronk.grid.InfoIconColumnRenderer</parameter>
                    <parameter name="function">infoColumn</parameter>
                    <parameter name="type">renderer</parameter>
                    <parameter name="arguments">
                        <!-- 1==Host 2==Service -->
                        <parameter name="type">2</parameter>
                    </parameter>
                </parameter>
            </display>

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

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

        </field>

        <field name="plugin_output">
            <datasource>
                <parameter name="field">SERVICE_OUTPUT</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Output</parameter>
                <parameter name="width">250</parameter>
                
                <parameter name="jsFunc">
                    <parameter>
                        <parameter name="namespace">Cronk.grid.ColumnRenderer</parameter>
                        <parameter name="function">customColumnPerfdataSanitized</parameter>
                    </parameter>
                </parameter>
            </display>

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

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

        <field name="service_check_attempt">
            <datasource>
                <parameter name="field">SERVICE_CURRENT_CHECK_ATTEMPT</parameter>
            </datasource>

            <display>
                <parameter name="visible">true</parameter>
                <parameter name="label">Attempt</parameter>
                
                <parameter name="width">60</parameter>
                
                <!-- Config for the AJAX grid (see http://www.extjs.com/deploy/dev/docs/?class=Ext.grid.Column) -->
                <parameter name="Ext.grid.Column">
                    <!-- fixed here is not recommened, it blocks resizing of "Output" -mfrosch
                    <parameter name="fixed">true</parameter>
                    -->
                    <parameter name="menuDisabled">true</parameter>
                </parameter>

                <parameter name="userFunc">
                    <parameter name="model">Cronks.ColumnDisplay.Format</parameter>
                    <parameter name="method">formatTemplate</parameter>
                    <parameter name="arguments">
                        <parameter name="format"><![CDATA[${field.service_check_attempt} / ${field.service_max_attempt}]]></parameter>
                    </parameter>
                </parameter>
            </display>

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

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

            <display>
                <parameter name="visible">false</parameter>
                <parameter name="label">Hard service state</parameter>
                <parameter name="width">100</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">serviceStatus</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.servicestatus</parameter>

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

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

    </fields>

</template>
