-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathheader.svelte
More file actions
65 lines (58 loc) · 1.79 KB
/
header.svelte
File metadata and controls
65 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import Badge, { type BadgeType } from '$lib/holocene/badge.svelte';
import ToggleSwitch from '$lib/holocene/toggle-switch.svelte';
import Tooltip from '$lib/holocene/tooltip.svelte';
import { translate } from '$lib/i18n/translate';
import { autoRefresh } from '$lib/stores/batch-operations';
import type { BatchOperation, BatchOperationState } from '$lib/types/batch';
interface Props {
operation: BatchOperation;
}
let { operation }: Props = $props();
const dispatch = createEventDispatcher<{
toggleAutoRefresh: { checked: boolean };
}>();
const handleToggleAutoRefresh = (
event: Event & { target: EventTarget & HTMLInputElement },
) => {
const { checked } = event.target;
dispatch('toggleAutoRefresh', { checked });
$autoRefresh = checked;
};
const jobStateToBadgeType: Record<BatchOperationState, BadgeType> = {
Completed: 'success',
Running: 'primary',
Failed: 'danger',
Unspecified: undefined,
};
</script>
<div class="flex items-center justify-between">
<div class="flex flex-col gap-2">
<div class="flex flex-row items-center gap-2 max-sm:flex-col">
<h1>
{translate('batch.describe-page-title')}
</h1>
<Badge type={jobStateToBadgeType[operation.state]}>
{operation.state}
</Badge>
</div>
<p>
{operation.jobId}
</p>
</div>
{#if operation.state === 'Running'}
<Tooltip
top
text={translate('common.auto-refresh-tooltip', { interval: '5' })}
>
<ToggleSwitch
id="batch-operation-auto-refresh"
label={translate('common.auto-refresh')}
labelPosition="left"
checked={$autoRefresh}
on:change={handleToggleAutoRefresh}
/>
</Tooltip>
{/if}
</div>