From f0cfe47a0852036bc1975c16e8a31d26d25efd9f Mon Sep 17 00:00:00 2001
From: Atila Fassina
Date: Mon, 20 Nov 2023 09:31:12 +0100
Subject: [PATCH 1/7] handle connection issue
---
web-client/package.json | 1 +
web-client/pnpm-lock.yaml | 11 ++
web-client/src/components/autoscroll-pane.tsx | 4 +-
web-client/src/components/boot-time.tsx | 8 +-
web-client/src/components/dialog.tsx | 50 +++++
.../src/components/disconnect-button.tsx | 15 +-
web-client/src/components/error-dialog.tsx | 62 ++++++
web-client/src/components/health-status.tsx | 118 +++++++----
.../src/components/sources/code-view.tsx | 51 +++--
.../src/components/sources/directory.tsx | 15 +-
.../src/components/sources/image-view.tsx | 7 +-
.../src/components/status-indicator.tsx | 12 --
.../src/context/connection-provider.tsx | 38 ++++
web-client/src/context/monitor-provider.tsx | 56 ++++++
web-client/src/entry.tsx | 16 +-
web-client/src/lib/connection/monitor.ts | 20 +-
web-client/src/lib/connection/transport.ts | 51 -----
web-client/src/lib/connection/transport.tsx | 105 ++++++++++
web-client/src/views/connect.tsx | 14 +-
web-client/src/views/dashboard/console.tsx | 2 +-
web-client/src/views/dashboard/layout.tsx | 187 ++++--------------
.../src/views/dashboard/span-waterfall.tsx | 2 +-
.../src/views/dashboard/tauri-config.tsx | 85 ++++++++
web-client/tailwind.config.ts | 3 +-
24 files changed, 596 insertions(+), 337 deletions(-)
create mode 100644 web-client/src/components/dialog.tsx
create mode 100644 web-client/src/components/error-dialog.tsx
delete mode 100644 web-client/src/components/status-indicator.tsx
create mode 100644 web-client/src/context/connection-provider.tsx
create mode 100644 web-client/src/context/monitor-provider.tsx
delete mode 100644 web-client/src/lib/connection/transport.ts
create mode 100644 web-client/src/lib/connection/transport.tsx
create mode 100644 web-client/src/views/dashboard/tauri-config.tsx
diff --git a/web-client/package.json b/web-client/package.json
index 5e7ad261..6b2dfd9a 100644
--- a/web-client/package.json
+++ b/web-client/package.json
@@ -44,6 +44,7 @@
"dependencies": {
"@crabnebula/file-icons": "^0.1.0",
"@kobalte/core": "^0.11.2",
+ "@kobalte/tailwindcss": "^0.9.0",
"@protobuf-ts/grpcweb-transport": "^2.9.1",
"@protobuf-ts/plugin": "^2.9.1",
"@protobuf-ts/runtime": "^2.9.1",
diff --git a/web-client/pnpm-lock.yaml b/web-client/pnpm-lock.yaml
index c6c1b3c4..a77d7dba 100644
--- a/web-client/pnpm-lock.yaml
+++ b/web-client/pnpm-lock.yaml
@@ -11,6 +11,9 @@ dependencies:
'@kobalte/core':
specifier: ^0.11.2
version: 0.11.2(solid-js@1.8.5)
+ '@kobalte/tailwindcss':
+ specifier: ^0.9.0
+ version: 0.9.0(tailwindcss@3.3.5)
'@protobuf-ts/grpcweb-transport':
specifier: ^2.9.1
version: 2.9.1
@@ -874,6 +877,14 @@ packages:
solid-js: 1.8.5
dev: false
+ /@kobalte/tailwindcss@0.9.0(tailwindcss@3.3.5):
+ resolution: {integrity: sha512-WbueJTVRiO4yrmfHIBwp07y3M5iibJ/gauEAQ7mOyg1tZulvpO7SM/UdgzX95a9a0KDt1mQFxwO7RmpOUXWOWA==}
+ peerDependencies:
+ tailwindcss: ^3.3.3
+ dependencies:
+ tailwindcss: 3.3.5
+ dev: false
+
/@kobalte/utils@0.9.0(solid-js@1.8.5):
resolution: {integrity: sha512-TYVCpQcpqo1+0HBn3NXoGEBzxd4tH6Um1oc07nrYw1V7Qq0qbMaYAOnfBc1qhlh7sGV4XZldmb0j13Of0FrZQg==}
peerDependencies:
diff --git a/web-client/src/components/autoscroll-pane.tsx b/web-client/src/components/autoscroll-pane.tsx
index 8c21abb2..ab748f08 100644
--- a/web-client/src/components/autoscroll-pane.tsx
+++ b/web-client/src/components/autoscroll-pane.tsx
@@ -1,4 +1,4 @@
-import { Accessor, JSX, createEffect, on } from "solid-js";
+import { Accessor, JSXElement, createEffect, on } from "solid-js";
function scrollEnd(ref?: HTMLElement, smooth?: boolean) {
ref?.scroll({
@@ -14,7 +14,7 @@ function scrollEnd(ref?: HTMLElement, smooth?: boolean) {
type AutoScrollPaneProps = {
dataStream: unknown;
shouldAutoScroll: Accessor;
- children: JSX.Element;
+ children: JSXElement;
};
export function AutoscrollPane(props: AutoScrollPaneProps) {
diff --git a/web-client/src/components/boot-time.tsx b/web-client/src/components/boot-time.tsx
index b8fc312a..12af1dfd 100644
--- a/web-client/src/components/boot-time.tsx
+++ b/web-client/src/components/boot-time.tsx
@@ -1,16 +1,16 @@
import { Show } from "solid-js";
-import { useMonitor } from "~/lib/connection/monitor";
+import { Loader } from "./loader";
+import { useMonitor } from "~/context/monitor-provider";
export function BootTime() {
const { monitorData } = useMonitor();
-
return (
-
+ }>
{(e) => (
Loading time:
- {Number(e().seconds) * 1000 + e().nanos / 1e6}ms
+ {(Number(e().seconds) * 1000 + e().nanos / 1e6).toFixed(2)}ms
)}
diff --git a/web-client/src/components/dialog.tsx b/web-client/src/components/dialog.tsx
new file mode 100644
index 00000000..4bb68127
--- /dev/null
+++ b/web-client/src/components/dialog.tsx
@@ -0,0 +1,50 @@
+import { AlertDialog } from "@kobalte/core";
+import { A } from "@solidjs/router";
+import { JSXElement, Show, mergeProps } from "solid-js";
+
+type Props = {
+ title?: JSXElement;
+ children: JSXElement;
+};
+
+export function Dialog(p: Props) {
+ const props = mergeProps({ title: "Alert" }, p);
+
+ return (
+
+ {/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion*/}
+
+
+
+
+
+ {props.title}
+
+
+ {props.children}
+
+
+
{
+ window.location.reload();
+ }}
+ >
+ Reload route
+
+
+ Dismiss
+
+
+ Reset App
+
+
+
+
+
+
+ );
+}
diff --git a/web-client/src/components/disconnect-button.tsx b/web-client/src/components/disconnect-button.tsx
index 647d6084..31bdb682 100644
--- a/web-client/src/components/disconnect-button.tsx
+++ b/web-client/src/components/disconnect-button.tsx
@@ -1,16 +1,19 @@
import { Button } from "@kobalte/core";
+import { useNavigate } from "@solidjs/router";
+import { useConnection } from "~/context/connection-provider";
-type DisconnectProps = {
- closeSession: () => void;
-};
-
-export function DisconnectButton(props: DisconnectProps) {
+export function DisconnectButton() {
+ const { connectionStore } = useConnection();
+ const goto = useNavigate();
return (
{
+ connectionStore.abortController.abort();
+ goto("/");
+ }}
>
Close connection
-