Skip to content

Commit eb5364b

Browse files
committed
ui: fix show data
1 parent 282e589 commit eb5364b

File tree

7 files changed

+133
-143
lines changed

7 files changed

+133
-143
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ go 1.24.0
44

55
require (
66
github.com/VictoriaMetrics/easyproto v0.1.4
7+
github.com/cespare/xxhash/v2 v2.3.0
78
github.com/dgraph-io/badger/v4 v4.7.0
89
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
910
github.com/jackc/pgx/v5 v5.6.0
10-
github.com/oklog/ulid/v2 v2.1.1
1111
github.com/rs/cors v1.11.1
1212
github.com/stretchr/testify v1.10.0
1313
github.com/thejerf/slogassert v0.3.4
@@ -18,7 +18,6 @@ require (
1818
)
1919

2020
require (
21-
github.com/cespare/xxhash/v2 v2.3.0 // indirect
2221
github.com/davecgh/go-spew v1.1.1 // indirect
2322
github.com/dgraph-io/ristretto/v2 v2.2.0 // indirect
2423
github.com/dustin/go-humanize v1.0.1 // indirect

go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
3838
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
3939
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
4040
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
41-
github.com/oklog/ulid/v2 v2.1.1 h1:suPZ4ARWLOJLegGFiZZ1dFAkqzhMjL3J1TzI+5wHz8s=
42-
github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNsTT1QQ=
43-
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
4441
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4542
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
4643
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=

protojson.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,10 +658,8 @@ type jsonGetDelayedStatesResult struct {
658658
}
659659

660660
type jsonData struct {
661-
ID *string `json:"id,omitempty"`
662-
Rev *string `json:"rev,omitempty"`
663-
Binary *bool `json:"binary,omitempty"`
664-
B *string `json:"b,omitempty"`
661+
Rev *string `json:"rev,omitempty"`
662+
Blob *string `json:"blob,omitempty"`
665663

666664
Annotations *map[string]string `json:"annotations,omitempty"`
667665
}
@@ -679,16 +677,16 @@ func (jsonData *jsonData) toData(d *Data) error {
679677
d.Annotations = *jsonData.Annotations
680678
}
681679

682-
if jsonData.B != nil {
680+
if jsonData.Blob != nil {
683681
if d.IsBinary() {
684682

685-
b, err := base64.StdEncoding.DecodeString(*jsonData.B)
683+
b, err := base64.StdEncoding.DecodeString(*jsonData.Blob)
686684
if err != nil {
687685
return err
688686
}
689687
d.Blob = b
690688
} else {
691-
d.Blob = []byte(*jsonData.B)
689+
d.Blob = []byte(*jsonData.Blob)
692690
}
693691
}
694692

@@ -712,7 +710,7 @@ func (jsonData *jsonData) fromData(d *Data) {
712710
} else {
713711
b = string(d.Blob)
714712
}
715-
jsonData.B = &b
713+
jsonData.Blob = &b
716714
}
717715

718716
return

ui/dist/assets/index-ClDjxM4h.js

Lines changed: 0 additions & 106 deletions
This file was deleted.

ui/dist/assets/index-CuFnp7DU.js

Lines changed: 106 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vite + React + TS</title>
8-
<script type="module" crossorigin src="/assets/index-ClDjxM4h.js"></script>
8+
<script type="module" crossorigin src="/assets/index-CuFnp7DU.js"></script>
99
<link rel="stylesheet" crossorigin href="/assets/index-Ch1f69RT.css">
1010
</head>
1111
<body>

ui/src/AnnotationDetails.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useContext, useEffect, useState } from "react";
22
import { ApiContext } from "./ApiContext";
3-
import {Command, GetDataCommand, Data, DataRef, State, StateCtx, StateCtxRef} from "./gen/flowstate/v1/messages_pb";
3+
import {Command, GetDataCommand, State, StateCtx, StateCtxRef} from "./gen/flowstate/v1/messages_pb";
44

55
export const AnnotationDetails = ({ alias, state }: { alias: string; state: State }) => {
66
const [info, setInfo] = useState<Command | null>(null);
@@ -13,13 +13,9 @@ export const AnnotationDetails = ({ alias, state }: { alias: string; state: Stat
1313
stateCtxs: [
1414
new StateCtx({current: state, committed: state})
1515
],
16-
datas: [
17-
new Data()
18-
],
1916
getData: new GetDataCommand({
2017
alias: alias,
21-
stateRef: new StateCtxRef({ idx: BigInt(0) }),
22-
dataRef: new DataRef({ idx: BigInt(0) })
18+
stateRef: new StateCtxRef({ idx: BigInt(0) })
2319
})
2420
});
2521

@@ -28,21 +24,21 @@ export const AnnotationDetails = ({ alias, state }: { alias: string; state: Stat
2824

2925
if (!info) return "Loading...";
3026

31-
return (
32-
<>
33-
{info.datas.map((d) => {
34-
if (d.binary) return <span>{d.b}</span>;
35-
36-
try {
37-
return (
38-
<pre className="text-left">
39-
{JSON.stringify(JSON.parse(d.b), null, 2)}
40-
</pre>
41-
);
42-
} catch {
43-
return <span>{d.b}</span>;
44-
}
45-
})}
46-
</>
47-
);
27+
const data = info.stateCtxs[0].datas[alias];
28+
29+
if (!data) return "No data found for alias";
30+
31+
if (data.annotations["binary"]) {
32+
return <span>{data.blob}</span>;
33+
}
34+
35+
try {
36+
return (
37+
<pre className="text-left">
38+
{JSON.stringify(JSON.parse(data.blob), null, 2)}
39+
</pre>
40+
);
41+
} catch {
42+
return <span>{data.blob}</span>;
43+
}
4844
};

0 commit comments

Comments
 (0)