-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from OpenC3/graph_limits
Allow user to graph limits
- Loading branch information
Showing
3 changed files
with
212 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
...c3-cosmos-init/plugins/packages/openc3-tool-common/src/components/GraphEditItemDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
<!-- | ||
# Copyright 2022 Ball Aerospace & Technologies Corp. | ||
# All Rights Reserved. | ||
# | ||
# This program is free software; you can modify and/or redistribute it | ||
# under the terms of the GNU Affero General Public License | ||
# as published by the Free Software Foundation; version 3 with | ||
# attribution addendums as found in the LICENSE.txt | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU Affero General Public License for more details. | ||
|
||
# Modified by OpenC3, Inc. | ||
# All changes Copyright 2023, OpenC3, Inc. | ||
# All Rights Reserved | ||
# | ||
# This file may also be used under the terms of a commercial license | ||
# if purchased from OpenC3, Inc. | ||
--> | ||
|
||
<template> | ||
<!-- Edit Item dialog --> | ||
<v-dialog v-model="show" width="600" @keydown.enter="success()"> | ||
<v-card class="pa-3"> | ||
<v-card-title class="headline">Edit Item</v-card-title> | ||
<v-select | ||
outlined | ||
hide-details | ||
label="Value Type" | ||
:items="valueTypes" | ||
v-model="editItem.valueType" | ||
/> | ||
<v-select | ||
outlined | ||
hide-details | ||
label="Reduction" | ||
:items="reduction" | ||
v-model="editItem.reduced" | ||
/> | ||
<v-select | ||
outlined | ||
hide-details | ||
label="Reduced Type" | ||
:items="reducedTypes" | ||
:disabled="currentReduced === 'DECOM'" | ||
v-model="editItem.reducedType" | ||
/> | ||
<v-select | ||
outlined | ||
hide-details | ||
label="Color" | ||
:items="colors" | ||
v-model="editItem.color" | ||
@change="$emit('changeColor', $event)" | ||
/> | ||
<div v-if="limitsNames.length > 1"> | ||
<v-select | ||
outlined | ||
hide-details | ||
label="Display Limits" | ||
:items="limitsNames" | ||
v-model="limitsName" | ||
@change="$emit('changeLimits', limits[limitsName])" | ||
/> | ||
<div class="pa-3">{{ limitsName }}: {{ limits[limitsName] }}</div> | ||
</div> | ||
<v-card-actions> | ||
<v-btn color="primary" @click="$emit('close', editItem)">Ok</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script> | ||
import { OpenC3Api } from '../services/openc3-api.js' | ||
export default { | ||
props: { | ||
value: Boolean, // value is the default prop when using v-model | ||
item: { | ||
type: Object, | ||
required: true, | ||
}, | ||
colors: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}, | ||
data: function () { | ||
return { | ||
editItem: null, | ||
limitsName: 'NONE', | ||
// NONE: [] matches the default limits assigned in Graph addItems | ||
limits: { NONE: [] }, | ||
valueTypes: ['CONVERTED', 'RAW'], | ||
reduction: [ | ||
// Map NONE to DECOM for clarity | ||
{ text: 'NONE', value: 'DECOM' }, | ||
{ text: 'REDUCED_MINUTE', value: 'REDUCED_MINUTE' }, | ||
{ text: 'REDUCED_HOUR', value: 'REDUCED_HOUR' }, | ||
{ text: 'REDUCED_DAY', value: 'REDUCED_DAY' }, | ||
], | ||
reducedTypes: ['MIN', 'MAX', 'AVG', 'STDDEV'], | ||
} | ||
}, | ||
computed: { | ||
show: { | ||
get() { | ||
return this.value | ||
}, | ||
set(value) { | ||
this.$emit('input', value) // input is the default event when using v-model | ||
}, | ||
}, | ||
limitsNames() { | ||
return Object.keys(this.limits) | ||
}, | ||
}, | ||
async created() { | ||
this.editItem = { ...this.item } | ||
await this.api | ||
this.api = new OpenC3Api() | ||
.get_item(this.item.targetName, this.item.packetName, this.item.itemName) | ||
.then((details) => { | ||
for (const [key, value] of Object.entries(details.limits)) { | ||
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 + '' | ||
) | ||
}) | ||
}, | ||
} | ||
</script> |