2013-09-13 15:52:13 -05:00
|
|
|
define([
|
|
|
|
'angular',
|
|
|
|
'app',
|
|
|
|
'underscore'
|
|
|
|
],
|
|
|
|
function (angular, app, _) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var module = angular.module('kibana.controllers');
|
|
|
|
|
2013-12-27 07:50:08 -06:00
|
|
|
module.controller('RowCtrl', function($scope, $rootScope, $timeout) {
|
2013-09-13 15:52:13 -05:00
|
|
|
var _d = {
|
|
|
|
title: "Row",
|
|
|
|
height: "150px",
|
|
|
|
collapse: false,
|
|
|
|
collapsable: true,
|
|
|
|
editable: true,
|
|
|
|
panels: [],
|
2013-10-05 18:41:20 -05:00
|
|
|
notice: false
|
2013-09-13 15:52:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
_.defaults($scope.row,_d);
|
|
|
|
|
|
|
|
$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');
|
|
|
|
});
|
2013-10-05 18:41:20 -05:00
|
|
|
} else {
|
|
|
|
row.notice = false;
|
2013-09-13 15:52:13 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-09-20 16:26:06 -05:00
|
|
|
$scope.rowSpan = function(row) {
|
2013-09-26 17:42:43 -05:00
|
|
|
var panels = _.filter(row.panels, function(p) {
|
|
|
|
return $scope.isPanel(p);
|
|
|
|
});
|
|
|
|
return _.reduce(_.pluck(panels,'span'), function(p,v) {
|
2013-09-20 16:26:06 -05:00
|
|
|
return p+v;
|
|
|
|
},0);
|
|
|
|
};
|
|
|
|
|
2013-09-13 15:52:13 -05:00
|
|
|
// This can be overridden by individual panels
|
|
|
|
$scope.close_edit = function() {
|
|
|
|
$scope.$broadcast('render');
|
|
|
|
};
|
|
|
|
|
|
|
|
$scope.add_panel = function(row,panel) {
|
|
|
|
$scope.row.panels.push(panel);
|
|
|
|
};
|
|
|
|
|
2013-12-09 02:13:13 -06:00
|
|
|
$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);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-12-02 13:43:39 -06:00
|
|
|
/** @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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-09-13 15:52:13 -05:00
|
|
|
$scope.reset_panel = function(type) {
|
2013-09-20 16:26:06 -05:00
|
|
|
var
|
|
|
|
defaultSpan = 4,
|
|
|
|
_as = 12-$scope.rowSpan($scope.row);
|
|
|
|
|
2013-09-13 15:52:13 -05:00
|
|
|
$scope.panel = {
|
|
|
|
error : false,
|
2013-12-02 13:43:39 -06:00
|
|
|
/** @scratch /panels/1
|
|
|
|
* span:: A number, 1-12, that describes the width of the panel.
|
|
|
|
*/
|
2013-09-20 16:26:06 -05:00
|
|
|
span : _as < defaultSpan && _as > 0 ? _as : defaultSpan,
|
2013-12-02 13:43:39 -06:00
|
|
|
/** @scratch /panels/1
|
|
|
|
* editable:: Enable or disable the edit button the the panel
|
|
|
|
*/
|
2013-09-13 15:52:13 -05:00
|
|
|
editable: true,
|
2013-12-02 13:43:39 -06:00
|
|
|
/** @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.
|
|
|
|
*/
|
2013-09-13 15:52:13 -05:00
|
|
|
type : type
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2013-12-02 13:43:39 -06:00
|
|
|
/** @scratch /panels/2
|
|
|
|
* --
|
|
|
|
*/
|
|
|
|
|
2013-09-13 15:52:13 -05:00
|
|
|
$scope.init();
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|