Browse Source

improved asset (css/js) build pipeline, added revision to css and js. Will remove issues related to the browser cache when upgrading grafana and improve load performance (Fixes #418)

Torkel Ödegaard 11 years ago
parent
commit
0f7a55d031
4 changed files with 5 additions and 74 deletions
  1. 2 0
      CHANGELOG.md
  2. 0 57
      src/app/panels/graphite/interval.js
  3. 1 1
      tasks/options/ngtemplates.js
  4. 2 16
      tasks/options/requirejs.js

+ 2 - 0
CHANGELOG.md

@@ -5,6 +5,8 @@ vNext
 - New config for playlist feature. Set playlist_timespan to set default playlist interval (Issue #445) - thx @rmca
 - New InfluxDB function difference add to function dropdown (PR #455)
 - Added parameter to keepLastValue graphite function definition (default 100), Closes #459
+- improved asset (css/js) build pipeline, added revision to css and js. Will remove issues related
+  to the browser cache when upgrading grafana and improve load performance (Fixes #418)
 
 # Fixes
 - Filter option loading when having muliple nested filters now works better.

+ 0 - 57
src/app/panels/graphite/interval.js

@@ -1,57 +0,0 @@
-define([
-  'kbn'
-],
-function (kbn) {
-  'use strict';
-
-  /**
-   * manages the interval logic
-   * @param {[type]} interval_string  An interval string in the format '1m', '1y', etc
-   */
-  function Interval(interval_string) {
-    this.string = interval_string;
-
-    var info = kbn.describe_interval(interval_string);
-    this.type = info.type;
-    this.ms = info.sec * 1000 * info.count;
-
-    // does the length of the interval change based on the current time?
-    if (this.type === 'y' || this.type === 'M') {
-      // we will just modify this time object rather that create a new one constantly
-      this.get = this.get_complex;
-      this.date = new Date(0);
-    } else {
-      this.get = this.get_simple;
-    }
-  }
-
-  Interval.prototype = {
-    toString: function () {
-      return this.string;
-    },
-    after: function(current_ms) {
-      return this.get(current_ms, 1);
-    },
-    before: function (current_ms) {
-      return this.get(current_ms, -1);
-    },
-    get_complex: function (current, delta) {
-      this.date.setTime(current);
-      switch(this.type) {
-      case 'M':
-        this.date.setUTCMonth(this.date.getUTCMonth() + delta);
-        break;
-      case 'y':
-        this.date.setUTCFullYear(this.date.getUTCFullYear() + delta);
-        break;
-      }
-      return this.date.getTime();
-    },
-    get_simple: function (current, delta) {
-      return current + (delta * this.ms);
-    }
-  };
-
-  return Interval;
-
-});

+ 1 - 1
tasks/options/ngtemplates.js

@@ -2,7 +2,7 @@ module.exports = function(config) {
   return {
     grafana: {
       cwd:  '<%= tempDir %>',
-      src:  'app/partials/**/*.html',
+      src:  ['app/**/*.html', '!app/panels/*/module.html'],
       dest: '<%= tempDir %>/app/components/partials.js',
       options: {
         bootstrap: function(module, script) {

+ 2 - 16
tasks/options/requirejs.js

@@ -61,9 +61,6 @@ module.exports = function(config,grunt) {
         'jquery.flot.pie',
         'angular-sanitize',
         'angular-dragdrop',
-        'panels/graphite/module',
-        'panels/text/module',
-        'panels/timepicker/module'
       ]
     }
   ];
@@ -73,19 +70,8 @@ module.exports = function(config,grunt) {
 
   // create a module for each directory in src/app/panels/
   fs.readdirSync(panelPath).forEach(function (panelName) {
-    if(!grunt.file.exists(panelPath+'/'+panelName+'/module.js')) {
-      fs.readdirSync(panelPath+"/"+panelName).forEach(function (subName) {
-        requireModules.push({
-          name: 'panels/'+panelName+'/'+subName+'/module',
-          exclude: ['app']
-        });
-      })
-    } else {
-      requireModules.push({
-        name: 'panels/'+panelName+'/module',
-        exclude: ['app']
-      });
-    }
+    requireModules[0].include.push('panels/'+panelName+'/module');
+    requireModules[0].include.push('text!panels/'+panelName+'/module.html');
   });
 
   // exclude the literal config definition from all modules