Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PacketViewer config bugs #1806

Merged
merged 5 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: {},
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice ... I think there's probably other places in COSMOS where we're "remembering" previous values but the most obvious is here in Packet Viewer

}
})
.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()
}
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is the bug fix because we were updating initalTargetName after the use ... I see it was only ever set in data. How did this ever work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed during scrum, but I'm not sure how this ever worked, but I suspect the TargetPacketItemChooser was being destroyed and recreated or something like that.

mode: function (newVal, oldVal) {
this.selectedPacketName = null
this.selectedItemName = null
Expand Down
Loading