mirror of
https://github.com/nasa/openmct.git
synced 2025-02-07 11:30:28 +00:00
[Clocks / Timers] adding ability to stop
added the stop timer menu option
This commit is contained in:
parent
7fc66e2de8
commit
9df59522d9
@ -811,6 +811,14 @@
|
|||||||
"id": 29,
|
"id": 29,
|
||||||
"code": 921897,
|
"code": 921897,
|
||||||
"tempChar": ""
|
"tempChar": ""
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"order": 121,
|
||||||
|
"prevSize": 24,
|
||||||
|
"name": "icon-stop",
|
||||||
|
"id": 89,
|
||||||
|
"code": 921637,
|
||||||
|
"tempChar": ""
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@ -3085,6 +3093,31 @@
|
|||||||
{}
|
{}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"paths": [
|
||||||
|
"M0 0h24v24H0z"
|
||||||
|
],
|
||||||
|
"grid": 16,
|
||||||
|
"tags": [
|
||||||
|
"icon-stop"
|
||||||
|
],
|
||||||
|
"defaultCode": 114,
|
||||||
|
"id": 89,
|
||||||
|
"attrs": [
|
||||||
|
{
|
||||||
|
"fill": "rgb(0, 161, 75)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"isMulticolor": false,
|
||||||
|
"isMulticolor2": false,
|
||||||
|
"colorPermutations": {
|
||||||
|
"1161751207457516161751": [
|
||||||
|
{
|
||||||
|
"f": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"colorThemes": [
|
"colorThemes": [
|
||||||
|
@ -107,4 +107,5 @@
|
|||||||
<glyph unicode="󡄧" glyph-name="icon-timer-v1.5" horiz-adv-x="896" d="M576 813.4v82.58c0 35.346-28.654 64-64 64h-128c-35.346 0-64-28.654-64-64v-82.58c-185.040-55.080-320-226.48-320-429.42 0-247.42 200.58-448 448-448s448 200.58 448 448c0 202.96-135 374.4-320 429.42zM468 363.98l-263.76-211c-57.105 59.935-92.24 141.251-92.24 230.772 0 0.080 0 0.16 0 0.24 0 185.268 150.72 335.988 336 335.988 6.72 0 13.38-0.22 20-0.62v-355.38z" />
|
<glyph unicode="󡄧" glyph-name="icon-timer-v1.5" horiz-adv-x="896" d="M576 813.4v82.58c0 35.346-28.654 64-64 64h-128c-35.346 0-64-28.654-64-64v-82.58c-185.040-55.080-320-226.48-320-429.42 0-247.42 200.58-448 448-448s448 200.58 448 448c0 202.96-135 374.4-320 429.42zM468 363.98l-263.76-211c-57.105 59.935-92.24 141.251-92.24 230.772 0 0.080 0 0.16 0 0.24 0 185.268 150.72 335.988 336 335.988 6.72 0 13.38-0.22 20-0.62v-355.38z" />
|
||||||
<glyph unicode="󡄨" glyph-name="icon-topic" d="M454.36 483.36l86.3 86.3c9.088 8.965 21.577 14.502 35.36 14.502s26.272-5.537 35.366-14.507l86.294-86.294c19.328-19.358 42.832-34.541 69.047-44.082l1.313 171.722-57.64 57.64c-34.407 34.33-81.9 55.558-134.35 55.558s-99.943-21.228-134.354-55.562l-86.296-86.297c-9.088-8.965-21.577-14.502-35.36-14.502s-26.272 5.537-35.366 14.507l-28.674 28.654v-172.14c19.045-7.022 41.040-11.084 63.984-11.084 52.463 0 99.966 21.239 134.379 55.587zM505.64 412.64l-86.3-86.3c-9.088-8.965-21.577-14.502-35.36-14.502s-26.272 5.537-35.366 14.507l-86.294 86.294c-2 2-4.2 4-6.36 6v-197.36c33.664-30.72 78.65-49.537 128.031-49.537 52.44 0 99.923 21.22 134.333 55.541l86.296 86.296c9.088 8.965 21.577 14.502 35.36 14.502s26.272-5.537 35.366-14.507l86.294-86.294c2-2 4.2-4 6.36-6v197.36c-33.664 30.72-78.65 49.537-128.031 49.537-52.44 0-99.923-21.22-134.333-55.541zM832 960h-128v-192h127.66l0.34-0.34v-639.32l-0.34-0.34h-127.66v-192h128c105.6 0 192 86.4 192 192v640c0 105.6-86.4 192-192 192zM320 128h-127.66l-0.34 0.34v639.32l0.34 0.34h127.66v192h-128c-105.6 0-192-86.4-192-192v-640c0-105.6 86.4-192 192-192h128v192z" />
|
<glyph unicode="󡄨" glyph-name="icon-topic" d="M454.36 483.36l86.3 86.3c9.088 8.965 21.577 14.502 35.36 14.502s26.272-5.537 35.366-14.507l86.294-86.294c19.328-19.358 42.832-34.541 69.047-44.082l1.313 171.722-57.64 57.64c-34.407 34.33-81.9 55.558-134.35 55.558s-99.943-21.228-134.354-55.562l-86.296-86.297c-9.088-8.965-21.577-14.502-35.36-14.502s-26.272 5.537-35.366 14.507l-28.674 28.654v-172.14c19.045-7.022 41.040-11.084 63.984-11.084 52.463 0 99.966 21.239 134.379 55.587zM505.64 412.64l-86.3-86.3c-9.088-8.965-21.577-14.502-35.36-14.502s-26.272 5.537-35.366 14.507l-86.294 86.294c-2 2-4.2 4-6.36 6v-197.36c33.664-30.72 78.65-49.537 128.031-49.537 52.44 0 99.923 21.22 134.333 55.541l86.296 86.296c9.088 8.965 21.577 14.502 35.36 14.502s26.272-5.537 35.366-14.507l86.294-86.294c2-2 4.2-4 6.36-6v197.36c-33.664 30.72-78.65 49.537-128.031 49.537-52.44 0-99.923-21.22-134.333-55.541zM832 960h-128v-192h127.66l0.34-0.34v-639.32l-0.34-0.34h-127.66v-192h128c105.6 0 192 86.4 192 192v640c0 105.6-86.4 192-192 192zM320 128h-127.66l-0.34 0.34v639.32l0.34 0.34h127.66v192h-128c-105.6 0-192-86.4-192-192v-640c0-105.6 86.4-192 192-192h128v192z" />
|
||||||
<glyph unicode="󡄩" glyph-name="icon-box-with-dashed-lines" d="M0 576h128v-256h-128v256zM128 831.78l0.22 0.22h191.78v128h-192c-70.606-0.215-127.785-57.394-128-127.979v-192.021h128v191.78zM128 64.22v191.78h-128v-192c0.215-70.606 57.394-127.785 127.979-128h192.021v128h-191.78zM384 960h256v-128h-256v128zM896 64.22l-0.22-0.22h-191.78v-128h192c70.606 0.215 127.785 57.394 128 127.979v192.021h-128v-191.78zM896 960h-192v-128h191.78l0.22-0.22v-191.78h128v192c-0.215 70.606-57.394 127.785-127.979 128zM896 576h128v-256h-128v256zM384 64h256v-128h-256v128zM256 704h512v-512h-512v512z" />
|
<glyph unicode="󡄩" glyph-name="icon-box-with-dashed-lines" d="M0 576h128v-256h-128v256zM128 831.78l0.22 0.22h191.78v128h-192c-70.606-0.215-127.785-57.394-128-127.979v-192.021h128v191.78zM128 64.22v191.78h-128v-192c0.215-70.606 57.394-127.785 127.979-128h192.021v128h-191.78zM384 960h256v-128h-256v128zM896 64.22l-0.22-0.22h-191.78v-128h192c70.606 0.215 127.785 57.394 128 127.979v192.021h-128v-191.78zM896 960h-192v-128h191.78l0.22-0.22v-191.78h128v192c-0.215 70.606-57.394 127.785-127.979 128zM896 576h128v-256h-128v256zM384 64h256v-128h-256v128zM256 704h512v-512h-512v512z" />
|
||||||
|
<glyph unicode="󡄰" glyph-name="icon-stop" d="M0 0h24v24H0z" />
|
||||||
</font></defs></svg>
|
</font></defs></svg>
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
@ -107,6 +107,7 @@ $glyph-icon-timeline: '\e1126';
|
|||||||
$glyph-icon-timer: '\e1127';
|
$glyph-icon-timer: '\e1127';
|
||||||
$glyph-icon-topic: '\e1128';
|
$glyph-icon-topic: '\e1128';
|
||||||
$glyph-icon-box-with-dashed-lines: '\e1129';
|
$glyph-icon-box-with-dashed-lines: '\e1129';
|
||||||
|
$glyph-icon-stop: '\e1130';
|
||||||
|
|
||||||
/************************** 16 PX CLASSES */
|
/************************** 16 PX CLASSES */
|
||||||
|
|
||||||
@ -210,6 +211,7 @@ $glyph-icon-box-with-dashed-lines: '\e1129';
|
|||||||
.icon-timer { @include glyph($glyph-icon-timer); }
|
.icon-timer { @include glyph($glyph-icon-timer); }
|
||||||
.icon-topic { @include glyph($glyph-icon-topic); }
|
.icon-topic { @include glyph($glyph-icon-topic); }
|
||||||
.icon-box-with-dashed-lines { @include glyph($glyph-icon-box-with-dashed-lines); }
|
.icon-box-with-dashed-lines { @include glyph($glyph-icon-box-with-dashed-lines); }
|
||||||
|
.icon-stop { @include glyph($glyph-icon-stop); }
|
||||||
|
|
||||||
/************************** 12 PX CLASSES */
|
/************************** 12 PX CLASSES */
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ define([
|
|||||||
"./src/controllers/RefreshingController",
|
"./src/controllers/RefreshingController",
|
||||||
"./src/actions/StartTimerAction",
|
"./src/actions/StartTimerAction",
|
||||||
"./src/actions/RestartTimerAction",
|
"./src/actions/RestartTimerAction",
|
||||||
|
"./src/actions/StopTimerAction",
|
||||||
"text!./res/templates/clock.html",
|
"text!./res/templates/clock.html",
|
||||||
"text!./res/templates/timer.html",
|
"text!./res/templates/timer.html",
|
||||||
'legacyRegistry'
|
'legacyRegistry'
|
||||||
@ -39,6 +40,7 @@ define([
|
|||||||
RefreshingController,
|
RefreshingController,
|
||||||
StartTimerAction,
|
StartTimerAction,
|
||||||
RestartTimerAction,
|
RestartTimerAction,
|
||||||
|
StopTimerAction,
|
||||||
clockTemplate,
|
clockTemplate,
|
||||||
timerTemplate,
|
timerTemplate,
|
||||||
legacyRegistry
|
legacyRegistry
|
||||||
@ -149,6 +151,17 @@ define([
|
|||||||
"name": "Restart at 0",
|
"name": "Restart at 0",
|
||||||
"cssclass": "icon-refresh",
|
"cssclass": "icon-refresh",
|
||||||
"priority": "preferred"
|
"priority": "preferred"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "timer.stop",
|
||||||
|
"implementation": StopTimerAction,
|
||||||
|
"depends": [
|
||||||
|
"now"
|
||||||
|
],
|
||||||
|
"category": "contextual",
|
||||||
|
"name": "Stop",
|
||||||
|
"cssclass": "icon-box",
|
||||||
|
"priority": "preferred"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
|
73
platform/features/clock/src/actions/StopTimerAction.js
Normal file
73
platform/features/clock/src/actions/StopTimerAction.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2009-2016, 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(
|
||||||
|
['./AbstractTimerAction'],
|
||||||
|
function (AbstractTimerAction) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements the "Start" action for timers.
|
||||||
|
*
|
||||||
|
* Sets the reference timestamp in a timer to the current
|
||||||
|
* time, such that it begins counting up.
|
||||||
|
*
|
||||||
|
* @extends {platform/features/clock.AbstractTimerAction}
|
||||||
|
* @implements {Action}
|
||||||
|
* @memberof platform/features/clock
|
||||||
|
* @constructor
|
||||||
|
* @param {Function} now a function which returns the current
|
||||||
|
* time (typically wrapping `Date.now`)
|
||||||
|
* @param {ActionContext} context the context for this action
|
||||||
|
*/
|
||||||
|
function StopTimerAction(now, context) {
|
||||||
|
AbstractTimerAction.apply(this, [now, context]);
|
||||||
|
}
|
||||||
|
|
||||||
|
StopTimerAction.prototype =
|
||||||
|
Object.create(AbstractTimerAction.prototype);
|
||||||
|
|
||||||
|
StopTimerAction.appliesTo = function (context) {
|
||||||
|
var model =
|
||||||
|
(context.domainObject && context.domainObject.getModel()) ||
|
||||||
|
{};
|
||||||
|
|
||||||
|
|
||||||
|
// We show this variant for timers which do not yet have
|
||||||
|
// a target time.
|
||||||
|
return model.type === 'timer' &&
|
||||||
|
model.timestamp !== undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
StopTimerAction.prototype.perform = function () {
|
||||||
|
var domainObject = this.domainObject;
|
||||||
|
|
||||||
|
function setTimestamp(model) {
|
||||||
|
model.timestamp = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return domainObject.useCapability('mutation', setTimestamp);
|
||||||
|
};
|
||||||
|
|
||||||
|
return StopTimerAction;
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
86
platform/features/clock/test/actions/StopTimerActionSpec.js
Normal file
86
platform/features/clock/test/actions/StopTimerActionSpec.js
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT, Copyright (c) 2009-2016, 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
define(
|
||||||
|
["../../src/actions/StopTimerAction"],
|
||||||
|
function (StopTimerAction) {
|
||||||
|
|
||||||
|
describe("A timer's stop action", function () {
|
||||||
|
var mockNow,
|
||||||
|
mockDomainObject,
|
||||||
|
testModel,
|
||||||
|
testContext,
|
||||||
|
action;
|
||||||
|
|
||||||
|
function asPromise(value) {
|
||||||
|
return (value || {}).then ? value : {
|
||||||
|
then: function (callback) {
|
||||||
|
return asPromise(callback(value));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockNow = jasmine.createSpy('now');
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
['getCapability', 'useCapability', 'getModel']
|
||||||
|
);
|
||||||
|
|
||||||
|
mockDomainObject.useCapability.andCallFake(function (c, v) {
|
||||||
|
if (c === 'mutation') {
|
||||||
|
testModel = v(testModel) || testModel;
|
||||||
|
return asPromise(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mockDomainObject.getModel.andCallFake(function () {
|
||||||
|
return testModel;
|
||||||
|
});
|
||||||
|
|
||||||
|
testModel = {};
|
||||||
|
testContext = { domainObject: mockDomainObject };
|
||||||
|
|
||||||
|
action = new StopTimerAction(mockNow, testContext);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("updates the model with a timestamp", function () {
|
||||||
|
mockNow.andReturn(12000);
|
||||||
|
action.perform();
|
||||||
|
expect(testModel.timestamp).toEqual(12000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("applies only to timers without a target time", function () {
|
||||||
|
testModel.type = 'timer';
|
||||||
|
testModel.timestamp = 12000;
|
||||||
|
expect(StopTimerAction.appliesTo(testContext)).toBeTruthy();
|
||||||
|
|
||||||
|
testModel.type = 'timer';
|
||||||
|
testModel.timestamp = undefined;
|
||||||
|
expect(StopTimerAction.appliesTo(testContext)).toBeFalsy();
|
||||||
|
|
||||||
|
testModel.type = 'clock';
|
||||||
|
testModel.timestamp = 12000;
|
||||||
|
expect(StopTimerAction.appliesTo(testContext)).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user