@bardioc/create-bardioc-app 0.5.8 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/_base/public/app-manifest.json +1 -2
- package/templates/angular/package.json +1 -1
- package/templates/angular/scripts/dev-env.mjs +31 -10
- package/templates/angular/scripts/dev.mjs +37 -8
- package/templates/angular/src/app/app.component.ts +42 -24
- package/templates/angular/src/app/bardioc.token.ts +2 -2
- package/templates/angular/src/main.ts +6 -8
- package/templates/nextjs/app/page.tsx +8 -8
- package/templates/nextjs/package.json +1 -1
- package/templates/nextjs/scripts/dev-env.mjs +31 -10
- package/templates/nextjs/scripts/dev.mjs +37 -8
- package/templates/preact/package.json +1 -1
- package/templates/preact/src/App.tsx +5 -5
- package/templates/preact/src/main.tsx +3 -3
- package/templates/solid/package.json +1 -1
- package/templates/solid/src/App.tsx +5 -5
- package/templates/solid/src/bardioc-sdk.tsx +11 -23
- package/templates/solid/src/main.tsx +5 -3
- package/templates/svelte/package.json +1 -1
- package/templates/svelte/src/App.svelte +7 -7
- package/templates/svelte/src/main.ts +5 -5
- package/templates/vite/package.json +1 -1
- package/templates/vite/public/app-manifest.json +0 -1
- package/templates/vite/src/auth/onboarding.tsx +4 -2
- package/templates/vite/src/climate/stations-view.tsx +1 -8
- package/templates/vite/src/climate/use-climate.ts +6 -6
- package/templates/vite/src/events/live-events-view.tsx +7 -9
- package/templates/vite/src/graph/explorer-view.tsx +4 -11
- package/templates/vite/src/graph/requests.ts +16 -19
- package/templates/vite/src/locales/de.json +5 -6
- package/templates/vite/src/locales/en.json +6 -7
- package/templates/vite/src/main.tsx +3 -3
- package/templates/vite/src/profile/profile-view.tsx +1 -8
- package/templates/vite/src/profile/use-profile.ts +3 -3
- package/templates/vite/src/shell/about-dialog.tsx +2 -8
- package/templates/vite/src/shell/app-shell.tsx +48 -11
- package/templates/vue/package.json +1 -1
- package/templates/vue/src/App.vue +7 -7
- package/templates/vue/src/bardioc-sdk.ts +6 -15
- package/templates/vue/src/main.ts +5 -4
- package/templates/angular/src/app/bardioc-bridge.ts +0 -5
|
@@ -9,7 +9,7 @@ type ResultState =
|
|
|
9
9
|
| { status: 'error'; request: string; message: string };
|
|
10
10
|
|
|
11
11
|
function SdkDemo() {
|
|
12
|
-
const
|
|
12
|
+
const bardioc = useSdk();
|
|
13
13
|
const notify = useNotify();
|
|
14
14
|
const [result, setResult] = createSignal<ResultState>({ status: 'idle' });
|
|
15
15
|
const [running, setRunning] = createSignal(false);
|
|
@@ -18,14 +18,14 @@ function SdkDemo() {
|
|
|
18
18
|
if (running()) return;
|
|
19
19
|
setRunning(true);
|
|
20
20
|
|
|
21
|
-
const request = '
|
|
21
|
+
const request = 'os.profile.get()';
|
|
22
22
|
setResult({ status: 'loading', request });
|
|
23
23
|
|
|
24
24
|
const startTime = Date.now();
|
|
25
25
|
notify('Getting user profile…', 'info');
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
|
-
const data = await
|
|
28
|
+
const data = await bardioc.os.profile.get();
|
|
29
29
|
|
|
30
30
|
const duration = Date.now() - startTime;
|
|
31
31
|
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
@@ -43,7 +43,7 @@ function SdkDemo() {
|
|
|
43
43
|
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
44
44
|
setResult({
|
|
45
45
|
status: 'success',
|
|
46
|
-
request: '
|
|
46
|
+
request: 'ui.notify',
|
|
47
47
|
data: { ok: true, message: 'Notification sent to OS' },
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -106,7 +106,7 @@ function SdkDemo() {
|
|
|
106
106
|
<div class="text-muted-foreground border-border border-b pb-2 font-mono text-xs">
|
|
107
107
|
{r.request}
|
|
108
108
|
</div>
|
|
109
|
-
<div class="text-destructive
|
|
109
|
+
<div class="text-destructive whitespace-pre-wrap break-all">{r.message}</div>
|
|
110
110
|
</div>
|
|
111
111
|
);
|
|
112
112
|
}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createContext,
|
|
1
|
+
import type { Bardioc, NotifyLevel } from '@bardioc/app-sdk';
|
|
2
|
+
import { createContext, useContext, type JSX } from 'solid-js';
|
|
3
3
|
|
|
4
|
-
const BardiocContext = createContext<
|
|
4
|
+
const BardiocContext = createContext<Bardioc>();
|
|
5
5
|
|
|
6
|
-
export function AppSdkProvider(props: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
onMount(() => {
|
|
10
|
-
void bridge.connect();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
onCleanup(() => {
|
|
14
|
-
bridge.destroy();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
return <BardiocContext.Provider value={bridge}>{props.children}</BardiocContext.Provider>;
|
|
6
|
+
export function AppSdkProvider(props: { bardioc: Bardioc; children: JSX.Element }) {
|
|
7
|
+
return <BardiocContext.Provider value={props.bardioc}>{props.children}</BardiocContext.Provider>;
|
|
18
8
|
}
|
|
19
9
|
|
|
20
|
-
export function useSdk():
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return bridge;
|
|
10
|
+
export function useSdk(): Bardioc {
|
|
11
|
+
const bardioc = useContext(BardiocContext);
|
|
12
|
+
if (!bardioc) throw new Error('useSdk() must be used inside AppSdkProvider');
|
|
13
|
+
return bardioc;
|
|
26
14
|
}
|
|
27
15
|
|
|
28
16
|
export function useNotify() {
|
|
29
|
-
const
|
|
17
|
+
const { ui } = useSdk();
|
|
30
18
|
return (message: string, level?: NotifyLevel) => {
|
|
31
|
-
|
|
19
|
+
ui.notify(message, level).catch(console.error);
|
|
32
20
|
};
|
|
33
21
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { connect } from '@bardioc/app-sdk';
|
|
2
|
+
import { installDevHost, isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
|
|
2
3
|
import { render } from 'solid-js/web';
|
|
3
4
|
import { App } from './App';
|
|
4
5
|
import { AppSdkProvider } from './bardioc-sdk';
|
|
@@ -15,15 +16,16 @@ const devStandalone = isDevStandalone();
|
|
|
15
16
|
const useSdkProvider = insideIframe || devStandalone;
|
|
16
17
|
|
|
17
18
|
if (devStandalone) {
|
|
18
|
-
|
|
19
|
+
installDevHost({ appId: APP_NAME });
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
const root = document.getElementById('root')!;
|
|
22
23
|
|
|
23
24
|
if (useSdkProvider) {
|
|
25
|
+
const bardioc = await connect();
|
|
24
26
|
render(
|
|
25
27
|
() => (
|
|
26
|
-
<AppSdkProvider
|
|
28
|
+
<AppSdkProvider bardioc={bardioc}>
|
|
27
29
|
<App />
|
|
28
30
|
</AppSdkProvider>
|
|
29
31
|
),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { Bardioc, NotifyLevel } from '@bardioc/app-sdk';
|
|
3
3
|
import { isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
|
|
4
4
|
import { type Snippet } from 'svelte';
|
|
5
5
|
import './index.css';
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
| { status: 'success'; request: string; data: unknown }
|
|
11
11
|
| { status: 'error'; request: string; message: string };
|
|
12
12
|
|
|
13
|
-
let {
|
|
13
|
+
let { bardioc = null, children }: { bardioc?: Bardioc | null; children?: Snippet } = $props();
|
|
14
14
|
|
|
15
15
|
const showSdkDemo = isInsideIframe() || isDevStandalone();
|
|
16
16
|
|
|
@@ -18,21 +18,21 @@
|
|
|
18
18
|
let running = $state(false);
|
|
19
19
|
|
|
20
20
|
function notify(message: string, level?: NotifyLevel) {
|
|
21
|
-
|
|
21
|
+
bardioc?.ui.notify(message, level).catch(console.error);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
async function runGetProfile() {
|
|
25
|
-
if (running || !
|
|
25
|
+
if (running || !bardioc) return;
|
|
26
26
|
running = true;
|
|
27
27
|
|
|
28
|
-
const request = '
|
|
28
|
+
const request = 'os.profile.get()';
|
|
29
29
|
result = { status: 'loading', request };
|
|
30
30
|
|
|
31
31
|
const startTime = Date.now();
|
|
32
32
|
notify('Getting user profile…', 'info');
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
|
-
const data = await
|
|
35
|
+
const data = await bardioc.os.profile.get();
|
|
36
36
|
|
|
37
37
|
const duration = Date.now() - startTime;
|
|
38
38
|
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
51
51
|
result = {
|
|
52
52
|
status: 'success',
|
|
53
|
-
request: '
|
|
53
|
+
request: 'ui.notify',
|
|
54
54
|
data: { ok: true, message: 'Notification sent to OS' },
|
|
55
55
|
};
|
|
56
56
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { connect } from '@bardioc/app-sdk';
|
|
2
|
+
import { installDevHost, isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
|
|
3
3
|
import { mount } from 'svelte';
|
|
4
4
|
import App from './App.svelte';
|
|
5
5
|
import './index.css';
|
|
@@ -15,12 +15,12 @@ const devStandalone = isDevStandalone();
|
|
|
15
15
|
const useSdkProvider = insideIframe || devStandalone;
|
|
16
16
|
|
|
17
17
|
if (devStandalone) {
|
|
18
|
-
|
|
18
|
+
installDevHost({ appId: APP_NAME });
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const
|
|
21
|
+
const bardioc = useSdkProvider ? await connect() : null;
|
|
22
22
|
|
|
23
23
|
mount(App, {
|
|
24
24
|
target: document.getElementById('app')!,
|
|
25
|
-
props: {
|
|
25
|
+
props: { bardioc },
|
|
26
26
|
});
|
|
@@ -27,7 +27,8 @@ export function Onboarding() {
|
|
|
27
27
|
titleSize="lg"
|
|
28
28
|
title={t('auth.title', { fallback: 'Connect to Bardioc' })}
|
|
29
29
|
description={t('auth.description', {
|
|
30
|
-
fallback:
|
|
30
|
+
fallback:
|
|
31
|
+
'This dashboard reads live data through the Bardioc SDK transport. It runs when opened inside Bardioc, or standalone with dev auth.',
|
|
31
32
|
})}
|
|
32
33
|
actions={
|
|
33
34
|
<Button onClick={() => globalThis.location.reload()}>
|
|
@@ -42,7 +43,8 @@ export function Onboarding() {
|
|
|
42
43
|
<ol className="text-muted-foreground list-decimal space-y-2 pl-4">
|
|
43
44
|
<li>
|
|
44
45
|
{t('auth.step1', {
|
|
45
|
-
fallback:
|
|
46
|
+
fallback:
|
|
47
|
+
'Set DEV_SECRET=<your-secret> and API_BASE_URL=<your-host> in the .env file.',
|
|
46
48
|
})}
|
|
47
49
|
</li>
|
|
48
50
|
<li>
|
|
@@ -120,14 +120,7 @@ export function StationsView() {
|
|
|
120
120
|
|
|
121
121
|
return (
|
|
122
122
|
<div className="flex flex-col gap-3">
|
|
123
|
-
<
|
|
124
|
-
<h2 className="text-lg font-semibold">
|
|
125
|
-
{t('stations.title', { fallback: 'Monitoring Stations' })}
|
|
126
|
-
</h2>
|
|
127
|
-
<p className="text-muted-foreground text-xs">
|
|
128
|
-
{t('stations.description', { fallback: '' })}
|
|
129
|
-
</p>
|
|
130
|
-
</div>
|
|
123
|
+
<p className="text-muted-foreground text-xs">{t('stations.description', { fallback: '' })}</p>
|
|
131
124
|
<DataTable
|
|
132
125
|
boxed
|
|
133
126
|
data={data}
|
|
@@ -6,10 +6,10 @@ import { generateState, syncState } from './climate-data';
|
|
|
6
6
|
import { IDB_LOG_PREFIX, IDB_STATE_KEY, IDB_STORE, type ClimateState } from './types';
|
|
7
7
|
|
|
8
8
|
export function useClimate() {
|
|
9
|
-
const
|
|
9
|
+
const bardioc = useSdk();
|
|
10
10
|
const notify = useAppNotify();
|
|
11
11
|
const { t } = useTranslation();
|
|
12
|
-
const store = useMemo(() =>
|
|
12
|
+
const store = useMemo(() => bardioc.idb(IDB_STORE), [bardioc]);
|
|
13
13
|
|
|
14
14
|
const [state, setState] = useState<ClimateState | null>(null);
|
|
15
15
|
const [syncing, setSyncing] = useState(false);
|
|
@@ -42,7 +42,7 @@ export function useClimate() {
|
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
let active = true;
|
|
44
44
|
void (async () => {
|
|
45
|
-
const raw = await store.get
|
|
45
|
+
const raw = (await store.get(IDB_STATE_KEY).catch(() => null))?.value;
|
|
46
46
|
const saved =
|
|
47
47
|
raw !== null &&
|
|
48
48
|
raw !== undefined &&
|
|
@@ -69,12 +69,12 @@ export function useClimate() {
|
|
|
69
69
|
try {
|
|
70
70
|
let source: ClimateState['source'] = 'graph';
|
|
71
71
|
try {
|
|
72
|
-
await
|
|
72
|
+
await bardioc.os.profile.get();
|
|
73
73
|
} catch {
|
|
74
74
|
source = 'mock';
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
const raw = await store.get
|
|
77
|
+
const raw = (await store.get(IDB_STATE_KEY).catch(() => null))?.value;
|
|
78
78
|
const saved =
|
|
79
79
|
raw !== null &&
|
|
80
80
|
raw !== undefined &&
|
|
@@ -97,7 +97,7 @@ export function useClimate() {
|
|
|
97
97
|
} finally {
|
|
98
98
|
setSyncing(false);
|
|
99
99
|
}
|
|
100
|
-
}, [
|
|
100
|
+
}, [bardioc, notify, persist, store, t]);
|
|
101
101
|
|
|
102
102
|
const setActiveStation = useCallback(
|
|
103
103
|
(id: string) => {
|
|
@@ -23,14 +23,11 @@ export function LiveEventsView() {
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<div className="flex h-full min-w-0 flex-col gap-3">
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})}
|
|
32
|
-
</p>
|
|
33
|
-
</div>
|
|
26
|
+
<p className="text-muted-foreground text-xs">
|
|
27
|
+
{t('events.description', {
|
|
28
|
+
fallback: 'Live graph events streamed from the OS over SSE (permission "events").',
|
|
29
|
+
})}
|
|
30
|
+
</p>
|
|
34
31
|
|
|
35
32
|
<Card className="min-h-0 min-w-0 flex-1">
|
|
36
33
|
{events.length === 0 ? (
|
|
@@ -44,7 +41,8 @@ export function LiveEventsView() {
|
|
|
44
41
|
fallback: 'No graph events yet — activity will appear here as it happens.',
|
|
45
42
|
})
|
|
46
43
|
: t('events.emptyStandalone', {
|
|
47
|
-
fallback:
|
|
44
|
+
fallback:
|
|
45
|
+
'Open inside Bardioc (or run standalone with dev auth) to receive live events.',
|
|
48
46
|
})
|
|
49
47
|
}
|
|
50
48
|
/>
|
|
@@ -13,7 +13,7 @@ type Result =
|
|
|
13
13
|
|
|
14
14
|
export function ExplorerView() {
|
|
15
15
|
const { t } = useTranslation();
|
|
16
|
-
const
|
|
16
|
+
const bardioc = useSdk();
|
|
17
17
|
const notify = useAppNotify();
|
|
18
18
|
const [activeId, setActiveId] = useState(SDK_REQUESTS[0].id);
|
|
19
19
|
const [result, setResult] = useState<Result>({ status: 'idle' });
|
|
@@ -25,10 +25,10 @@ export function ExplorerView() {
|
|
|
25
25
|
setResult({ status: 'running' });
|
|
26
26
|
const started = Date.now();
|
|
27
27
|
try {
|
|
28
|
-
const data = await request.run(
|
|
28
|
+
const data = await request.run(bardioc);
|
|
29
29
|
const ms = Date.now() - started;
|
|
30
30
|
setResult({ status: 'done', live: true, ms, data });
|
|
31
|
-
notify(t('notify.queryOk', { fallback: 'Request
|
|
31
|
+
notify(t('notify.queryOk', { fallback: 'Request OK ({ms} ms).', params: { ms } }), 'success');
|
|
32
32
|
} catch {
|
|
33
33
|
const ms = Date.now() - started;
|
|
34
34
|
setResult({ status: 'done', live: false, ms, data: request.mock() });
|
|
@@ -41,14 +41,7 @@ export function ExplorerView() {
|
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<div className="flex h-full min-w-0 flex-col gap-3">
|
|
44
|
-
<
|
|
45
|
-
<h2 className="text-lg font-semibold">
|
|
46
|
-
{t('explorer.title', { fallback: 'Graph Explorer' })}
|
|
47
|
-
</h2>
|
|
48
|
-
<p className="text-muted-foreground text-xs">
|
|
49
|
-
{t('explorer.description', { fallback: '' })}
|
|
50
|
-
</p>
|
|
51
|
-
</div>
|
|
44
|
+
<p className="text-muted-foreground text-xs">{t('explorer.description', { fallback: '' })}</p>
|
|
52
45
|
|
|
53
46
|
<div className="grid min-w-0 gap-3 lg:grid-cols-[minmax(0,240px)_minmax(0,1fr)]">
|
|
54
47
|
<div className="flex min-w-0 flex-col gap-1">
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Bardioc } from '@bardioc/app-sdk';
|
|
2
2
|
|
|
3
3
|
export type RequestCategory = 'graph' | 'os';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ export interface SdkRequest {
|
|
|
6
6
|
id: string;
|
|
7
7
|
category: RequestCategory;
|
|
8
8
|
label: string;
|
|
9
|
-
run: (
|
|
9
|
+
run: (bardioc: Bardioc) => Promise<unknown>;
|
|
10
10
|
mock: () => unknown;
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -32,8 +32,8 @@ function toItems(result: unknown): GraphNode[] {
|
|
|
32
32
|
return [];
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
async function sampleNodes(
|
|
36
|
-
return toItems(await
|
|
35
|
+
async function sampleNodes(bardioc: Bardioc, limit: number): Promise<GraphNode[]> {
|
|
36
|
+
return toItems(await bardioc.graph.query<GraphNode>('*', { limit }));
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
// The full surface a hosted app can reach over the SDK transport. Each `run` issues a real call
|
|
@@ -48,7 +48,7 @@ export const SDK_REQUESTS: [SdkRequest, ...SdkRequest[]] = [
|
|
|
48
48
|
id: 'graph.query.all',
|
|
49
49
|
category: 'graph',
|
|
50
50
|
label: "graph.query('*', { limit: 10 })",
|
|
51
|
-
run:
|
|
51
|
+
run: bardioc => bardioc.graph.query('*', { limit: 10 }),
|
|
52
52
|
mock: () => ({
|
|
53
53
|
items: [
|
|
54
54
|
{
|
|
@@ -63,14 +63,14 @@ export const SDK_REQUESTS: [SdkRequest, ...SdkRequest[]] = [
|
|
|
63
63
|
id: 'graph.query.type',
|
|
64
64
|
category: 'graph',
|
|
65
65
|
label: String.raw`graph.query('ogit\/_type:"<first result type>"', { limit: 5 })`,
|
|
66
|
-
run: async
|
|
67
|
-
const [first] = await sampleNodes(
|
|
66
|
+
run: async bardioc => {
|
|
67
|
+
const [first] = await sampleNodes(bardioc, 1);
|
|
68
68
|
const type = first?.['ogit/_type'];
|
|
69
69
|
if (!type) {
|
|
70
70
|
return [];
|
|
71
71
|
}
|
|
72
72
|
const escapedType = type.replaceAll('/', String.raw`\/`);
|
|
73
|
-
return
|
|
73
|
+
return bardioc.graph.query(String.raw`ogit\/_type:"${escapedType}"`, { limit: 5 });
|
|
74
74
|
},
|
|
75
75
|
mock: () => ({
|
|
76
76
|
items: [
|
|
@@ -86,13 +86,13 @@ export const SDK_REQUESTS: [SdkRequest, ...SdkRequest[]] = [
|
|
|
86
86
|
id: 'graph.get',
|
|
87
87
|
category: 'graph',
|
|
88
88
|
label: 'graph.get(firstNodeId)',
|
|
89
|
-
run: async
|
|
90
|
-
const [first] = await sampleNodes(
|
|
89
|
+
run: async bardioc => {
|
|
90
|
+
const [first] = await sampleNodes(bardioc, 1);
|
|
91
91
|
const id = first?.['ogit/_id'];
|
|
92
92
|
if (!id) {
|
|
93
93
|
return null;
|
|
94
94
|
}
|
|
95
|
-
return
|
|
95
|
+
return bardioc.graph.get(id);
|
|
96
96
|
},
|
|
97
97
|
mock: () => ({
|
|
98
98
|
'ogit/_id': 'cmexample_app-1',
|
|
@@ -106,11 +106,8 @@ export const SDK_REQUESTS: [SdkRequest, ...SdkRequest[]] = [
|
|
|
106
106
|
label: "graph.gremlin(nodeId, 'both()')",
|
|
107
107
|
// `both()` returns adjacent vertices in either direction. Replace this id with a connected
|
|
108
108
|
// node from your own instance — many nodes (e.g. config vertices) have no traversable edges.
|
|
109
|
-
run:
|
|
110
|
-
|
|
111
|
-
'cjohdg6y80000ai48sw7swsq0_cmm2b2jz3t6dq0110poeobock',
|
|
112
|
-
'both()'
|
|
113
|
-
),
|
|
109
|
+
run: bardioc =>
|
|
110
|
+
bardioc.graph.gremlin('cjohdg6y80000ai48sw7swsq0_cmm2b2jz3t6dq0110poeobock', 'both()'),
|
|
114
111
|
mock: () => [
|
|
115
112
|
{
|
|
116
113
|
'ogit/_id': 'cmexample_node-2',
|
|
@@ -123,21 +120,21 @@ export const SDK_REQUESTS: [SdkRequest, ...SdkRequest[]] = [
|
|
|
123
120
|
id: 'os.profile',
|
|
124
121
|
category: 'os',
|
|
125
122
|
label: 'os.profile.get()',
|
|
126
|
-
run:
|
|
123
|
+
run: bardioc => bardioc.os.profile.get(),
|
|
127
124
|
mock: () => ({ id: 'usr-demo', email: 'operator@bardioc.dev', name: 'Demo Operator' }),
|
|
128
125
|
},
|
|
129
126
|
{
|
|
130
127
|
id: 'os.organization',
|
|
131
128
|
category: 'os',
|
|
132
129
|
label: 'os.organization.getStructure()',
|
|
133
|
-
run:
|
|
130
|
+
run: bardioc => bardioc.os.organization.getStructure(),
|
|
134
131
|
mock: () => ({ id: 'org-demo', name: 'Bardioc Climate Corp', units: [], members: [] }),
|
|
135
132
|
},
|
|
136
133
|
{
|
|
137
134
|
id: 'os.applications',
|
|
138
135
|
category: 'os',
|
|
139
136
|
label: 'os.applications.list()',
|
|
140
|
-
run:
|
|
137
|
+
run: bardioc => bardioc.os.applications.list(),
|
|
141
138
|
mock: () => [{ id: 'app-demo', name: 'Climate Dashboard', version: '0.0.1' }],
|
|
142
139
|
},
|
|
143
140
|
];
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
"version": "Version",
|
|
17
17
|
"id": "App-ID",
|
|
18
18
|
"description": "Beschreibung",
|
|
19
|
-
"permissions": "Berechtigungen",
|
|
20
19
|
"error": "app-manifest.json konnte nicht gelesen werden",
|
|
21
20
|
"source": "Live aus public/app-manifest.json gelesen"
|
|
22
21
|
},
|
|
23
22
|
"genericTable": {
|
|
24
|
-
"filterPlaceholder": "Ergebnisse filtern
|
|
23
|
+
"filterPlaceholder": "Ergebnisse filtern…",
|
|
25
24
|
"itemLabel": "Zeilen",
|
|
26
25
|
"showing": "{from} bis {to} von {total}",
|
|
27
26
|
"columns": "Spalten",
|
|
@@ -40,8 +39,8 @@
|
|
|
40
39
|
},
|
|
41
40
|
"auth": {
|
|
42
41
|
"title": "Mit Bardioc verbinden",
|
|
43
|
-
"description": "Dieses Dashboard liest Live-Daten über den Bardioc-SDK-Transport. Es läuft in Bardioc oder eigenständig mit
|
|
44
|
-
"stepsTitle": "Eigenständig mit Dev-
|
|
42
|
+
"description": "Dieses Dashboard liest Live-Daten über den Bardioc-SDK-Transport. Es läuft in Bardioc oder eigenständig mit Dev-Auth.",
|
|
43
|
+
"stepsTitle": "Eigenständig mit Dev-Auth ausführen:",
|
|
45
44
|
"step1": "Setze DEV_SECRET=<dein-secret> und API_BASE_URL=<dein-host> in .env",
|
|
46
45
|
"step2": "Dev-Server starten:",
|
|
47
46
|
"detectedTitle": "Erkannte Umgebung",
|
|
@@ -127,14 +126,14 @@
|
|
|
127
126
|
"description": "Live-Graph-Ereignisse, vom OS über SSE gestreamt (Berechtigung \"events\").",
|
|
128
127
|
"emptyTitle": "Warte auf Ereignisse",
|
|
129
128
|
"emptyHost": "Noch keine Graph-Ereignisse — Aktivität erscheint hier, sobald sie auftritt.",
|
|
130
|
-
"emptyStandalone": "In Bardioc (oder
|
|
129
|
+
"emptyStandalone": "In Bardioc öffnen (oder eigenständig mit Dev-Auth ausführen), um Live-Ereignisse zu empfangen."
|
|
131
130
|
},
|
|
132
131
|
"notify": {
|
|
133
132
|
"synced": "{count} Stationen synchronisiert",
|
|
134
133
|
"saved": "In IndexedDB gespeichert",
|
|
135
134
|
"stationSelected": "Aktive Station: {name}",
|
|
136
135
|
"localeChanged": "Sprache gewechselt zu {locale}",
|
|
137
|
-
"queryOk": "Anfrage
|
|
136
|
+
"queryOk": "Anfrage OK ({ms} ms)",
|
|
138
137
|
"queryFailed": "Anfrage fehlgeschlagen — zeige simulierte Daten"
|
|
139
138
|
}
|
|
140
139
|
}
|
|
@@ -16,12 +16,11 @@
|
|
|
16
16
|
"version": "Version",
|
|
17
17
|
"id": "App ID",
|
|
18
18
|
"description": "Description",
|
|
19
|
-
"permissions": "Permissions",
|
|
20
19
|
"error": "Could not read app-manifest.json.",
|
|
21
20
|
"source": "Read live from public/app-manifest.json."
|
|
22
21
|
},
|
|
23
22
|
"genericTable": {
|
|
24
|
-
"filterPlaceholder": "Filter Results
|
|
23
|
+
"filterPlaceholder": "Filter Results…",
|
|
25
24
|
"itemLabel": "rows",
|
|
26
25
|
"showing": "{from} to {to} of {total}",
|
|
27
26
|
"columns": "Columns",
|
|
@@ -40,9 +39,9 @@
|
|
|
40
39
|
},
|
|
41
40
|
"auth": {
|
|
42
41
|
"title": "Connect to Bardioc",
|
|
43
|
-
"description": "This dashboard reads live data through the Bardioc SDK transport. It runs when opened inside Bardioc, or standalone with
|
|
44
|
-
"stepsTitle": "Run standalone with
|
|
45
|
-
"step1": "Set DEV_SECRET=<your-secret> and API_BASE_URL=<your-host> in .env.",
|
|
42
|
+
"description": "This dashboard reads live data through the Bardioc SDK transport. It runs when opened inside Bardioc, or standalone with dev auth.",
|
|
43
|
+
"stepsTitle": "Run standalone with dev auth:",
|
|
44
|
+
"step1": "Set DEV_SECRET=<your-secret> and API_BASE_URL=<your-host> in the .env file.",
|
|
46
45
|
"step2": "Start the dev server:",
|
|
47
46
|
"detectedTitle": "Detected Environment",
|
|
48
47
|
"insideHost": "Inside Host Iframe",
|
|
@@ -127,14 +126,14 @@
|
|
|
127
126
|
"description": "Live graph events streamed from the OS over SSE (permission \"events\").",
|
|
128
127
|
"emptyTitle": "Waiting for Events",
|
|
129
128
|
"emptyHost": "No graph events yet — activity will appear here as it happens.",
|
|
130
|
-
"emptyStandalone": "Open inside Bardioc (or
|
|
129
|
+
"emptyStandalone": "Open inside Bardioc (or run standalone with dev auth) to receive live events."
|
|
131
130
|
},
|
|
132
131
|
"notify": {
|
|
133
132
|
"synced": "Synced {count} stations.",
|
|
134
133
|
"saved": "Saved to IndexedDB.",
|
|
135
134
|
"stationSelected": "Active station: {name}.",
|
|
136
135
|
"localeChanged": "Language switched to {locale}.",
|
|
137
|
-
"queryOk": "Request
|
|
136
|
+
"queryOk": "Request OK ({ms} ms).",
|
|
138
137
|
"queryFailed": "Request failed — showing simulated data."
|
|
139
138
|
}
|
|
140
139
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { installDevHost, isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
|
|
2
2
|
import { AppSdkProvider } from '@bardioc/app-sdk/react';
|
|
3
3
|
import { StrictMode } from 'react';
|
|
4
4
|
import { createRoot } from 'react-dom/client';
|
|
@@ -17,13 +17,13 @@ const devStandalone = isDevStandalone();
|
|
|
17
17
|
const useSdkProvider = insideIframe || devStandalone;
|
|
18
18
|
|
|
19
19
|
if (devStandalone) {
|
|
20
|
-
|
|
20
|
+
installDevHost({ appId: APP_NAME });
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
createRoot(document.getElementById('root')!).render(
|
|
24
24
|
<StrictMode>
|
|
25
25
|
{useSdkProvider ? (
|
|
26
|
-
<AppSdkProvider
|
|
26
|
+
<AppSdkProvider>
|
|
27
27
|
<AppI18nProvider syncWithOs>
|
|
28
28
|
<App />
|
|
29
29
|
</AppI18nProvider>
|
|
@@ -42,14 +42,7 @@ export function ProfileView() {
|
|
|
42
42
|
|
|
43
43
|
return (
|
|
44
44
|
<div className="flex flex-col gap-4">
|
|
45
|
-
<
|
|
46
|
-
<h2 className="text-lg font-semibold">
|
|
47
|
-
{t('profile.title', { fallback: 'Operator Profile' })}
|
|
48
|
-
</h2>
|
|
49
|
-
<p className="text-muted-foreground text-xs">
|
|
50
|
-
{t('profile.description', { fallback: '' })}
|
|
51
|
-
</p>
|
|
52
|
-
</div>
|
|
45
|
+
<p className="text-muted-foreground text-xs">{t('profile.description', { fallback: '' })}</p>
|
|
53
46
|
|
|
54
47
|
<Card>
|
|
55
48
|
<div className="flex items-center gap-4">
|
|
@@ -25,7 +25,7 @@ export function operatorLabel(profile: Record_ | null): string | null {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export function useProfile(): ProfileState {
|
|
28
|
-
const
|
|
28
|
+
const bardioc = useSdk();
|
|
29
29
|
const [state, setState] = useState<ProfileState>({
|
|
30
30
|
loading: true,
|
|
31
31
|
profile: null,
|
|
@@ -36,7 +36,7 @@ export function useProfile(): ProfileState {
|
|
|
36
36
|
let active = true;
|
|
37
37
|
void (async () => {
|
|
38
38
|
try {
|
|
39
|
-
const profile = (await
|
|
39
|
+
const profile = (await bardioc.os.profile.get()) as Record_;
|
|
40
40
|
if (active) setState({ loading: false, profile, error: null });
|
|
41
41
|
} catch (error) {
|
|
42
42
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -46,7 +46,7 @@ export function useProfile(): ProfileState {
|
|
|
46
46
|
return () => {
|
|
47
47
|
active = false;
|
|
48
48
|
};
|
|
49
|
-
}, [
|
|
49
|
+
}, [bardioc]);
|
|
50
50
|
|
|
51
51
|
return state;
|
|
52
52
|
}
|