refactor(dashboard): use bootstrap tooltip on shard status page

This commit is contained in:
spiral 2022-07-14 19:40:12 +02:00
parent f864498392
commit d17cb80db4
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E
2 changed files with 16 additions and 37 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts"> <script lang="ts">
export let hover; import { Tooltip } from 'sveltestrap';
export let shard = { export let shard = {
id: 1, id: 1,
@ -25,23 +25,20 @@
<div class="wrapper"> <div class="wrapper">
<div <div
on:click={() => hover = (hover != shard.id) ? shard.id : null} class="shard" id={`shard-${shard.id.toString()}`}
class="shard" id={shard.id.toString()}
style={color} style={color}
>{ shard.id }</div> >{ shard.id }</div>
{#if hover == shard.id} <Tooltip target={`shard-${shard.id.toString()}`} placement="bottom">
<div class="more-info"> <br>
<br> <h3>Shard { shard.id }</h3>
<h3>Shard { shard.id }</h3> <br>
<br> <span>Status: <b>{ shard.status }</b></span><br>
<span>Status: <b>{ shard.status }</b></span><br> <span>Latency: { shard.ping }ms</span><br>
<span>Latency: { shard.ping }ms</span><br> <span>Disconnection count: { shard.disconnection_count }</span><br>
<span>Disconnection count: { shard.disconnection_count }</span><br> <span>Last connection: { shard.last_connection }</span><br>
<span>Last connection: { shard.last_connection }</span><br> <span>Last heartbeat: { shard.last_heartbeat }</span><br>
<span>Last heartbeat: { shard.last_heartbeat }</span><br> <br>
<br> </Tooltip>
</div>
{/if}
</div> </div>
<style> <style>
@ -73,20 +70,4 @@
user-select: none; /* Non-prefixed version, currently user-select: none; /* Non-prefixed version, currently
supported by Chrome, Edge, Opera and Firefox */ supported by Chrome, Edge, Opera and Firefox */
} }
.more-info {
/* display: none; */
position: absolute;
top: 100%;
right: -50%;
will-change: transform;
min-height: 150px;
width: 12em;
z-index: 2;
border-radius: 5px;
background-color: #333;
color: #fff;
opacity: 95%;
text-align: center;
}
</style> </style>

View File

@ -5,8 +5,6 @@
import api from '../api'; import api from '../api';
let hover = null;
let message = "Loading..."; let message = "Loading...";
let shards = []; let shards = [];
let clusters = {}; let clusters = {};
@ -147,7 +145,7 @@
<CardBody> <CardBody>
<span>{ message }</span> <span>{ message }</span>
{#each shards as shard} {#each shards as shard}
<ShardItem shard={shard} bind:hover={hover} /> <ShardItem shard={shard} />
{/each} {/each}
</CardBody> </CardBody>
</Card> </Card>
@ -163,7 +161,7 @@
</div> </div>
<div class="cluster-shards"> <div class="cluster-shards">
{#each clusters[key] as shard} {#each clusters[key] as shard}
<ShardItem shard={shard} bind:hover={hover} /> <ShardItem shard={shard} />
{/each} {/each}
</div> </div>
{/each} {/each}