Compare commits

...

3 Commits

Author SHA1 Message Date
Henry Hsu
6b6cf2daa8 render value for each column 2021-08-17 10:12:17 -07:00
Henry Hsu
6112d47134 extract table header to its own view. pass column names to it 2021-08-16 16:37:12 -07:00
Henry Hsu
1a07f7604a include all other data in value 2021-08-16 15:24:51 -07:00
3 changed files with 96 additions and 18 deletions

View File

@@ -0,0 +1,50 @@
<template>
<thead>
<tr>
<th>Name</th>
<th>Timestamp</th>
<th v-for="name in columnNames"
:key="name"
>
{{ name }}
</th>
<th v-if="hasUnits">Unit</th>
</tr>
</thead>
</template>
<script>
export default {
props: {
item: {
type: Object,
required: true
},
columnNames: {
type: Array,
required: true
}
},
data() {
return {};
},
computed: {
hasUnits() {
// let itemsWithUnits = this.items.filter((item) => {
// let metadata = this.openmct.telemetry.getMetadata(item.domainObject);
// return this.metadataHasUnits(metadata.valueMetadatas);
// });
// return itemsWithUnits.length !== 0;
return false;
}
},
mounted() {
// console.log(this.names);
}
};
</script>

View File

@@ -29,9 +29,11 @@
<td class="js-first-data">{{ domainObject.name }}</td> <td class="js-first-data">{{ domainObject.name }}</td>
<td class="js-second-data">{{ formattedTimestamp }}</td> <td class="js-second-data">{{ formattedTimestamp }}</td>
<td <td
v-for="name in columnNames"
:key="name"
class="js-third-data" class="js-third-data"
:class="valueClass" :class="valueClass"
>{{ value }}</td> >{{ value[name] }}</td>
<td <td
v-if="hasUnits" v-if="hasUnits"
class="js-units" class="js-units"
@@ -63,6 +65,10 @@ export default {
hasUnits: { hasUnits: {
type: Boolean, type: Boolean,
requred: true requred: true
},
columnNames: {
type: Array,
required: true
} }
}, },
data() { data() {
@@ -82,6 +88,7 @@ export default {
} }
}, },
mounted() { mounted() {
console.log(this.colNames);
this.metadata = this.openmct.telemetry.getMetadata(this.domainObject); this.metadata = this.openmct.telemetry.getMetadata(this.domainObject);
this.formats = this.openmct.telemetry.getFormatMap(this.metadata); this.formats = this.openmct.telemetry.getFormatMap(this.metadata);
this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier); this.keyString = this.openmct.objects.makeKeyString(this.domainObject.identifier);
@@ -96,12 +103,17 @@ export default {
this.timestampKey = this.openmct.time.timeSystem().key; this.timestampKey = this.openmct.time.timeSystem().key;
// this.valueMetadata = this
// .metadata
// .valuesForHints(['range'])[0];
// this.valueKey = this.valueMetadata.key;
this.valueMetadata = this this.valueMetadata = this
.metadata .metadata
.valuesForHints(['range'])[0]; .valuesForHints(['range']);
// console.log(this.valueMetadata);
this.valueKey = this.valueMetadata.key; this.valueKey = this.valueMetadata.map(value => value.key);
// console.log(this.valueKey);
this.unsubscribe = this.openmct this.unsubscribe = this.openmct
.telemetry .telemetry
.subscribe(this.domainObject, this.updateValues); .subscribe(this.domainObject, this.updateValues);
@@ -123,9 +135,18 @@ export default {
let limit; let limit;
if (this.shouldUpdate(newTimestamp)) { if (this.shouldUpdate(newTimestamp)) {
// console.log(datum);
this.datum = datum; this.datum = datum;
this.timestamp = newTimestamp; this.timestamp = newTimestamp;
this.value = this.formats[this.valueKey].format(datum); // console.log(this.formats);
// this.value = this.formats[this.valueKey].format(datum);
this.value = {};
this.valueKey.forEach(key => {
let formattedDatum = this.formats[key].format(datum);
this.value[key] = formattedDatum;
limit = this.limitEvaluator.evaluate(formattedDatum, this.valueMetadata);
});
// console.log(this.value);
limit = this.limitEvaluator.evaluate(datum, this.valueMetadata); limit = this.limitEvaluator.evaluate(datum, this.valueMetadata);
if (limit) { if (limit) {
this.valueClass = limit.cssClass; this.valueClass = limit.cssClass;

View File

@@ -22,19 +22,17 @@
<template> <template>
<div class="c-lad-table-wrapper u-style-receiver js-style-receiver"> <div class="c-lad-table-wrapper u-style-receiver js-style-receiver">
<table class="c-table c-lad-table"> <table v-for="ladRow in items"
<thead> :key="ladRow.key"
<tr> class="c-table c-lad-table"
<th>Name</th> >
<th>Timestamp</th> <lad-head
<th>Value</th> :item="ladRow"
<th v-if="hasUnits">Unit</th> :column-names="columnNames(ladRow)"
</tr> />
</thead>
<tbody> <tbody>
<lad-row <lad-row
v-for="ladRow in items" :column-names="columnNames(ladRow)"
:key="ladRow.key"
:domain-object="ladRow.domainObject" :domain-object="ladRow.domainObject"
:path-to-table="objectPath" :path-to-table="objectPath"
:has-units="hasUnits" :has-units="hasUnits"
@@ -47,10 +45,12 @@
<script> <script>
import LadRow from './LADRow.vue'; import LadRow from './LADRow.vue';
import LadHead from './LADHead.vue';
export default { export default {
components: { components: {
LadRow LadRow,
LadHead
}, },
inject: ['openmct', 'currentView'], inject: ['openmct', 'currentView'],
props: { props: {
@@ -94,6 +94,13 @@ export default {
this.composition.off('reorder', this.reorder); this.composition.off('reorder', this.reorder);
}, },
methods: { methods: {
columnNames(item) {
let metadata = this.openmct.telemetry.getMetadata(item.domainObject);
let valueMetadata = metadata
.valuesForHints(['range']);
return valueMetadata.map(value => value.key);
},
addItem(domainObject) { addItem(domainObject) {
let item = {}; let item = {};
item.domainObject = domainObject; item.domainObject = domainObject;