Pārlūkot izejas kodu

worked on css and js asset reving, and angular partial precaching, still need to fix panel module.html, issue #418

Torkel Ödegaard 11 gadi atpakaļ
vecāks
revīzija
f799ded434

+ 1 - 0
src/app/components/require.config.js

@@ -47,6 +47,7 @@ require.config({
     elasticjs:                '../vendor/elasticjs/elastic-angular-client',
 
     'bootstrap-tagsinput':    '../vendor/tagsinput/bootstrap-tagsinput',
+
   },
   shim: {
     underscore: {

+ 6 - 3
src/index.html

@@ -7,17 +7,20 @@
     <meta name="viewport" content="width=device-width">
 
     <title>Grafana</title>
-    <link rel="stylesheet" href="css/default.min.css" title="Light">
-    <!-- load the root require context -->
+    <link rel="stylesheet" href="css/default.min.css" title="Dark">
+
+    <!-- build:js app/app.js -->
     <script src="vendor/require/require.js"></script>
     <script src="app/components/require.config.js"></script>
+    <!-- endbuild -->
+
     <script>require(['app'], function () {})</script>
 
   </head>
 
   <body ng-cloak body-class>
 
-    <link rel="stylesheet" ng-href="css/bootstrap.{{dashboard.current.style||'dark'}}.min.css">
+    <link rel="stylesheet" href="css/bootstrap.light.min.css" ng-if="dashboard.current.style === 'light'">
     <link rel="stylesheet" href="css/bootstrap-responsive.min.css">
     <link rel="stylesheet" href="css/font-awesome.min.css">
 

+ 3 - 1
tasks/build_task.js

@@ -9,11 +9,13 @@ module.exports = function(grunt) {
     'concat:css',
     'copy:everything_but_less_to_temp',
     'htmlmin:build',
-    'ngtemplates:app',
+    'ngtemplates',
     'cssmin:build',
     'ngmin:build',
     'requirejs:build',
+    'concat:js',
     'filerev',
+    'usemin',
     'clean:temp',
     'build:write_revision',
     'uglify:dest'

+ 8 - 0
tasks/options/concat.js

@@ -10,5 +10,13 @@ module.exports = function(config) {
       ],
       dest: '<%= srcDir %>/css/default.min.css'
     },
+    js: {
+      src: [
+        '<%= destDir %>/vendor/require/require.js',
+        '<%= destDir %>/app/components/require.config.js',
+        '<%= destDir %>/app/app.js',
+      ],
+      dest: '<%= destDir %>/app/app.js'
+    },
   };
 };

+ 5 - 1
tasks/options/filerev.js

@@ -6,8 +6,12 @@ module.exports = function(config) {
       length: 8,
     },
     css: {
-      src: '<%= srcDir %>/css/default.min.css',
+      src: '<%= destDir %>/css/default.min.css',
       dest: '<%= destDir %>/css'
+    },
+    js: {
+      src: '<%= destDir %>/app/app.js',
+      dest: '<%= destDir %>/app'
     }
   };
 };

+ 1 - 1
tasks/options/htmlmin.js

@@ -8,7 +8,7 @@ module.exports = function(config) {
       expand: true,
       cwd: '<%= tempDir %>',
       src: [
-        'index.html',
+        //'index.html',
         'app/panels/**/*.html',
         'app/partials/**/*.html'
       ],

+ 11 - 2
tasks/options/ngtemplates.js

@@ -1,9 +1,18 @@
 module.exports = function(config) {
   return {
-    kibana: {
+    grafana: {
       cwd:  '<%= tempDir %>',
-      src:  'app/**/*.html',
+      src:  'app/partials/**/*.html',
       dest: '<%= tempDir %>/app/components/partials.js',
+      options: {
+        bootstrap: function(module, script) {
+          return "define('components/partials', ['angular'], function(angular) { \n" +
+            "angular.module('kibana').run(['$templateCache', function($templateCache) { \n" +
+                script +
+            '\n}]);' +
+          '\n});';
+        }
+      }
     }
   };
 };

+ 6 - 2
tasks/options/requirejs.js

@@ -60,7 +60,10 @@ module.exports = function(config,grunt) {
         'directives/all',
         'jquery.flot.pie',
         'angular-sanitize',
-        'angular-dragdrop'
+        'angular-dragdrop',
+        'panels/graphite/module',
+        'panels/text/module',
+        'panels/timepicker/module'
       ]
     }
   ];
@@ -75,7 +78,8 @@ module.exports = function(config,grunt) {
         requireModules.push({
           name: 'panels/'+panelName+'/'+subName+'/module',
           exclude: ['app']
-        });      })
+        });
+      })
     } else {
       requireModules.push({
         name: 'panels/'+panelName+'/module',

+ 0 - 3
tasks/options/usemin.js

@@ -1,8 +1,5 @@
 module.exports = function(config) {
   return {
     html: '<%= destDir %>/index.html',
-    options: {
-      assetsDirs: ['<%= destDir %>/css/']
-    }
   };
 };