<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2010-2019 Evolveum
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<dashboard xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
       xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3"
         xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3">
    <name>System Status Dashboard</name>
    <display>
    <!-- May be also given by archetype ... and display may be part of ObjectType later. -->
        <label>System Status Dashboard</label>
    </display>
    <widget>
        <identifier>resources-up</identifier>
        <description>Widget that shows all the resources that are up. Based on "Resources Up" object collection.</description>
        <display>
            <label>Resources up</label>
            <color>#00a65a</color>
            <icon>
                <cssClass>fa fa-database</cssClass>
            </icon>
        </display>
        <data>
            <sourceType>objectCollection</sourceType>
            <collection>
                <collectionRef oid="15de186e-1d8c-11e9-a469-8f5d9cfc0259" type="c:ObjectCollectionType"/>
            </collection>
        </data>
        <presentation>
            <dataField>
                <fieldType>value</fieldType>
                <expression>
                    <proportional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ProportionalExpressionEvaluatorType">
                        <style>percentage</style>
                    </proportional>
                </expression>
            </dataField>
            <dataField>
                <fieldType>unit</fieldType>
                <expression>
                    <value>up</value>
                </expression>
            </dataField>
            <variation>
                <condition>
                    <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                        <code>
                           policySituations.contains("#resourceHealthDanger")
                        </code>
                    </script>
                </condition>
                <display>
                    <color>#dd4b39</color>
                </display>
            </variation>
        </presentation>
    </widget>
    <widget>
        <identifier>audit-recent-errors</identifier>
        <description>Widget that shows recent errors. Data are taken from audit log.</description>
        <display>
            <label>Recent errors</label>
            <color>#00a65a</color>
            <icon>
                <cssClass>fa fa-ban</cssClass>
            </icon>
        </display>
        <data>
            <sourceType>auditSearch</sourceType>
            <collection>
                <collectionRef oid="16be4077-53fd-4ada-b0cc-572318e855f5" type="c:ObjectCollectionType"/>
            </collection>
        </data>
        <presentation>
            <dataField>
                <fieldType>value</fieldType>
                <expression>
                    <proportional xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ProportionalExpressionEvaluatorType">
                        <style>percentage</style>
                    </proportional>
                </expression>
            </dataField>
            <dataField>
                <fieldType>unit</fieldType>
                <expression>
                    <value>failed</value>
                </expression>
            </dataField>
            <variation>
                <condition>
                    <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                        <code>proportional.getPercentage() &gt; 5</code>
                    </script>
                </condition>
                <display>
                    <color>#dd4b39</color>
                </display>
            </variation>
            <view>
                <!-- This will be used when the list of audit entries is displayed. -->
                <!-- EXPERIMENTAL: do not rely on this. Functionality is very limited. And it is likely to change. -->
                <display>
                    <!-- Custom CSS class/style for the entire table can be here. -->
                </display>
                <column>
                    <name>delta</name>
                    <path>delta</path>
                    <display>
                        <label>Delta</label>
                        <!-- CSS class/style for the column may be here -->
                    </display>
                    <previousColumn>outcome</previousColumn>
                    <export>
                        <expression>
                            <script>
                                <code>ReportUtils.printDelta(....)</code>
                            </script>
                        </expression>
                    </export>
                </column>
            </view>
        </presentation>
    </widget>
    <widget>
        <identifier>hr-sync</identifier>
        <description>Widget that shows status of Cleanup task.</description>
        <display>
            <label>Cleanup</label>
            <color>#dd4b39</color>
            <icon>
                <cssClass>fa fa-tasks</cssClass>
            </icon>
        </display>
        <data>
            <sourceType>object</sourceType>
            <objectRef oid="00000000-0000-0000-0000-000000000005" type="c:TaskType"/>
        </data>
        <presentation>
            <dataField>
                <fieldType>value</fieldType>
                <expression>
                    <c:path xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="t:ItemPathType">$object/executionState</c:path>
                </expression>
            </dataField>
            <variation>
                <condition>
                    <script xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="c:ScriptExpressionEvaluatorType">
                        <code>
                           import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskExecutionStatusType;

                           object.getExecutionStatus().equals(TaskExecutionStatusType.RUNNABLE)
                        </code>
                    </script>
                </condition>
                <display>
                    <color>#00a65a</color>
                </display>
            </variation>
        </presentation>
    </widget>
</dashboard>
