grafana 303 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. commit 882ee4d49f1df4550e898a914b4d17d40add4ddf
  2. Author: Torkel Ödegaard <torkel.odegaard@gmail.com>
  3. Date: Wed Feb 4 11:35:19 2015 +0100
  4. A start on a dashboard list panel, can now list starred dashboards
  5. diff --git a/src/app/components/settings.js b/src/app/components/settings.js
  6. index bf5f3adcb..7e896b475 100644
  7. --- a/src/app/components/settings.js
  8. +++ b/src/app/components/settings.js
  9. @@ -16,23 +16,19 @@ function (_, crypto) {
  10. datasources : {},
  11. window_title_prefix : 'Grafana - ',
  12. panels : {
  13. - 'graph': { path: 'panels/graph' },
  14. - 'singlestat': { path: 'panels/singlestat' },
  15. - 'text': { path: 'panels/text' },
  16. - 'starred': { path: 'panels/starred', hide: true },
  17. + 'graph': { path: 'panels/graph', name: 'Graph' },
  18. + 'singlestat': { path: 'panels/singlestat', name: 'Single stat' },
  19. + 'text': { path: 'panels/text', name: 'Text' },
  20. + 'dashlist': { path: 'panels/dashlist', name: 'Dashboard list' },
  21. },
  22. - plugins : {},
  23. - default_route : '/dashboard/file/default.json',
  24. - playlist_timespan : "1m",
  25. - unsaved_changes_warning : true,
  26. - search : { max_results: 100 },
  27. - admin : {},
  28. - appSubUrl: "",
  29. - buildInfo: {
  30. - version: 'master',
  31. - commit: 'NA',
  32. - buildstamp: new Date().getTime()
  33. - }
  34. + new_panel_title: 'no title (click here)',
  35. + plugins: {},
  36. + default_route: '/dashboard/file/default.json',
  37. + playlist_timespan: "1m",
  38. + unsaved_changes_warning: true,
  39. + search: { max_results: 100 },
  40. + admin: {},
  41. + appSubUrl: ""
  42. };
  43. var settings = _.extend({}, defaults, options);
  44. diff --git a/src/app/features/dashboard/dashboardCtrl.js b/src/app/features/dashboard/dashboardCtrl.js
  45. index ef3db1228..fe41dcccf 100644
  46. --- a/src/app/features/dashboard/dashboardCtrl.js
  47. +++ b/src/app/features/dashboard/dashboardCtrl.js
  48. @@ -4,7 +4,7 @@ define([
  49. 'config',
  50. 'lodash',
  51. ],
  52. -function (angular, $, config, _) {
  53. +function (angular, $, config) {
  54. "use strict";
  55. var module = angular.module('grafana.controllers');
  56. @@ -20,11 +20,11 @@ function (angular, $, config, _) {
  57. $timeout) {
  58. $scope.editor = { index: 0 };
  59. - $scope.panelNames = _.map(config.panels, function(value, key) { return key; });
  60. + $scope.panels = config.panels;
  61. +
  62. var resizeEventTimeout;
  63. this.init = function(dashboard) {
  64. - $scope.availablePanels = config.panels;
  65. $scope.reset_row();
  66. $scope.registerWindowResizeEvent();
  67. $scope.onAppEvent('show-json-editor', $scope.showJsonEditor);
  68. diff --git a/src/app/features/dashboard/rowCtrl.js b/src/app/features/dashboard/rowCtrl.js
  69. index dfd602751..bf10d9842 100644
  70. --- a/src/app/features/dashboard/rowCtrl.js
  71. +++ b/src/app/features/dashboard/rowCtrl.js
  72. @@ -1,9 +1,10 @@
  73. define([
  74. 'angular',
  75. 'app',
  76. - 'lodash'
  77. + 'lodash',
  78. + 'config'
  79. ],
  80. -function (angular, app, _) {
  81. +function (angular, app, _, config) {
  82. 'use strict';
  83. var module = angular.module('grafana.controllers');
  84. @@ -107,11 +108,11 @@ function (angular, app, _) {
  85. var _as = 12 - $scope.dashboard.rowSpan($scope.row);
  86. $scope.panel = {
  87. - title: 'no title (click here)',
  88. - error : false,
  89. - span : _as < defaultSpan && _as > 0 ? _as : defaultSpan,
  90. + title: config.new_panel_title,
  91. + error: false,
  92. + span: _as < defaultSpan && _as > 0 ? _as : defaultSpan,
  93. editable: true,
  94. - type : type
  95. + type: type
  96. };
  97. function fixRowHeight(height) {
  98. diff --git a/src/app/features/panel/panelSrv.js b/src/app/features/panel/panelSrv.js
  99. index 2f475c249..88f53e5ed 100644
  100. --- a/src/app/features/panel/panelSrv.js
  101. +++ b/src/app/features/panel/panelSrv.js
  102. @@ -1,8 +1,9 @@
  103. define([
  104. 'angular',
  105. 'lodash',
  106. + 'config',
  107. ],
  108. -function (angular, _) {
  109. +function (angular, _, config) {
  110. 'use strict';
  111. var module = angular.module('grafana.services');
  112. @@ -77,6 +78,10 @@ function (angular, _) {
  113. $scope.editorHelpIndex = index;
  114. };
  115. + $scope.isNewPanel = function() {
  116. + return $scope.panel.title === config.new_panel_title;
  117. + };
  118. +
  119. $scope.toggleFullscreen = function(edit) {
  120. $scope.dashboardViewState.update({ fullscreen: true, edit: edit, panelId: $scope.panel.id });
  121. };
  122. diff --git a/src/app/panels/dashlist/module.html b/src/app/panels/dashlist/module.html
  123. new file mode 100644
  124. index 000000000..3ecf6372f
  125. --- /dev/null
  126. +++ b/src/app/panels/dashlist/module.html
  127. @@ -0,0 +1,13 @@
  128. +<grafana-panel>
  129. + <div class="dashlist">
  130. + <div class="dashlist-item" ng-repeat="dash in dashList">
  131. + <a class="dashlist-link" href="{{dash.url}}">
  132. + <span class="dashlist-title">
  133. + {{dash.title}}
  134. + </span>
  135. + <span class="dashlist-star">
  136. + <i class="fa fa-star"></i>
  137. + </span>
  138. + </a>
  139. + </div>
  140. +</grafana-panel>
  141. diff --git a/src/app/panels/dashlist/module.js b/src/app/panels/dashlist/module.js
  142. new file mode 100644
  143. index 000000000..829816967
  144. --- /dev/null
  145. +++ b/src/app/panels/dashlist/module.js
  146. @@ -0,0 +1,56 @@
  147. +define([
  148. + 'angular',
  149. + 'app',
  150. + 'lodash',
  151. + 'config',
  152. + 'components/panelmeta',
  153. +],
  154. +function (angular, app, _, config, PanelMeta) {
  155. + 'use strict';
  156. +
  157. + var module = angular.module('grafana.panels.dashlist', []);
  158. + app.useModule(module);
  159. +
  160. + module.directive('grafanaPanelDashlist', function() {
  161. + return {
  162. + controller: 'DashListPanelCtrl',
  163. + templateUrl: 'app/panels/dashlist/module.html',
  164. + };
  165. + });
  166. +
  167. + module.controller('DashListPanelCtrl', function($scope, panelSrv, backendSrv) {
  168. +
  169. + $scope.panelMeta = new PanelMeta({
  170. + panelName: 'Dash list',
  171. + editIcon: "fa fa-star",
  172. + fullscreen: true,
  173. + });
  174. +
  175. + var defaults = {
  176. + };
  177. +
  178. + _.defaults($scope.panel, defaults);
  179. +
  180. + $scope.dashList = [];
  181. +
  182. + $scope.init = function() {
  183. + panelSrv.init($scope);
  184. +
  185. +
  186. + if ($scope.isNewPanel()) {
  187. + $scope.panel.title = "Starred Dashboards";
  188. + }
  189. +
  190. + $scope.$on('refresh', $scope.get_data);
  191. + };
  192. +
  193. + $scope.get_data = function() {
  194. + backendSrv.get('/api/search', { starred: 1 }).then(function(result) {
  195. + $scope.dashList = result.dashboards;
  196. + $scope.panelMeta.loading = false;
  197. + });
  198. + };
  199. +
  200. + $scope.init();
  201. + });
  202. +});
  203. diff --git a/src/app/panels/starred/module.html b/src/app/panels/starred/module.html
  204. deleted file mode 100644
  205. index afc74b1e8..000000000
  206. --- a/src/app/panels/starred/module.html
  207. +++ /dev/null
  208. @@ -1,3 +0,0 @@
  209. -<grafana-panel>
  210. - <h2>Starred</h2>
  211. -</grafana-panel>
  212. diff --git a/src/app/panels/starred/module.js b/src/app/panels/starred/module.js
  213. deleted file mode 100644
  214. index de012a32b..000000000
  215. --- a/src/app/panels/starred/module.js
  216. +++ /dev/null
  217. @@ -1,33 +0,0 @@
  218. -define([
  219. - 'angular',
  220. - 'app',
  221. - 'components/panelmeta',
  222. -],
  223. -function (angular, app, PanelMeta) {
  224. - 'use strict';
  225. -
  226. - var module = angular.module('grafana.panels.starred', []);
  227. - app.useModule(module);
  228. -
  229. - module.directive('grafanaPanelStarred', function() {
  230. - return {
  231. - controller: 'StarredPanelCtrl',
  232. - templateUrl: 'app/panels/starred/module.html',
  233. - };
  234. - });
  235. -
  236. - module.controller('StarredPanelCtrl', function($scope, panelSrv) {
  237. -
  238. - $scope.panelMeta = new PanelMeta({
  239. - panelName: 'Starred',
  240. - editIcon: "fa fa-star",
  241. - fullscreen: true,
  242. - });
  243. -
  244. - $scope.init = function() {
  245. - panelSrv.init($scope);
  246. - };
  247. -
  248. - $scope.init();
  249. - });
  250. -});
  251. diff --git a/src/app/partials/dashboard.html b/src/app/partials/dashboard.html
  252. index d6d9e1bde..b4c0c5179 100644
  253. --- a/src/app/partials/dashboard.html
  254. +++ b/src/app/partials/dashboard.html
  255. @@ -35,8 +35,8 @@
  256. <li class="dropdown-submenu">
  257. <a href="javascript:void(0);">Add Panel</a>
  258. <ul class="dropdown-menu">
  259. - <li bindonce ng-repeat="name in panelNames">
  260. - <a ng-click="add_panel_default(name)" bo-text="name"></a>
  261. + <li bindonce ng-repeat="(key, value) in panels">
  262. + <a ng-click="add_panel_default(key)" bo-text="value.name"></a>
  263. </li>
  264. </ul>
  265. </li>
  266. diff --git a/src/css/less/dashlist.less b/src/css/less/dashlist.less
  267. new file mode 100644
  268. index 000000000..87264a0d9
  269. --- /dev/null
  270. +++ b/src/css/less/dashlist.less
  271. @@ -0,0 +1,16 @@
  272. +.dashlist-item {
  273. +
  274. +}
  275. +
  276. +.dashlist-link {
  277. + display: block;
  278. + margin: 5px;
  279. + padding: 7px;
  280. + background-color: @grafanaTargetBackground;
  281. + border: 1px solid @grafanaTargetBorder;
  282. + .fa {
  283. + float: right;
  284. + color: @orange;
  285. + padding-top: 3px;
  286. + }
  287. +}
  288. diff --git a/src/css/less/grafana.less b/src/css/less/grafana.less
  289. index 15bef4201..e55cc6aca 100644
  290. --- a/src/css/less/grafana.less
  291. +++ b/src/css/less/grafana.less
  292. @@ -11,6 +11,7 @@
  293. @import "sidemenu.less";
  294. @import "gfbox.less";
  295. @import "navbar.less";
  296. +@import "dashlist.less";
  297. .row-control-inner {
  298. padding:0px;
  299. diff --git a/src/css/less/navbar.less b/src/css/less/navbar.less
  300. index a96372e86..2398de3c7 100644
  301. --- a/src/css/less/navbar.less
  302. +++ b/src/css/less/navbar.less
  303. @@ -3,8 +3,8 @@
  304. }
  305. .navbar .nav>li>a {
  306. - padding: 19px 15px 8px;
  307. - .fa { font-size: 130%; }
  308. + padding: 17px 15px 11px;
  309. + .fa { font-size: 115%; }
  310. }
  311. .top-nav {
  312. @@ -12,7 +12,7 @@
  313. }
  314. .fa.top-nav-breadcrumb-icon {
  315. - margin: 17px 21px 8px 0px;
  316. + margin: 15px 21px 8px 0px;
  317. float: left;
  318. font-size: 160%;
  319. color: @textColor;
  320. @@ -37,13 +37,13 @@
  321. font-size: 150%;
  322. opacity: 0;
  323. position: absolute;
  324. - transition: opacity .25s ease-in-out;
  325. + transition: opacity .35s ease-in-out;
  326. }
  327. img {
  328. width: 30px;
  329. position: absolute;
  330. opacity: 1;
  331. - transition: opacity .25s ease-in-out;
  332. + transition: opacity .35s ease-in-out;
  333. }
  334. &:hover {
  335. .fa {
  336. @@ -58,7 +58,7 @@
  337. .top-nav-dashboards-btn {
  338. display: block;
  339. float: left;
  340. - margin: 10px 8px 5px 14px;
  341. + margin: 9px 8px 5px 14px;
  342. border-radius: 3px;
  343. font-size: 1.4em;
  344. font-weight: bold;
  345. @@ -113,7 +113,7 @@
  346. .top-nav-title {
  347. display: block;
  348. float: left;
  349. - padding: 18px 10px 10px 0px;
  350. + padding: 16px 10px 10px 0px;
  351. font-size: 1.3em;
  352. font-weight: bold;
  353. i {
  354. diff --git a/src/dashboards/home.json b/src/dashboards/home.json
  355. index c600d1b0f..15b6e5bfd 100644
  356. --- a/src/dashboards/home.json
  357. +++ b/src/dashboards/home.json
  358. @@ -1,5 +1,5 @@
  359. {
  360. - "title": "Grafana Home",
  361. + "title": "Home",
  362. "tags": [],
  363. "style": "dark",
  364. "timezone": "browser",
  365. @@ -24,13 +24,19 @@
  366. ]
  367. },
  368. {
  369. - "height": "210px",
  370. + "height": "410px",
  371. "panels": [
  372. {
  373. "id": 2,
  374. "span": 6,
  375. - "type": "starred",
  376. + "type": "dashlist",
  377. "title": "Starred dashboards"
  378. + },
  379. + {
  380. + "id": 3,
  381. + "span": 6,
  382. + "type": "dashlist",
  383. + "title": "Previously visited dashboards"
  384. }
  385. ]
  386. }