feat(timepickerv2): more work on new timepicker, now absolute time mixed with relative time works, yesterday, this day last week, etc now work

This commit is contained in:
Torkel Ödegaard
2015-09-18 13:54:31 +02:00
parent cea13b1823
commit f5e6722826
5 changed files with 41 additions and 21 deletions

View File

@@ -11,17 +11,17 @@
<i class="fa fa-clock-o"></i>
<span ng-bind="ctrl.rangeString"></span>
<span ng-show="dashboard.refresh" class="text-warning">
<span ng-show="ctrl.dashboard.refresh" class="text-warning">
&nbsp;
&nbsp;
<i class="fa fa-refresh"></i>
refreshed every {{dashboard.refresh}}
Refreshed every {{ctrl.dashboard.refresh}}
</span>
</a>
</li>
<li class="grafana-menu-refresh" ng-show="!dashboard.refresh">
<a ng-click="timeSrv.refreshDashboard()">
<li class="grafana-menu-refresh" ng-show="!ctrl.dashboard.refresh">
<a ng-click="ctrl.timeSrv.refreshDashboard()">
<i class="fa fa-refresh"></i>
</a>
</li>

View File

@@ -37,21 +37,13 @@ export class TimePickerCtrl {
init() {
this.panel = this.dashboard.timepicker;
this.panel.now = false;
_.defaults(this.panel, TimePickerCtrl.defaults);
var time = this.timeSrv.timeRange();
var timeRaw = this.timeSrv.timeRange(false);
if (_.isString(timeRaw.to) && timeRaw.to.indexOf('now') === 0) {
this.panel.now = true;
this.rangeString = rangeUtil.describeTimeRange(timeRaw);
} else {
this.rangeString = this.dashboard.formatDate(time.from, TimePickerCtrl.tooltipFormat) + ' to ' +
this.dashboard.formatDate(time.to, TimePickerCtrl.tooltipFormat);
}
this.rangeString = rangeUtil.describeTimeRange(timeRaw);
this.absolute = {fromJs: time.from.toDate(), toJs: time.to.toDate()};
this.timeRaw = timeRaw;
this.tooltip = this.dashboard.formatDate(time.from) + ' <br>to<br>';