From b162bd64cedb33e00656c2875c00c59388711825 Mon Sep 17 00:00:00 2001 From: Rashid Khan Date: Wed, 13 Feb 2013 12:23:24 -0700 Subject: [PATCH] Added row editor --- common/lib/shared.js | 17 ++++++++++++++- js/controllers.js | 20 ++++++++++++++++++ panels/fields/editor.html | 0 panels/histogram/editor.html | 8 +++---- panels/histogram/module.js | 6 ++++-- panels/hits/editor.html | 2 +- panels/map/editor.html | 18 +++++++++++----- panels/pie/editor.html | 2 +- panels/sort/editor.html | 0 panels/stringquery/editor.html | 0 panels/table/editor.html | 2 +- panels/text/editor.html | 8 ++++--- panels/timepicker/editor.html | 0 partials/paneleditor.html | 17 ++------------- partials/panelgeneral.html | 14 +++++++++++++ partials/roweditor.html | 38 ++++++++++++++++++++++++++++------ 16 files changed, 113 insertions(+), 39 deletions(-) delete mode 100644 panels/fields/editor.html delete mode 100644 panels/sort/editor.html delete mode 100644 panels/stringquery/editor.html delete mode 100644 panels/timepicker/editor.html create mode 100644 partials/panelgeneral.html diff --git a/common/lib/shared.js b/common/lib/shared.js index ca4f2b73ab1..9d4f45fca8a 100644 --- a/common/lib/shared.js +++ b/common/lib/shared.js @@ -437,4 +437,19 @@ function htmlEntities(str) { //g, '>').replace( /"/g, '"'); -} \ No newline at end of file +} + + +_.mixin({ + move: function (array, fromIndex, toIndex) { + array.splice(toIndex, 0, array.splice(fromIndex, 1)[0] ); + return array; + } +}); + +_.mixin({ + remove: function (array, index) { + array.splice(index, 1); + return array; + } +}); diff --git a/js/controllers.js b/js/controllers.js index d72df596de9..81fab71812c 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -9,6 +9,7 @@ angular.module('kibana.controllers', []) $scope._ = _; + // The global dashboards object should be moved to an $http request for json if (Modernizr.localstorage && !(_.isUndefined(localStorage['dashboard'])) && localStorage['dashboard'] !== '' @@ -46,6 +47,10 @@ angular.module('kibana.controllers', []) }) .controller('RowCtrl', function($scope, $rootScope, $timeout, ejsResource, timer) { + $scope.init = function(){ + $scope.reset_panel(); + } + $scope.toggle_row = function(row) { row.collapse = row.collapse ? false : true; if (!row.collapse) { @@ -55,6 +60,21 @@ angular.module('kibana.controllers', []) } } + $scope.add_panel = function(row,panel) { + console.log(panel) + $scope.row.panels.push(panel); + } + + $scope.reset_panel = function() { + $scope.panel = { + span: 1, + editable: true, + groups: ['default'], + }; + }; + + $scope.init(); + }); diff --git a/panels/fields/editor.html b/panels/fields/editor.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/panels/histogram/editor.html b/panels/histogram/editor.html index 67eb79dd7b2..543260ce9e6 100644 --- a/panels/histogram/editor.html +++ b/panels/histogram/editor.html @@ -1,4 +1,4 @@ -
+
Label
@@ -18,7 +18,7 @@
- +
@@ -34,10 +34,10 @@
- +
- +
\ No newline at end of file diff --git a/panels/histogram/module.js b/panels/histogram/module.js index b351789ffeb..6e398e7922f 100644 --- a/panels/histogram/module.js +++ b/panels/histogram/module.js @@ -5,7 +5,7 @@ angular.module('kibana.histogram', []) // Set and populate defaults var _d = { - query : { query: "*" }, + query : [ {query: "*", label:"Query"} ], interval: secondsToHms(calculate_interval($scope.from,$scope.to,40,0)/1000), show : ['bars'], fill : false, @@ -31,6 +31,8 @@ angular.module('kibana.histogram', []) } $scope.add_query = function(label,query) { + if(!(_.isArray($scope.panel.query))) + $scope.panel.query = new Array(); $scope.panel.query.unshift({ query: query, label: label, @@ -111,7 +113,7 @@ angular.module('kibana.histogram', []) restrict: 'A', link: function(scope, elem, attrs, ctrl) { - // If the data or row state changes, re-render + // Receive render events scope.$on('render',function(){ render_panel(); }); diff --git a/panels/hits/editor.html b/panels/hits/editor.html index 3d1852ed454..294e4eead23 100644 --- a/panels/hits/editor.html +++ b/panels/hits/editor.html @@ -1,4 +1,4 @@ -
+
Query
diff --git a/panels/map/editor.html b/panels/map/editor.html index 3b83a0b7547..4f87e9f207e 100644 --- a/panels/map/editor.html +++ b/panels/map/editor.html @@ -1,11 +1,19 @@ -
-
+
+
Query
- +
-
Map
- +
+
+
Field
+ + +
+
+
Map
+ +
diff --git a/panels/pie/editor.html b/panels/pie/editor.html index 291307eade7..ddcc94bf87b 100644 --- a/panels/pie/editor.html +++ b/panels/pie/editor.html @@ -1,4 +1,4 @@ -
+
diff --git a/panels/sort/editor.html b/panels/sort/editor.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/panels/stringquery/editor.html b/panels/stringquery/editor.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/panels/table/editor.html b/panels/table/editor.html index dc70b3fba5f..1b6a7dc4e28 100644 --- a/panels/table/editor.html +++ b/panels/table/editor.html @@ -1,4 +1,4 @@ -
+
Query
diff --git a/panels/text/editor.html b/panels/text/editor.html index 005e4fa3dd6..add058a6232 100644 --- a/panels/text/editor.html +++ b/panels/text/editor.html @@ -1,3 +1,5 @@ - - - \ No newline at end of file +
+ + + +
\ No newline at end of file diff --git a/panels/timepicker/editor.html b/panels/timepicker/editor.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/partials/paneleditor.html b/partials/paneleditor.html index 014cfb70d9e..f5389aa1648 100644 --- a/partials/paneleditor.html +++ b/partials/paneleditor.html @@ -4,22 +4,9 @@