@@ -129,7 +129,7 @@ We will create this file in the directory tutorials/todo (we can hereafter refer
129
129
to this plugin as tutorials/todo as well.) We will start with an "empty bundle",
130
130
one which exposes no extensions - which looks like:
131
131
132
- ``` diff
132
+ ``` js
133
133
define ([
134
134
' openmct'
135
135
], function (
@@ -154,7 +154,7 @@ The tutorials will be updated with the new bundle registration mechanism once it
154
154
has been finalized.
155
155
156
156
#### Before
157
- ``` diff
157
+ ``` html
158
158
<!--
159
159
Open MCT, Copyright (c) 2014-2016, United States Government
160
160
as represented by the Administrator of the National Aeronautics and Space
@@ -219,7 +219,7 @@ __index.html__
219
219
220
220
#### After
221
221
222
- ``` diff
222
+ ``` html
223
223
<!--
224
224
Open MCT, Copyright (c) 2014-2016, United States Government
225
225
as represented by the Administrator of the National Aeronautics and Space
@@ -305,7 +305,7 @@ In the case of our to-do list feature, the to-do list itself is the thing we'll
305
305
want users to be able to create and edit. So, we will add that as a new type in
306
306
our bundle definition:
307
307
308
- ``` diff
308
+ ``` js
309
309
define ([
310
310
' openmct'
311
311
], function (
@@ -369,7 +369,7 @@ directory `tutorials/todo/res/templates` (`res` is, by default, the directory
369
369
where bundle-related resources are kept, and ` templates ` is where HTML templates
370
370
are stored by convention.)
371
371
372
- ``` diff
372
+ ``` html
373
373
<div >
374
374
<a href =" " >All</a >
375
375
<a href =" " >Incomplete</a >
@@ -401,7 +401,7 @@ boolean `completed` flag.
401
401
To expose this view in Open MCT, we need to declare it in our bundle
402
402
definition:
403
403
404
- ``` diff
404
+ ``` js
405
405
define ([
406
406
' openmct'
407
407
], function (
@@ -458,7 +458,7 @@ the user to create these yet. As a temporary workaround to test the view, we
458
458
will specify an initial state for To-do List domain object models in the
459
459
definition of that type.
460
460
461
- ``` diff
461
+ ``` js
462
462
define ([
463
463
' openmct'
464
464
], function (
@@ -529,7 +529,7 @@ in the directory `tutorials/todo/src/controllers` (`src` is, by default, the
529
529
directory where bundle-related source code is kept, and controllers is where
530
530
Angular controllers are stored by convention.)
531
531
532
- ``` diff
532
+ ``` js
533
533
define (function () {
534
534
function TodoController ($scope ) {
535
535
var showAll = true ,
@@ -594,7 +594,7 @@ prior to our template being utilized.
594
594
On its own, this controller merely exposes these functions; the next step is to
595
595
use them from our template:
596
596
597
- ``` diff
597
+ ``` html
598
598
+ <div ng-controller =" TodoController" >
599
599
<div >
600
600
+ <a ng-click =" setVisibility(true)" >All</a >
@@ -630,7 +630,7 @@ If we were to try to run at this point, we'd run into problems because the
630
630
` TodoController ` has not been registered with Angular. We need to first declare
631
631
it in our bundle definition, as an extension of category ` controllers ` :
632
632
633
- ``` diff
633
+ ``` js
634
634
define ([
635
635
' openmct' ,
636
636
+ ' ./src/controllers/TodoController'
@@ -724,7 +724,7 @@ An Editing user interface is typically handled in a tool bar associated with a
724
724
view. The contents of this tool bar are defined declaratively in a view's
725
725
extension definition.
726
726
727
- ``` diff
727
+ ``` js
728
728
define ([
729
729
' openmct' ,
730
730
' ./src/controllers/TodoController'
@@ -813,7 +813,7 @@ all the applicable controls, which means no controls at all.
813
813
814
814
To support selection, we will need to make some changes to our controller:
815
815
816
- ``` diff
816
+ ``` js
817
817
define (function () {
818
818
+ // Form to display when adding new tasks
819
819
+ var NEW_TASK_FORM = {
@@ -928,7 +928,7 @@ Additionally, we need to make changes to our template to select specific tasks
928
928
in response to some user gesture. Here, we will select tasks when a user clicks
929
929
the description.
930
930
931
- ``` diff
931
+ ``` html
932
932
<div ng-controller =" TodoController" >
933
933
<div >
934
934
<a ng-click =" setVisibility(true)" >All</a >
@@ -954,7 +954,7 @@ __tutorials/todo/res/templates/todo.html__
954
954
Finally, the ` TodoController ` uses the ` dialogService ` now, so we need to
955
955
declare that dependency in its extension definition:
956
956
957
- ``` diff
957
+ ``` js
958
958
define ([
959
959
' openmct' ,
960
960
' ./src/controllers/TodoController'
@@ -1058,7 +1058,7 @@ In this section, our goal is to:
1058
1058
To support the first two, we'll need to expose some methods for checking these
1059
1059
states in the controller:
1060
1060
1061
- ``` diff
1061
+ ``` js
1062
1062
define (function () {
1063
1063
// Form to display when adding new tasks
1064
1064
var NEW_TASK_FORM = {
@@ -1175,7 +1175,7 @@ states visually, and to generally improve the appearance of our view. We add
1175
1175
another file to the res directory of our bundle; this time, it is ` css/todo.css `
1176
1176
(with the ` css ` directory again being a convention.)
1177
1177
1178
- ``` diff
1178
+ ``` css
1179
1179
.example-todo div .example-button-group {
1180
1180
margin-top : 12px ;
1181
1181
margin-bottom : 12px ;
@@ -1219,7 +1219,7 @@ To include this CSS file in our running instance of Open MCT, we need to
1219
1219
declare it in our bundle definition, this time as an extension of category
1220
1220
` stylesheets ` :
1221
1221
1222
- ``` diff
1222
+ ``` js
1223
1223
define ([
1224
1224
' openmct' ,
1225
1225
' ./src/controllers/TodoController'
@@ -1299,7 +1299,7 @@ To-Do List's type above; now To-Do Lists will start off empty.
1299
1299
1300
1300
Finally, let's utilize these changes from our view's template:
1301
1301
1302
- ``` diff
1302
+ ``` html
1303
1303
+ <div ng-controller =" TodoController" class =" example-todo" >
1304
1304
+ <div class =" example-button-group" >
1305
1305
+ <a ng-class =" { selected: checkVisibility(true) }"
@@ -1359,7 +1359,7 @@ We'll also be defining some custom styles, so we'll include that extension as
1359
1359
well. We'll be creating this plugin in ` tutorials/bargraph ` , so our initial
1360
1360
bundle definition looks like:
1361
1361
1362
- ``` diff
1362
+ ``` js
1363
1363
define ([
1364
1364
' openmct'
1365
1365
], function (
@@ -1406,7 +1406,7 @@ For this tutorial, we'll assume that we've sketched out our template and CSS
1406
1406
file ahead of time to describe the general look we want for the view. These
1407
1407
look like:
1408
1408
1409
- ``` diff
1409
+ ``` html
1410
1410
<div class =" example-bargraph" >
1411
1411
<div class =" example-tick-labels" >
1412
1412
<div class =" example-tick-label" style =" bottom : 0% " >High</div >
@@ -1457,7 +1457,7 @@ bar corresponds to which telemetry point. Inline `style` attributes are used
1457
1457
wherever dynamic positioning (handled by a script) is anticipated.
1458
1458
The corresponding CSS file which styles and positions these elements:
1459
1459
1460
- ``` diff
1460
+ ``` css
1461
1461
.example-bargraph {
1462
1462
position : absolute ;
1463
1463
top : 0 ;
@@ -1555,7 +1555,7 @@ Notably, we will not try to show telemetry data after this step.
1555
1555
1556
1556
To support this, we will add a new controller which supports our Bar Graph view:
1557
1557
1558
- ``` diff
1558
+ ``` js
1559
1559
define (function () {
1560
1560
function BarGraphController ($scope , telemetryHandler ) {
1561
1561
var handle;
@@ -1607,7 +1607,7 @@ telemetry objects in view, as well as the width for each bar.
1607
1607
1608
1608
We will also utilize this from our template:
1609
1609
1610
- ``` diff
1610
+ ``` html
1611
1611
+ <div class =" example-bargraph" ng-controller =" BarGraphController" >
1612
1612
<div class =" example-tick-labels" >
1613
1613
+ <div ng-repeat =" value in [low, middle, high] track by $index"
@@ -1660,7 +1660,7 @@ Finally, we expose our controller from our bundle definition. Note that the
1660
1660
depends declaration includes both ` $scope ` as well as the ` telemetryHandler `
1661
1661
service we made use of.
1662
1662
1663
- ``` diff
1663
+ ``` js
1664
1664
define ([
1665
1665
' openmct' ,
1666
1666
' ./src/controllers/BarGraphController'
@@ -1715,7 +1715,7 @@ First, let's add expose some more functionality from our controller. To make it
1715
1715
simple, we'll expose the top and bottom for a bar graph for a given
1716
1716
telemetry-providing domain object, as percentages.
1717
1717
1718
- ``` diff
1718
+ ``` js
1719
1719
define (function () {
1720
1720
function BarGraphController ($scope , telemetryHandler ) {
1721
1721
var handle;
@@ -1767,7 +1767,7 @@ decide this.
1767
1767
1768
1768
Next, we utilize this functionality from the template:
1769
1769
1770
- ``` diff
1770
+ ``` html
1771
1771
<div class =" example-bargraph" ng-controller =" BarGraphController" >
1772
1772
<div class =" example-tick-labels" >
1773
1773
<div ng-repeat =" value in [low, middle, high] track by $index"
@@ -1826,7 +1826,7 @@ when we return to our view later, those changes will be persisted.
1826
1826
1827
1827
First, let's add a tool bar for changing these three values in Edit mode:
1828
1828
1829
- ``` diff
1829
+ ``` js
1830
1830
define ([
1831
1831
' openmct' ,
1832
1832
' ./src/controllers/BarGraphController'
@@ -1900,7 +1900,7 @@ a view proxy to work from. We will add this to our controller, and additionally
1900
1900
will start reading/writing those properties to the view's ` configuration `
1901
1901
object.
1902
1902
1903
- ``` diff
1903
+ ``` js
1904
1904
define (function () {
1905
1905
function BarGraphController ($scope , telemetryHandler ) {
1906
1906
var handle;
@@ -2023,7 +2023,7 @@ For purposes of this tutorial, a simple node server is provided to stand
2023
2023
in place of this existing telemetry system. It generates real-time data
2024
2024
and exposes it over a WebSocket connection.
2025
2025
2026
- ``` diff
2026
+ ``` js
2027
2027
/* global require,process,console*/
2028
2028
2029
2029
var CONFIG = {
@@ -2205,7 +2205,7 @@ used by the server. It uses a custom format and, for purposes of example,
2205
2205
contains three "subsystems" containing a mix of numeric and string-based
2206
2206
telemetry.
2207
2207
2208
- ``` diff
2208
+ ``` json
2209
2209
{
2210
2210
"name" : " Example Spacecraft" ,
2211
2211
"identifier" : " sc" ,
@@ -2432,7 +2432,7 @@ server. Our first step will be to add a service that will handle interactions
2432
2432
with the server; this will not be used by Open MCT directly, but will be
2433
2433
used by subsequent components we add.
2434
2434
2435
- ``` diff
2435
+ ``` js
2436
2436
/* global define,WebSocket*/
2437
2437
2438
2438
define (
@@ -2487,7 +2487,7 @@ subsystems. This means that we need to convert the data from the dictionary
2487
2487
into domain object models, and expose these to Open MCT via a
2488
2488
` modelService ` .
2489
2489
2490
- ``` diff
2490
+ ``` js
2491
2491
/* global define*/
2492
2492
2493
2493
define (
@@ -2621,7 +2621,7 @@ This allows our telemetry dictionary to be expressed as domain object models
2621
2621
fix this, we will need another script which will add these subsystems to the
2622
2622
root-level object we added in Step 1.
2623
2623
2624
- ``` diff
2624
+ ``` js
2625
2625
/* global define*/
2626
2626
2627
2627
define (
@@ -2686,7 +2686,7 @@ Finally, we wire in these changes by modifying our plugin's `bundle.js` to
2686
2686
provide metadata about how these pieces interact (both with each other, and
2687
2687
with the platform):
2688
2688
2689
- ``` diff
2689
+ ``` js
2690
2690
define ([
2691
2691
' openmct' ,
2692
2692
+ ' ./src/ExampleTelemetryServerAdapter' ,
@@ -2834,7 +2834,7 @@ will do so for the server's historical telemetry.
2834
2834
Our first step will be to add a method to our server adapter which allows us to
2835
2835
send history requests to the server:
2836
2836
2837
- ``` diff
2837
+ ``` js
2838
2838
/* global define,WebSocket*/
2839
2839
2840
2840
define (
@@ -2893,7 +2893,7 @@ identifier, the pending promise is resolved.
2893
2893
This ` history ` method will be used by a ` telemetryService ` provider which we
2894
2894
will implement:
2895
2895
2896
- ``` diff
2896
+ ``` js
2897
2897
/* global define*/
2898
2898
2899
2899
define (
@@ -2979,7 +2979,7 @@ Finally, note that we also have a `subscribe` method, to satisfy the interface o
2979
2979
2980
2980
This script uses an ` ExampleTelemetrySeries ` class, which looks like:
2981
2981
2982
- ``` diff
2982
+ ``` js
2983
2983
/* global define*/
2984
2984
2985
2985
define (
@@ -3011,7 +3011,7 @@ it with the interface expected by the platform (the methods shown.)
3011
3011
3012
3012
Finally, we expose this ` telemetryService ` provider declaratively:
3013
3013
3014
- ``` diff
3014
+ ``` js
3015
3015
define ([
3016
3016
' openmct' ,
3017
3017
' ./src/ExampleTelemetryServerAdapter' ,
@@ -3126,7 +3126,7 @@ Finally, we want to utilize the server's ability to subscribe to telemetry
3126
3126
from Open MCT. To do this, first we want to expose some new methods for
3127
3127
this from our server adapter:
3128
3128
3129
- ``` diff
3129
+ ``` js
3130
3130
/* global define,WebSocket*/
3131
3131
3132
3132
define (
@@ -3199,7 +3199,7 @@ with these subscriptions.
3199
3199
3200
3200
We then need only to utilize these methods from our ` telemetryService ` :
3201
3201
3202
- ``` diff
3202
+ ``` js
3203
3203
/* global define*/
3204
3204
3205
3205
define (
@@ -3305,4 +3305,4 @@ server can handle this.)
3305
3305
Running Open MCT again, we can still plot our historical telemetry - but
3306
3306
now we also see that it updates in real-time as more data comes in from the
3307
3307
server.
3308
-
3308
+
0 commit comments