Skip to content

Commit

Permalink
Feat: network events for activity page(will do homepage later)
Browse files Browse the repository at this point in the history
  • Loading branch information
avivash committed Nov 15, 2023
1 parent 9479493 commit bab3b24
Show file tree
Hide file tree
Showing 11 changed files with 356 additions and 65 deletions.
142 changes: 140 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"dependencies": {
"@fission-codes/homestar": "^0.6.0",
"@oddjs/odd": "0.37.0",
"@open-rpc/client-js": "^1.8.1",
"@types/three": "^0.156.0",
"chart.js": "^4.4.0",
"clipboard-copy": "^4.0.1",
Expand Down
69 changes: 69 additions & 0 deletions src/components/settings/NodeInfo.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<script lang="ts">
import clipboardCopy from 'clipboard-copy'
import { onDestroy, onMount } from 'svelte'
import { requestHealth } from '$lib/health'
import { addNotification } from '$lib/notifications'
import ClipboardIcon from '$components/icons/ClipboardIcon.svelte'
let health = null
let interval
const handleCopyToClipboard = async (value: string): Promise<void> => {
await clipboardCopy(value)
addNotification('Copied to clipboard', 'success')
}
onMount(async () => {
health = await requestHealth()
// Poll until listener addresses are returned
if (!health?.nodeInfo?.dynamic?.listeners?.length) {
interval = setInterval(async () => {
health = await requestHealth()
if (health?.nodeInfo?.dynamic?.listeners?.length) {
clearInterval(interval)
}
}, 200)
}
})
onDestroy(() => {
clearInterval(interval)
})
</script>

{#if health}
<div>
<h3 class="text-heading-lg mb-4">Peer ID</h3>
<div class="flex items-center">
<p>
{health.nodeInfo.static.peer_id}
</p>
<button
class="pl-2 hover:text-neutral-500 transition-colors"
on:click={() => handleCopyToClipboard(health.nodeInfo.static.peer_id)}
>
<ClipboardIcon />
</button>
</div>
</div>

<div>
<h3 class="text-heading-lg mb-4">Listener Addresses</h3>

{#each health.nodeInfo.dynamic.listeners as listener}
<div class="flex items-center">
<p>
{listener}
</p>
<button
class="pl-2 hover:text-neutral-500 transition-colors"
on:click={() => handleCopyToClipboard(listener)}
>
<ClipboardIcon />
</button>
</div>
{/each}
</div>
{/if}
36 changes: 0 additions & 36 deletions src/components/settings/PeerID.svelte

This file was deleted.

Loading

0 comments on commit bab3b24

Please sign in to comment.