Skip to content

Commit d419efc

Browse files
author
jan hof
committed
fixed service schema
1 parent d16a146 commit d419efc

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/hooks/configHook.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import Axios from "axios";
22
import { JSONSchema6 } from "json-schema";
33
import { useEffect, useState } from "react";
4+
import { ServiceSchema } from "../types/ServiceTypes";
45

56
const useConfig = (namespace: string) => {
6-
const [config, setConfig] = useState<JSONSchema6>();
7+
const [config, setConfig] = useState<ServiceSchema>();
78

89
useEffect(() => {
910
Axios.get("/api/webinterface/service/" + namespace).then((res) =>

src/types/ServiceTypes.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { JSONSchema6 } from "json-schema";
2+
13
interface Service {
24
namespace: string;
35
name: string;
@@ -9,6 +11,11 @@ interface Service {
911
error?: string;
1012
}
1113

14+
interface ServiceSchema{
15+
schema: JSONSchema6
16+
uiSchema: JSONSchema6
17+
}
18+
1219
enum ServiceState {
1320
RUNNNING = 0,
1421
IDLE = 1,
@@ -22,4 +29,4 @@ interface SocketMessage{
2229
}
2330

2431
export {ServiceState}
25-
export type { Service, SocketMessage };
32+
export type { Service, ServiceSchema, SocketMessage };

src/views/service/ServiceDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ type ServiceDetailsProps = {
1212

1313
const ServiceDetails = (props: RouteComponentProps<ServiceDetailsProps>) => {
1414
const namespace = props.match.params.namespace;
15-
const [config, setConfig] = useConfig(namespace);
15+
const [config, setConfig]: any = useConfig(namespace);
1616

1717
return (
1818
<>
1919
<CRow>
2020
{config && (
2121
<Form
22-
schema={config as JSONSchema6}
22+
schema={config.schema}
23+
uiSchema={config.uiSchema}
2324
onChange={() => console.log("changed")}
2425
onSubmit={(e) =>
2526
Axios.post("/api/webinterface/service/" + namespace, e.formData)

0 commit comments

Comments
 (0)