File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
import Axios from "axios" ;
2
2
import { JSONSchema6 } from "json-schema" ;
3
3
import { useEffect , useState } from "react" ;
4
+ import { ServiceSchema } from "../types/ServiceTypes" ;
4
5
5
6
const useConfig = ( namespace : string ) => {
6
- const [ config , setConfig ] = useState < JSONSchema6 > ( ) ;
7
+ const [ config , setConfig ] = useState < ServiceSchema > ( ) ;
7
8
8
9
useEffect ( ( ) => {
9
10
Axios . get ( "/api/webinterface/service/" + namespace ) . then ( ( res ) =>
Original file line number Diff line number Diff line change
1
+ import { JSONSchema6 } from "json-schema" ;
2
+
1
3
interface Service {
2
4
namespace : string ;
3
5
name : string ;
@@ -9,6 +11,11 @@ interface Service {
9
11
error ?: string ;
10
12
}
11
13
14
+ interface ServiceSchema {
15
+ schema : JSONSchema6
16
+ uiSchema : JSONSchema6
17
+ }
18
+
12
19
enum ServiceState {
13
20
RUNNNING = 0 ,
14
21
IDLE = 1 ,
@@ -22,4 +29,4 @@ interface SocketMessage{
22
29
}
23
30
24
31
export { ServiceState }
25
- export type { Service , SocketMessage } ;
32
+ export type { Service , ServiceSchema , SocketMessage } ;
Original file line number Diff line number Diff line change @@ -12,14 +12,15 @@ type ServiceDetailsProps = {
12
12
13
13
const ServiceDetails = ( props : RouteComponentProps < ServiceDetailsProps > ) => {
14
14
const namespace = props . match . params . namespace ;
15
- const [ config , setConfig ] = useConfig ( namespace ) ;
15
+ const [ config , setConfig ] : any = useConfig ( namespace ) ;
16
16
17
17
return (
18
18
< >
19
19
< CRow >
20
20
{ config && (
21
21
< Form
22
- schema = { config as JSONSchema6 }
22
+ schema = { config . schema }
23
+ uiSchema = { config . uiSchema }
23
24
onChange = { ( ) => console . log ( "changed" ) }
24
25
onSubmit = { ( e ) =>
25
26
Axios . post ( "/api/webinterface/service/" + namespace , e . formData )
You can’t perform that action at this time.
0 commit comments