Compare commits

...

129 Commits

Author SHA1 Message Date
709c3fff65 no current output rendered 2020-01-22 13:15:44 -08:00
73d0507f1f persist name change 2020-01-22 11:15:49 -08:00
4d263bcf32 added persist for remove 2020-01-22 08:53:25 -08:00
2d8f61172d fixed remove 2020-01-22 08:17:03 -08:00
621c1dc11e renders current output section 2020-01-21 16:00:21 -08:00
dd136a5ff4 WIP: set current condition 2020-01-21 13:37:36 -08:00
82be503f4f Fix broken rendering 2020-01-17 13:00:41 -08:00
7feb933519 Fix errors after converting conditionCollection to persist identifiers only 2020-01-17 11:26:46 -08:00
e806e5a293 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-17 11:04:41 -08:00
7b7c7b528a 1. Persist the condition domain object — done
2. Persist the condition identifier only in configuration.conditionCollection array, not the domain object — done
3. WIP - Retrieve the condition domain object and instantiate the condition classes on load
2020-01-16 16:11:23 -08:00
a554aa20f8 Addresses code review comments (#2624)
* Addresses code review comments
- Change copyright to 2020
- Fix class parameters, tests

* Fixes this for initilize function
2020-01-16 15:56:58 -08:00
bf1efaf912 Merge branch 'condition-class' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:47:34 -08:00
ff2bc41317 Merge branch 'telemetry-criterion' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:47:04 -08:00
bdaf8aff15 Merge branch 'condition-view' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:46:28 -08:00
1dc4f9f6bb Fixes this for the handleConditionUpdated function 2020-01-16 15:44:59 -08:00
d6320f5da1 Fixes this for initilize function 2020-01-16 15:43:33 -08:00
276be5e857 Merge branch 'condition-class' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:36:29 -08:00
3101e77ecc Merge branch 'telemetry-criterion' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:34:53 -08:00
ab6dae16f1 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-16 15:32:40 -08:00
36222d79c6 Updates copyright, jsdocs, small refactor 2020-01-16 15:30:49 -08:00
08656a6674 persist output string selection 2020-01-16 15:29:07 -08:00
8034317796 Merge branch 'telemetry-criterion' of https://github.com/nasa/openmct into condition-class 2020-01-16 15:08:15 -08:00
a59f3a550e Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into condition-class 2020-01-16 15:07:57 -08:00
415b967c0b Addresses code review comments
- Change copyright to 2020
- Fix class parameters, tests
2020-01-16 15:03:14 -08:00
642499d519 added string output field 2020-01-16 09:56:17 -08:00
fa0a54eee7 css fixes and add any/all control 2020-01-16 09:13:43 -08:00
82f175f6c7 fixed style issues and added default select labels 2020-01-15 17:59:51 -08:00
8df549e8d9 Addresses comments from PR: https://github.com/nasa/openmct/pull/2621 (#2623)
* Addresses comments from PR: https://github.com/nasa/openmct/pull/2621

* Fixes import path.
2020-01-15 15:39:31 -08:00
9fd720777b Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-15 11:28:18 -08:00
4c68c725b1 Adding telemetry options to ConditionEdit 2020-01-15 10:51:45 -08:00
06a5207c6d deriving current output from current (blue) condition output and persisting 2020-01-14 17:07:32 -08:00
78b885c508 using current condition output for current output label 2020-01-14 13:44:19 -08:00
a18a3b6099 Adds telemetry objects on composition add 2020-01-14 13:32:13 -08:00
68949e070c Merge pull request #2621 from nasa/conditionSet-telemetry
Updates conditionSet composition policy to allow only telemetry since…
2020-01-14 11:04:46 -08:00
654333dabe Removes fdescribe 2020-01-14 10:59:11 -08:00
81b8a76f1b (WIP) Fixes cyclic error while saving conditionCollection 2020-01-14 10:57:00 -08:00
31736fa194 Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-with-classes 2020-01-14 10:27:10 -08:00
33632ef1dc (WIP) conditionSets using ConditionClasses 2020-01-14 09:52:12 -08:00
94305ed82c persist data changes on update 2020-01-14 09:29:00 -08:00
c8abc45e25 add default condition only when none present 2020-01-14 08:38:12 -08:00
cd25459ac9 Merge branch 'conditionSet-telemetry' of https://github.com/nasa/openmct into conditionSet-view 2020-01-13 22:53:45 -08:00
aaf1eb8059 Merge branch 'condition-class' of https://github.com/nasa/openmct into conditionSet-view 2020-01-13 22:52:51 -08:00
1589e4236a Merge branch 'conditionSet-telemetry' of https://github.com/nasa/openmct into condition-class 2020-01-13 22:51:13 -08:00
8ca202d0a9 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into condition-class 2020-01-13 22:48:08 -08:00
d2f7904118 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into conditionSet-telemetry 2020-01-13 22:47:52 -08:00
2d059fb856 Merge pull request #2610 from nasa/telemetry-criterion
Adds telemetry criterion class and related tests
2020-01-13 16:07:32 -08:00
8bbd7898bb Updates conditionSet composition policy to allow only telemetry since we're no longer using composition for condition domain objects 2020-01-13 14:59:45 -08:00
ea6f8c9a50 small fixes 2020-01-13 14:45:00 -08:00
d152440436 Fixes careless mistake - undefined object. 2020-01-13 14:12:05 -08:00
1ffe76a525 Fixes linting issue. 2020-01-13 14:09:59 -08:00
a6825f530c Fixes failing test. 2020-01-13 14:05:43 -08:00
7cf6dc386f Removes use of createOpenMCT and uses mock object for openmct instead. 2020-01-13 13:58:25 -08:00
5d8252bb07 Adds tests for condition class 2020-01-13 13:55:54 -08:00
e1e1e0fb2f temp 2020-01-13 13:52:26 -08:00
4f7345563f temp 2020-01-13 13:40:43 -08:00
68a2b9f3a8 added Default name 2020-01-10 16:45:20 -08:00
d79402c568 name property WIP 2020-01-10 15:58:16 -08:00
d0e8f650be remove condition with persistance 2020-01-10 12:59:43 -08:00
d819c6efe2 add condition button working with persistance 2020-01-10 12:22:05 -08:00
91c877f234 Adds tests for Condition class 2020-01-10 10:43:55 -08:00
55a674ba7b Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into condition-class 2020-01-09 06:46:27 -08:00
36055b7c04 Changes name of emitted event 2020-01-09 06:44:19 -08:00
fe3cc661d3 Fixes tests. 2020-01-08 12:20:17 -08:00
eb7efae1cc Persist condition to conditionSet. Remove extra condition unshift in addCondition method. 2020-01-07 11:56:24 -08:00
63f8fb54d4 conditions added to conditioncollection 2020-01-07 11:42:31 -08:00
097fa2e655 condition collection add to composition 2020-01-07 08:44:30 -08:00
3d0b4d51c2 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into telemetry-criterion 2020-01-06 13:10:58 -08:00
37650487f7 Merge pull request #2608 from nasa/conditionSet-view-provider
Condition set view provider
2020-01-06 13:10:00 -08:00
6ccc0b4fbf added TODO comments 2020-01-06 12:04:19 -08:00
79fe95372d fix lint errors 2020-01-06 10:44:09 -08:00
6adb190d0e Merge branch 'conditionSet-view' of https://github.com/nasa/openmct into conditionSet-view-provider 2020-01-06 10:36:25 -08:00
c094e6c6f4 change icon 2020-01-06 10:35:10 -08:00
8c796b4e57 Allows adding new conditions and associated criteria.
Stub for evaluating conditions.
2020-01-06 10:09:47 -08:00
c08e9a89ff add condition 2020-01-06 09:48:11 -08:00
cc8ba18ccc Fixes condition plugin tests 2020-01-03 11:27:06 -08:00
57c671a42e combined tests in one pluginSpec file 2020-01-03 09:13:17 -08:00
1ee6ecf3ae removed conditionSet folder and fixed lint errors 2020-01-03 08:39:13 -08:00
5f80b3773b restructured folders 2020-01-02 15:19:57 -08:00
8452455050 WIP: all condition set UI elements in place - started condition form elements 2020-01-02 12:59:32 -08:00
e5d8f60cdb WIP: all condition set UI elements in place except condition form elements 2019-12-31 11:33:33 -08:00
de466000a0 WIP: styling for conditionSet and condition 2019-12-30 18:26:59 -08:00
49664c011c component styling and expand funcitonality 2019-12-27 18:17:56 -08:00
cf34d6b127 added domainObject bakc into provider 2019-12-27 14:23:04 -08:00
e52f6ce099 WIP: styling components 2019-12-27 14:19:39 -08:00
1ecdc4c487 addressed review comment 2019-12-27 13:22:05 -08:00
d38e2c49cb WIP: current output styling 2019-12-27 13:20:21 -08:00
f8464fa76f Adds telemetry criterion class and related tests 2019-12-27 12:57:30 -08:00
308ae2cb2e added CurrentOutput and TestData components 2019-12-26 16:07:55 -08:00
88219659fb renamed Conditions component to ConditionSet 2019-12-26 13:40:58 -08:00
c34c2df061 remove fdescribe 2019-12-26 12:36:58 -08:00
99c7bd4c10 added conditions and condition components 2019-12-26 12:25:30 -08:00
f93d5a6fbf skeletal html mockup 2019-12-26 08:25:58 -08:00
cd116667be change to inject domainObject 2019-12-23 14:32:57 -08:00
2f2de3952d addressed review comments 2019-12-23 12:14:35 -08:00
45e56798c5 removed fit 2019-12-23 11:24:25 -08:00
0664d480e6 conditionSet provider with tests 2019-12-23 11:19:56 -08:00
283599ddf5 Merge branch 'topic-conditionals' of https://github.com/nasa/openmct into conditionSet-view-provider 2019-12-20 09:56:26 -08:00
09e3ceefa0 Merge pull request #2600 from nasa/condition-set-policy
Adds ConditionSet composition policy. Allows conditions to be added to conditionSets
2019-12-20 08:51:37 -08:00
87f76ebfe4 Addresses comments. 2019-12-19 21:20:38 -08:00
55a195b841 Adds ConditionSet composition policy. Allows conditions to be added to conditionSets 2019-12-19 12:33:11 -08:00
c7946fd7b3 refactor conditionSet pluginSpec 2019-12-19 11:14:55 -08:00
5d3ba3199c Merge remote-tracking branch 'origin/topic-conditionals' into conditionSet-view-provider 2019-12-19 09:07:44 -08:00
f0d10306fc completing merge 2019-12-19 09:06:19 -08:00
161943b5b8 Merge pull request #2598 from nasa/condition-type
Adds new condition type and plugin. Also adds tests
2019-12-18 15:56:20 -08:00
e545043a26 Merge branch 'topic-conditionals' into condition-type 2019-12-18 15:52:46 -08:00
40fb58b5b7 Merge pull request #2597 from nasa/conditionSet-object-type
Condition set object type
2019-12-18 15:50:42 -08:00
1f9d4708b3 Adds copyright 2019-12-18 13:19:21 -08:00
162809e081 [#2570] adds new condition type and plugin. Also adds tests 2019-12-18 13:13:54 -08:00
482c871ac2 removed fdescribe 2019-12-18 13:10:29 -08:00
f0b3311630 fixed merge conflicts 2019-12-18 13:01:28 -08:00
656d6d6c3f addressed review comments 2019-12-18 12:48:05 -08:00
ea45f0f4aa WIP 2019-12-18 12:16:25 -08:00
6a25cb0a58 renaming 2019-12-18 11:50:10 -08:00
4a1901420d removed fdescribe 2019-12-18 11:44:40 -08:00
ad64f00608 WIP renaming 2019-12-18 11:43:20 -08:00
65aea29cb9 renamed conditionCollection to conditionSet and made all filenames and references consistent 2019-12-18 11:23:37 -08:00
7981424e9a WIP: - preparing to rename branch 2019-12-18 11:08:21 -08:00
10c4340475 completed tests for condition collection object 2019-12-17 13:24:34 -08:00
0a95db1a51 fixed missing commas 2019-12-17 08:15:15 -08:00
ace77dce65 WIP 2019-12-17 08:10:35 -08:00
c1d58bb25f fixed another minor merge conflict 2019-12-16 16:55:26 -08:00
fbcafe0f62 mfixed merge conflicts 2019-12-16 16:50:57 -08:00
9a9d9222a9 Merge branch 'master' into condition-object-type 2019-12-16 14:52:48 -08:00
221e5b4f6c Added tests for ConditionPlugin 2019-12-16 14:42:19 -08:00
5df74aee68 [test-framework] Adds basic test for condition plugin 2019-12-16 11:06:19 -08:00
17838d8040 WIP: setting up test framework for conditionals 2019-12-12 14:36:24 -08:00
f82ca91a61 changed node mules path 2019-12-06 15:13:03 -08:00
b06c234b59 import path for vue component 2019-12-06 13:02:23 -08:00
31a7ebd4f1 basic skeleton for conditions code 2019-12-06 12:05:36 -08:00
32 changed files with 2339 additions and 3 deletions

View File

@ -0,0 +1,80 @@
<!doctype html>
<html lang="en">
<head>
<title>Code coverage report for All files</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="prettify.css" />
<link rel="stylesheet" href="base.css" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type='text/css'>
.coverage-summary .sorter {
background-image: url(sort-arrow-sprite.png);
}
</style>
</head>
<body>
<div class='wrapper'>
<div class='pad1'>
<h1>
/
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Statements</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Branches</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Functions</span>
<span class='fraction'>0/0</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">100% </span>
<span class="quiet">Lines</span>
<span class='fraction'>0/0</span>
</div>
</div>
</div>
<div class='status-line high'></div>
<div class="pad1">
<table class="coverage-summary">
<thead>
<tr>
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
</tr>
</thead>
<tbody></tbody>
</table>
</div><div class='push'></div><!-- for sticky footer -->
</div><!-- /wrapper -->
<div class='footer quiet pad2 space-top1 center small'>
Code coverage
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Wed Dec 11 2019 13:15:10 GMT-0800 (Pacific Standard Time)
</div>
</div>
<script src="prettify.js"></script>
<script>
window.onload = function () {
if (typeof prettyPrint === 'function') {
prettyPrint();
}
};
</script>
<script src="sorter.js"></script>
</body>
</html>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

View File

@ -0,0 +1,158 @@
var addSorting = (function () {
"use strict";
var cols,
currentSort = {
index: 0,
desc: false
};
// returns the summary table element
function getTable() { return document.querySelector('.coverage-summary'); }
// returns the thead element of the summary table
function getTableHeader() { return getTable().querySelector('thead tr'); }
// returns the tbody element of the summary table
function getTableBody() { return getTable().querySelector('tbody'); }
// returns the th element for nth column
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
// loads all columns
function loadColumns() {
var colNodes = getTableHeader().querySelectorAll('th'),
colNode,
cols = [],
col,
i;
for (i = 0; i < colNodes.length; i += 1) {
colNode = colNodes[i];
col = {
key: colNode.getAttribute('data-col'),
sortable: !colNode.getAttribute('data-nosort'),
type: colNode.getAttribute('data-type') || 'string'
};
cols.push(col);
if (col.sortable) {
col.defaultDescSort = col.type === 'number';
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
}
}
return cols;
}
// attaches a data attribute to every tr element with an object
// of data values keyed by column name
function loadRowData(tableRow) {
var tableCols = tableRow.querySelectorAll('td'),
colNode,
col,
data = {},
i,
val;
for (i = 0; i < tableCols.length; i += 1) {
colNode = tableCols[i];
col = cols[i];
val = colNode.getAttribute('data-value');
if (col.type === 'number') {
val = Number(val);
}
data[col.key] = val;
}
return data;
}
// loads all row data
function loadData() {
var rows = getTableBody().querySelectorAll('tr'),
i;
for (i = 0; i < rows.length; i += 1) {
rows[i].data = loadRowData(rows[i]);
}
}
// sorts the table using the data for the ith column
function sortByIndex(index, desc) {
var key = cols[index].key,
sorter = function (a, b) {
a = a.data[key];
b = b.data[key];
return a < b ? -1 : a > b ? 1 : 0;
},
finalSorter = sorter,
tableBody = document.querySelector('.coverage-summary tbody'),
rowNodes = tableBody.querySelectorAll('tr'),
rows = [],
i;
if (desc) {
finalSorter = function (a, b) {
return -1 * sorter(a, b);
};
}
for (i = 0; i < rowNodes.length; i += 1) {
rows.push(rowNodes[i]);
tableBody.removeChild(rowNodes[i]);
}
rows.sort(finalSorter);
for (i = 0; i < rows.length; i += 1) {
tableBody.appendChild(rows[i]);
}
}
// removes sort indicators for current column being sorted
function removeSortIndicators() {
var col = getNthColumn(currentSort.index),
cls = col.className;
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
col.className = cls;
}
// adds sort indicators for current column being sorted
function addSortIndicators() {
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
}
// adds event listeners for all sorter widgets
function enableUI() {
var i,
el,
ithSorter = function ithSorter(i) {
var col = cols[i];
return function () {
var desc = col.defaultDescSort;
if (currentSort.index === i) {
desc = !currentSort.desc;
}
sortByIndex(i, desc);
removeSortIndicators();
currentSort.index = i;
currentSort.desc = desc;
addSortIndicators();
};
};
for (i =0 ; i < cols.length; i += 1) {
if (cols[i].sortable) {
// add the click event handler on the th so users
// dont have to click on those tiny arrows
el = getNthColumn(i).querySelector('.sorter').parentElement;
if (el.addEventListener) {
el.addEventListener('click', ithSorter(i));
} else {
el.attachEvent('onclick', ithSorter(i));
}
}
}
}
// adds sorting functionality to the UI
return function () {
if (!getTable()) {
return;
}
cols = loadColumns();
loadData(cols);
addSortIndicators();
enableUI();
};
})();
window.addEventListener('load', addSorting);

View File

@ -43,7 +43,7 @@
openmct.legacyRegistry.enable.bind(openmct.legacyRegistry)
);
openmct.install(openmct.plugins.Espresso());
openmct.install(openmct.plugins.Snow());
openmct.install(openmct.plugins.MyItems());
openmct.install(openmct.plugins.LocalStorage());
openmct.install(openmct.plugins.Generator());

View File

@ -64,6 +64,7 @@
"request": "^2.69.0",
"split": "^1.0.0",
"style-loader": "^1.0.1",
"uuid": "^3.3.3",
"v8-compile-cache": "^1.1.0",
"vue": "2.5.6",
"vue-loader": "^15.2.6",

View File

@ -1,5 +1,5 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* Open MCT, Copyright (c) 2014-2019, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
@ -264,6 +264,7 @@ define([
this.install(this.plugins.GoToOriginalAction());
this.install(this.plugins.ImportExport());
this.install(this.plugins.WebPage());
this.install(this.plugins.Condition());
}
MCT.prototype = Object.create(EventEmitter.prototype);

View File

@ -0,0 +1,205 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import * as EventEmitter from 'eventemitter3';
import uuid from 'uuid';
import TelemetryCriterion from "@/plugins/condition/criterion/TelemetryCriterion";
import { TRIGGER } from "@/plugins/condition/utils/constants";
/*
* conditionDefinition = {
* identifier: {
* key: '',
* namespace: ''
* },
* trigger: 'any'/'all',
* criteria: [
* {
* operation: '',
* input: '',
* metaDataKey: '',
* key: 'someTelemetryObjectKey'
* }
* ]
* }
*/
export default class ConditionClass extends EventEmitter {
/**
* Manages criteria and emits the result of - true or false - based on criteria evaluated.
* @constructor
* @param conditionDefinition: {identifier: {domainObject.identifier},trigger: enum, criteria: Array of {id: uuid, operation: enum, input: Array, metaDataKey: string, key: {domainObject.identifier} }
* @param openmct
*/
constructor(conditionDefinition, openmct) {
super();
this.openmct = openmct;
this.id = this.openmct.objects.makeKeyString(conditionDefinition.identifier);
if (conditionDefinition.criteria) {
this.createCriteria(conditionDefinition.criteria);
} else {
this.criteria = [];
}
this.trigger = conditionDefinition.trigger;
this.result = null;
}
updateTrigger(conditionDefinition) {
if (this.trigger !== conditionDefinition.trigger) {
this.trigger = conditionDefinition.trigger;
this.handleConditionUpdated();
}
}
generateCriterion(criterionDefinition) {
return {
id: uuid(),
operation: criterionDefinition.operation || '',
input: criterionDefinition.input === undefined ? [] : criterionDefinition.input,
metaDataKey: criterionDefinition.metaDataKey || '',
key: criterionDefinition.key || ''
};
}
createCriteria(criterionDefinitions) {
criterionDefinitions.forEach((criterionDefinition) => {
this.addCriterion(criterionDefinition);
});
}
updateCriteria(criterionDefinitions) {
this.destroyCriteria();
this.createCriteria(criterionDefinitions);
}
/**
* adds criterion to the condition.
*/
addCriterion(criterionDefinition) {
let criterionDefinitionWithId = this.generateCriterion(criterionDefinition || null);
let criterion = new TelemetryCriterion(criterionDefinitionWithId, this.openmct);
criterion.on('criterionUpdated', (obj) => this.handleCriterionUpdated(obj));
if (!this.criteria) {
this.criteria = [];
}
this.criteria.push(criterion);
this.handleConditionUpdated();
return criterionDefinitionWithId.id;
}
findCriterion(id) {
let criterion;
for (let i=0, ii=this.criteria.length; i < ii; i ++) {
if (this.criteria[i].id === id) {
criterion = {
item: this.criteria[i],
index: i
}
}
}
return criterion;
}
updateCriterion(id, criterionDefinition) {
let found = this.findCriterion(id);
if (found) {
const newCriterionDefinition = this.generateCriterion(criterionDefinition);
let newCriterion = new TelemetryCriterion(newCriterionDefinition, this.openmct);
let criterion = found.item;
criterion.unsubscribe();
criterion.off('criterionUpdated', (result) => {
this.handleCriterionUpdated(id, result);
});
this.criteria.splice(found.index, 1, newCriterion);
this.handleConditionUpdated();
}
}
removeCriterion(id) {
if (this.destroyCriterion(id)) {
this.handleConditionUpdated();
}
}
destroyCriterion(id) {
let found = this.findCriterion(id);
if (found) {
let criterion = found.item;
criterion.unsubscribe();
criterion.off('criterionUpdated', (result) => {
this.handleCriterionUpdated(id, result);
});
this.criteria.splice(found.index, 1);
return true;
}
return false;
}
handleCriterionUpdated(criterion) {
let found = this.findCriterion(criterion.id);
if (found) {
this.criteria[found.index] = criterion;
this.emitEvent('conditionUpdated', {
trigger: this.trigger,
criteria: this.criteria
});
}
this.handleConditionUpdated();
}
handleConditionUpdated() {
// trigger an updated event so that consumers can react accordingly
this.emitEvent('conditionResultUpdated');
}
getCriteria() {
return this.criteria;
}
destroyCriteria() {
let success = true;
//looping through the array backwards since destroyCriterion modifies the criteria array
for (let i=this.criteria.length-1; i >= 0; i--) {
success = success && this.destroyCriterion(this.criteria[i].id);
}
return success;
}
//TODO: implement as part of the evaluator class task.
evaluate() {
if (this.trigger === TRIGGER.ANY) {
this.result = false;
} else if (this.trigger === TRIGGER.ALL) {
this.result = false;
}
}
emitEvent(eventName, data) {
this.emit(eventName, {
id: this.id,
data: data
});
}
}

View File

@ -0,0 +1,33 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
export default function ConditionSetCompositionPolicy(openmct) {
return {
allow: function (parent, child) {
if (parent.type === 'conditionSet' && !openmct.telemetry.isTelemetryObject(child)) {
return false;
}
return true;
}
}
}

View File

@ -0,0 +1,87 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionSetCompositionPolicy from './ConditionSetCompositionPolicy';
describe('ConditionSetCompositionPolicy', () => {
let policy;
let testTelemetryObject;
let openmct = {};
let parentDomainObject;
let composition;
beforeAll(function () {
testTelemetryObject = {
identifier:{ namespace: "", key: "test-object"},
type: "test-object",
name: "Test Object",
telemetry: {
values: [{
key: "some-key",
name: "Some attribute",
hints: {
domain: 1
}
}, {
key: "some-other-key",
name: "Another attribute",
hints: {
range: 1
}
}]
}
};
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
openmct.objects.get.and.returnValue(testTelemetryObject);
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject']);
policy = new ConditionSetCompositionPolicy(openmct);
parentDomainObject = {};
composition = {};
});
it('returns true for object types that are not conditionSets', function () {
parentDomainObject.type = 'random';
openmct.telemetry.isTelemetryObject.and.returnValue(false);
expect(policy.allow(parentDomainObject, {})).toBe(true);
});
it('returns false for object types that are not telemetry objects when parent is a conditionSet', function () {
parentDomainObject.type = 'conditionSet';
openmct.telemetry.isTelemetryObject.and.returnValue(false);
expect(policy.allow(parentDomainObject, {})).toBe(false);
});
it('returns true for object types that are telemetry objects when parent is a conditionSet', function () {
parentDomainObject.type = 'conditionSet';
openmct.telemetry.isTelemetryObject.and.returnValue(true);
expect(policy.allow(parentDomainObject, testTelemetryObject)).toBe(true);
});
it('returns true for object types that are telemetry objects when parent is not a conditionSet', function () {
parentDomainObject.type = 'random';
openmct.telemetry.isTelemetryObject.and.returnValue(true);
expect(policy.allow(parentDomainObject, testTelemetryObject)).toBe(true);
});
});

View File

@ -0,0 +1,73 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionSet from './components/ConditionSet.vue';
import Vue from 'vue';
export default class ConditionSetViewProvider {
constructor(openmct) {
this.openmct = openmct;
this.key = 'conditionSet.view';
this.cssClass = 'icon-summary-widget'; // TODO: replace with class for new icon
}
canView(domainObject) {
return domainObject.type === 'conditionSet';
}
canEdit(domainObject) {
return domainObject.type === 'conditionSet';
}
view(domainObject, objectPath) {
let component;
const openmct = this.openmct;
return {
show: (container, isEditing) => {
component = new Vue({
el: container,
components: {
ConditionSet
},
provide: {
openmct,
domainObject,
objectPath
},
data() {
return {
isEditing
}
},
template: '<condition-set ref="conditionSet" :isEditing="isEditing"></condition-set>'
});
},
onEditModeChange: (isEditing) => {
component.isEditing = isEditing;
},
destroy: () => {
component.$destroy();
component = undefined;
}
};
}
}

View File

@ -0,0 +1,120 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import Condition from "./Condition";
import {TRIGGER} from "./utils/constants";
import TelemetryCriterion from "./criterion/TelemetryCriterion";
let openmct = {},
mockListener,
testConditionDefinition,
testTelemetryObject,
conditionObj;
describe("The condition", function () {
beforeEach (() => {
mockListener = jasmine.createSpy('listener');
testTelemetryObject = {
identifier:{ namespace: "", key: "test-object"},
type: "test-object",
name: "Test Object",
telemetry: {
values: [{
key: "some-key",
name: "Some attribute",
hints: {
domain: 1
}
}, {
key: "some-other-key",
name: "Another attribute",
hints: {
range: 1
}
}]
}
};
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
resolve(testTelemetryObject);
})); openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', 'subscribe', 'getMetadata']);
openmct.telemetry.isTelemetryObject.and.returnValue(true);
openmct.telemetry.subscribe.and.returnValue(function () {});
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values);
testConditionDefinition = {
trigger: TRIGGER.ANY,
criteria: [
{
operation: 'equalTo',
input: false,
metaDataKey: 'value',
key: testTelemetryObject.identifier
}
]
};
conditionObj = new Condition(
testConditionDefinition,
openmct
);
conditionObj.on('conditionUpdated', mockListener);
});
it("generates criteria with an id", function () {
const testCriterion = testConditionDefinition.criteria[0];
let criterion = conditionObj.generateCriterion(testCriterion);
expect(criterion.id).toBeDefined();
expect(criterion.operation).toEqual(testCriterion.operation);
expect(criterion.input).toEqual(testCriterion.input);
expect(criterion.metaDataKey).toEqual(testCriterion.metaDataKey);
expect(criterion.key).toEqual(testCriterion.key);
});
it("initializes with an id", function () {
expect(conditionObj.id).toBeDefined();
});
it("initializes with criteria from the condition definition", function () {
expect(conditionObj.criteria.length).toEqual(1);
let criterion = conditionObj.criteria[0];
expect(criterion instanceof TelemetryCriterion).toBeTrue();
expect(criterion.operator).toEqual(testConditionDefinition.operator);
expect(criterion.input).toEqual(testConditionDefinition.input);
expect(criterion.metaDataKey).toEqual(testConditionDefinition.metaDataKey);
expect(criterion.key).toEqual(testConditionDefinition.key);
});
it("initializes with the trigger from the condition definition", function () {
expect(conditionObj.trigger).toEqual(testConditionDefinition.trigger);
});
it("destroys all criteria for a condition", function () {
const result = conditionObj.destroyCriteria();
expect(result).toBeTrue();
expect(conditionObj.criteria.length).toEqual(0);
});
});

View File

@ -0,0 +1,48 @@
<template>
<div v-if="condition"
id="conditionArea"
class="c-cs-ui__conditions"
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
>
<div class="title-bar">
<span class="condition-name">
{{ condition.definition.name }}
</span>
<span class="condition-output">
Output: {{ condition.definition.output }}
</span>
</div>
<div class="condition-config">
<span class="condition-description">
{{ condition.definition.description }}
</span>
</div>
</div>
</template>
<script>
export default {
inject: ['openmct', 'domainObject'],
props: {
conditionIdentifier: {
type: Object,
required: true
},
isCurrent: {
type: Object,
required: true
}
},
data() {
return {
condition: this.condition
};
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
console.log('this.isCurrent', this.isCurrent)
}));
}
}
</script>

View File

@ -0,0 +1,153 @@
<template>
<section id="conditionCollection"
class="c-cs__ui_section"
>
<div class="c-cs__ui__header">
<span class="c-cs__ui__header-label">Conditions</span>
<span
class="is-enabled flex-elem"
:class="['c-cs__disclosure-triangle', { 'c-cs__disclosure-triangle--expanded': expanded }]"
@click="expanded = !expanded"
></span>
</div>
<div v-if="expanded"
class="c-cs__ui_content"
>
<div v-show="isEditing"
class="help"
>
<span>The first condition to match is the one that wins. Drag conditions to rearrange.</span>
</div>
<div class="holder add-condition-button-wrapper align-left">
<button
v-show="isEditing"
id="addCondition"
class="c-cs-button c-cs-button--major add-condition-button"
@click="addCondition"
>
<span class="c-cs-button__label">Add Condition</span>
</button>
</div>
<div class="condition-collection">
<div v-for="conditionIdentifier in conditionCollection"
:key="conditionIdentifier.key"
class="conditionArea"
>
<div v-if="isEditing">
<ConditionEdit :condition-identifier="conditionIdentifier"
:is-current="currentConditionIdentifier"
@update-current-condition="updateCurrentCondition"
@remove-condition="removeCondition"
/>
</div>
<div v-else>
<Condition :condition-identifier="conditionIdentifier"
:is-current="currentConditionIdentifier"
/>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import Condition from '../../condition/components/Condition.vue';
import ConditionEdit from '../../condition/components/ConditionEdit.vue';
import uuid from 'uuid';
export default {
inject: ['openmct', 'domainObject'],
components: {
Condition,
ConditionEdit
},
props: {
isEditing: Boolean
},
data() {
return {
expanded: true,
parentKeyString: this.openmct.objects.makeKeyString(this.domainObject.identifier),
conditionCollection: [],
conditions: [],
currentConditionIdentifier: this.currentConditionIdentifier || {}
};
},
destroyed() {
this.composition.off('add', this.addTelemetry);
},
mounted() {
this.telemetryObjs = [];
this.instantiate = this.openmct.$injector.get('instantiate');
this.composition = this.openmct.composition.get(this.domainObject);
this.composition.on('add', this.addTelemetry);
this.composition.load();
this.conditionCollection = this.domainObject.configuration ? this.domainObject.configuration.conditionCollection : [];
if (!this.conditionCollection.length) {this.addCondition(null, true)}
},
methods: {
handleConditionResult(args) {
console.log('ConditionCollection: ', args.result);
},
addTelemetry(telemetryDomainObject) {
this.telemetryObjs.push(telemetryDomainObject);
},
addCondition(event, isDefault) {
let conditionDO = this.getConditionDomainObject(!!isDefault);
//persist the condition DO so that we can do an openmct.objects.get on it and only persist the identifier in the conditionCollection of conditionSet
this.openmct.objects.mutate(conditionDO, 'created', new Date());
this.conditionCollection.unshift(conditionDO.identifier);
},
updateCurrentCondition(identifier) {
this.currentConditionIdentifier = identifier;
},
getConditionDomainObject(isDefault) {
let conditionObj = {
isDefault: isDefault,
identifier: {
namespace: this.domainObject.identifier.namespace,
key: uuid()
},
definition: {
name: isDefault ? 'Default' : 'Unnamed Condition',
output: 'false',
trigger: 'any',
criteria: isDefault ? [] : [{
operation: '',
input: '',
metaDataKey: this.openmct.telemetry.getMetadata(this.telemetryObjs[0]).values()[0].key,
key: this.telemetryObjs.length ? this.openmct.objects.makeKeyString(this.telemetryObjs[0].identifier) : null
}]
},
summary: 'summary description'
};
let conditionDOKeyString = this.openmct.objects.makeKeyString(conditionObj.identifier);
let newDO = this.instantiate(conditionObj, conditionDOKeyString);
return newDO.useCapability('adapter');
},
updateCondition(updatedCondition) {
let index = _.findIndex(this.conditions, (condition) => condition.id === updatedCondition.id);
this.conditions[index] = updatedCondition;
},
removeCondition(identifier) {
console.log('this.conditions', this.conditions);
let index = _.findIndex(this.conditionCollection, (condition) => {
identifier.key === condition.key
});
this.conditionCollection.splice(index + 1, 1);
this.persist();
},
reorder(reorderPlan) {
let oldConditions = this.conditionCollection.slice();
reorderPlan.forEach((reorderEvent) => {
this.$set(this.conditionCollection, reorderEvent.newIndex, oldConditions[reorderEvent.oldIndex]);
});
},
persist() {
this.openmct.objects.mutate(this.domainObject, 'configuration.conditionCollection', this.conditionCollection);
}
}
}
</script>

View File

@ -0,0 +1,276 @@
<template>
<div v-if="condition"
class="c-cs-editui__conditions"
:class="['widget-condition', { 'widget-condition--current': isCurrent && (isCurrent.key === conditionIdentifier.key) }]"
>
<div class="title-bar">
<span
class="c-c__menu-hamburger"
:class="{ 'is-enabled': !condition.isDefault }"
@click="expanded = !condition.expanded"
></span>
<span
class="is-enabled flex-elem"
:class="['c-c__disclosure-triangle', { 'c-c__disclosure-triangle--expanded': expanded }]"
@click="expanded = !condition.expanded"
></span>
<div class="condition-summary">
<span class="condition-name">{{ condition.definition.name }}</span>
<span class="condition-description">{{ condition.definition.name }}</span>
</div>
<span v-if="!condition.isDefault"
class="is-enabled c-c__duplicate"
></span>
<span v-if="!condition.isDefault"
class="is-enabled c-c__trash"
@click="removeCondition"
></span>
</div>
<div v-if="expanded"
class="condition-config-edit widget-rule-content c-sw-editui__rules-wrapper holder widget-rules-wrapper flex-elem expanded"
>
<div id="ruleArea"
class="c-sw-editui__rules widget-rules"
>
<div class="c-sw-rule">
<div class="c-sw-rule__ui l-compact-form l-widget-rule has-local-controls">
<div>
<ul class="t-widget-rule-config">
<li>
<label>Condition Name</label>
<span class="controls">
<input v-model="condition.definition.name"
class="t-rule-name-input"
type="text"
>
</span>
</li>
<li>
<label>Output</label>
<span class="controls">
<select v-model="selectedOutputKey"
@change="checkInputValue"
>
<option value="">- Select Output -</option>
<option v-for="option in outputOptions"
:key="option.key"
:value="option.key"
>
{{ option.text }}
</option>
</select>
<input v-if="selectedOutputKey === outputOptions[2].key"
v-model="condition.definition.output"
class="t-rule-name-input"
type="text"
>
</span>
</li>
</ul>
<div v-if="!condition.isDefault"
class="widget-rule-content expanded"
>
<ul class="t-widget-rule-config">
<li class="has-local-controls t-condition">
<label>Match when</label>
<span class="controls">
<select>
<option value="all">all criteria are met</option>
<option value="any">any criteria are met</option>
</select>
</span>
</li>
</ul>
<ul class="t-widget-rule-config">
<li v-if="telemetryObject && telemetryMetadata"
class="has-local-controls t-condition"
>
<label>when</label>
<span class="t-configuration">
<span class="controls">
<select class="">
<option value="">- Select Telemetry -</option>
<option :value="telemetryObject.key">{{ telemetryObject.name }}</option>
</select>
</span>
<span class="controls">
<select v-model="selectedMetaDataKey">
<option value="">- Select Field -</option>
<option v-for="option in telemetryMetadata"
:key="option.key"
:value="option.key"
>
{{ option.name }}
</option>
</select>
</span>
<span class="controls">
<select @change="getOperationKey">
<option value="">- Select Comparison -</option>
<option v-for="option in operations"
:key="option.name"
:value="option.name"
>
{{ option.text }}
</option>
</select>
<input v-if="comparisonValueField"
class="t-rule-name-input"
type="text"
@keyup="getOperationValue"
>
</span>
</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { OPERATIONS } from '../utils/operations';
import ConditionClass from "@/plugins/condition/Condition";
export default {
inject: ['openmct', 'domainObject'],
props: {
conditionIdentifier: {
type: Object,
required: true
},
isCurrent: {
type: Object,
required: true
}
},
data() {
return {
condition: this.condition,
expanded: true,
telemetryObject: this.telemetryObject,
telemetryMetadata: this.telemetryMetadata,
operations: OPERATIONS,
selectedMetaDataKey: null,
selectedTelemetryKey: null,
selectedOperationKey: null,
stringOutputField: false,
selectedOutputKey: null,
comparisonValueField: false,
outputOptions: [
{
key: 'false',
text: 'False'
},
{
key: 'true',
text: 'True'
},
{
key: 'string',
text: 'String'
}
]
};
},
destroyed() {
if (this.conditionClass && typeof this.conditionClass.destroy === 'function') {
this.conditionClass.destroy();
}
},
mounted() {
this.openmct.objects.get(this.conditionIdentifier).then((obj => {
this.condition = obj;
this.conditionClass = new ConditionClass(this.condition, this.openmct);
this.conditionClass.on('conditionResultUpdated', this.handleConditionResult.bind(this))
this.setOutput();
this.updateTelemetry();
}));
},
updated() {
if (this.isCurrent && this.isCurrent.key === this.condition.key) {
this.updateCurrentCondition();
}
this.persist();
},
methods: {
handleConditionResult(args) {
console.log('ConditionEdit::Result', args);
this.$emit('condition-result-updated', {
id: this.conditionIdentifier,
result: args.data.result
})
},
removeCondition() {
this.$emit('remove-condition', this.conditionIdentifier);
},
setOutput() {
if (this.condition.definition.output !== 'false' && this.condition.definition.output !== 'true') {
// this.$refs.outputSelect.value = 'string';
this.selectedOutputKey = this.outputOptions[2].key;
// this.stringOutputField = true;
} else {
if (this.condition.definition.output === 'true') {
this.selectedOutputKey = this.outputOptions[1].key;
} else {
this.selectedOutputKey = this.outputOptions[0].key;
}
}
},
updateTelemetry() {
if (this.hasTelemetry()) {
this.openmct.objects.get(this.condition.definition.criteria[0].key).then((obj) => {
this.telemetryObject = obj;
this.telemetryMetadata = this.openmct.telemetry.getMetadata(this.telemetryObject).values();
this.selectedMetaDataKey = this.telemetryMetadata[0].key;
});
} else {
this.telemetryObject = null;
}
},
hasTelemetry() {
return this.condition.definition.criteria.length && this.condition.definition.criteria[0].key;
},
persist() {
this.openmct.objects.mutate(this.condition, 'definition', this.condition.definition);
},
updateCurrentCondition() {
this.$emit('update-current-condition', this.conditionIdentifier);
},
getOutputBoolean(ev) {
if (ev.target.value !== 'string') {
this.condition.output = ev.target.value;
this.stringOutputField = false;
} else {
this.stringOutputField = true
}
},
getOutputString(ev) {
this.condition.output = ev.target.value;
},
checkInputValue() {
if (this.selectedOutputKey === this.outputOptions[2].key) {
this.condition.definition.output = '';
}
},
getOperationKey(ev) {
if (ev.target.value !== 'isUndefined' && ev.target.value !== 'isDefined') {
this.comparisonValueField = true;
} else {
this.comparisonValueField = false;
}
this.selectedOperationKey = ev.target.value;
this.condition.definition.operator = this.selectedOperationKey;
this.persist();
},
getOperationValue(ev) {
this.selectedOperationKey = ev.target.value;
}
}
}
</script>

View File

@ -0,0 +1,56 @@
<template>
<div class="c-object-view u-contents">
<div class="c-cs-edit w-condition-set">
<div class="c-sw-edit__ui holder">
<CurrentOutput :condition="currentCondition" />
<TestData :is-editing="isEditing" />
<ConditionCollection :is-editing="isEditing"
@update-current-condition="updateCurrentcondition"
/>
</div>
</div>
</div>
</template>
<script>
import CurrentOutput from './CurrentOutput.vue';
import TestData from './TestData.vue';
import ConditionCollection from './ConditionCollection.vue';
export default {
inject: ["openmct", "domainObject"],
components: {
CurrentOutput,
TestData,
ConditionCollection
},
props: {
isEditing: Boolean
},
data() {
return {
currentCondition: this.currentCondition
}
},
mounted() {
let conditionCollection = this.domainObject.configuration.conditionCollection;
this.currentConditionIdentifier = conditionCollection.length ? this.domainObject.configuration.conditionCollection[0] : null;
if (this.currentConditionIdentifier) {
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
});
}
},
methods: {
updateCurrentcondition(identifier) {
this.currentConditionIdentifier = identifier;
this.openmct.objects.get(this.currentConditionIdentifier).then((obj) => {
this.currentCondition = obj;
});
}
}
};
</script>

View File

@ -0,0 +1,44 @@
<template>
<section id="current-output">
<div v-if="condition"
class="c-cs__ui__header"
>
<span class="c-cs__ui__header-label">Current Output</span>
<span
class="is-enabled flex-elem"
:class="['c-cs__disclosure-triangle', { 'c-cs__disclosure-triangle--expanded': expanded }]"
@click="expanded = !expanded"
></span>
</div>
<div v-if="expanded && condition"
class="c-cs__ui_content"
>
<div>
<span class="current-output">{{ condition.output }}</span>
</div>
</div>
</section>
</template>
<script>
export default {
inject: ['openmct', 'domainObject'],
props: {
isEditing: Boolean,
condition: {
default: () => {return null;},
type: Object
}
},
data() {
return {
expanded: true
}
},
mounted() {
},
methods: {
}
}
</script>

View File

@ -0,0 +1,68 @@
<template>
<section v-show="isEditing"
id="test-data"
class="test-data"
>
<div class="c-cs__ui__header">
<span class="c-cs__ui__header-label">Test Data</span>
<span
class="is-enabled flex-elem"
:class="['c-cs__disclosure-triangle', { 'c-cs__disclosure-triangle--expanded': expanded }]"
@click="expanded = !expanded"
></span>
</div>
<div v-if="expanded"
class="c-cs__ui_content"
>
<label class="checkbox custom">
<input type="checkbox"
class="t-test-data-checkbox"
>
<span>Apply Test Data</span>
</label>
<div class="t-test-data-config">
<div class="c-cs-editui__conditions widget-condition">
<form>
<label>
<span>Set</span>
<select>
<option>- Select Input -</option>
</select>
</label>
<span class="is-enabled flex-elem c-cs__duplicate"></span>
<span class="is-enabled flex-elem c-cs__trash"></span>
</form>
</div>
<div class="c-cs-editui__conditions widget-condition">
<form>
<label>
<span>Set</span>
<select>
<option>- Select Input -</option>
</select>
</label>
<span class="is-enabled c-cs__duplicate"></span>
<span class="is-enabled c-cs__trash"></span>
</form>
</div>
</div>
</div>
</section>
</template>
<script>
export default {
inject: ['openmct'],
props: {
isEditing: Boolean
},
data() {
return {
expanded: true
};
},
methods: {
}
}
</script>

View File

@ -0,0 +1,142 @@
.c-cs-edit {
padding: 0;
}
section {
padding-bottom: 5px;
}
.c-cs__ui__header {
background-color: #D0D1D3;
padding: 0.4em 0.6em;
text-transform: uppercase;
font-size: 0.8em;
font-weight: bold;
color: #7C7D80;
display: flex;
justify-content: stretch;
align-items: center;
}
.c-cs__ui__header-label {
display: inline-block;
width: 100%;
}
.c-cs__ui_content {
padding: 0.4em;
}
.c-cs__ui_content .help {
font-style: italic;
padding: 0.4em 0;
}
.current-output {
text-transform: uppercase;
font-weight: bold;
margin: 0.4em 0.6em;
}
.condition-output {
color: #999;
}
.condition-description {
color: #333;
}
.checkbox.custom {
display: flex;
align-items: center;
margin-left: 0.6em;
}
.checkbox.custom span {
display: inline-block;
margin-left: 0.6em;
}
.t-test-data-config {
margin-top: 5px;
}
.widget-condition form {
padding: 0.5em;
display: flex;
align-items: center;
justify-content: stretch;
}
.widget-condition form label {
flex-grow: 1;
margin-left: 0;
}
.widget-condition form input {
min-height: 24px;
}
.c-cs-button[class*="--major"],
.c-cs-button[class*='is-active'],
.c-cs-button--menu[class*="--major"],
.c-cs-button--menu[class*='is-active'] {
border: solid 1.5px #0B427C;
background-color: #4778A3;
padding: 0.2em 0.6em;
margin: 0.4em;
font-weight: bold;
color: #eee;
border-radius: 6px;
}
.c-cs__disclosure-triangle,
.c-cs__menu-hamburger,
.c-cs__duplicate,
.c-cs__trash {
$d: 8px;
color: $colorDisclosureCtrl;
width: $d;
visibility: hidden;
&.is-enabled {
cursor: pointer;
visibility: visible;
&:hover {
color: $colorDisclosureCtrlHov;
}
&:before {
$s: .5;
display: block;
font-family: symbolsfont;
font-size: 1rem * $s;
}
}
}
.c-cs__disclosure-triangle {
&:before {
content: $glyph-icon-arrow-right;
}
&--expanded {
&:before {
transform: rotate(90deg);
}
}
}
.c-cs__duplicate {
margin-right: 0.3em;
&:before {
content: $glyph-icon-duplicate;
}
}
.c-cs__trash {
&:before {
content: $glyph-icon-trash;
}
}

View File

@ -0,0 +1,154 @@
.widget-condition {
background-color: #eee;
margin: 0 0 0.6em;
border-radius: 3px;
&--current {
background-color: #DEECFA;
}
}
.title-bar {
display: flex;
align-items: center;
justify-content: stretch;
padding: 0.4em 0;
}
.title-bar span {
margin-right: 0.6em;
}
.title-bar span.c-c__duplicate,
.title-bar span.c-c__trash{
margin-right: 0;
margin-left: 0.3em;
}
.widget-condition > div {
margin: 0 0.4em;
}
.condition-name {
font-weight: bold;
}
.condition-summary .condition-description {
color: #999;
}
.condition-summary {
flex-grow: 1;
}
.condition-config {
padding: 0.3em 0;
}
.widget-condition form label {
flex-grow: 1;
margin-left: 0;
}
.l-widget-rule {
padding: 0;
}
.l-compact-form ul li {
padding: 0;
}
.widget-rule-content.expanded {
margin: 0 3px;
}
.widget-rule-content.expanded ul {
border-top: solid 1px #ccc;
padding: 2px;
}
.l-compact-form ul li .controls {
display: inline-flex;
flex-grow: inherit;
padding: 2px 0;
}
.l-compact-form ul li > label {
display: block;
width: 90px;
min-width: 90px;
text-align: right;
line-height: 20px;
}
.l-compact-form ul li .controls input[type="text"],
.l-compact-form ul li .controls input[type="search"],
.l-compact-form ul li .controls input[type="number"],
.l-compact-form ul li .controls button,
.l-compact-form ul li .controls select {
min-height: 20px;
}
.condition-config-edit {
padding: 3px 0;
}
.c-c__disclosure-triangle,
.c-c__menu-hamburger,
.c-c__duplicate,
.c-c__trash {
$d: 8px;
color: $colorDisclosureCtrl;
width: $d;
visibility: hidden;
&.is-enabled {
cursor: pointer;
visibility: visible;
&:hover {
color: $colorDisclosureCtrlHov;
}
&:before {
$s: .5;
display: block;
font-family: symbolsfont;
font-size: 1rem * $s;
}
}
}
.c-c__disclosure-triangle {
&:before {
content: $glyph-icon-arrow-right;
}
&--expanded {
&:before {
transform: rotate(90deg);
}
}
}
.c-c__menu-hamburger {
&:before {
content: $glyph-icon-menu-hamburger;
}
}
.c-c__duplicate {
&:before {
content: $glyph-icon-duplicate;
}
}
.c-c__trash {
&:before {
content: $glyph-icon-trash;
}
}

View File

@ -0,0 +1,98 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import * as EventEmitter from 'eventemitter3';
export default class TelemetryCriterion extends EventEmitter {
/**
* Subscribes/Unsubscribes to telemetry and emits the result
* of operations performed on the telemetry data returned and a given input value.
* @constructor
* @param telemetryDomainObjectDefinition {id: uuid, operation: enum, input: Array, metaDataKey: string, key: {domainObject.identifier} }
* @param openmct
*/
constructor(telemetryDomainObjectDefinition, openmct) {
super();
this.openmct = openmct;
this.objectAPI = this.openmct.objects;
this.telemetryAPI = this.openmct.telemetry;
this.id = telemetryDomainObjectDefinition.id;
this.subscription = null;
this.telemetryMetadata = null;
this.telemetryObjectIdAsString = null;
this.objectAPI.get(this.objectAPI.makeKeyString(telemetryDomainObjectDefinition.key)).then((obj) => this.initialize(obj));
}
initialize(obj) {
this.telemetryObject = obj;
this.telemetryObjectIdAsString = this.objectAPI.makeKeyString(this.telemetryObject.identifier);
this.telemetryMetadata = this.telemetryAPI.getMetadata(this.telemetryObject.identifier);
this.emitEvent('criterionUpdated', this);
}
handleSubscription(datum) {
let data = this.normalizeData(datum);
this.emitEvent('criterionResultUpdated', {
result: data,
error: null
})
}
normalizeData(datum) {
return {
[datum.key]: datum[datum.source]
}
}
emitEvent(eventName, data) {
this.emit(eventName, {
id: this.id,
data: data
});
}
/**
* Subscribes to the telemetry object and returns an unsubscribe function
*/
subscribe() {
this.subscription = this.telemetryAPI.subscribe(this.telemetryObject, (datum) => {
this.handleSubscription(datum);
});
}
/**
* Calls an unsubscribe function returned by subscribe() and deletes any initialized data
*/
unsubscribe() {
//unsubscribe from telemetry source
if (typeof this.subscription === 'function') {
this.subscription();
}
delete this.subscription;
this.emitEvent('criterionRemoved');
delete this.telemetryObjectIdAsString;
delete this.telemetryObject;
delete this.telemetryMetadata;
}
}

View File

@ -0,0 +1,129 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import TelemetryCriterion from "./TelemetryCriterion";
let openmct = {},
mockListener,
mockListener2,
testCriterionDefinition,
testTelemetryObject,
telemetryCriterion;
describe("The telemetry criterion", function () {
beforeEach (() => {
testTelemetryObject = {
identifier:{ namespace: "", key: "test-object"},
type: "test-object",
name: "Test Object",
telemetry: {
values: [{
key: "some-key",
name: "Some attribute",
hints: {
domain: 1
}
}, {
key: "some-other-key",
name: "Another attribute",
hints: {
range: 1
}
}]
}
};
openmct.objects = jasmine.createSpyObj('objects', ['get', 'makeKeyString']);
openmct.objects.get.and.returnValue(new Promise(function (resolve, reject) {
resolve(testTelemetryObject);
}));
openmct.objects.makeKeyString.and.returnValue(testTelemetryObject.identifier.key);
openmct.telemetry = jasmine.createSpyObj('telemetry', ['isTelemetryObject', "subscribe", "getMetadata"]);
openmct.telemetry.isTelemetryObject.and.returnValue(true);
openmct.telemetry.subscribe.and.returnValue(function () {});
openmct.telemetry.getMetadata.and.returnValue(testTelemetryObject.telemetry.values);
testCriterionDefinition = {
id: 'test-criterion-id',
key: openmct.objects.makeKeyString(testTelemetryObject.identifier)
};
mockListener = jasmine.createSpy('listener');
mockListener2 = jasmine.createSpy('updatedListener', (data) => {
console.log(data);
});
telemetryCriterion = new TelemetryCriterion(
testCriterionDefinition,
openmct
);
telemetryCriterion.on('criterionResultUpdated', mockListener);
telemetryCriterion.on('criterionUpdated', mockListener2);
});
it("initializes with a telemetry objectId as string", function () {
telemetryCriterion.initialize(testTelemetryObject);
expect(telemetryCriterion.telemetryObjectIdAsString).toEqual(testTelemetryObject.identifier.key);
expect(telemetryCriterion.telemetryMetadata.length).toEqual(2);
expect(mockListener2).toHaveBeenCalled();
});
it("subscribes to telemetry providers", function () {
telemetryCriterion.subscribe();
expect(telemetryCriterion.subscription).toBeDefined();
});
it("normalizes telemetry data", function () {
let result = telemetryCriterion.normalizeData({
key: 'some-key',
source: 'testSource',
testSource: 'Hello'
});
expect(result).toEqual({
'some-key': 'Hello'
})
});
it("emits update event on new data from telemetry providers", function () {
spyOn(telemetryCriterion, 'emitEvent').and.callThrough();
telemetryCriterion.handleSubscription({
key: 'some-key',
source: 'testSource',
testSource: 'Hello'
});
expect(telemetryCriterion.emitEvent).toHaveBeenCalled();
expect(mockListener).toHaveBeenCalled();
});
it("un-subscribes from telemetry providers", function () {
telemetryCriterion.subscribe();
expect(telemetryCriterion.subscription).toBeDefined();
telemetryCriterion.unsubscribe();
expect(telemetryCriterion.subscription).toBeUndefined();
expect(telemetryCriterion.telemetryObjectIdAsString).toBeUndefined();
expect(telemetryCriterion.telemetryObject).toBeUndefined();
expect(telemetryCriterion.telemetryMetadata).toBeUndefined();
});
});

View File

View File

@ -0,0 +1,57 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import ConditionSetViewProvider from './ConditionSetViewProvider.js';
import ConditionSetCompositionPolicy from "./ConditionSetCompositionPolicy";
export default function ConditionPlugin() {
return function install(openmct) {
openmct.types.addType('condition', {
name: 'Condition',
key: 'condition',
description: 'A list of criteria which will be evaluated based on a trigger',
creatable: false,
initialize: function (domainObject) {
domainObject.composition = [];
}
});
openmct.types.addType('conditionSet', {
name: 'Condition Set',
key: 'conditionSet',
description: 'A set of one or more conditions based on user-specified criteria.',
creatable: true,
cssClass: 'icon-summary-widget', // TODO: replace with class for new icon
initialize: function (domainObject) {
domainObject.configuration = {
conditionCollection: []
};
domainObject.composition = [];
}
});
openmct.composition.addPolicy(new ConditionSetCompositionPolicy(openmct).allow);
openmct.objectViews.addProvider(new ConditionSetViewProvider(openmct));
}
}

View File

@ -0,0 +1,128 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2020, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import { createOpenMct } from "testTools";
import ConditionPlugin from "./plugin";
let openmct = createOpenMct();
openmct.install(new ConditionPlugin());
let conditionDefinition;
let conditionSetDefinition;
let mockDomainObject;
let mockDomainObject2;
let element;
let child;
describe('the plugin', function () {
beforeAll((done) => {
conditionDefinition = openmct.types.get('condition').definition;
mockDomainObject = {
identifier: {
key: 'testConditionKey',
namespace: ''
},
type: 'condition'
};
conditionDefinition.initialize(mockDomainObject);
conditionSetDefinition = openmct.types.get('conditionSet').definition;
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
element = document.createElement('div');
child = document.createElement('div');
element.appendChild(child);
mockDomainObject2 = {
identifier: {
key: 'testConditionSetKey',
namespace: ''
},
type: 'conditionSet'
};
conditionSetDefinition.initialize(mockDomainObject2);
openmct.on('start', done);
openmct.start(appHolder);
});
let mockConditionObject = {
name: 'Condition',
key: 'condition',
creatable: false
};
it('defines a condition object type with the correct key', () => {
expect(conditionDefinition.key).toEqual(mockConditionObject.key);
});
let mockConditionSetObject = {
name: 'Condition Set',
key: 'conditionSet',
creatable: true
};
it('defines a conditionSet object type with the correct key', () => {
expect(conditionSetDefinition.key).toEqual(mockConditionSetObject.key);
});
describe('the condition object', () => {
it('is not creatable', () => {
expect(conditionDefinition.creatable).toEqual(mockConditionObject.creatable);
});
it('initializes with an empty composition list', () => {
expect(mockDomainObject.composition instanceof Array).toBeTrue();
expect(mockDomainObject.composition.length).toEqual(0);
});
});
describe('the conditionSet object', () => {
it('is creatable', () => {
expect(conditionSetDefinition.creatable).toEqual(mockConditionSetObject.creatable);
});
it('initializes with an empty composition list', () => {
expect(mockDomainObject2.composition instanceof Array).toBeTrue();
expect(mockDomainObject2.composition.length).toEqual(0);
});
it('provides a view', () => {
const testViewObject = {
id:"test-object",
type: "conditionSet"
};
const applicableViews = openmct.objectViews.get(testViewObject);
let conditionSetView = applicableViews.find((viewProvider) => viewProvider.key === 'conditionSet.view');
expect(conditionSetView).toBeDefined();
});
});
});

View File

@ -0,0 +1,4 @@
export const TRIGGER = {
ANY: 'any',
ALL: 'all'
};

View File

@ -0,0 +1,7 @@
export const computeConditionForAny = (args) => {
return false;
};
export const computeConditionForAll = (args) => {
return false;
};

View File

@ -0,0 +1,2 @@
import Vue from 'vue';
export const EventBus = new Vue();

View File

@ -0,0 +1,206 @@
export const OPERATIONS = [
{
name: 'equalTo',
operation: function (input) {
return input[0] === input[1];
},
text: 'is equal to',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' == ' + values[0];
}
},
{
name: 'notEqualTo',
operation: function (input) {
return input[0] !== input[1];
},
text: 'is not equal to',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' != ' + values[0];
}
},
{
name: 'greaterThan',
operation: function (input) {
return input[0] > input[1];
},
text: 'is greater than',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' > ' + values[0];
}
},
{
name: 'lessThan',
operation: function (input) {
return input[0] < input[1];
},
text: 'is less than',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' < ' + values[0];
}
},
{
name: 'greaterThanOrEq',
operation: function (input) {
return input[0] >= input[1];
},
text: 'is greater than or equal to',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' >= ' + values[0];
}
},
{
name: 'lessThanOrEq',
operation: function (input) {
return input[0] <= input[1];
},
text: 'is less than or equal to',
appliesTo: ['number'],
inputCount: 1,
getDescription: function (values) {
return ' <= ' + values[0];
}
},
{
name: 'between',
operation: function (input) {
return input[0] > input[1] && input[0] < input[2];
},
text: 'is between',
appliesTo: ['number'],
inputCount: 2,
getDescription: function (values) {
return ' between ' + values[0] + ' and ' + values[1];
}
},
{
name: 'notBetween',
operation: function (input) {
return input[0] < input[1] || input[0] > input[2];
},
text: 'is not between',
appliesTo: ['number'],
inputCount: 2,
getDescription: function (values) {
return ' not between ' + values[0] + ' and ' + values[1];
}
},
{
name: 'textContains',
operation: function (input) {
return input[0] && input[1] && input[0].includes(input[1]);
},
text: 'text contains',
appliesTo: ['string'],
inputCount: 1,
getDescription: function (values) {
return ' contains ' + values[0];
}
},
{
name: 'textDoesNotContain',
operation: function (input) {
return input[0] && input[1] && !input[0].includes(input[1]);
},
text: 'text does not contain',
appliesTo: ['string'],
inputCount: 1,
getDescription: function (values) {
return ' does not contain ' + values[0];
}
},
{
name: 'textStartsWith',
operation: function (input) {
return input[0].startsWith(input[1]);
},
text: 'text starts with',
appliesTo: ['string'],
inputCount: 1,
getDescription: function (values) {
return ' starts with ' + values[0];
}
},
{
name: 'textEndsWith',
operation: function (input) {
return input[0].endsWith(input[1]);
},
text: 'text ends with',
appliesTo: ['string'],
inputCount: 1,
getDescription: function (values) {
return ' ends with ' + values[0];
}
},
{
name: 'textIsExactly',
operation: function (input) {
return input[0] === input[1];
},
text: 'text is exactly',
appliesTo: ['string'],
inputCount: 1,
getDescription: function (values) {
return ' is exactly ' + values[0];
}
},
{
name: 'isUndefined',
operation: function (input) {
return typeof input[0] === 'undefined';
},
text: 'is undefined',
appliesTo: ['string', 'number', 'enum'],
inputCount: 0,
getDescription: function () {
return ' is undefined';
}
},
{
name: 'isDefined',
operation: function (input) {
return typeof input[0] !== 'undefined';
},
text: 'is defined',
appliesTo: ['string', 'number', 'enum'],
inputCount: 0,
getDescription: function () {
return ' is defined';
}
},
{
name: 'enumValueIs',
operation: function (input) {
return input[0] === input[1];
},
text: 'is',
appliesTo: ['enum'],
inputCount: 1,
getDescription: function (values) {
return ' == ' + values[0];
}
},
{
name: 'enumValueIsNot',
operation: function (input) {
return input[0] !== input[1];
},
text: 'is not',
appliesTo: ['enum'],
inputCount: 1,
getDescription: function (values) {
return ' != ' + values[0];
}
}
];

View File

@ -1,5 +1,5 @@
/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* Open MCT, Copyright (c) 2014-2019, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
@ -47,6 +47,7 @@ define([
'./goToOriginalAction/plugin',
'./clearData/plugin',
'./webPage/plugin',
'./condition/plugin',
'./themes/espresso',
'./themes/maelstrom',
'./themes/snow'
@ -77,6 +78,7 @@ define([
GoToOriginalAction,
ClearData,
WebPagePlugin,
ConditionPlugin,
Espresso,
Maelstrom,
Snow
@ -185,6 +187,7 @@ define([
plugins.Espresso = Espresso.default;
plugins.Maelstrom = Maelstrom.default;
plugins.Snow = Snow.default;
plugins.Condition = ConditionPlugin.default;
return plugins;
});

View File

@ -1,5 +1,7 @@
@import "../api/overlays/components/dialog-component.scss";
@import "../api/overlays/components/overlay-component.scss";
@import "../plugins/condition/components/condition.scss";
@import "../plugins/condition/components/condition-set.scss";
@import "../plugins/displayLayout/components/box-view.scss";
@import "../plugins/displayLayout/components/display-layout.scss";
@import "../plugins/displayLayout/components/edit-marquee.scss";