Skip to content

Commit 7ef9db8

Browse files
#729 Default configuration for live mode (#730)
1 parent 54da03a commit 7ef9db8

File tree

8 files changed

+140
-25
lines changed

8 files changed

+140
-25
lines changed

configure/src/core/Maker.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,10 @@ const getComponent = (
406406
{inlineHelp ? (
407407
<>
408408
{inner}
409-
<Typography className={c.subtitle2}>
410-
{com.description || ""}
411-
</Typography>
409+
<div
410+
className={c.subtitle2}
411+
dangerouslySetInnerHTML={{ __html: com.description || "" }}
412+
></div>
412413
</>
413414
) : (
414415
<Tooltip title={com.description || ""} placement="top" arrow>
@@ -708,9 +709,10 @@ const getComponent = (
708709
{inlineHelp ? (
709710
<>
710711
{inner}
711-
<Typography className={c.subtitle2}>
712-
{com.description || ""}
713-
</Typography>
712+
<div
713+
className={c.subtitle2}
714+
dangerouslySetInnerHTML={{ __html: com.description || "" }}
715+
></div>
714716
</>
715717
) : (
716718
<Tooltip title={com.description || ""} placement="top" arrow>

configure/src/metaconfigs/tab-coordinates-config.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@
116116
{
117117
"field": "coordinates.coordmain",
118118
"name": "Main Coordinate Type",
119-
"description": "",
119+
"description": "Sets which coordinates are shown by default in the bottom-right of the map.\n\t<strong>• LL</strong>: Longitude, Latitude\n\t<strong>• EN</strong>: Easting, Northing\n\t<strong>• CPROJ</strong>: Custom Projected (uses Projection tab)\n\t<strong>• SPROJ</strong>: Secondary Projected\n\t<strong>• RXY</strong>: Relative X, Y, (Z) in meters\n\t<strong>• SITE</strong>: Local Level Y, X, -Z",
120120
"type": "dropdown",
121-
"width": 2,
121+
"width": 4,
122122
"options": ["ll", "en", "cproj", "sproj", "rxy", "site"]
123123
}
124124
]

configure/src/metaconfigs/tab-time-config.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,6 @@
3131
"type": "checkbox",
3232
"width": 3,
3333
"defaultChecked": false
34-
},
35-
{
36-
"field": "time.startInPointMode",
37-
"name": "Start In Point Mode",
38-
"description": "The Time UI begins in the Range Mode and allows users to bound by start and end times. Point Mode has users only control the end time and has start time implied by negative infinity.",
39-
"type": "checkbox",
40-
"width": 3,
41-
"defaultChecked": false
4234
}
4335
]
4436
},
@@ -50,7 +42,23 @@
5042
"name": "Time Format",
5143
"description": "The time format to be displayed on the Time UI. Uses D3 time format specifiers: <a target='_blank' href='https://github.com/d3/d3-time-format'>https://github.com/d3/d3-time-format</a>. Default: %Y-%m-%dT%H:%M:%SZ",
5244
"type": "text",
53-
"width": 12
45+
"width": 6
46+
},
47+
{
48+
"field": "time.liveByDefault",
49+
"name": "Live Mode On By Default",
50+
"description": "If enabled, the Time UI will start in Live (Present) mode.",
51+
"type": "checkbox",
52+
"width": 3,
53+
"defaultChecked": false
54+
},
55+
{
56+
"field": "time.startInPointMode",
57+
"name": "Start In Point Mode",
58+
"description": "The Time UI begins in the Range Mode and allows users to bound by start and end times. Point Mode has users only control the end time and has start time implied by negative infinity.",
59+
"type": "checkbox",
60+
"width": 3,
61+
"defaultChecked": false
5462
}
5563
]
5664
},

src/essence/Ancillary/Coordinates.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ const Coordinates = {
124124
!(
125125
L_.configData.time &&
126126
L_.configData.time.enabled === true &&
127-
L_.configData.time.visible === true
127+
(
128+
L_.configData.time.visible === true ||
129+
L_.configData.time.liveByDefault === true ||
130+
L_.FUTURES.live === true
131+
)
128132
)
129133
) {
130134
$('#toggleTimeUI').css({ display: 'none' })
@@ -275,8 +279,13 @@ const Coordinates = {
275279
if (
276280
L_.configData.time &&
277281
L_.configData.time.enabled === true &&
278-
L_.configData.time.visible === true &&
279-
L_.configData.time.initiallyOpen === true
282+
(
283+
L_.FUTURES.live === true ||
284+
(L_.FUTURES.live == null && (
285+
L_.configData.time.initiallyOpen === true ||
286+
L_.configData.time.liveByDefault === true
287+
))
288+
)
280289
) {
281290
toggleTimeUI()
282291
}

src/essence/Ancillary/QueryURL.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var QueryURL = {
3737

3838
var startTime = this.getSingleQueryVariable('startTime')
3939
var endTime = this.getSingleQueryVariable('endTime')
40+
var live = this.getSingleQueryVariable('live')
4041

4142
if (urlSite !== false) {
4243
L_.FUTURES.site = urlSite
@@ -176,6 +177,11 @@ var QueryURL = {
176177
}
177178
}
178179

180+
if (live !== false) {
181+
const liveStr = (live + '').toLowerCase()
182+
L_.FUTURES.live = liveStr === 'true' || liveStr === '1'
183+
}
184+
179185
if (layersOn !== false || selected !== false) {
180186
L_.FUTURES.customOn = true
181187
// lists all the on layers
@@ -400,6 +406,8 @@ var QueryURL = {
400406
urlAppendage += '&startTime=' + TimeControl.startTime
401407
if (TimeControl.endTime)
402408
urlAppendage += '&endTime=' + TimeControl.endTime
409+
if (TimeControl.timeUI && typeof TimeControl.timeUI.now === 'boolean')
410+
urlAppendage += '&live=' + (TimeControl.timeUI.now ? '1' : '0')
403411
}
404412

405413
var url = encodeURI(urlAppendage)

src/essence/Ancillary/TimeUI.css

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,7 @@
179179
text-transform: capitalize;
180180
color: var(--color-a5);
181181
}
182-
#mmgisTimeUIStartWrapper {
183-
}
184-
#mmgisTimeUIEndWrapper {
185-
}
182+
/* Start/End wrappers intentionally left for future styling hooks */
186183
#mmgisTimeUIActionsLeft,
187184
#mmgisTimeUIActionsRight {
188185
background: var(--color-a);
@@ -296,6 +293,28 @@
296293
transition: color 0.2s ease-out;
297294
}
298295

296+
/* Live (Present) progress indicator */
297+
#mmgisTimeUIPresent {
298+
position: relative;
299+
overflow: hidden;
300+
margin: 3px;
301+
width: 34px;
302+
height: 34px;
303+
}
304+
#mmgisTimeUIPresentProgress {
305+
position: absolute;
306+
left: 0;
307+
bottom: 0;
308+
height: 3px;
309+
width: 0;
310+
background: #dcc565;
311+
opacity: 0;
312+
transition: width var(--live-duration, 1000ms) linear;
313+
}
314+
#mmgisTimeUIPresent.live #mmgisTimeUIPresentProgress {
315+
opacity: 0.9;
316+
}
317+
299318
#mmgisTimeUIFitTime:hover,
300319
#mmgisTimeUIFitWindow:hover,
301320
#mmgisTimeUIPresent:hover {
@@ -386,3 +405,12 @@
386405
transition: opacity 0.2s ease-out;
387406
z-index: -1;
388407
}
408+
409+
/* Subtle tick flash on Live update (title text) */
410+
#mmgisTimeUIEndWrapper > span.flash {
411+
animation: mmgis-time-text-flash 0.35s ease-out;
412+
}
413+
@keyframes mmgis-time-text-flash {
414+
0% { color: var(--color-p4); }
415+
100% { color: var(--color-h); }
416+
}

src/essence/Ancillary/TimeUI.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const TimeUI = {
116116
`</div>`,
117117
`<div id="mmgisTimeUIPresent" class="mmgisTimeUIButton">`,
118118
`<i class='mdi mdi-clock-end mdi-24px'></i>`,
119+
`<div id="mmgisTimeUIPresentProgress"></div>`,
119120
`</div>`,
120121
`</div>`,
121122
/*
@@ -443,6 +444,8 @@ const TimeUI = {
443444
placement: 'top',
444445
theme: 'blue',
445446
})
447+
// Initialize live progress duration on load
448+
TimeUI._refreshLiveProgress()
446449

447450
if (L_.configData.time?.startInPointMode == true) {
448451
TimeUI.modeIndex = TimeUI.modes.indexOf('Point')
@@ -516,6 +519,7 @@ const TimeUI = {
516519
Dropy.init($('#mmgisTimeUIRateDropdown'), function (idx) {
517520
TimeUI.intervalIndex = idx
518521
TimeUI._refreshIntervals()
522+
TimeUI._refreshLiveProgress()
519523
})
520524

521525
// Interval Duration dropdown
@@ -730,6 +734,17 @@ const TimeUI = {
730734
// Set modeIndex to 1/Point if a deeplink had an endtime but no starttime
731735
else if (TimeUI.modeIndex != TimeUI._startingModeIndex)
732736
TimeUI.changeMode(TimeUI._startingModeIndex)
737+
738+
// Enable live (present) based on deeplink override, else config default
739+
const deeplinkLive = L_.FUTURES?.live
740+
if (TimeUI.now !== true) {
741+
if (deeplinkLive === true) {
742+
TimeUI.toggleTimeNow(true)
743+
} else if (deeplinkLive == null && L_.configData.time?.liveByDefault === true) {
744+
TimeUI.toggleTimeNow(true)
745+
}
746+
}
747+
TimeUI._refreshLiveProgress()
733748
},
734749
changeMode(idx) {
735750
TimeUI.modeIndex = idx
@@ -865,6 +880,7 @@ const TimeUI = {
865880
$('#mmgisTimeUIEndWrapper').css('cursor', 'inherit')
866881
}
867882
if (butDontActuallyPlay !== true) TimeUI._refreshIntervals()
883+
TimeUI._refreshLiveProgress()
868884
},
869885
_updateExtentIndicator(forceStartTimestamp, forceEndTimestamp) {
870886
if (TimeUI.play) return
@@ -917,6 +933,35 @@ const TimeUI = {
917933
TimeUI.intervalValues[TimeUI.intervalIndex]
918934
)
919935
}
936+
TimeUI._refreshLiveProgress()
937+
},
938+
_refreshLiveProgress() {
939+
const dur = TimeUI.intervalValues[TimeUI.intervalIndex] || 1000
940+
const present = $('#mmgisTimeUIPresent')
941+
const progress = $('#mmgisTimeUIPresentProgress')
942+
progress.css('--live-duration', `${dur}ms`)
943+
if (TimeUI.now === true) {
944+
present.addClass('live')
945+
progress.css('opacity', 0.9)
946+
TimeUI._restartLiveProgressTransition()
947+
} else {
948+
present.removeClass('live')
949+
progress.css('opacity', 0)
950+
progress.css('transition', 'none')
951+
progress.css('width', '0')
952+
}
953+
},
954+
_restartLiveProgressTransition() {
955+
const dur = TimeUI.intervalValues[TimeUI.intervalIndex] || 1000
956+
const progress = $('#mmgisTimeUIPresentProgress')
957+
// Reset width to 0 without transition, then animate to 100%
958+
progress.css('transition', 'none')
959+
progress.css('width', '0')
960+
// Force reflow to apply width reset before re-enabling transition
961+
const _ = progress.get(0) && progress.get(0).offsetWidth
962+
progress.css('transition', `width ${dur}ms linear`)
963+
// Kick off the ramp
964+
progress.css('width', '100%')
920965
},
921966
_loopTime(loopBackwards) {
922967
const mode = TimeUI.modes[TimeUI.modeIndex]
@@ -1025,6 +1070,8 @@ const TimeUI = {
10251070
.css('color', 'white')
10261071
$('#mmgisTimeUIEnd').css('pointer-events', 'none')
10271072
$('#mmgisTimeUIEndWrapper').css('cursor', 'not-allowed')
1073+
// Rename label to Live Time
1074+
$('#mmgisTimeUIEndWrapper > span').text('Live Time')
10281075
TimeUI.now = true
10291076
TimeUI.togglePlay(false)
10301077
} else {
@@ -1034,6 +1081,8 @@ const TimeUI = {
10341081
.css('color', 'var(--color-a4)')
10351082
$('#mmgisTimeUIEnd').css('pointer-events', 'inherit')
10361083
$('#mmgisTimeUIEndWrapper').css('cursor', 'inherit')
1084+
// Restore label to Active Time
1085+
$('#mmgisTimeUIEndWrapper > span').text('Active Time')
10371086
TimeUI.now = false
10381087
}
10391088
TimeUI._refreshIntervals()
@@ -1310,6 +1359,17 @@ const TimeUI = {
13101359
TimeUI.setCurrentTime(parsedNow, disableChange)
13111360
//TimeUI._remakeTimeSlider(true)
13121361
TimeUI.endTempus.dates.setValue(parsedNow)
1362+
// Subtle tick flash indicator when live updates (title text)
1363+
if (TimeUI.now === true) {
1364+
const endLabel = $('#mmgisTimeUIEndWrapper > span')
1365+
endLabel.addClass('flash')
1366+
clearTimeout(TimeUI._flashTimeout)
1367+
TimeUI._flashTimeout = setTimeout(() => {
1368+
endLabel.removeClass('flash')
1369+
}, 600)
1370+
// Restart progress bar exactly on tick
1371+
TimeUI._restartLiveProgressTransition()
1372+
}
13131373
}
13141374
},
13151375
updateTimes(start, end, current) {

src/essence/Basics/Layers_/Layers_.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3200,7 +3200,7 @@ const L_ = {
32003200
layerConfig.type === 'vector' &&
32013201
layerConfig.time.type === 'local' &&
32023202
layerConfig.time.endProp != null &&
3203-
layer != false &&
3203+
layer != false && layer != null &&
32043204
layer._sourceGeoJSON != null
32053205
) {
32063206
const filteredGeoJSON = JSON.parse(

0 commit comments

Comments
 (0)