Skip to content

Commit

Permalink
Alarm pathway editing, lessen control-page updates
Browse files Browse the repository at this point in the history
  • Loading branch information
balbatross committed Feb 16, 2024
1 parent 7918f86 commit 346f65c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export default (prisma: PrismaClient) => {
id: nanoid(),
name: args.input.name,
scope: args.input.scope,
script: args.input.script,
program: {
connect: {id: args.program}
}
Expand All @@ -140,6 +141,7 @@ export default (prisma: PrismaClient) => {
},
data: {
name: args.input.name,
script: args.input.script,
scope: args.input.scope
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { gql, useApolloClient, useQuery } from "@apollo/client";
import { useEffect } from "react";

export const useDevice = (id: string) => {

const client = useApolloClient();

const refetch = () => {
client.refetchQueries({include: ['BaseDeviceInfo']})
}

const { data } = useQuery(gql`
query BaseDeviceInfo ($id: ID){
Expand Down Expand Up @@ -191,11 +197,19 @@ import { useEffect } from "react";
}
})

useEffect(() => {
const interval = setInterval(() => {
refetch();
}, 30 * 1000)

return () => {
clearInterval(interval)
}
}, [])

return {
results: data?.commandDevices || [],
refetch: () => {
client.refetchQueries({include: ['BaseDeviceInfo']})
}
refetch
}

}
Expand All @@ -220,13 +234,14 @@ export const useConnectivity = (deviceId: string) => {
`, {
variables: {
id: deviceId,
}
},
fetchPolicy: 'no-cache'
})

useEffect(() => {
const interval = setInterval(() => {
refetch();
}, 2000)
}, 10 * 1000)

return () => {
clearInterval(interval)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { Box } from "@mui/material";
import React from "react";
import { CodeEditor } from "./code";
import { useParams } from "react-router-dom";
import { useCommandEditor } from "../../context";

export const AlarmPathwayEditor = () => {

return (
<Box sx={{flex: 1, display: 'flex'}}>
<CodeEditor defaultValue={`export const sendNotification = (message: string) => {}`}/>
<CodeEditor
defaultValue={`export const sendNotification = (message: string) => {}`}/>
</Box>
)
}

0 comments on commit 346f65c

Please sign in to comment.