added unit column hiding in telemetry tables, added units to lad tables and sets

This commit is contained in:
Jamie Vigliotta 2020-07-14 13:20:42 -07:00
parent 3735a85c69
commit 8c8a14af7b
6 changed files with 72 additions and 15 deletions

View File

@ -32,6 +32,12 @@
class="js-third-data"
:class="valueClass"
>{{ value }}</td>
<td
v-if="hasUnits"
class="js-units"
>
{{ unit }}
</td>
</tr>
</template>
@ -48,6 +54,10 @@ export default {
domainObject: {
type: Object,
required: true
},
hasUnits: {
type: Boolean,
requred: true
}
},
data() {
@ -59,7 +69,8 @@ export default {
timestamp: undefined,
value: '---',
valueClass: '',
currentObjectPath
currentObjectPath,
unit: ''
}
},
computed: {
@ -101,6 +112,10 @@ export default {
.subscribe(this.domainObject, this.updateValues);
this.requestHistory();
if(this.hasUnits) {
this.setUnit();
}
},
destroyed() {
this.stopWatchingMutation();
@ -185,6 +200,9 @@ export default {
console.warn(`No formatter for ${this.timestampKey} time system for ${this.domainObject.name}.`);
return false;
}
},
setUnit() {
this.unit = this.valueMetadata.unit || '';
}
}
}

View File

@ -28,6 +28,7 @@
<th>Name</th>
<th>Timestamp</th>
<th>Value</th>
<th v-if="hasUnits">Unit</th>
</tr>
</thead>
<tbody>
@ -35,6 +36,7 @@
v-for="item in items"
:key="item.key"
:domain-object="item.domainObject"
:has-units="hasUnits"
/>
</tbody>
</table>
@ -51,7 +53,8 @@ export default {
},
data() {
return {
items: []
items: [],
hasUnits: false
}
},
mounted() {
@ -73,6 +76,9 @@ export default {
item.key = this.openmct.objects.makeKeyString(domainObject.identifier);
this.items.push(item);
if(!this.hasUnits) {
this.checkForUnits(domainObject);
}
},
removeItem(identifier) {
let index = this.items.findIndex(item => this.openmct.objects.makeKeyString(identifier) === item.key);
@ -84,6 +90,15 @@ export default {
reorderPlan.forEach((reorderEvent) => {
this.$set(this.items, reorderEvent.newIndex, oldItems[reorderEvent.oldIndex]);
});
},
checkForUnits(domainObject) {
let metadata = this.openmct.telemetry.getMetadata(domainObject);
metadata.valueMetadatas.forEach((metadatum) => {
if(metadatum.unit) {
this.hasUnits = true;
return;
}
});
}
}
}

View File

@ -27,6 +27,7 @@
<th>Name</th>
<th>Timestamp</th>
<th>Value</th>
<th v-if="hasUnits">Unit</th>
</tr>
</thead>
<tbody>
@ -45,6 +46,7 @@
v-for="secondary in secondaryTelemetryObjects[primary.key]"
:key="secondary.key"
:domain-object="secondary.domainObject"
:has-units="hasUnits"
/>
</template>
</tbody>
@ -63,7 +65,8 @@ export default {
return {
primaryTelemetryObjects: [],
secondaryTelemetryObjects: {},
compositions: []
compositions: [],
hasUnits: false
}
},
mounted() {
@ -108,6 +111,7 @@ export default {
this.$set(this.secondaryTelemetryObjects, primary.key, undefined);
this.primaryTelemetryObjects.splice(index,1);
primary = undefined;
this.checkForUnits();
},
reorderPrimary(reorderPlan) {
let oldComposition = this.primaryTelemetryObjects.slice();
@ -125,6 +129,9 @@ export default {
array.push(secondary);
this.$set(this.secondaryTelemetryObjects, primary.key, array);
if(!this.hasUnits) {
this.checkForUnits(domainObject);
}
}
},
removeSecondary(primary) {
@ -135,7 +142,25 @@ export default {
array.splice(index, 1);
this.$set(this.secondaryTelemetryObjects, primary.key, array);
this.checkForUnits();
}
},
checkForUnits() {
let hasUnits = false;
for(let telemetryObject in this.secondaryTelemetryObjects) {
if(this.secondaryTelemetryObjects[telemetryObject]) {
let objects = this.secondaryTelemetryObjects[telemetryObject];
for(let current of objects) {
let metadata = this.openmct.telemetry.getMetadata(current.domainObject);
for(let metadatum of metadata.valueMetadatas) {
if(metadatum.unit) {
hasUnits = true;
}
};
}
}
}
this.hasUnits = hasUnits;
}
}
}

View File

@ -521,7 +521,6 @@ define(['lodash'], function (_) {
applicableSelectedItems: applicableItems,
contextMethod: 'toggleUnits',
property: function (selectionPath) {
console.log('path', selectionPath, getPath(selectionPath) + '.showUnits');
return getPath(selectionPath) + '.showUnits';
},
options: [

View File

@ -29,12 +29,12 @@ define([
super(openmct, metadatum);
this.isUnit = true;
this.titleValue += ' Unit';
this.formatter = {
format(datum) {
return metadatum.unit;
this.formatter = {
format: (datum) => {
return this.metadatum.unit;
},
parse(datum) {
return metadatum.unit;
parse: (datum) => {
return this.metadatum.unit;
}
};
}
@ -54,10 +54,6 @@ define([
getFormattedValue(telemetryDatum) {
return this.formatter.format(telemetryDatum);
}
getParsedValue(telemetryDatum) {
return this.formatter.parse(telemetryDatum);
}
}
return TelemetryTableUnitColumn;

View File

@ -69,6 +69,7 @@
<script>
import TelemetryTableColumn from '../TelemetryTableColumn';
import TelemetryTableUnitColumn from '../TelemetryTableUnitColumn';
export default {
inject: ['tableConfiguration', 'openmct'],
@ -80,7 +81,6 @@ export default {
}
},
mounted() {
console.log('table-config mounted');
this.unlisteners = [];
this.openmct.editor.on('isEditing', this.toggleEdit);
let compositionCollection = this.openmct.composition.get(this.tableConfiguration.domainObject);
@ -132,10 +132,14 @@ export default {
},
addColumnsForObject(telemetryObject) {
let metadataValues = this.openmct.telemetry.getMetadata(telemetryObject).values();
console.log(metadataValues);
metadataValues.forEach(metadatum => {
let column = new TelemetryTableColumn(this.openmct, metadatum);
this.tableConfiguration.addSingleColumnForObject(telemetryObject, column);
// if units are available, need to add columns to be hidden
if(metadatum.unit !== undefined) {
let unitColumn = new TelemetryTableUnitColumn(this.openmct, metadatum);
this.tableConfiguration.addSingleColumnForObject(telemetryObject, unitColumn);
}
});
},
toggleHeaderVisibility() {