2022-07-08 15:17:17 +00:00
|
|
|
<script>
|
2022-07-12 10:06:26 +00:00
|
|
|
import { formatDuration } from './lib';
|
|
|
|
import { onMount } from 'svelte';
|
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
export let tile;
|
2022-07-12 10:06:26 +00:00
|
|
|
|
|
|
|
let formattedDuration = '';
|
2023-02-23 13:47:51 +00:00
|
|
|
$: formattedDate = tile.service?.checked ? tile.service.checked.toLocaleTimeString('en-GB', {
|
2022-07-12 10:06:26 +00:00
|
|
|
timeStyle: 'short',
|
|
|
|
}) : '';
|
|
|
|
|
|
|
|
onMount(() => {
|
2022-08-29 10:22:17 +00:00
|
|
|
function updateDuration() {
|
|
|
|
formattedDuration = formatDuration(
|
2023-02-23 13:47:51 +00:00
|
|
|
new Date().getTime() - tile.since.getTime()
|
2022-08-29 10:22:17 +00:00
|
|
|
);
|
|
|
|
}
|
2022-07-12 10:06:26 +00:00
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
if (tile.since) {
|
2022-07-12 10:06:26 +00:00
|
|
|
updateDuration();
|
|
|
|
const interval = setInterval(updateDuration, 100);
|
|
|
|
return () => clearInterval(interval);
|
|
|
|
}
|
|
|
|
});
|
2022-07-08 15:17:17 +00:00
|
|
|
</script>
|
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
<div class="tile prio{tile.prio}">
|
|
|
|
<div class="desc">
|
|
|
|
{#if tile.service?.name?.en}
|
|
|
|
<div class="title">{tile.service.name.en}</div>
|
|
|
|
{/if}
|
2022-07-08 15:17:17 +00:00
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
{#if tile.service?.cluster}
|
|
|
|
<div class="subtitle">{tile.service.cluster}</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
{#if tile.badges?.length}
|
|
|
|
<div class="badges">
|
|
|
|
{#each tile.badges as badge}
|
|
|
|
<span class="badge">{badge}</span>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2022-07-11 09:20:44 +00:00
|
|
|
|
2022-07-15 14:35:54 +00:00
|
|
|
<div class="bottom">
|
2023-02-23 13:47:51 +00:00
|
|
|
<div class="content">
|
|
|
|
<div class="statustext">
|
|
|
|
{tile.statusText}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if tile.date || tile.since}
|
2022-07-12 10:38:57 +00:00
|
|
|
<div class="time">
|
2022-07-12 10:46:53 +00:00
|
|
|
{#if formattedDate}<div>{formattedDate}</div>{/if}
|
|
|
|
{#if formattedDuration}<div>{formattedDuration}</div>{/if}
|
2022-07-12 10:38:57 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
2022-07-08 15:17:17 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.tile {
|
|
|
|
padding: 1rem;
|
2022-07-09 09:12:39 +00:00
|
|
|
background-color: var(--tile-bg);
|
2022-07-08 15:17:17 +00:00
|
|
|
border-radius: var(--radius);
|
2022-07-11 09:32:28 +00:00
|
|
|
border: 2px solid var(--tile-bg);
|
2022-07-12 08:18:29 +00:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2022-07-11 09:32:28 +00:00
|
|
|
}
|
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
.tile.prio2 {
|
2022-07-11 09:32:28 +00:00
|
|
|
background-color: var(--red);
|
|
|
|
border-color: var(--red);
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
.tile.prio1 {
|
|
|
|
background-color: var(--orange);
|
|
|
|
border-color: var(--orange);
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tile.prio0 {
|
2022-07-11 09:32:28 +00:00
|
|
|
border-color: var(--green);
|
2022-07-11 13:07:47 +00:00
|
|
|
background-color: var(--green);
|
2022-07-12 10:28:53 +00:00
|
|
|
color: #fff;
|
2022-07-11 09:32:28 +00:00
|
|
|
}
|
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
.tile.prio-1 {
|
2022-07-11 11:17:26 +00:00
|
|
|
opacity: 0.5;
|
2022-07-11 11:20:42 +00:00
|
|
|
border-color: var(--grey);
|
2022-07-11 11:17:26 +00:00
|
|
|
}
|
|
|
|
|
2022-07-12 10:38:57 +00:00
|
|
|
.tile.grey .bottom {
|
2022-07-11 11:15:39 +00:00
|
|
|
color: var(--grey);
|
|
|
|
}
|
|
|
|
|
2022-07-11 09:32:28 +00:00
|
|
|
.desc {
|
|
|
|
margin-bottom: 1rem;
|
2022-07-08 15:17:17 +00:00
|
|
|
}
|
|
|
|
|
2022-07-11 09:32:28 +00:00
|
|
|
.desc .title {
|
2022-07-11 13:09:37 +00:00
|
|
|
font-weight: 300;
|
2022-07-18 09:40:44 +00:00
|
|
|
font-size: 1.3em;
|
2022-07-08 15:17:17 +00:00
|
|
|
}
|
|
|
|
|
2022-07-11 09:32:28 +00:00
|
|
|
.desc .subtitle {
|
2022-07-15 14:41:10 +00:00
|
|
|
font-weight: 300;
|
2022-07-18 09:40:44 +00:00
|
|
|
font-size: 1.1em;
|
2022-07-15 14:41:10 +00:00
|
|
|
opacity: 0.7;
|
2022-07-08 15:17:17 +00:00
|
|
|
}
|
2022-07-11 11:15:39 +00:00
|
|
|
|
2023-02-23 13:47:51 +00:00
|
|
|
.badges {
|
|
|
|
margin-top: 0.2em;
|
|
|
|
}
|
|
|
|
.badges .badge {
|
|
|
|
display: inline-block;
|
|
|
|
margin-right: 0.3em;
|
|
|
|
background-color: rgba(0, 0, 0, 0.3);
|
|
|
|
border: 1px solid rgba(0, 0, 0, 0.4);
|
|
|
|
padding: 0.2em 0.4em;
|
|
|
|
border-radius: 0.4em;
|
|
|
|
}
|
|
|
|
|
2022-07-12 10:38:57 +00:00
|
|
|
.bottom {
|
|
|
|
display: flex;
|
|
|
|
margin-top: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
.bottom .time {
|
2022-07-12 10:46:53 +00:00
|
|
|
margin: auto 0 0 auto;
|
2022-07-11 11:15:39 +00:00
|
|
|
opacity: 0.6;
|
2022-07-18 09:40:44 +00:00
|
|
|
font-size: 1em;
|
2022-07-12 10:06:26 +00:00
|
|
|
text-align: right;
|
2022-07-12 10:46:53 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: flex-end;
|
|
|
|
flex-direction: column;
|
2022-07-11 11:15:39 +00:00
|
|
|
}
|
2022-07-12 08:18:29 +00:00
|
|
|
|
2022-07-12 10:38:57 +00:00
|
|
|
.bottom .content {
|
2022-07-12 08:18:29 +00:00
|
|
|
flex-grow: 1;
|
2022-07-12 09:34:04 +00:00
|
|
|
display: flex;
|
|
|
|
}
|
2023-02-23 13:47:51 +00:00
|
|
|
|
|
|
|
.statustext {
|
|
|
|
font-size: 3em;
|
|
|
|
font-weight: 600;
|
|
|
|
margin-top: auto;
|
|
|
|
}
|
2022-07-08 15:17:17 +00:00
|
|
|
</style>
|