Skip to content
Snippets Groups Projects
Commit 972be70e authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #8887: various time scroll and zoom enhancements

parent 4e182af4
Branches
No related tags found
No related merge requests found
......@@ -662,26 +662,26 @@ dataControllerMod.controller('DataController',
$scope.openViewFromDatePopup = function() { $scope.viewFromDatePopupOpened = true; };
$scope.openViewToDatePopup = function() { $scope.viewToDatePopupOpened = true; };
$scope.jumpTimespanWidths = [{value:30, name:'30 Minutes'}, {value:60, name:'1 Hour'}, {value:3*60, name:'3 Hours'}, {value:6*60, name:'6 Hours'}, {value:12*60, name:'12 Hours'}, {value:24*60, name:'1 Day'}, {value:2*24*60, name:'2 Days'}, {value:3*24*60, name:'3 Days'}, {value:5*24*60, name:'5 Days'}, {value:7*24*60, name:'1 Week'}, {value:14*24*60, name:'2 Weeks'}, {value:28*24*60, name:'4 Weeks'}];
$scope.jumpTimespanWidth = $scope.jumpTimespanWidths[7];
$scope.zoomTimespans = [{value:30, name:'30 Minutes'}, {value:60, name:'1 Hour'}, {value:3*60, name:'3 Hours'}, {value:6*60, name:'6 Hours'}, {value:12*60, name:'12 Hours'}, {value:24*60, name:'1 Day'}, {value:2*24*60, name:'2 Days'}, {value:3*24*60, name:'3 Days'}, {value:5*24*60, name:'5 Days'}, {value:7*24*60, name:'1 Week'}, {value:14*24*60, name:'2 Weeks'}, {value:28*24*60, name:'4 Weeks'}, {value:1, name:'Custom (1 min)'}];
$scope.zoomTimespan = $scope.zoomTimespans[5];
$scope.jumpToNow = function() {
var floorLofarTime = dataService.floorDate(dataService.lofarTime, 1, 5);
dataService.viewTimeSpan = {
from: dataService.floorDate(new Date(floorLofarTime.getTime() - 0.33*$scope.jumpTimespanWidth.value*60*1000), 1, 5),
to: dataService.ceilDate(new Date(floorLofarTime.getTime() + 0.67*$scope.jumpTimespanWidth.value*60*1000), 1, 5)
from: dataService.floorDate(new Date(floorLofarTime.getTime() - 0.4*$scope.zoomTimespan.value*60*1000), 1, 5),
to: dataService.floorDate(new Date(floorLofarTime.getTime() + 0.6*$scope.zoomTimespan.value*60*1000), 1, 5)
};
};
$scope.jumpToNow();
//automatically select current task
$scope.selectCurrentTask = function() {
var currentTasks = dataService.tasks.filter(function(t) { return t.starttime <= dataService.viewTimeSpan.to && t.endime >= dataService.viewTimeSpan.from; });
if(currentTasks.lenght > 0) {
dataService.selected_task_id = currentTasks[0].id;
}
};
//initialize are now
$scope.jumpToNow();
$scope.jumpToSelectedTasks = function() {
$scope.jumpToSelectedTask = function() {
if(dataService.selected_task_id == undefined)
return;
......@@ -694,17 +694,20 @@ dataControllerMod.controller('DataController',
var taskDurationInMinutes = taskDurationInmsec/60000;
var viewSpanInMinutes = taskDurationInMinutes;
var fittingSpans = $scope.jumpTimespanWidths.filter(function(w) { return w.value >= taskDurationInMinutes; });
var fittingSpans = $scope.zoomTimespans.filter(function(w) { return w.value >= taskDurationInMinutes; });
if(fittingSpans.length > 0) {
$scope.jumpTimespanWidth = fittingSpans[0];
viewSpanInMinutes = $scope.jumpTimespanWidth.value;
$scope.zoomTimespan = fittingSpans[0];
//select one span larger if possible
if(fittingSpans.length > 1)
$scope.zoomTimespan = fittingSpans[1];
viewSpanInMinutes = $scope.zoomTimespan.value;
}
var focusTime = new Date(task.starttime.getTime() + 0.5*taskDurationInmsec);
dataService.viewTimeSpan = {
from: dataService.floorDate(new Date(focusTime.getTime() - 0.33*viewSpanInMinutes*60*1000), 1, 5),
to: dataService.ceilDate(new Date(focusTime.getTime() + 0.67*viewSpanInMinutes*60*1000), 1, 5)
from: dataService.floorDate(new Date(focusTime.getTime() - 0.4*viewSpanInMinutes*60*1000), 1, 5),
to: dataService.floorDate(new Date(focusTime.getTime() + 0.6*viewSpanInMinutes*60*1000), 1, 5)
};
};
......@@ -726,10 +729,13 @@ dataControllerMod.controller('DataController',
};
};
$scope.onJumpTimespanWidthChanged = function(span) {
var focusTime = dataService.floorDate(dataService.lofarTime, 1, 5);
$scope.onZoomTimespanChanged = function(span) {
var viewTimeSpanInmsec = dataService.viewTimeSpan.to.getTime() - dataService.viewTimeSpan.from.getTime();
var focusTime = new Date(dataService.viewTimeSpan.from + 0.5*viewTimeSpanInmsec);
if(dataService.selected_task_id != undefined) {
if(dataService.autoFollowNow) {
focusTime = dataService.floorDate(dataService.lofarTime, 1, 5);
} else if(dataService.selected_task_id != undefined) {
var task = dataService.taskDict[dataService.selected_task_id];
if(task) {
......@@ -738,26 +744,44 @@ dataControllerMod.controller('DataController',
}
dataService.viewTimeSpan = {
from: dataService.floorDate(new Date(focusTime.getTime() - 0.33*$scope.jumpTimespanWidth.value*60*1000)),
to: dataService.ceilDate(new Date(focusTime.getTime() + 0.67*$scope.jumpTimespanWidth.value*60*1000))
from: dataService.floorDate(new Date(focusTime.getTime() - 0.4*$scope.zoomTimespan.value*60*1000)),
to: dataService.floorDate(new Date(focusTime.getTime() + 0.6*$scope.zoomTimespan.value*60*1000))
};
};
$scope.selectZoomTimespan = function() {
var viewTimeSpanInmsec = dataService.viewTimeSpan.to.getTime() - dataService.viewTimeSpan.from.getTime();
var viewTimeSpanInMinutes = Math.round(viewTimeSpanInmsec/60000);
var foundZoomTimespan = $scope.zoomTimespans.find(function(zts) { return zts.value == viewTimeSpanInMinutes; });
if(foundZoomTimespan) {
$scope.zoomTimespan = foundZoomTimespan;
} else {
var customZoomTimespan = $scope.zoomTimespans.find(function(zts) { return zts.name.startsWith('Custom'); });
customZoomTimespan.value = viewTimeSpanInMinutes;
customZoomTimespan.name = 'Custom (' + viewTimeSpanInMinutes + ' min)';
$scope.zoomTimespan = customZoomTimespan;
}
};
$scope.$watch('dataService.viewTimeSpan.from', function() {
if(dataService.viewTimeSpan.from >= dataService.viewTimeSpan.to) {
dataService.viewTimeSpan.to = dataService.ceilDate(new Date(dataService.viewTimeSpan.from.getTime() + 60*60*1000), 1, 5);
dataService.viewTimeSpan.from = dataService.floorDate(new Date(dataService.viewTimeSpan.to.getTime() - 5*60*1000), 1, 5);
}
});
$scope.$watch('dataService.viewTimeSpan.to', function() {
if(dataService.viewTimeSpan.to <= dataService.viewTimeSpan.from) {
dataService.viewTimeSpan.from = dataService.floorDate(new Date(dataService.viewTimeSpan.to.getTime() - 60*60*1000), 1, 5);
dataService.viewTimeSpan.to = dataService.floorDate(new Date(dataService.viewTimeSpan.from.getTime() + 5*60*1000), 1, 5);
}
});
$scope.$watch('dataService.viewTimeSpan', function() {
dataService.clearTasksAndClaimsOutsideViewSpan();
dataService.getTasksAndClaimsForViewSpan();
$scope.selectZoomTimespan();
$scope.$evalAsync(function() { dataService.clearTasksAndClaimsOutsideViewSpan(); });
$scope.$evalAsync(function() { dataService.getTasksAndClaimsForViewSpan(); });
}, true);
$scope.$watch('dataService.filteredTasks', dataService.computeMinMaxTaskTimes);
......@@ -768,6 +792,18 @@ dataControllerMod.controller('DataController',
}
});
$scope.$watch('dataService.lofarTime', function() {
if(dataService.autoFollowNow && (Math.round(dataService.lofarTime.getTime()/1000))%5==0) {
$scope.jumpToNow();
}
});
$scope.$watch('dataService.autoFollowNow', function() {
if(dataService.autoFollowNow) {
$scope.jumpToNow();
}
});
dataService.initialLoad();
//clock ticking every second
......
......@@ -64,7 +64,7 @@ ganttProjectControllerMod.controller('GanttProjectController', ['$scope', 'dataS
element.bind('dblclick', function(event) {
if(directiveScope.task.model.raTask) {
$scope.dataService.selected_task_id = directiveScope.task.model.raTask.id;
$scope.jumpToSelectedTasks();
$scope.jumpToSelectedTask();
}
});
}
......
......@@ -45,7 +45,7 @@ gridControllerMod.controller('GridController', ['$scope', 'dataService', 'uiGrid
},
{ field: 'duration',
displayName: 'Duration',
width: '8%',
width: '7%',
enableFiltering: false,
enableCellEdit: false,
enableCellEditOnFocus: false,
......@@ -53,7 +53,7 @@ gridControllerMod.controller('GridController', ['$scope', 'dataService', 'uiGrid
},
{ field: 'status',
enableCellEdit: true,
width: '8%',
width: '7%',
filter: {
type: uiGridConstants.filter.SELECT,
selectOptions: []
......
......@@ -75,23 +75,15 @@
<div class="col-md-2">
<label>Scroll:</label>
<p class="input-group">
<label title="Follow 'now' automatically" style="padding-right: 4px; vertical-align: top;">auto<input type="checkbox" ng-model="dataService.autoFollowNow"></label>
<label title="Automatically scroll 'From' and 'To' to watch live events" style="padding-right: 4px; vertical-align: top;">Live <input type="checkbox" ng-model="dataService.autoFollowNow"></label>
<button title="Scroll back in time" type="button" class="btn btn-default" ng-click="scrollBack()"><i class="glyphicon glyphicon-step-backward"></i></button>
<button title="Scroll forward in time"type="button" class="btn btn-default" ng-click="scrollForward()"><i class="glyphicon glyphicon-step-forward"></i></button>
</p>
</div>
<div class="col-md-2">
<label>Jump:</label>
<label>Zoom:</label>
<p class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="jumpToSelectedTasks()" title="Jump to selected Task(s)">Task</button>
</span>
<span class="input-group-btn" style="width:10px;"></span>
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="jumpToNow()" title="Jump to Now">Now</button>
</span>
<select class="form-control" ng-model=jumpTimespanWidth ng-options="option.name for option in jumpTimespanWidths track by option.value" ng-change="onJumpTimespanWidthChanged(span)">
</select>
<select class="form-control" ng-model=zoomTimespan ng-options="option.name for option in zoomTimespans track by option.value" ng-change="onZoomTimespanChanged(span)"></select>
</p>
</div>
</div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment