<form script="autodiscover.js" stylesheet="ui_simple.css" isVisible="true" version="1.1" theme="dark">

    <label>mcatalog data dictionary - discover and explore performance metrics</label>
    <description>Explore available raw metrics with the dendogram visualization</description>

    <row>
        <html>
            <div style="text-align: center;">
                <img src="../../static/app/metricator-for-nmon/icons/dark_theme/dictionary.png" alt="Dictionary"/>
            </div>
            <div class="custom">
                <h1>Data dictionary</h1>
            </div>
        </html>
    </row>

    <row>
        <panel>
            <title>Filtering options:</title>

            <input type="dropdown" token="show_OStype_tk" searchWhenChanged="true">
                <label>Filter by Operating System:</label>
                <choice value="false">false</choice>
                <choice value="true">true</choice>
                <default>false</default>
                <change>
                    <condition value="true">
                        <set token="show_OStype">true</set>
                    </condition>
                    <condition value="true">
                        <unset token="show_OStype"></unset>
                    </condition>
                </change>
            </input>

            <input type="dropdown" depends="$show_OStype$" token="osfilter" searchWhenChanged="true">
                <label>Is relevant for:</label>
                <choice value="*">Any</choice>
                <choice value="AIX">AIX</choice>
                <choice value="Linux">Linux</choice>
                <choice value="Solaris">Solaris</choice>
                <default>*</default>
            </input>

        </panel>
    </row>

    <row>
        <panel>

            <table>
                <title>Brief Data Table: click on a row to show the detail of metrics available</title>
                <search>
                    <query>| `def_mcatalog_dictionary($osfilter$)`
|  eval main_type="raw_metrics"
|  stats dc(metric) as "number of metrics" by main_type, metric_category</query>
                    <earliest>-24h</earliest>
                    <latest>now</latest>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">50</option>
                <drilldown>
                    <set token="drilldown_itemfilter">"$row.metric_category$"</set>
                    <set token="form.filtered_metric_category">"$row.metric_category$"</set>
                    <set token="show_filtered_metric_category">true</set>
                </drilldown>
            </table>

            <table depends="$drilldown_itemfilter$">
                <title>Details:</title>
                <search>
                    <query>| `def_mcatalog_dictionary($osfilter$)` | where (metric_category == $drilldown_itemfilter$ ) | fields - count | sort 0 metric_category, nmon_section, metric</query>
                    <earliest>-24h</earliest>
                    <latest>now</latest>
                </search>
                <option name="wrap">true</option>
                <option name="rowNumbers">false</option>
                <option name="dataOverlayMode">none</option>
                <option name="drilldown">row</option>
                <option name="count">50</option>
            </table>

        </panel>
    </row>

    <!-- See https://splunkbase.splunk.com/app/2717-->
    <!-- All components are integrated within the App core -->

    <row>
        <panel>
            <title>mcatalog dictionary</title>

            <input type="dropdown" token="mcatalog_macro" searchWhenChanged="true">
                <label>Show metric dimensions:</label>
                <choice value="def_mcatalog_dictionary">false</choice>
                <choice value="def_mcatalog_dictionary_with_dimensions">true</choice>
                <default>def_mcatalog_dictionary</default>
            </input>

            <input type="dropdown" depends="$show_filtered_metric_category$" token="filtered_metric_category" searchWhenChanged="true">
                <label>Filtered metric_category:</label>
                <choice value="*">Any</choice>
                <default>*</default>
            </input>

            <html>
                <h4>Click on nodes to hide or develop associated items:</h4>

                <br />
                <i>Dendgram built using Custom viz Dendogram visualization, https://splunkbase.splunk.com/app/2717</i>
                <br />

                <div id="dendrogram_search" class="splunk-manager" data-require="splunkjs/mvc/searchmanager" data-options='{
          "search": {
            "type": "token_safe",
            "value": "| `$$mcatalog_macro$$($$osfilter$$)` | search (metric_category=$$filtered_metric_category$$ )"
          },
          "preview": true,
          "earliest_time": {
            "type": "token_safe",
            "value": "-24h"
          },
          "latest_time": {
            "type": "token_safe",
            "value": "now"
          }
        }'>
                </div>
                <div id="dendrogram" style="width:100%; overflow-x:scroll; border:dotted 1px black;" class="splunk-view" data-require="app/metricator-for-nmon/components/dendrogram/dendrogram" data-options='{
          "managerid": "dendrogram_search",
          "root_label": "Nmon Splunk App",
          "height": 3500,
          "width": 1700,
          "initial_open_level": 6,
          "has_size": true,
          "margin_left": 200,
          "margin_right": 200
        }'>
                </div>
            </html>
        </panel>
    </row>

</form>
