Skip to content

Commit d96a6a5

Browse files
committed
refactor: moved timepicker from a simple panel to component, removed simple panel directive
1 parent 7535677 commit d96a6a5

File tree

21 files changed

+208
-344
lines changed

21 files changed

+208
-344
lines changed

public/app/controllers/signupCtrl.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
///<reference path="../headers/common.d.ts" />
2-
///<amd-dependency path="config" name="config" />
32

43
import angular = require('angular');
5-
declare var config : any;
4+
import config = require('config');
65

76
var module = angular.module('grafana.controllers');
87

public/app/core/directives/array_join.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import angular = require('angular');
44
import _ = require('lodash');
55

6-
export function ArrayJoin() {
6+
export function arrayJoin() {
77
'use strict';
88

99
return {
@@ -29,5 +29,5 @@ export function ArrayJoin() {
2929
};
3030
}
3131

32-
angular.module('grafana.directives').directive('arrayJoin', ArrayJoin);
32+
angular.module('grafana.directives').directive('arrayJoin', arrayJoin);
3333

public/app/directives/grafanaSimplePanel.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

public/app/features/dashboard/all.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ define([
1616
'./timeSrv',
1717
'./unsavedChangesSrv',
1818
'./directives/dashSearchView',
19+
'./timepicker/timepicker',
1920
'./graphiteImportCtrl',
2021
'./dynamicDashboardSrv',
2122
'./importCtrl',

public/app/features/dashboard/dashboardSrv.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function (angular, $, kbn, _, moment) {
3131
this.hideControls = data.hideControls || false;
3232
this.sharedCrosshair = data.sharedCrosshair || false;
3333
this.rows = data.rows || [];
34-
this.nav = data.nav || [];
34+
this.timepicker = data.timepicker || {};
3535
this.time = data.time || { from: 'now-6h', to: 'now' };
3636
this.templating = this._ensureListExist(data.templating);
3737
this.annotations = this._ensureListExist(data.annotations);
@@ -40,11 +40,6 @@ function (angular, $, kbn, _, moment) {
4040
this.schemaVersion = data.schemaVersion || 0;
4141
this.version = data.version || 0;
4242
this.links = data.links || [];
43-
44-
if (this.nav.length === 0) {
45-
this.nav.push({ type: 'timepicker' });
46-
}
47-
4843
this._updateSchema(data);
4944
this._initMeta(meta);
5045
}
@@ -232,9 +227,9 @@ function (angular, $, kbn, _, moment) {
232227
var i, j, k;
233228
var oldVersion = this.schemaVersion;
234229
var panelUpgrades = [];
235-
this.schemaVersion = 6;
230+
this.schemaVersion = 7;
236231

237-
if (oldVersion === 6) {
232+
if (oldVersion === 7) {
238233
return;
239234
}
240235

@@ -329,6 +324,11 @@ function (angular, $, kbn, _, moment) {
329324
}
330325
}
331326

327+
if (oldVersion < 7 && old.nav && old.nav.length) {
328+
this.timepicker = old.nav[0];
329+
delete this.nav;
330+
}
331+
332332
if (panelUpgrades.length === 0) {
333333
return;
334334
}

public/app/features/dashboard/partials/dashboardTopNav.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@
6161
Back to dashboard
6262
</a>
6363
</li>
64-
<li ng-repeat="pulldown in dashboard.nav" ng-controller="PulldownCtrl" ng-show="pulldown.enable">
65-
<grafana-simple-panel type="pulldown.type" ng-cloak>
66-
</grafana-simple-panel>
64+
<li ng-if="dashboard">
65+
<gf-time-picker></gf-time-picker>
6766
</li>
6867
</ul>
6968
</div>

public/app/features/dashboard/partials/settings.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
</div>
66

77
<div ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
8-
<div ng-repeat="tab in ['General', 'Rows', 'Links']" data-title="{{tab}}">
9-
</div>
10-
<div ng-repeat="tab in dashboard.nav" data-title="{{tab.type}}">
8+
<div ng-repeat="tab in ['General', 'Rows', 'Links', 'Time picker']" data-title="{{tab}}">
119
</div>
1210
</div>
1311

@@ -40,7 +38,7 @@ <h5>Dashboard info</h5>
4038
</ul>
4139
<div class="clearfix"></div>
4240
</div>
43-
<div class="tight-form">
41+
<div class="tight-form last">
4442
<ul class="tight-form-list">
4543
<li class="tight-form-item" style="width: 90px">
4644
Timezone
@@ -110,9 +108,8 @@ <h5>Rows settings</h5>
110108
<dash-links-editor></dash-links-editor>
111109
</div>
112110

113-
<div ng-repeat="pulldown in dashboard.nav" ng-controller="SubmenuCtrl" ng-show="editor.index == 3+$index">
114-
<ng-include ng-show="pulldown.enable" src="pulldownEditorPath(pulldown.type)"></ng-include>
115-
<button ng-hide="pulldown.enable" class="btn" ng-click="pulldown.enable = true">Enable the {{pulldown.type}}</button>
111+
<div ng-if="editor.index == 3">
112+
<gf-time-picker-settings></gf-time-picker-settings>
116113
</div>
117114

118115
</div>
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<div class="editor-row">
2+
<div class="section">
3+
<div>
4+
<div class="tight-form">
5+
<ul class="tight-form-list">
6+
<li class="tight-form-item" style="width: 118px">
7+
Relative times
8+
</li>
9+
<li>
10+
<input type="text" class="input-xlarge tight-form-input last" style="width: 450px" ng-model="panel.time_options" array-join>
11+
</li>
12+
</ul>
13+
<div class="clearfix"></div>
14+
</div>
15+
<div class="tight-form">
16+
<ul class="tight-form-list">
17+
<li class="tight-form-item" style="width: 118px">
18+
Auto-refresh
19+
</li>
20+
<li>
21+
<input type="text" class="input-xlarge tight-form-input last" style="width: 450px" ng-model="panel.refresh_intervals" array-join>
22+
</li>
23+
</ul>
24+
<div class="clearfix"></div>
25+
</div>
26+
27+
<div class="tight-form last">
28+
<ul class="tight-form-list">
29+
<li class="tight-form-item" style="width: 118px">
30+
Now delay
31+
</li>
32+
<li class="tight-form-item">
33+
now-
34+
</li>
35+
<li>
36+
<input type="text" class="input-mini tight-form-input last"
37+
ng-model="panel.nowDelay" placeholder="0m"
38+
valid-time-span
39+
bs-tooltip="'Enter 1m to ignore the last minute (because it can contain incomplete metrics)'"
40+
data-placement="right">
41+
</li>
42+
43+
</ul>
44+
<div class="clearfix"></div>
45+
</div>
46+
47+
</div>
48+
49+
<p>
50+
<br>
51+
<i class="fa fa-info-circle"></i>
52+
For these changes to fully take effect save and reload the dashboard.
53+
</i>
54+
</div>
55+
</div>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<style>
2+
.timepicker-timestring {
3+
font-weight: normal;
4+
}
5+
6+
.timepicker-dropdown {
7+
margin: 0px !important;
8+
border: 0px !important;
9+
}
10+
</style>
11+
<form name="input" style="margin:0">
12+
<ul class="nav timepicker-dropdown">
13+
14+
<li class="grafana-menu-zoom-out">
15+
<a class='small' ng-click='zoom(2)'>
16+
Zoom Out
17+
</a>
18+
</li>
19+
20+
<li class="dropdown">
21+
22+
<a class="dropdown-toggle timepicker-dropdown" data-toggle="dropdown" bs-tooltip="time.tooltip" data-placement="bottom" ng-click="loadTimeOptions();">
23+
<i class="fa fa-clock-o"></i>
24+
<span ng-bind="time.rangeString"></span>
25+
<span ng-show="dashboard.refresh" class="text-warning">refreshed every {{dashboard.refresh}} </span>
26+
<i class="fa fa-caret-down"></i>
27+
</a>
28+
29+
<!-- lacy load this -->
30+
<ul class="dropdown-menu" ng-if="time_options" >
31+
<li bindonce ng-repeat='option in time_options'>
32+
<a ng-click="setRelativeFilter(option)" bo-text="option.text"></a>
33+
</li>
34+
35+
<!-- Auto refresh submenu -->
36+
<li class="dropdown-submenu">
37+
<a href="#">Auto-Refresh</a>
38+
<ul class="dropdown-menu" ng-class="{'dropdown-submenu-left': refreshMenuLeftSide}">
39+
<li>
40+
<a ng-click="timeSrv.set_interval(false)">Off</a>
41+
</li>
42+
<li bindonce ng-repeat="interval in panel.refresh_intervals track by $index">
43+
<a ng-click="timeSrv.set_interval(interval)" bo-text="'Every ' + interval"></a>
44+
</li>
45+
</ul>
46+
</li>
47+
<li><a ng-click="customTime()">Custom</a></li>
48+
</ul>
49+
50+
</li>
51+
<li ng-show="!dashboard.refresh" class="grafana-menu-refresh">
52+
<a ng-click="timeSrv.refreshDashboard()"><i class="fa fa-refresh"></i></a>
53+
</li>
54+
</ul>
55+
</form>
56+
</div>

0 commit comments

Comments
 (0)