-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08fcab1
commit a2e6146
Showing
10 changed files
with
233 additions
and
9 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
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
53 changes: 53 additions & 0 deletions
53
src/frontend/src/lib/components/satellites/SatelliteStart.svelte
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,53 @@ | ||
<script lang="ts"> | ||
import { i18n } from '$lib/stores/i18n.store'; | ||
import Confirmation from '$lib/components/core/Confirmation.svelte'; | ||
import type { Satellite } from '$declarations/mission_control/mission_control.did'; | ||
import { authSignedInStore, authStore } from '$lib/stores/auth.store'; | ||
import { toasts } from '$lib/stores/toasts.store'; | ||
import { busy } from '$lib/stores/busy.store'; | ||
import { canisterStart } from '$lib/api/ic.api'; | ||
import { emit } from '$lib/utils/events.utils'; | ||
export let satellite: Satellite; | ||
let visible = false; | ||
const start = async () => { | ||
if (!$authSignedInStore) { | ||
toasts.error({ | ||
text: $i18n.errors.no_identity | ||
}); | ||
return; | ||
} | ||
busy.start(); | ||
try { | ||
await canisterStart({ canisterId: satellite.satellite_id, identity: $authStore.identity! }); | ||
emit({ message: 'junoRestartCycles', detail: { canisterId: satellite.satellite_id } }); | ||
emit({ message: 'junoReloadVersions' }); | ||
close(); | ||
toasts.success($i18n.satellites.start_success); | ||
} catch (err: unknown) { | ||
toasts.error({ | ||
text: $i18n.errors.satellite_start, | ||
detail: err | ||
}); | ||
} | ||
busy.stop(); | ||
}; | ||
const close = () => (visible = false); | ||
</script> | ||
|
||
<button on:click={() => (visible = true)}>{$i18n.core.start}</button> | ||
|
||
<Confirmation bind:visible on:junoYes={start} on:junoNo={close}> | ||
<svelte:fragment slot="title">{$i18n.satellites.start_tile}</svelte:fragment> | ||
|
||
<p>{$i18n.satellites.start_info}</p> | ||
</Confirmation> |
56 changes: 56 additions & 0 deletions
56
src/frontend/src/lib/components/satellites/SatelliteStop.svelte
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,56 @@ | ||
<script lang="ts"> | ||
import { i18n } from '$lib/stores/i18n.store'; | ||
import Confirmation from '$lib/components/core/Confirmation.svelte'; | ||
import { busy } from '$lib/stores/busy.store'; | ||
import { toasts } from '$lib/stores/toasts.store'; | ||
import { canisterStop } from '$lib/api/ic.api'; | ||
import type { Satellite } from '$declarations/mission_control/mission_control.did'; | ||
import { authSignedInStore, authStore } from '$lib/stores/auth.store'; | ||
import { emit } from '$lib/utils/events.utils'; | ||
export let satellite: Satellite; | ||
let visible = false; | ||
const stop = async () => { | ||
if (!$authSignedInStore) { | ||
toasts.error({ | ||
text: $i18n.errors.no_identity | ||
}); | ||
return; | ||
} | ||
busy.start(); | ||
try { | ||
await canisterStop({ canisterId: satellite.satellite_id, identity: $authStore.identity! }); | ||
emit({ message: 'junoRestartCycles', detail: { canisterId: satellite.satellite_id } }); | ||
close(); | ||
toasts.success($i18n.satellites.stop_success); | ||
} catch (err: unknown) { | ||
toasts.error({ | ||
text: $i18n.errors.satellite_stop, | ||
detail: err | ||
}); | ||
} | ||
busy.stop(); | ||
}; | ||
const close = () => (visible = false); | ||
</script> | ||
|
||
<button on:click={() => (visible = true)}>{$i18n.core.stop}</button> | ||
|
||
<Confirmation bind:visible on:junoYes={stop} on:junoNo={close}> | ||
<svelte:fragment slot="title">{$i18n.satellites.stop_title}</svelte:fragment> | ||
|
||
<p>{$i18n.satellites.stop_explanation}</p> | ||
|
||
<p>{$i18n.satellites.stop_error}</p> | ||
|
||
<p>{$i18n.satellites.stop_info}</p> | ||
</Confirmation> |
38 changes: 38 additions & 0 deletions
38
src/frontend/src/lib/components/satellites/SatelliteStopStart.svelte
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,38 @@ | ||
<script lang="ts"> | ||
import type { Canister, CanisterStatus, CanisterSyncStatus } from '$lib/types/canister'; | ||
import CanisterStart from '$lib/components/satellites/SatelliteStart.svelte'; | ||
import CanisterStop from '$lib/components/satellites/SatelliteStop.svelte'; | ||
import { fade } from 'svelte/transition'; | ||
import type { Satellite } from '$declarations/mission_control/mission_control.did'; | ||
export let satellite: Satellite; | ||
const onSyncCanister = (syncCanister: Canister) => { | ||
if (syncCanister.id !== satellite.satellite_id.toText()) { | ||
return; | ||
} | ||
canister = syncCanister; | ||
}; | ||
let canister: Canister | undefined = undefined; | ||
let status: CanisterStatus | undefined = undefined; | ||
let sync: CanisterSyncStatus | undefined = undefined; | ||
$: status = canister?.data?.status; | ||
$: sync = canister?.sync; | ||
</script> | ||
|
||
<svelte:window on:junoSyncCanister={({ detail: { canister } }) => onSyncCanister(canister)} /> | ||
|
||
{#if status === 'stopped' && sync === 'synced'} | ||
<div in:fade><CanisterStart {satellite} /></div> | ||
{:else if status === 'running' && sync === 'synced'} | ||
<div in:fade><CanisterStop {satellite} /></div> | ||
{/if} | ||
|
||
<style lang="scss"> | ||
div { | ||
display: inline-block; | ||
} | ||
</style> |
3 changes: 3 additions & 0 deletions
3
src/frontend/src/lib/components/satellites/SatelliteTopUp.svelte
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
<script lang="ts"> | ||
import type { Satellite } from '$declarations/mission_control/mission_control.did'; | ||
import TopUp from '$lib/components/canister/TopUp.svelte'; | ||
import CanisterStopStart from "$lib/components/satellites/SatelliteStopStart.svelte"; | ||
export let satellite: Satellite; | ||
let detail = { satellite }; | ||
</script> | ||
|
||
<TopUp type="topup_satellite" {detail} /> | ||
|
||
<CanisterStopStart {satellite} /> |
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
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