Skip to content

Commit

Permalink
[Frontend] Merge latest from open933
Browse files Browse the repository at this point in the history
Fixes #933
Resolve conflicts in
mode-menu.html, mode-selector.html,
time-conductor.html; apply tweaks, language, etc.
  • Loading branch information
charlesh88 committed Jul 11, 2016
2 parents 0a0bc55 + 4e7b69c commit 7b19f91
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,15 @@
<div class="contents">
<div class="pane left menu-items">
<ul>
<li ng-click="representation.mode='fixed'">
<li ng-repeat="option in ngModel.options"
ng-click="ngModel.selected=option.key">
<a
ng-mouseover="representation.activeMetadata = {
glyph: '\ue604',
name: 'Fixed Timespan Mode',
description: 'Query and explore data that falls between two fixed dates.'
}"
ng-mouseover="representation.activeMetadata = option"
ng-mouseleave="representation.activeMetadata = undefined">
<span class="ui-symbol icon type-icon">
&#xe604;
{{option.glyph}}
</span>
Fixed Timespan Mode
</a>
</li>
<li ng-click="representation.mode='realtime'">
<a
ng-mouseover="representation.activeMetadata = {
glyph: '\u0043',
name: 'Real-time Mode',
description: 'Monitor real-time streaming data as it comes in. The Time Conductor will automatically advance itself based on a UTC clock.'
}"
ng-mouseleave="representation.activeMetadata = undefined">
<span class="ui-symbol icon type-icon">
&#x43;
</span>
Real-time Mode
</a>
</li>
<li ng-click="representation.mode='latest'">
<a
ng-mouseover="representation.activeMetadata = {
glyph: '\u0044',
name: 'Latest Available Data Mode',
description: 'Monitor real-time streaming data as it comes in. The Time Conductor will only advance when data becomes available.'
}"
ng-mouseleave="representation.activeMetadata = undefined">
<span class="ui-symbol icon type-icon">
&#x44;
</span>
Latest Available Data Mode
{{option.name}}
</a>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
}
.super-menu.mode-selector-menu {
height: 200px;
bottom: 0px;
}
.super-menu.mode-selector-menu .menu-item-description .desc-area.icon {
height: 20%;
Expand All @@ -38,12 +39,13 @@
<span ng-controller="ClickAwayController as modeController">
<div class="s-menu-btn"
ng-click="modeController.toggle()">
<span class="title-label">Historical Data Mode</span>
<span class="title-label">{{ngModel.selected}}</span>
</div>
<div class="menu super-menu mini mode-selector-menu"
ng-show="modeController.isActive()">
<mct-representation mct-object="domainObject"
key="'mode-menu'">
key="'mode-menu'"
ng-model="ngModel">
</mct-representation>
</div>
</span>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Parent holder for time conductor. follow-mode | fixed-mode -->
<div class="l-time-conductor follow-mode"
ng-controller="TimeConductorController as tcController" class="l-flex-col">
<div ng-controller="TimeConductorController as tcController"
class="l-time-conductor l-flex-col" ng-class="{'follow-mode': followMode}">
<!-- Holds inputs and ticks -->
<div class="l-time-conductor-ticks l-row-elem l-flex-row flex-elem no-margin">
<form class="abs l-time-conductor-inputs-holder"
Expand Down Expand Up @@ -30,7 +30,7 @@
class="time-range-end">
</mct-control>
</span>
<input type="submit" class="hidden">
<input type="submit" class="hidden">
</form>
<mct-conductor-axis></mct-conductor-axis>
</div>
Expand All @@ -43,6 +43,7 @@
<mct-representation
key="'mode-selector'"
mct-object="domainObject"
ng-model="modeModel"
class="holder flex-elem menus-up mode-selector">
</mct-representation>
<mct-control
Expand Down
87 changes: 80 additions & 7 deletions platform/features/conductor-v2/src/TimeConductorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ define(
var SIX_HOURS = 6 * 60 * 60 * 1000;

function TimeConductorController($scope, $timeout, conductor) {
var now = Date.now();
var self = this;

this.$scope = $scope;
this.$timeout = $timeout;
this.conductor = conductor;

$scope.formModel = {};
$scope.modeSelector = {
value: 'fixed'
};

conductor.on('bounds', function (bounds) {
$scope.formModel = {
Expand All @@ -42,19 +45,52 @@ define(
};
});

//Temporary workaround for resizing issue
$timeout(function() {
//Set the time conductor to some default
conductor.bounds({start: now - SIX_HOURS, end: now});
}, 1000);
conductor.on('follow', function (follow){
$scope.followMode = follow;
});

Object.keys(TimeConductorController.prototype).filter(function (key){
Object.keys(TimeConductorController.prototype).filter(function (key) {
return typeof TimeConductorController.prototype[key] === 'function';
}).forEach(function (key) {
self[key] = self[key].bind(self);
});

//Temporary workaround for resizing issue
$timeout(self.initialize, 1000);

$scope.$watch('modeModel.selected', this.switchMode);

$scope.modeModel = {
selected: 'fixed',
options: [
{
key: 'fixed',
glyph: '\ue604',
name: 'Fixed Time-Span',
description: 'Display data that falls between two fixed dates'
},
{
key: 'realtime',
glyph: '\u0043',
name: 'Real-time Mode',
description: 'Monitor real-time streaming data as it comes in to the application. The Time Conductor will automatically advance itself based on a UTC clock.'
},
{
key: 'latest',
glyph: '\u0044',
name: 'Latest Available Data',
description: 'Monitor real-time streaming data as it comes in to the application. In contrast to real-time mode the time conductor will only advance when data becomes available.'
}
]
}
}

TimeConductorController.prototype.initialize = function () {
var now = Math.ceil(Date.now() / 1000) * 1000;
//Set the time conductor to some default
this.conductor.bounds({start: now - SIX_HOURS, end: now});
};

TimeConductorController.prototype.validateStart = function (start) {
var bounds = this.conductor.bounds();
return this.conductor.validateBounds({start: start, end: bounds.end}) === true;
Expand All @@ -73,6 +109,43 @@ define(
}
};

TimeConductorController.prototype.switchMode = function (newMode) {
if (this.mode) {
this.mode();
}
this.mode = TimeConductorController.modes[newMode].call(this, this.conductor);
};

TimeConductorController.modes = {
'fixed': function (conductor) {
conductor.follow(false);
},
'realtime': function (conductor) {
var tickInterval = 1000;
var $timeout = this.$timeout;
var timeoutPromise = $timeout(tick, tickInterval);

conductor.follow(true);

function tick() {
var bounds = conductor.bounds();
var interval = bounds.end - bounds.start;
var now = Math.ceil(Date.now() / 1000) * 1000;
conductor.bounds({start: now - interval, end: now});

timeoutPromise = $timeout(tick, tickInterval)
}

return function destroy() {
$timeout.cancel(timeoutPromise);
}
},
'latest': function (conductor) {
//Don't know what to do here yet...
conductor.follow(true);
}
};

return TimeConductorController;
}
);

0 comments on commit 7b19f91

Please sign in to comment.