mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-29 10:10:30 +08:00
Show node state indicator
This commit is contained in:
+12
-4
@@ -1,6 +1,10 @@
|
||||
<script lang="ts">
|
||||
import Connect from "@app/App/Header/Connect.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import NodeInfo from "@app/App/Header/NodeInfo.svelte";
|
||||
import Authenticate from "./Header/Authenticate.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
import { nodeStore } from "@app/lib/node";
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -44,9 +48,13 @@
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<div class="right">
|
||||
<div class="layout-desktop">
|
||||
<Connect />
|
||||
</div>
|
||||
<div class="right layout-desktop-flex">
|
||||
{#if $httpdStore.state !== "stopped"}
|
||||
{#if $nodeStore}
|
||||
<NodeInfo running={$nodeStore === "running"} />
|
||||
{/if}
|
||||
<Authenticate />
|
||||
{/if}
|
||||
<Connect />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
<script lang="ts">
|
||||
import * as httpd from "@app/lib/httpd";
|
||||
import * as modal from "@app/lib/modal";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import ConnectModal from "@app/modals/ConnectModal.svelte";
|
||||
import IconButton from "@app/components/IconButton.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import NodeId from "@app/components/NodeId.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
}
|
||||
.host {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.status {
|
||||
font-size: var(--font-size-tiny);
|
||||
color: var(--color-fill-gray);
|
||||
text-align: left;
|
||||
}
|
||||
.separator {
|
||||
height: 1px;
|
||||
background-color: var(--color-border-hint);
|
||||
}
|
||||
.avatar {
|
||||
height: 1.5rem;
|
||||
color: var(--color-fill-primary) !important;
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: var(--font-weight-regular);
|
||||
font-family: var(--font-family-monospace);
|
||||
}
|
||||
.indicator {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
background-color: var(--color-fill-secondary);
|
||||
border-radius: var(--border-radius-round);
|
||||
position: absolute;
|
||||
top: -0.375rem;
|
||||
right: -0.375rem;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.user {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.identity {
|
||||
color: var(--color-fill-secondary);
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if $httpdStore.state === "authenticated"}
|
||||
<Popover
|
||||
popoverPositionTop="3rem"
|
||||
popoverPositionRight="-10rem"
|
||||
popoverPositionLeft="0">
|
||||
<Button
|
||||
slot="toggle"
|
||||
let:toggle
|
||||
on:click={toggle}
|
||||
size="large"
|
||||
variant="primary">
|
||||
<div class="avatar">
|
||||
<NodeId
|
||||
large
|
||||
disableTooltip
|
||||
styleColor="var(--color-fill-primary)"
|
||||
nodeId={$httpdStore.session.publicKey}
|
||||
alias={$httpdStore.session.alias} />
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
<div slot="popover" class="container">
|
||||
<div class="row">
|
||||
<div class="status">Httpd server running</div>
|
||||
|
||||
<div class="host">
|
||||
radicle.local
|
||||
|
||||
<Link
|
||||
on:afterNavigate={closeFocused}
|
||||
route={{
|
||||
resource: "nodes",
|
||||
params: {
|
||||
baseUrl: httpd.api.baseUrl,
|
||||
projectPageIndex: 0,
|
||||
},
|
||||
}}>
|
||||
<IconButton>Browse</IconButton>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="separator" />
|
||||
|
||||
<div class="row">
|
||||
<div class="status">Authenticated as</div>
|
||||
<div class="user">
|
||||
<div class="identity">
|
||||
<NodeId
|
||||
nodeId={$httpdStore.session.publicKey}
|
||||
alias={$httpdStore.session.alias} />
|
||||
</div>
|
||||
<IconButton
|
||||
on:click={() => {
|
||||
void httpd.disconnect();
|
||||
closeFocused();
|
||||
}}>
|
||||
Disconnect
|
||||
</IconButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Popover>
|
||||
{:else if $httpdStore.state === "running"}
|
||||
<Button
|
||||
on:click={() => {
|
||||
modal.show({
|
||||
component: ConnectModal,
|
||||
props: {},
|
||||
});
|
||||
}}
|
||||
size="large"
|
||||
variant="outline">
|
||||
<IconSmall name="key" />
|
||||
Authenticate
|
||||
<div class="indicator" />
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
on:click={() => {
|
||||
modal.show({
|
||||
component: ConnectModal,
|
||||
props: {},
|
||||
});
|
||||
}}
|
||||
size="large"
|
||||
variant="outline">
|
||||
<IconSmall name="chat" />
|
||||
Authenticate
|
||||
</Button>
|
||||
{/if}
|
||||
+30
-133
@@ -1,18 +1,12 @@
|
||||
<script lang="ts">
|
||||
import type { HttpdState } from "@app/lib/httpd";
|
||||
|
||||
import * as httpd from "@app/lib/httpd";
|
||||
import * as modal from "@app/lib/modal";
|
||||
import { closeFocused } from "@app/components/Popover.svelte";
|
||||
import { httpdStore } from "@app/lib/httpd";
|
||||
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import ConnectModal from "@app/modals/ConnectModal.svelte";
|
||||
import Icon from "@app/components/Icon.svelte";
|
||||
import IconButton from "@app/components/IconButton.svelte";
|
||||
import Link from "@app/components/Link.svelte";
|
||||
import NodeId from "@app/components/NodeId.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
import Command from "@app/components/Command.svelte";
|
||||
|
||||
const buttonTitle: Record<HttpdState["state"], string> = {
|
||||
stopped: "radicle-httpd is stopped",
|
||||
@@ -22,64 +16,19 @@
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
width: "23rem";
|
||||
}
|
||||
.host {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
.label {
|
||||
display: block;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
.status {
|
||||
font-size: var(--font-size-tiny);
|
||||
color: var(--color-fill-gray);
|
||||
text-align: left;
|
||||
}
|
||||
.separator {
|
||||
height: 1px;
|
||||
background-color: var(--color-border-hint);
|
||||
}
|
||||
.avatar {
|
||||
height: 1.5rem;
|
||||
color: var(--color-fill-secondary);
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: var(--font-weight-regular);
|
||||
font-family: var(--font-family-monospace);
|
||||
}
|
||||
.indicator {
|
||||
width: 0.75rem;
|
||||
height: 0.75rem;
|
||||
background-color: var(--color-fill-secondary);
|
||||
border-radius: var(--border-radius-round);
|
||||
position: absolute;
|
||||
top: -0.375rem;
|
||||
right: -0.375rem;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.user {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.identity {
|
||||
color: var(--color-fill-secondary);
|
||||
display: flex;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
{#if $httpdStore.state === "authenticated"}
|
||||
<Popover popoverPositionTop="3rem" popoverPositionRight="0">
|
||||
{#if $httpdStore.state === "stopped"}
|
||||
<Popover
|
||||
popoverPositionTop="3rem"
|
||||
popoverPositionRight="0"
|
||||
popoverPositionLeft="-13rem">
|
||||
<Button
|
||||
slot="toggle"
|
||||
let:toggle
|
||||
@@ -87,84 +36,32 @@
|
||||
title={buttonTitle[$httpdStore.state]}
|
||||
size="large"
|
||||
variant="outline">
|
||||
<div class="avatar">
|
||||
<NodeId
|
||||
large
|
||||
disableTooltip
|
||||
nodeId={$httpdStore.session.publicKey}
|
||||
alias={$httpdStore.session.alias} />
|
||||
</div>
|
||||
<IconSmall name="device" />
|
||||
Connect
|
||||
</Button>
|
||||
|
||||
<div slot="popover" class="container">
|
||||
<div class="row">
|
||||
<div class="status">Httpd server running</div>
|
||||
|
||||
<div class="host">
|
||||
radicle.local
|
||||
|
||||
<Link
|
||||
on:afterNavigate={closeFocused}
|
||||
route={{
|
||||
resource: "nodes",
|
||||
params: {
|
||||
baseUrl: httpd.api.baseUrl,
|
||||
projectPageIndex: 0,
|
||||
},
|
||||
}}>
|
||||
<IconButton>Browse</IconButton>
|
||||
</Link>
|
||||
<svelte:fragment slot="popover">
|
||||
<div>
|
||||
<div class="label">
|
||||
Use the <a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href="https://radicle.xyz/#try"
|
||||
class="txt-link txt-bold">
|
||||
Radicle CLI
|
||||
</a>
|
||||
to connect your device.
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="separator" />
|
||||
|
||||
<div class="row">
|
||||
<div class="status">Authenticated as</div>
|
||||
<div class="user">
|
||||
<div class="identity">
|
||||
<NodeId
|
||||
nodeId={$httpdStore.session.publicKey}
|
||||
alias={$httpdStore.session.alias} />
|
||||
</div>
|
||||
<IconButton
|
||||
on:click={() => {
|
||||
void httpd.disconnect();
|
||||
closeFocused();
|
||||
}}>
|
||||
Disconnect
|
||||
</IconButton>
|
||||
<div class="label">
|
||||
Run the following command to start the httpd daemon.
|
||||
</div>
|
||||
<Command command="radicle-httpd" fullWidth />
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Popover>
|
||||
{:else if $httpdStore.state === "running"}
|
||||
<Button
|
||||
on:click={() => {
|
||||
modal.show({
|
||||
component: ConnectModal,
|
||||
props: {},
|
||||
});
|
||||
}}
|
||||
title={buttonTitle[$httpdStore.state]}
|
||||
size="large"
|
||||
variant="outline">
|
||||
<Icon name="device" />
|
||||
Read only
|
||||
<div class="indicator" />
|
||||
</Button>
|
||||
{:else}
|
||||
<Button
|
||||
on:click={() => {
|
||||
modal.show({
|
||||
component: ConnectModal,
|
||||
props: {},
|
||||
});
|
||||
}}
|
||||
title={buttonTitle[$httpdStore.state]}
|
||||
size="large"
|
||||
variant="secondary">
|
||||
<Icon name="device" />
|
||||
Connect
|
||||
<Button title={buttonTitle[$httpdStore.state]} size="large" variant="primary">
|
||||
<IconSmall name="device" />
|
||||
Connected
|
||||
</Button>
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import Button from "@app/components/Button.svelte";
|
||||
import Popover from "@app/components/Popover.svelte";
|
||||
import Command from "@app/components/Command.svelte";
|
||||
import IconSmall from "@app/components/IconSmall.svelte";
|
||||
|
||||
export let running: boolean = false;
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.label {
|
||||
display: block;
|
||||
font-size: var(--font-size-small);
|
||||
font-weight: var(--font-weight-regular);
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
<Popover
|
||||
popoverPositionTop="3rem"
|
||||
popoverPositionRight="-13rem"
|
||||
popoverPositionLeft="0">
|
||||
<Button
|
||||
slot="toggle"
|
||||
let:toggle
|
||||
on:click={toggle}
|
||||
size="large"
|
||||
variant={running ? "primary" : "outline"}>
|
||||
<IconSmall name="broadcasting" />
|
||||
{#if running}
|
||||
Syncing
|
||||
{:else}
|
||||
Sync
|
||||
{/if}
|
||||
</Button>
|
||||
|
||||
<svelte:fragment slot="popover">
|
||||
{#if running}
|
||||
<div class="label">
|
||||
Use the <a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href="https://radicle.xyz/#try"
|
||||
class="txt-link txt-bold">
|
||||
Radicle CLI
|
||||
</a>
|
||||
to stop your node.
|
||||
</div>
|
||||
<Command command="rad node stop" fullWidth />
|
||||
{:else}
|
||||
<div class="label">
|
||||
Use the <a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href="https://radicle.xyz/#try"
|
||||
class="txt-link txt-bold">
|
||||
Radicle CLI
|
||||
</a>
|
||||
to start your node.
|
||||
</div>
|
||||
<Command command="rad node start" fullWidth />
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</Popover>
|
||||
Reference in New Issue
Block a user