Skip to content

Commit

Permalink
Store limits values
Browse files Browse the repository at this point in the history
  • Loading branch information
jmthomas committed Mar 16, 2023
1 parent 51c0671 commit 6f10350
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,12 @@ export default {
this.graph.root.querySelectorAll('.u-marker')[index].style.borderColor =
event
},
changeLimits: function (limits, limitsValues) {
changeLimits: function (limits) {
let key = this.subscriptionKey(this.selectedItem)
let index = this.indexes[key]
this.items[index - 1].limits = limits
this.selectedItem.limits = limits
this.limitsValues = limitsValues
this.limitsValues = limits
},
linesPlugin: function () {
return {
Expand Down Expand Up @@ -1281,7 +1281,12 @@ export default {
item.color = this.colors[this.colorIndex]
}
if (item.limits === undefined) {
item.limits = 'NONE'
// [] matches 'NONE' in GraphEditItemDialog
item.limits = []
} else {
// If somehow we have more than one limits
// the last one wins which is fine
this.limitsValues = item.limits
}
this.colorIndex++
if (this.colorIndex === this.colors.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,10 @@
hide-details
label="Display Limits"
:items="limitsNames"
v-model="editItem.limits"
@change="
$emit('changeLimits', editItem.limits, limits[editItem.limits])
"
v-model="limitsName"
@change="$emit('changeLimits', limits[limitsName])"
/>
<div class="pa-3">
{{ editItem.limits }}: {{ limits[editItem.limits] }}
</div>
<div class="pa-3">{{ limitsName }}: {{ limits[limitsName] }}</div>
</div>
<v-card-actions>
<v-btn color="primary" @click="$emit('close', editItem)">Ok</v-btn>
Expand All @@ -94,6 +90,8 @@ export default {
data: function () {
return {
editItem: null,
limitsName: 'NONE',
// NONE: [] matches the default limits assigned in Graph addItems
limits: { NONE: [] },
valueTypes: ['CONVERTED', 'RAW'],
reduction: [
Expand Down Expand Up @@ -121,20 +119,21 @@ export default {
},
async created() {
this.editItem = { ...this.item }
console.log('editItem:')
console.log(this.editItem)
await this.api
this.api = new OpenC3Api()
.get_item(this.item.targetName, this.item.packetName, this.item.itemName)
.then((details) => {
// console.log(details.limits)
for (const [key, value] of Object.entries(details.limits)) {
// console.log(`${key}: ${value} keys:${Object.keys(value)}`)
if (Object.keys(value).includes('red_low')) {
// Must call this.$set to allow Vue to make the limits object reactive
this.$set(this.limits, key, Object.values(value))
}
}
// Locate the key for the value array that we pass in
this.limitsName = Object.keys(this.limits).find(
// Little hack to compare arrays you convert them to strings
(key) => this.limits[key] + '' === this.editItem.limits + ''
)
})
},
}
Expand Down

0 comments on commit 6f10350

Please sign in to comment.