-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Smaller improvements to the frontend ui
synchronized time-ago, apps can be sorted by status and name, added last seen column
- Loading branch information
Showing
6 changed files
with
135 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import type { AppService } from '../types'; | ||
import TimeAgo from './time-ago.svelte'; | ||
export let services: AppService[] = []; | ||
let lastStarted: string | null = null; | ||
$: { | ||
if (services.length > 0) { | ||
lastStarted = | ||
services.reduce( | ||
(oldest, service) => { | ||
if (!oldest || new Date(service.started_at) < new Date(oldest.started_at)) { | ||
return service; | ||
} | ||
return oldest; | ||
}, | ||
null as AppService | null | ||
)?.started_at ?? null; | ||
} | ||
} | ||
</script> | ||
|
||
<TimeAgo dateString={lastStarted}></TimeAgo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import Icon from '@iconify/svelte'; | ||
export let name: string; | ||
export let key: string; | ||
export let sortBy: string; | ||
import { createEventDispatcher } from 'svelte'; | ||
const dispatch = createEventDispatcher(); | ||
function setSort(sortValue: string) { | ||
dispatch('setSort', { sortBy: sortValue }); | ||
} | ||
</script> | ||
|
||
<button class="link" on:click={() => setSort(key)} | ||
>{name} | ||
{#if sortBy == key}<Icon class="float-right" icon="heroicons:arrow-small-up-solid" /> | ||
{/if}</button | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { readable } from 'svelte/store'; | ||
|
||
export const time = readable(new Date(), function start(set) { | ||
const interval = setInterval(() => { | ||
set(new Date()); | ||
}, 1000); // update every second | ||
|
||
return function stop() { | ||
clearInterval(interval); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters