addressed review comments

This commit is contained in:
Joel McKinnon 2020-02-25 15:36:37 -08:00
parent 70b5c627ca
commit fd0c19026d
2 changed files with 24 additions and 21 deletions

View File

@ -91,21 +91,40 @@ export default {
telemetryMetadata: {}, telemetryMetadata: {},
telemetryMetadataOptions: {}, telemetryMetadataOptions: {},
operations: OPERATIONS, operations: OPERATIONS,
filteredOps: [],
inputCount: 0, inputCount: 0,
rowLabel: '' rowLabel: '',
operationFormat: ''
} }
}, },
computed: { computed: {
setRowLabel: function () { setRowLabel: function () {
let operator = this.trigger === 'all' ? 'and ': 'or '; let operator = this.trigger === 'all' ? 'and ': 'or ';
return (this.index !== 0 ? operator : '') + 'when'; return (this.index !== 0 ? operator : '') + 'when';
},
filteredOps: function () {
return [...this.operations.filter(op => op.appliesTo.indexOf(this.operationFormat) !== -1)];
} }
}, },
mounted() { mounted() {
this.updateMetadataOptions(); this.updateMetadataOptions();
}, },
methods: { methods: {
getOperationFormat() {
this.telemetryMetadata.valueMetadatas.forEach((value, index) => {
let valueMetadata = this.telemetryMetadataOptions[index];
if (valueMetadata.formatString) {
this.operationFormat = 'number';
} else if (valueMetadata.format) {
if (valueMetadata.format === 'utc') {
this.operationFormat = 'number';
} else if (valueMetadata.format === 'enum') {
this.operationFormat = 'enum';
}
} else {
this.operationFormat = 'string';
}
});
},
updateMetadataOptions(ev) { updateMetadataOptions(ev) {
if (ev) {this.clearInputs()} if (ev) {this.clearInputs()}
if (this.criterion.telemetry) { if (this.criterion.telemetry) {
@ -121,27 +140,13 @@ export default {
}, },
updateOperations(ev) { updateOperations(ev) {
if (ev) {this.clearInputs()} if (ev) {this.clearInputs()}
let operationFormat = 'string'; this.getOperationFormat();
this.telemetryMetadata.valueMetadatas.forEach((value, index) => {
if (value.key === this.criterion.metadata) {
let valueMetadata = this.telemetryMetadataOptions[index];
if (valueMetadata.formatString) {
operationFormat = 'number';
} else if (valueMetadata.format) {
if (valueMetadata.format === 'utc') {
operationFormat = 'number';
} else if (valueMetadata.format === 'enum') {
operationFormat = 'enum';
}
}
}
});
this.filteredOps = [...this.operations.filter(op => op.appliesTo.indexOf(operationFormat) !== -1)];
this.persist(); this.persist();
}, },
updateOperationInputVisibility(ev) { updateOperationInputVisibility(ev) {
if (ev) { if (ev) {
this.criterion.input = []; this.criterion.input = [];
this.inputCount = 0;
} }
for (let i = 0; i < this.filteredOps.length; i++) { for (let i = 0; i < this.filteredOps.length; i++) {
if (this.criterion.operation === this.filteredOps[i].name) { if (this.criterion.operation === this.filteredOps[i].name) {

View File

@ -76,10 +76,8 @@ export default class TelemetryCriterion extends EventEmitter {
let params = []; let params = [];
let result = false; let result = false;
params.push(data[this.metadata]); params.push(data[this.metadata]);
if (this.input instanceof Array && this.input.length) { if (this.input.length) {
this.input.forEach(input => {params.push(this.input[0])}); this.input.forEach(input => {params.push(this.input[0])});
} else if (this.input) {
params.push(this.input);
} }
if (typeof comparator === 'function') { if (typeof comparator === 'function') {
result = comparator(params); result = comparator(params);