WiP
This commit is contained in:
@@ -12,7 +12,7 @@ export const clearRetainedTopic = () => (dispatch: Dispatch<any>, getState: () =
|
|||||||
dispatch(clearTopic(selectedTopic, false))
|
dispatch(clearTopic(selectedTopic, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean, subtopicClearLimit = 50) => (dispatch: Dispatch<any>, getState: () => AppState) => {
|
||||||
const { connectionId } = getState().connection
|
const { connectionId } = getState().connection
|
||||||
if (!connectionId) {
|
if (!connectionId) {
|
||||||
return
|
return
|
||||||
@@ -29,15 +29,18 @@ export const clearTopic = (topic: q.TreeNode<any>, recursive: boolean) => (dispa
|
|||||||
rendererEvents.emit(publishEvent, mqttMessage)
|
rendererEvents.emit(publishEvent, mqttMessage)
|
||||||
|
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
topic.childTopics().forEach((topic) => {
|
topic.childTopics()
|
||||||
console.log('deleting', topic.path())
|
.filter(topic => Boolean(topic.message && topic.message.value))
|
||||||
const mqttMessage = {
|
.slice(0, subtopicClearLimit)
|
||||||
topic: topic.path(),
|
.forEach((topic) => {
|
||||||
payload: null,
|
console.log('deleting', topic.path())
|
||||||
retain: true,
|
const mqttMessage = {
|
||||||
qos: 0 as 0,
|
topic: topic.path(),
|
||||||
}
|
payload: null,
|
||||||
rendererEvents.emit(publishEvent, mqttMessage)
|
retain: true,
|
||||||
})
|
qos: 0 as 0,
|
||||||
|
}
|
||||||
|
rendererEvents.emit(publishEvent, mqttMessage)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Clear from '@material-ui/icons/Clear'
|
|||||||
import Copy from '../Copy'
|
import Copy from '../Copy'
|
||||||
import DateFormatter from '../helper/DateFormatter'
|
import DateFormatter from '../helper/DateFormatter'
|
||||||
import Delete from '@material-ui/icons/Delete'
|
import Delete from '@material-ui/icons/Delete'
|
||||||
|
import DeleteForever from '@material-ui/icons/DeleteForever'
|
||||||
import ExpandMore from '@material-ui/icons/ExpandMore'
|
import ExpandMore from '@material-ui/icons/ExpandMore'
|
||||||
import MessageHistory from './MessageHistory'
|
import MessageHistory from './MessageHistory'
|
||||||
import NodeStats from './NodeStats'
|
import NodeStats from './NodeStats'
|
||||||
@@ -26,8 +27,10 @@ import {
|
|||||||
Popper,
|
Popper,
|
||||||
Typography,
|
Typography,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
|
Badge,
|
||||||
} from '@material-ui/core'
|
} from '@material-ui/core'
|
||||||
import CustomIconButton from '../CustomIconButton';
|
import CustomIconButton from '../CustomIconButton';
|
||||||
|
import { max } from 'moment';
|
||||||
|
|
||||||
const throttle = require('lodash.throttle')
|
const throttle = require('lodash.throttle')
|
||||||
|
|
||||||
@@ -102,19 +105,33 @@ class Sidebar extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private renderRecursiveTopicDeleteButton() {
|
private renderRecursiveTopicDeleteButton() {
|
||||||
if (!this.props.node) {
|
const deleteLimit = 50
|
||||||
|
const topicCount = this.props.node ? this.props.node.childTopicCount() : 0
|
||||||
|
if (!this.props.node || topicCount <= 1) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return <CustomIconButton onClick={() => this.deleteTopic(this.props.node, true)}><Delete style={{ color: 'red' }} /></CustomIconButton>
|
return (
|
||||||
|
<CustomIconButton onClick={() => this.deleteTopic(this.props.node, true, deleteLimit)}>
|
||||||
|
<Tooltip title={`Deletes up to ${deleteLimit} sub-topics with a single click`}>
|
||||||
|
<Badge
|
||||||
|
classes={{ badge: this.props.classes.badge }}
|
||||||
|
badgeContent={<span style={{ whiteSpace: 'nowrap' }}>{topicCount >= deleteLimit ? '50+' : topicCount}</span>}
|
||||||
|
color="secondary"
|
||||||
|
>
|
||||||
|
<DeleteForever color="action" />
|
||||||
|
</Badge>
|
||||||
|
</Tooltip>
|
||||||
|
</CustomIconButton>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private deleteTopic = (topic?: q.TreeNode<TopicViewModel>, recursive: boolean = false) => {
|
private deleteTopic = (topic?: q.TreeNode<TopicViewModel>, recursive: boolean = false, maxCount = 50) => {
|
||||||
if (!topic) {
|
if (!topic) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.actions.clearTopic(topic, recursive)
|
this.props.actions.clearTopic(topic, recursive, maxCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
private renderNode() {
|
private renderNode() {
|
||||||
|
|||||||
Reference in New Issue
Block a user