Refactor components to improve logging and ID handling
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-ui/pipeline/head This commit looks good
- Removed console.log statements from FilePreview and ObjectForm components for cleaner code. - Replaced console.log with loglevel in KeyboardShortcut for better logging management. - Updated ID handling in ObjectForm, ObjectTable, PrinterMiscPanel, PrinterPositionPanel, and PrinterTemperaturePanel components to ensure IDs are consistently converted to lowercase, enhancing data integrity.
This commit is contained in:
parent
a2d27c692a
commit
d982b8dfb3
@ -36,8 +36,6 @@ const FilePreview = ({ file, style = {} }) => {
|
|||||||
}
|
}
|
||||||
}, [file._id, file?.type, fetchPreview, token])
|
}, [file._id, file?.type, fetchPreview, token])
|
||||||
|
|
||||||
console.log(file)
|
|
||||||
|
|
||||||
if (loading == true || !file?.type) {
|
if (loading == true || !file?.type) {
|
||||||
return <LoadingPlaceholder message={'Loading file preview...'} />
|
return <LoadingPlaceholder message={'Loading file preview...'} />
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,10 @@
|
|||||||
import { useEffect, useRef, cloneElement, useMemo } from 'react'
|
import { useEffect, useRef, cloneElement, useMemo } from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import { Popover, Typography } from 'antd'
|
import { Popover, Typography } from 'antd'
|
||||||
|
import loglevel from 'loglevel'
|
||||||
|
import config from '../../../config'
|
||||||
|
const logger = loglevel.getLogger('ApiServerContext')
|
||||||
|
logger.setLevel(config.logLevel)
|
||||||
|
|
||||||
const MODIFIER_ALIASES = {
|
const MODIFIER_ALIASES = {
|
||||||
cmd: 'meta',
|
cmd: 'meta',
|
||||||
@ -59,7 +63,9 @@ const KeyboardShortcut = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (log) {
|
if (log) {
|
||||||
console.log('Key Down:', key, 'Pressed Keys:', [...pressedKeysRef.current])
|
logger.info('Key Down:', key, 'Pressed Keys:', [
|
||||||
|
...pressedKeysRef.current
|
||||||
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|||||||
@ -127,8 +127,6 @@ const ObjectForm = forwardRef(
|
|||||||
searchParams.delete(actionParam)
|
searchParams.delete(actionParam)
|
||||||
const newSearch = searchParams.toString()
|
const newSearch = searchParams.toString()
|
||||||
|
|
||||||
console.log('newSearch', newSearch)
|
|
||||||
console.log('location.pathname', location.pathname)
|
|
||||||
const newPath = location.pathname + (newSearch ? `?${newSearch}` : '')
|
const newPath = location.pathname + (newSearch ? `?${newSearch}` : '')
|
||||||
navigate(newPath, { replace: true })
|
navigate(newPath, { replace: true })
|
||||||
},
|
},
|
||||||
@ -537,7 +535,7 @@ const ObjectForm = forwardRef(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const activityUnsubscribe = subscribeToObjectActivity(
|
const activityUnsubscribe = subscribeToObjectActivity(
|
||||||
id,
|
id?.toLowerCase(),
|
||||||
type,
|
type,
|
||||||
activityHandler
|
activityHandler
|
||||||
)
|
)
|
||||||
@ -565,7 +563,7 @@ const ObjectForm = forwardRef(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const objectUpdatesUnsubscribe = subscribeToObjectUpdates(
|
const objectUpdatesUnsubscribe = subscribeToObjectUpdates(
|
||||||
id,
|
id?.toLowerCase(),
|
||||||
type,
|
type,
|
||||||
objectUpdateHandler
|
objectUpdateHandler
|
||||||
)
|
)
|
||||||
|
|||||||
@ -693,7 +693,7 @@ const ObjectTable = forwardRef(
|
|||||||
// Subscribe to new items only
|
// Subscribe to new items only
|
||||||
newItemIds.forEach((itemId) => {
|
newItemIds.forEach((itemId) => {
|
||||||
const unsubscribe = subscribeToObjectUpdates(
|
const unsubscribe = subscribeToObjectUpdates(
|
||||||
itemId,
|
itemId?.toLowerCase(),
|
||||||
type,
|
type,
|
||||||
(updateData) => {
|
(updateData) => {
|
||||||
updateEventHandlerRef.current(itemId, updateData)
|
updateEventHandlerRef.current(itemId, updateData)
|
||||||
|
|||||||
@ -55,7 +55,7 @@ const PrinterMiscPanel = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id && connected == true) {
|
if (id && connected == true) {
|
||||||
const miscEventUnsubscribe = subscribeToObjectEvent(
|
const miscEventUnsubscribe = subscribeToObjectEvent(
|
||||||
id,
|
id?.toLowerCase(),
|
||||||
'printer',
|
'printer',
|
||||||
'misc',
|
'misc',
|
||||||
(event) => {
|
(event) => {
|
||||||
|
|||||||
@ -90,7 +90,7 @@ const PrinterPositionPanel = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id && connected == true) {
|
if (id && connected == true) {
|
||||||
const motionEventUnsubscribe = subscribeToObjectEvent(
|
const motionEventUnsubscribe = subscribeToObjectEvent(
|
||||||
id,
|
id?.toLowerCase(),
|
||||||
'printer',
|
'printer',
|
||||||
'motion',
|
'motion',
|
||||||
(event) => {
|
(event) => {
|
||||||
|
|||||||
@ -84,9 +84,9 @@ const PrinterTemperaturePanel = ({
|
|||||||
}, [temperatureData.bed?.target])
|
}, [temperatureData.bed?.target])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (id && connected == true) {
|
if (id && connected == true && offline == false) {
|
||||||
const temperatureEventUnsubscribe = subscribeToObjectEvent(
|
const temperatureEventUnsubscribe = subscribeToObjectEvent(
|
||||||
id,
|
id?.toLowerCase(),
|
||||||
'printer',
|
'printer',
|
||||||
'temperature',
|
'temperature',
|
||||||
(event) => {
|
(event) => {
|
||||||
@ -100,7 +100,7 @@ const PrinterTemperaturePanel = ({
|
|||||||
if (temperatureEventUnsubscribe) temperatureEventUnsubscribe()
|
if (temperatureEventUnsubscribe) temperatureEventUnsubscribe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [id, connected, subscribeToObjectEvent])
|
}, [id, connected, subscribeToObjectEvent, offline])
|
||||||
|
|
||||||
const [extruderTarget, setExtruderTarget] = useState(0)
|
const [extruderTarget, setExtruderTarget] = useState(0)
|
||||||
const [bedTarget, setBedTarget] = useState(0)
|
const [bedTarget, setBedTarget] = useState(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user