<!--
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You 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.
-->
<script id="owner-summary-template" type="text/html">
    <table id="owner-summary-table" class="table compact">
        <thead>
        <tr>
            <th>
                Owner
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="above" title="Total number of topologies owned by owner.">
                    Total Topologies
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="above" title="Total number of tasks used by owner.">
                    Total Tasks
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="above" title="Total number of executors used by owner.">
                    Total Executors
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="above" title="Total number of workers used by owner.">
                    Total Workers
                </span>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>{{owner}}</td>
            <td>{{totalTopologies}}</td>
            <td>{{totalTasks}}</td>
            <td>{{totalExecutors}}</td>
            <td>{{totalWorkers}}</td>
        </tr>
        </tbody>
    </table>
</script>

<script id="owner-resource-usage-template" type="text/html">
    <table id="owner-resource-usage-table" class="table compact">
        <thead>
        <tr>
            <th>
            </th>
            <th>
                On-Heap Mem (MB)
            </th>
            <th>
                Off-Heap Mem (MB)
            </th>
            <th>
                Total Mem (MB)
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="Total CPU Resource. Every 100 means 1 core.">
                    Total CPU (%)
                </span>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>Requested</td>
            <td>{{totalReqOnHeapMem}}</td>
            <td>{{totalReqOffHeapMem}}</td>
            <td>{{totalReqMem}}</td>
            <td>{{totalReqCpu}}</td>
        </tr>
        <tr>
            <td>Assigned</td>
            <td>{{totalAssignedOnHeapMem}}</td>
            <td>{{totalAssignedOffHeapMem}}</td>
            <td>{{totalMemoryUsage}}</td>
            <td>{{totalCpuUsage}}</td>
        </tr>
        </tbody>
    </table>
</script>

<script id="owner-resource-guarantee-template" type="text/html">
    <table id="owner-resource-guarantee-table" class="table compact">
        <thead>
        <tr>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of CPU resource (every 100 means 1 core) guaranteed to owner.">
                    CPU Guarantee (%)
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of CPU resource (every 100 means 1 core) used by owner.">
                    CPU Usage (%)
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of guaranteed CPU resource (every 100 means 1 core) remaining.">
                    CPU Guarantee Remaining (%)
                </span>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>{{cpuGuarantee}}</td>
            <td>{{totalCpuUsage}}</td>
            <td id="cpu-guarantee-util">{{cpuGuaranteeRemaining}}</td>
        </tr>
        </tbody>
        <thead>
        <tr>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of memory resource (in MB) guaranteed to owner.">
                    Memory Guarantee (MB)
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of memory resource (in MB) used by owner.">
                    Memory Usage (MB)
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The amount of guaranteed memory resources (in MB) remaining.">
                    Memory Guarantee Remaining (MB)
                </span>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>{{memoryGuarantee}}</td>
            <td>{{totalMemoryUsage}}</td>
            <td id="mem-guarantee-util">{{memoryGuaranteeRemaining}}</td>
        </tr>
        </tbody>
    </table>
</script>

<script id="owner-topology-summary-template" type="text/html">
    <table id="owner-topology-summary-table" class="table table-striped compact">
        <thead>
        <tr>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The name given to the topology by when it was submitted. Click the name to view the Topology's information.">
                    Name
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The owner that submitted the Topology, if authentication is enabled.">
                    Owner
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The status can be one of ACTIVE, INACTIVE, KILLED, or REBALANCING.">
                    Status
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The time since the Topology was submitted.">
                    Uptime
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="The number of Workers (processes).">
                    Num workers
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="Executors are threads in a Worker process.">
                    Num executors
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="A Task is an instance of a Bolt or Spout. The number of Tasks is almost always equal to the number of Executors.">
                    Num tasks
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="Assigned Total Memory by Scheduler.">
                    Assigned Mem (MB)
                </span>
            </th>
            {{#schedulerDisplayResource}}
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="top" title="Assigned Total CPU by Scheduler. Every 100 means 1 core.">
                    Assigned CPU (%)
                </span>
            </th>
            {{/schedulerDisplayResource}}
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="left" title="This shows information from the scheduler about the latest attempt to schedule the Topology on the cluster.">
                    Scheduler Info
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="left" title="The version of this topology">
                    Topology Version
                </span>
            </th>
            <th>
                <span data-bs-toggle="tooltip" data-bs-placement="left" title="The version of the storm client that this topology request (was launched with)">
                    Storm Version
                </span>
            </th>
        </tr>
        </thead>
        <tbody>
        {{#topologies}}
        <tr>
            <td><a href="/topology.html?id={{encodedId}}">{{name}}</a></td>
            <td><a href="/owner.html?id={{owner}}">{{owner}}</a></td>
            <td>{{status}}</td>
            <td>{{uptime}}</td>
            <td>{{workersTotal}}</td>
            <td>{{executorsTotal}}</td>
            <td>{{tasksTotal}}</td>
            <td>{{assignedTotalMem}}</td>
            {{#schedulerDisplayResource}}
            <td>{{assignedCpu}}</td>
            {{/schedulerDisplayResource}}
            <td>{{schedulerInfo}}</td>
            <td>{{topologyVersion}}</td>
            <td>{{stormVersion}}</td>
        </tr>
        {{/topologies}}
        </tbody>
    </table>
</script>
