diff --git a/src/app/controllers/row.js b/src/app/controllers/row.js index 98436ab1dca..846095f4556 100644 --- a/src/app/controllers/row.js +++ b/src/app/controllers/row.js @@ -9,109 +9,129 @@ function (angular, app, _) { var module = angular.module('kibana.controllers'); module.controller('RowCtrl', function($scope, $rootScope, $timeout) { - var _d = { - title: "Row", - height: "150px", - collapse: false, - collapsable: true, - editable: true, - panels: [], - notice: false - }; + var _d = { + title: "Row", + height: "150px", + collapse: false, + collapsable: true, + editable: true, + panels: [], + notice: false + }; - _.defaults($scope.row,_d); + _.defaults($scope.row,_d); - $scope.init = function() { - $scope.reset_panel(); - }; + $scope.init = function() { + $scope.reset_panel(); + }; - $scope.toggle_row = function(row) { - if(!row.collapsable) { - return; - } - row.collapse = row.collapse ? false : true; - if (!row.collapse) { - $timeout(function() { - $scope.$broadcast('render'); - }); - } else { - row.notice = false; - } - }; - - $scope.rowSpan = function(row) { - var panels = _.filter(row.panels, function(p) { - return $scope.isPanel(p); + $scope.toggle_row = function(row) { + if(!row.collapsable) { + return; + } + row.collapse = row.collapse ? false : true; + if (!row.collapse) { + $timeout(function() { + $scope.$broadcast('render'); }); - return _.reduce(_.pluck(panels,'span'), function(p,v) { - return p+v; - },0); - }; + } else { + row.notice = false; + } + }; - // This can be overridden by individual panels - $scope.close_edit = function() { - $scope.$broadcast('render'); - }; + $scope.rowSpan = function(row) { + var panels = _.filter(row.panels, function(p) { + return $scope.isPanel(p); + }); + return _.reduce(_.pluck(panels,'span'), function(p,v) { + return p+v; + },0); + }; - $scope.add_panel = function(row,panel) { - $scope.row.panels.push(panel); - }; + // This can be overridden by individual panels + $scope.close_edit = function() { + $scope.$broadcast('render'); + }; - $scope.remove_panel_from_row = function(row, panel) { - if (confirm('Are you sure you want to remove this ' + panel.type + ' panel?')) { - row.panels = _.without(row.panels,panel); + $scope.add_panel = function(row,panel) { + $scope.row.panels.push(panel); + }; + + $scope.remove_panel_from_row = function(row, panel) { + if (confirm('Are you sure you want to remove this ' + panel.type + ' panel?')) { + row.panels = _.without(row.panels,panel); + } + }; + + $scope.duplicatePanel = function(panel, row) { + row = row || $scope.row; + var currentRowSpan = $scope.rowSpan(row); + if (currentRowSpan <= 9) { + row.panels.push(angular.copy(panel)); + } + else { + var rowsList = $scope.dashboard.current.rows; + var rowIndex = _.indexOf(rowsList, row); + if (rowIndex === rowsList.length - 1) { + var newRow = angular.copy($scope.row); + newRow.panels = []; + $scope.dashboard.current.rows.push(newRow); + $scope.duplicatePanel(panel, newRow); } + else { + $scope.duplicatePanel(panel, rowsList[rowIndex+1]); + } + } + }; + + /** @scratch /panels/0 + * [[panels]] + * = Panels + * + * [partintro] + * -- + * *Kibana* dashboards are made up of blocks called +panels+. Panels are organized into rows + * and can serve many purposes, though most are designed to provide the results of a query or + * multiple queries as a visualization. Other panels may show collections of documents or + * allow you to insert instructions for your users. + * + * Panels can be configured easily via the Kibana web interface. For more advanced usage, such + * as templated or scripted dashboards, documentation of panel properties is available in this + * section. You may find settings here which are not exposed via the web interface. + * + * Each panel type has its own properties, hover there are several that are shared. + * + */ + + $scope.reset_panel = function(type) { + var + defaultSpan = 4, + _as = 12-$scope.rowSpan($scope.row); + + $scope.panel = { + error : false, + /** @scratch /panels/1 + * span:: A number, 1-12, that describes the width of the panel. + */ + span : _as < defaultSpan && _as > 0 ? _as : defaultSpan, + /** @scratch /panels/1 + * editable:: Enable or disable the edit button the the panel + */ + editable: true, + /** @scratch /panels/1 + * type:: The type of panel this object contains. Each panel type will require additional + * properties. See the panel types list to the right. + */ + type : type }; + }; - /** @scratch /panels/0 - * [[panels]] - * = Panels - * - * [partintro] - * -- - * *Kibana* dashboards are made up of blocks called +panels+. Panels are organized into rows - * and can serve many purposes, though most are designed to provide the results of a query or - * multiple queries as a visualization. Other panels may show collections of documents or - * allow you to insert instructions for your users. - * - * Panels can be configured easily via the Kibana web interface. For more advanced usage, such - * as templated or scripted dashboards, documentation of panel properties is available in this - * section. You may find settings here which are not exposed via the web interface. - * - * Each panel type has its own properties, hover there are several that are shared. - * - */ + /** @scratch /panels/2 + * -- + */ - $scope.reset_panel = function(type) { - var - defaultSpan = 4, - _as = 12-$scope.rowSpan($scope.row); + $scope.init(); - $scope.panel = { - error : false, - /** @scratch /panels/1 - * span:: A number, 1-12, that describes the width of the panel. - */ - span : _as < defaultSpan && _as > 0 ? _as : defaultSpan, - /** @scratch /panels/1 - * editable:: Enable or disable the edit button the the panel - */ - editable: true, - /** @scratch /panels/1 - * type:: The type of panel this object contains. Each panel type will require additional - * properties. See the panel types list to the right. - */ - type : type - }; - }; - - /** @scratch /panels/2 - * -- - */ - - $scope.init(); - - } - ); + }); }); \ No newline at end of file diff --git a/src/app/panels/graphite/module.js b/src/app/panels/graphite/module.js index abbd382f02c..91554c236da 100644 --- a/src/app/panels/graphite/module.js +++ b/src/app/panels/graphite/module.js @@ -61,7 +61,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) { menuItems: [ { text: 'Edit', click: 'openConfigureModal()' }, { text: 'Fullscreen', click: 'toggleFullscreen()' }, - { text: 'Duplicate', click: 'duplicate()' }, + { text: 'Duplicate', click: 'duplicatePanel(panel)' }, { text: 'Span', submenu: [ { text: '1', click: 'updateColumnSpan(1)' }, { text: '2', click: 'updateColumnSpan(2)' }, @@ -266,15 +266,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { } }; - /** - * Fetch the data for a chunk of a queries results. Multiple segments occur when several indicies - * need to be consulted (like timestamped logstash indicies) - * - * The results of this function are stored on the scope's data property. This property will be an - * array of objects with the properties info, time_series, and hits. These objects are used in the - * render_panel function to create the historgram. - * - */ $scope.get_data = function() { delete $scope.panel.error; @@ -381,11 +372,12 @@ function (angular, app, $, _, kbn, moment, timeSeries) { closeEditMode(); $timeout(function() { - $scope.$emit('render'); - if (oldTimeRange !== $scope.range) { $scope.dashboard.refresh(); } + else { + $scope.$emit('render'); + } }); }); } @@ -421,27 +413,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) { $scope.render(); }; - $scope.duplicate = function(addToRow) { - addToRow = addToRow || $scope.row; - var currentRowSpan = $scope.rowSpan(addToRow); - if (currentRowSpan <= 9) { - addToRow.panels.push(angular.copy($scope.panel)); - } - else { - var rowsList = $scope.dashboard.current.rows; - var rowIndex = _.indexOf(rowsList, addToRow); - if (rowIndex === rowsList.length - 1) { - var newRow = angular.copy($scope.row); - newRow.panels = []; - $scope.dashboard.current.rows.push(newRow); - $scope.duplicate(newRow); - } - else { - $scope.duplicate(rowsList[rowIndex+1]); - } - } - }; - $scope.toggleFullscreen = function() { if ($scope.fullscreen && !$scope.editMode) { $rootScope.$emit('panel-fullscreen-exit');