Skip to content

Commit 482fcbf

Browse files
committed
Refactored bundle
1 parent 7af2212 commit 482fcbf

26 files changed

+293
-23
lines changed

example/localTimeSystem/bundle.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define([
24+
"./src/LocalTimeSystem",
25+
"./src/LocalTimeFormat",
26+
'legacyRegistry'
27+
], function (
28+
LocalTimeSystem,
29+
LocalTimeFormat,
30+
legacyRegistry
31+
) {
32+
legacyRegistry.register("example/localTimeSystem", {
33+
"extensions": {
34+
"formats": [
35+
{
36+
"key": "local",
37+
"implementation": LocalTimeFormat
38+
}
39+
],
40+
"timeSystems": [
41+
{
42+
"implementation": LocalTimeSystem,
43+
"depends": ["$timeout"]
44+
}
45+
]
46+
}
47+
});
48+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define([
24+
'moment'
25+
], function (
26+
moment
27+
) {
28+
29+
var DATE_FORMAT = "YYYY-MM-DD hh:mm:ss.SSS",
30+
DATE_FORMATS = [
31+
DATE_FORMAT,
32+
"YYYY-MM-DD hh:mm:ss",
33+
"YYYY-MM-DD hh:mm",
34+
"YYYY-MM-DD"
35+
];
36+
37+
/**
38+
* @typedef Scale
39+
* @property {number} min the minimum scale value, in ms
40+
* @property {number} max the maximum scale value, in ms
41+
*/
42+
43+
/**
44+
* Formatter for UTC timestamps. Interprets numeric values as
45+
* milliseconds since the start of 1970.
46+
*
47+
* @implements {Format}
48+
* @constructor
49+
* @memberof platform/commonUI/formats
50+
*/
51+
function LocalTimeFormat() {
52+
}
53+
54+
/**
55+
* Returns an appropriate time format based on the provided value and
56+
* the threshold required.
57+
* @private
58+
*/
59+
function getScaledFormat (d) {
60+
var m = moment.utc(d);
61+
/**
62+
* Uses logic from d3 Time-Scales, v3 of the API. See
63+
* https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Scales.md
64+
*
65+
* Licensed
66+
*/
67+
return [
68+
[".SSS", function(m) { return m.milliseconds(); }],
69+
[":ss", function(m) { return m.seconds(); }],
70+
["hh:mm", function(m) { return m.minutes(); }],
71+
["hh", function(m) { return m.hours(); }],
72+
["ddd DD", function(m) {
73+
return m.days() &&
74+
m.date() != 1;
75+
}],
76+
["MMM DD", function(m) { return m.date() != 1; }],
77+
["MMMM", function(m) {
78+
return m.month();
79+
}],
80+
["YYYY", function() { return true; }]
81+
].filter(function (row){
82+
return row[1](m);
83+
})[0][0];
84+
};
85+
86+
/**
87+
*
88+
* @param value
89+
* @param {Scale} [scale] Optionally provides context to the
90+
* format request, allowing for scale-appropriate formatting.
91+
* @returns {string} the formatted date
92+
*/
93+
LocalTimeFormat.prototype.format = function (value, scale) {
94+
if (scale !== undefined){
95+
var scaledFormat = getScaledFormat(value, scale);
96+
if (scaledFormat) {
97+
return moment.utc(value).format(scaledFormat);
98+
}
99+
}
100+
return moment(value).format(DATE_FORMAT);
101+
};
102+
103+
LocalTimeFormat.prototype.parse = function (text) {
104+
return moment(text, DATE_FORMATS).valueOf();
105+
};
106+
107+
LocalTimeFormat.prototype.validate = function (text) {
108+
return moment(text, DATE_FORMATS).isValid();
109+
};
110+
111+
return LocalTimeFormat;
112+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define([
24+
'../../../platform/features/conductor/src/timeSystems/TimeSystem',
25+
'../../platform/features/conductor/src/timeSystems/LocalClock'
26+
], function (TimeSystem, LocalClock) {
27+
var FIFTEEN_MINUTES = 15 * 60 * 1000,
28+
DEFAULT_PERIOD = 1000;
29+
30+
/**
31+
* This time system supports UTC dates and provides a ticking clock source.
32+
* @implements TimeSystem
33+
* @constructor
34+
*/
35+
function LocalTimeSystem ($timeout) {
36+
TimeSystem.call(this);
37+
38+
/**
39+
* Some metadata, which will be used to identify the time system in
40+
* the UI
41+
* @type {{key: string, name: string, glyph: string}}
42+
*/
43+
this.metadata = {
44+
'key': 'local',
45+
'name': 'Local 12 hour',
46+
'glyph': '\u0043'
47+
};
48+
49+
this._formats = ['utc'];
50+
this._tickSources = [new LocalClock($timeout, DEFAULT_PERIOD)];
51+
}
52+
53+
LocalTimeSystem.prototype = Object.create(TimeSystem.prototype);
54+
55+
LocalTimeSystem.prototype.formats = function () {
56+
return this._formats;
57+
};
58+
59+
LocalTimeSystem.prototype.tickSources = function () {
60+
return this._tickSources;
61+
};
62+
63+
LocalTimeSystem.prototype.defaults = function () {
64+
var now = Math.ceil(Date.now() / 1000) * 1000;
65+
return [
66+
{
67+
key: 'local-default',
68+
name: 'Local 12 hour time system defaults',
69+
deltas: {start: FIFTEEN_MINUTES, end: 0},
70+
bounds: {start: now - FIFTEEN_MINUTES, end: now}
71+
}
72+
];
73+
};
74+
75+
return LocalTimeSystem;
76+
});

main.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ define([
9191
'./platform/features/plot/bundle',
9292
'./platform/features/timeline/bundle',
9393
//'./platform/features/conductor/bundle',
94-
'./platform/features/conductor-v2/bundle',
95-
'./platform/features/conductor-v2-compatibility/bundle',
94+
'./platform/features/conductor-v2/conductor/bundle',
95+
'./platform/features/conductor-v2/compatibility/bundle',
96+
'./platform/features/conductor-v2/utcTimeSystem/bundle',
9697
'./platform/features/table/bundle',
9798
'./platform/forms/bundle',
9899
'./platform/identity/bundle',
@@ -104,7 +105,8 @@ define([
104105
'./platform/search/bundle',
105106
'./platform/status/bundle',
106107
'./platform/commonUI/regions/bundle',
107-
'./example/msl/bundle'
108+
'./example/msl/bundle',
109+
'./example/localTimeSystem/bundle'
108110
], function (Main, legacyRegistry) {
109111
return {
110112
legacyRegistry: legacyRegistry,

platform/features/conductor-v2-compatibility/bundle.js platform/features/conductor-v2/compatibility/bundle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define([
3030
legacyRegistry
3131
) {
3232

33-
legacyRegistry.register("platform/features/conductor-v2-compatibility", {
33+
legacyRegistry.register("platform/features/conductor-v2/compatibility", {
3434
"extensions": {
3535
"representers": [
3636
{

platform/features/conductor-v2/bundle.js platform/features/conductor-v2/conductor/bundle.js

+1-9
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ define([
2424
"./src/TimeConductor",
2525
"./src/ui/TimeConductorController",
2626
"./src/ui/MCTConductorAxis",
27-
"./src/timeSystems/UTCTimeSystem",
2827
"text!./res/templates/time-conductor.html",
2928
"text!./res/templates/mode-selector/mode-selector.html",
3029
"text!./res/templates/mode-selector/mode-menu.html",
@@ -33,14 +32,13 @@ define([
3332
TimeConductor,
3433
TimeConductorController,
3534
MCTConductorAxis,
36-
UTCTimeSystem,
3735
timeConductorTemplate,
3836
modeSelectorTemplate,
3937
modeMenuTemplate,
4038
legacyRegistry
4139
) {
4240

43-
legacyRegistry.register("platform/features/conductor-v2", {
41+
legacyRegistry.register("platform/features/conductor-v2/conductor", {
4442
"extensions": {
4543
"services": [
4644
{
@@ -87,12 +85,6 @@ define([
8785
"key": "mode-menu",
8886
"template": modeMenuTemplate
8987
}
90-
],
91-
"timeSystems": [
92-
{
93-
"implementation": UTCTimeSystem,
94-
"depends": ["$timeout"]
95-
}
9688
]
9789
}
9890
});

platform/features/conductor-v2/res/sass/time-conductor.scss platform/features/conductor-v2/conductor/res/sass/time-conductor.scss

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
* at runtime from the About dialog for additional information.
2121
*****************************************************************************/
2222
@import "bourbon";
23-
@import "../../../../commonUI/general/res/sass/constants";
24-
@import "../../../../commonUI/general/res/sass/mixins";
25-
@import "../../../../commonUI/general/res/sass/mobile/constants";
26-
@import "../../../../commonUI/general/res/sass/mobile/mixins";
27-
@import "../../../../commonUI/themes/espresso/res/sass/constants";
28-
@import "../../../../commonUI/themes/espresso/res/sass/mixins";
29-
@import "../../../../commonUI/general/res/sass/icons";
23+
@import "../../../../../commonUI/general/res/sass/constants";
24+
@import "../../../../../commonUI/general/res/sass/mixins";
25+
@import "../../../../../commonUI/general/res/sass/mobile/constants";
26+
@import "../../../../../commonUI/general/res/sass/mobile/mixins";
27+
@import "../../../../../commonUI/themes/espresso/res/sass/constants";
28+
@import "../../../../../commonUI/themes/espresso/res/sass/mixins";
29+
@import "../../../../../commonUI/general/res/sass/icons";
3030
@import "constants";
3131

3232
@mixin toiLineHovEffects() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*****************************************************************************
2+
* Open MCT Web, Copyright (c) 2014-2015, United States Government
3+
* as represented by the Administrator of the National Aeronautics and Space
4+
* Administration. All rights reserved.
5+
*
6+
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*
17+
* Open MCT Web includes source code licensed under additional open source
18+
* licenses. See the Open Source Licenses file (LICENSES.md) included with
19+
* this source code distribution or the Licensing information page available
20+
* at runtime from the About dialog for additional information.
21+
*****************************************************************************/
22+
23+
define([
24+
"./src/UTCTimeSystem",
25+
'legacyRegistry'
26+
], function (
27+
UTCTimeSystem,
28+
legacyRegistry
29+
) {
30+
legacyRegistry.register("platform/features/conductor-v2/utcTimeSystem", {
31+
"extensions": {
32+
"timeSystems": [
33+
{
34+
"implementation": UTCTimeSystem,
35+
"depends": ["$timeout"]
36+
}
37+
]
38+
}
39+
});
40+
});

platform/features/conductor-v2/src/timeSystems/UTCTimeSystem.js platform/features/conductor-v2/utcTimeSystem/src/UTCTimeSystem.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
*****************************************************************************/
2222

2323
define([
24-
'./TimeSystem',
25-
'./LocalClock'
26-
], function (TimeSystem, LocalClock, UTCTimeFormat) {
24+
'../../conductor/src/timeSystems/TimeSystem',
25+
'../../conductor/src/timeSystems/LocalClock'
26+
], function (TimeSystem, LocalClock) {
2727
var FIFTEEN_MINUTES = 15 * 60 * 1000,
2828
DEFAULT_PERIOD = 1000;
2929

0 commit comments

Comments
 (0)