Skip to content

Commit

Permalink
fix: Refactor WebSocketStatus out to reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
mman committed Oct 15, 2024
1 parent 0e9cac7 commit ab12a0c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/views/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import CIcon from "@coreui/icons-react"
import { cilRss } from "@coreui/icons"
import { AppState } from "../../store"
import { WebSocketStatus } from "../settings/WebsocketStatus"

function Dashboard() {
const { measurementRate, measurementCount, deviceStatistics } = useSelector((state: AppState) => {
Expand Down Expand Up @@ -100,7 +101,7 @@ function Dashboard() {
</div>
)}

{websocketStatus !== "open" && <CAlert color="danger">Not connected to the server</CAlert>}
<WebSocketStatus websocketStatus={websocketStatus} />
</div>
)
}
Expand Down
15 changes: 15 additions & 0 deletions src/client/views/settings/WebsocketStatus.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { CAlert } from "@coreui/react"
import { AppWebSocketStatus } from "../../store"

interface WebSocketStatusProps {
websocketStatus: AppWebSocketStatus
}

function WebSocketStatus(props: WebSocketStatusProps) {
if (props.websocketStatus !== "open") {
return <CAlert color="danger">Not connected to the Venus Influx Loader</CAlert>
}
return null
}

export { WebSocketStatus }

0 comments on commit ab12a0c

Please sign in to comment.