Просмотр исходного кода

Added new config setting timezoneOffset, usefull when your graphite server is on a different timezone thant your users browsers. This is not optimal (for example if your users have different timezones) can be improved by finding a way to query the timezone different between browser and graphite server. Or fix so that the &tz graphite parameter works for json, then all absolute filters can use UTC time. #31

Torkel Ödegaard 12 лет назад
Родитель
Сommit
58dbb01e76

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
     "company": "Coding Instinct AB"
   },
   "name": "grafana",
-  "version": "1.0.3",
+  "version": "1.0.4",
   "repository": {
     "type": "git",
     "url": "http://github.com/torkelo/grafana.git"

+ 2 - 1
src/app/components/settings.js

@@ -17,7 +17,8 @@ function (_, crypto) {
       graphiteUrl       : "http://"+window.location.hostname+":8080",
       panel_names       : [],
       default_route     : '/dashboard/file/default.json',
-      grafana_index     : 'grafana-dash'
+      grafana_index     : 'grafana-dash',
+      timezoneOffset    : null,
     };
 
     // This initializes a new hash on purpose, to avoid adding parameters to

+ 4 - 0
src/app/panels/graphite/styleEditor.html

@@ -1,6 +1,10 @@
 <div class="editor-row">
   <div class="section">
     <h5>Chart Options</h5>
+    <div class="editor-option">
+        <label class="small">Time correction</label>
+        <select ng-model="panel.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
+    </div>
     <div class="editor-option">
       <label class="small">Bars</label><input type="checkbox" ng-model="panel.bars" ng-checked="panel.bars" ng-change="render()">
     </div>

+ 7 - 1
src/app/services/graphite/graphiteSrv.js

@@ -52,7 +52,13 @@ function (angular, _, $, config, kbn) {
         date = kbn.parseDate(date);
       }
 
-      return $.plot.formatDate(date, '%H%:%M_%Y%m%d');
+      date = moment.utc(date).local();
+
+      if (config.timezoneOffset) {
+        date = date.zone(config.timezoneOffset)
+      }
+
+      return date.format('HH:mm_YYYYMMDD');
     };
 
     this.match = function(targets, graphiteTargetStr) {

+ 6 - 0
src/config.js

@@ -20,6 +20,12 @@ function (Settings) {
 
     default_route: '/dashboard/file/default.json',
 
+    /**
+     * If your graphite server has another timezone than you & users browsers specify the offset here
+     * Example: "-0500" (for UTC - 5 hours)
+     */
+    timezoneOffset: null,
+
     grafana_index: "grafana-dash",
 
     panel_names: [

Разница между файлами не показана из-за своего большого размера
+ 642 - 139
src/vendor/moment.js


Некоторые файлы не были показаны из-за большого количества измененных файлов