Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
- Get rid of factory function and Panel class.
- Rename panel.js to panel_state.js
- Rename dashboard_panel_directive to dashboard_panel
  • Loading branch information
stacey-gammon committed Dec 6, 2016
1 parent 93afafa commit aa8d6c8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 84 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export const DEFAULT_PANEL_WIDTH = 3;
export const DEFAULT_PANEL_HEIGHT = 2;

/**
* Represents a panel on a grid. Keeps track of position in the grid and what visualization it
* contains.
*
* @typedef PanelState
* @property {number} id - Id of the visualization contained in the panel.
* @property {Element} $el - A reference to the gridster widget holding this panel. Used to
* update the size and column attributes. TODO: move out of panel state as this couples state to ui.
* @property {string} type - Type of the visualization in the panel.
* @property {number} panelId - Unique id to represent this panel in the grid.
* @property {number} size_x - Width of the panel.
* @property {number} size_y - Height of the panel.
* @property {number} col - Column index in the grid.
* @property {number} row - Row index in the grid.
*/

/**
* Creates and initializes a basic panel state.
* @param {number} id
* @param {string} type
* @param {number} panelId
* @return {PanelState}
*/
export function createPanelState(id, type, panelId) {
return {
size_x: DEFAULT_PANEL_WIDTH,
size_y: DEFAULT_PANEL_HEIGHT,
panelId: panelId,
type: type,
id: id
};
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from 'plugins/kibana/dashboard/components/panel/lib/panel';
import { DEFAULT_PANEL_WIDTH, DEFAULT_PANEL_HEIGHT } from 'plugins/kibana/dashboard/components/panel/lib/panel_state';

export class PanelUtils {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ uiModules

/**
* Returns a unique id for storing the panel state in the persistent ui.
* @param panel
* @param {PanelState} panel
* @returns {string}
*/
const getPersistedStateId = function (panel) {
Expand All @@ -46,7 +46,7 @@ uiModules
parentUiState: '=',
/**
* Contains information about this panel.
* @type {Panel}
* @type {PanelState}
*/
panel: '=',
/**
Expand Down
8 changes: 4 additions & 4 deletions src/core_plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'ui/notify';
import 'ui/typeahead';
import 'ui/share';
import 'plugins/kibana/dashboard/directives/grid';
import 'plugins/kibana/dashboard/directives/dashboard_panel_directive';
import 'plugins/kibana/dashboard/directives/dashboard_panel';
import 'plugins/kibana/dashboard/services/saved_dashboards';
import 'plugins/kibana/dashboard/styles/main.less';
import FilterBarQueryFilterProvider from 'ui/filter_bar/query_filter';
Expand All @@ -17,7 +17,7 @@ import uiRoutes from 'ui/routes';
import uiModules from 'ui/modules';
import indexTemplate from 'plugins/kibana/dashboard/index.html';
import { savedDashboardRegister } from 'plugins/kibana/dashboard/services/saved_dashboard_register';
import { PanelFactory } from 'plugins/kibana/dashboard/components/panel/lib/panel';
import { createPanelState } from 'plugins/kibana/dashboard/components/panel/lib/panel_state';
require('ui/saved_objects/saved_object_registry').register(savedDashboardRegister);

const app = uiModules.get('app/dashboard', [
Expand Down Expand Up @@ -272,12 +272,12 @@ app.directive('dashboardApp', function (Notifier, courier, AppState, timefilter,
// called by the saved-object-finder when a user clicks a vis
$scope.addVis = function (hit) {
pendingVis++;
$state.panels.push(PanelFactory.create(hit.id, 'visualization', getMaxPanelId()));
$state.panels.push(createPanelState(hit.id, 'visualization', getMaxPanelId()));
};

$scope.addSearch = function (hit) {
pendingVis++;
$state.panels.push(PanelFactory.create(hit.id, 'search', getMaxPanelId()));
$state.panels.push(createPanelState(hit.id, 'search', getMaxPanelId()));
};

// Setup configurable values for config directive, after objects are initialized
Expand Down

0 comments on commit aa8d6c8

Please sign in to comment.