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])
|
||||
|
||||
console.log(file)
|
||||
|
||||
if (loading == true || !file?.type) {
|
||||
return <LoadingPlaceholder message={'Loading file preview...'} />
|
||||
}
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
import { useEffect, useRef, cloneElement, useMemo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
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 = {
|
||||
cmd: 'meta',
|
||||
@ -59,7 +63,9 @@ const KeyboardShortcut = ({
|
||||
}
|
||||
|
||||
if (log) {
|
||||
console.log('Key Down:', key, 'Pressed Keys:', [...pressedKeysRef.current])
|
||||
logger.info('Key Down:', key, 'Pressed Keys:', [
|
||||
...pressedKeysRef.current
|
||||
])
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@ -127,8 +127,6 @@ const ObjectForm = forwardRef(
|
||||
searchParams.delete(actionParam)
|
||||
const newSearch = searchParams.toString()
|
||||
|
||||
console.log('newSearch', newSearch)
|
||||
console.log('location.pathname', location.pathname)
|
||||
const newPath = location.pathname + (newSearch ? `?${newSearch}` : '')
|
||||
navigate(newPath, { replace: true })
|
||||
},
|
||||
@ -537,7 +535,7 @@ const ObjectForm = forwardRef(
|
||||
}
|
||||
|
||||
const activityUnsubscribe = subscribeToObjectActivity(
|
||||
id,
|
||||
id?.toLowerCase(),
|
||||
type,
|
||||
activityHandler
|
||||
)
|
||||
@ -565,7 +563,7 @@ const ObjectForm = forwardRef(
|
||||
}
|
||||
|
||||
const objectUpdatesUnsubscribe = subscribeToObjectUpdates(
|
||||
id,
|
||||
id?.toLowerCase(),
|
||||
type,
|
||||
objectUpdateHandler
|
||||
)
|
||||
|
||||
@ -693,7 +693,7 @@ const ObjectTable = forwardRef(
|
||||
// Subscribe to new items only
|
||||
newItemIds.forEach((itemId) => {
|
||||
const unsubscribe = subscribeToObjectUpdates(
|
||||
itemId,
|
||||
itemId?.toLowerCase(),
|
||||
type,
|
||||
(updateData) => {
|
||||
updateEventHandlerRef.current(itemId, updateData)
|
||||
|
||||
@ -55,7 +55,7 @@ const PrinterMiscPanel = ({
|
||||
useEffect(() => {
|
||||
if (id && connected == true) {
|
||||
const miscEventUnsubscribe = subscribeToObjectEvent(
|
||||
id,
|
||||
id?.toLowerCase(),
|
||||
'printer',
|
||||
'misc',
|
||||
(event) => {
|
||||
|
||||
@ -90,7 +90,7 @@ const PrinterPositionPanel = ({
|
||||
useEffect(() => {
|
||||
if (id && connected == true) {
|
||||
const motionEventUnsubscribe = subscribeToObjectEvent(
|
||||
id,
|
||||
id?.toLowerCase(),
|
||||
'printer',
|
||||
'motion',
|
||||
(event) => {
|
||||
|
||||
@ -84,9 +84,9 @@ const PrinterTemperaturePanel = ({
|
||||
}, [temperatureData.bed?.target])
|
||||
|
||||
useEffect(() => {
|
||||
if (id && connected == true) {
|
||||
if (id && connected == true && offline == false) {
|
||||
const temperatureEventUnsubscribe = subscribeToObjectEvent(
|
||||
id,
|
||||
id?.toLowerCase(),
|
||||
'printer',
|
||||
'temperature',
|
||||
(event) => {
|
||||
@ -100,7 +100,7 @@ const PrinterTemperaturePanel = ({
|
||||
if (temperatureEventUnsubscribe) temperatureEventUnsubscribe()
|
||||
}
|
||||
}
|
||||
}, [id, connected, subscribeToObjectEvent])
|
||||
}, [id, connected, subscribeToObjectEvent, offline])
|
||||
|
||||
const [extruderTarget, setExtruderTarget] = useState(0)
|
||||
const [bedTarget, setBedTarget] = useState(0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user