Skip to content

Commit

Permalink
Merge pull request #1806 from OpenC3/bug/packetviewer-config
Browse files Browse the repository at this point in the history
PacketViewer config bugs
  • Loading branch information
ryan-pratt authored Jan 3, 2025
2 parents a792ac2 + cefeac0 commit 88de888
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,31 +491,49 @@ export default {
}
},
packetChanged(event) {
this.api.get_target(event.targetName).then((target) => {
this.ignoredItems = target.ignored_items
})
this.api
.get_packet_derived_items(event.targetName, event.packetName)
.then((derived) => {
this.derivedItems = derived
.get_target(event.targetName)
.then((target) => {
if (target) {
this.ignoredItems = target.ignored_items

return this.api.get_packet_derived_items(
event.targetName,
event.packetName,
)
} else {
// Probably got here from an old config or URL params that point to something that no longer exists
// (e.g. the plugin that defined this target was deleted). Unset these to avoid API errors.
this.targetName = null
this.packetName = null
this.$router.push({
name: 'PackerViewer',
params: {},
})
}
})
.then((derived) => {
if (derived) {
this.derivedItems = derived

this.targetName = event.targetName
this.packetName = event.packetName
if (
this.$route.params.target !== event.targetName ||
this.$route.params.packet !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
this.targetName = event.targetName
this.packetName = event.packetName
if (
this.$route.params.target !== event.targetName ||
this.$route.params.packet !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
})
}
this.changeUpdater(true)
}
})
}
this.changeUpdater(true)
},
changeUpdater(clearExisting) {
if (this.updater != null) {
Expand All @@ -526,6 +544,9 @@ export default {
this.rows = []
}
this.updater = setInterval(() => {
if (!this.targetName || !this.packetName) {
return // noop if target/packet aren't set
}
this.api
.get_tlm_packet(
this.targetName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ export default {
if (this.errors.length !== 0) {
let messages = new Set()
let result = []
this.errors.sort((a, b) => a.lineNumber - b.lineNumber)
for (const error of this.errors) {
const sortedErrors = this.errors.toSorted(
(a, b) => a.lineNumber - b.lineNumber,
)
for (const error of sortedErrors) {
let msg = `At ${error.lineNumber}: (${error.line}) ${error.message}.`
if (error.usage) {
msg += ` Usage: ${error.usage}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,24 @@ export default {
},
},
watch: {
initialTargetName: function (val) {
// These three "initial" watchers are here in case the parent component doesn't figure out its initial values
// until after this component has already been created. All this logic incl. the "on-set" events could be
// simplified with a refactor to use named v-models, but that's probably a significant breaking change.
if (val) {
this.selectedTargetName = val.toUpperCase()
}
},
initialPacketName: function (val) {
if (val) {
this.selectedPacketName = val.toUpperCase()
}
},
initialItemName: function (val) {
if (val) {
this.selectedItemName = val.toUpperCase()
}
},
mode: function (newVal, oldVal) {
this.selectedPacketName = null
this.selectedItemName = null
Expand Down

0 comments on commit 88de888

Please sign in to comment.