Commit 2e155bde by Torkel Ödegaard

fix(dashboard): minor function name fixes, removed insert row above/below…

fix(dashboard): minor function name fixes, removed insert row above/below because it did not work, #2909
parent 8305fd04
...@@ -29,7 +29,7 @@ function (angular, $, config) { ...@@ -29,7 +29,7 @@ function (angular, $, config) {
var resizeEventTimeout; var resizeEventTimeout;
this.init = function(dashboard) { this.init = function(dashboard) {
$scope.reset_row(); $scope.resetRow();
$scope.registerWindowResizeEvent(); $scope.registerWindowResizeEvent();
$scope.onAppEvent('show-json-editor', $scope.showJsonEditor); $scope.onAppEvent('show-json-editor', $scope.showJsonEditor);
$scope.setupDashboard(dashboard); $scope.setupDashboard(dashboard);
...@@ -88,17 +88,17 @@ function (angular, $, config) { ...@@ -88,17 +88,17 @@ function (angular, $, config) {
$rootScope.$broadcast('refresh'); $rootScope.$broadcast('refresh');
}; };
$scope.add_row = function(dash, row) { $scope.addRow = function(dash, row) {
dash.rows.push(row); dash.rows.push(row);
}; };
$scope.add_row_default = function() { $scope.addRowDefault = function() {
$scope.reset_row(); $scope.resetRow();
$scope.row.title = 'New row'; $scope.row.title = 'New row';
$scope.add_row($scope.dashboard, $scope.row); $scope.addRow($scope.dashboard, $scope.row);
}; };
$scope.reset_row = function() { $scope.resetRow = function() {
$scope.row = { $scope.row = {
title: '', title: '',
height: '250px', height: '250px',
......
...@@ -118,7 +118,7 @@ function (angular, $, kbn, _, moment) { ...@@ -118,7 +118,7 @@ function (angular, $, kbn, _, moment) {
},0); },0);
}; };
p.add_panel = function(panel, row) { p.addPanel = function(panel, row) {
var rowSpan = this.rowSpan(row); var rowSpan = this.rowSpan(row);
var panelCount = row.panels.length; var panelCount = row.panels.length;
var space = (12 - rowSpan) - panel.span; var space = (12 - rowSpan) - panel.span;
......
...@@ -28,7 +28,7 @@ function (angular, _, config) { ...@@ -28,7 +28,7 @@ function (angular, _, config) {
$scope.panelMenuPos = posX; $scope.panelMenuPos = posX;
}; };
$scope.toggle_row = function(row) { $scope.toggleRow = function(row) {
row.collapse = row.collapse ? false : true; row.collapse = row.collapse ? false : true;
if (!row.collapse) { if (!row.collapse) {
$timeout(function() { $timeout(function() {
...@@ -37,11 +37,11 @@ function (angular, _, config) { ...@@ -37,11 +37,11 @@ function (angular, _, config) {
} }
}; };
$scope.add_panel = function(panel) { $scope.addPanel = function(panel) {
$scope.dashboard.add_panel(panel, $scope.row); $scope.dashboard.addPanel(panel, $scope.row);
}; };
$scope.delete_row = function() { $scope.deleteRow = function() {
$scope.appEvent('confirm-modal', { $scope.appEvent('confirm-modal', {
title: 'Are you sure you want to delete this row?', title: 'Are you sure you want to delete this row?',
icon: 'fa-trash', icon: 'fa-trash',
...@@ -52,7 +52,7 @@ function (angular, _, config) { ...@@ -52,7 +52,7 @@ function (angular, _, config) {
}); });
}; };
$scope.move_row = function(direction) { $scope.moveRow = function(direction) {
var rowsList = $scope.dashboard.rows; var rowsList = $scope.dashboard.rows;
var rowIndex = _.indexOf(rowsList, $scope.row); var rowIndex = _.indexOf(rowsList, $scope.row);
var newIndex = rowIndex; var newIndex = rowIndex;
...@@ -82,17 +82,7 @@ function (angular, _, config) { ...@@ -82,17 +82,7 @@ function (angular, _, config) {
} }
}; };
$scope.insert_row = function(direction) { $scope.addPanelDefault = function(type) {
var rowsList = $scope.dashboard.rows;
var currentRowIndex = _.indexOf(rowsList, $scope.row);
$scope.add_row_default();
var newIndex = currentRowIndex + direction;
if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) {
_.move(rowsList, rowsList.length - 1, newIndex);
}
};
$scope.add_panel_default = function(type) {
var defaultSpan = 12; var defaultSpan = 12;
var _as = 12 - $scope.dashboard.rowSpan($scope.row); var _as = 12 - $scope.dashboard.rowSpan($scope.row);
...@@ -104,14 +94,14 @@ function (angular, _, config) { ...@@ -104,14 +94,14 @@ function (angular, _, config) {
type: type type: type
}; };
$scope.add_panel(panel); $scope.addPanel(panel);
$timeout(function() { $timeout(function() {
$scope.$broadcast('render'); $scope.$broadcast('render');
}); });
}; };
$scope.set_height = function(height) { $scope.setHeight = function(height) {
$scope.row.height = height; $scope.row.height = height;
$scope.$broadcast('render'); $scope.$broadcast('render');
}; };
......
...@@ -18,11 +18,11 @@ ...@@ -18,11 +18,11 @@
<div class="row-control-inner"> <div class="row-control-inner">
<div class="row-close" ng-show="row.collapse" data-placement="bottom" > <div class="row-close" ng-show="row.collapse" data-placement="bottom" >
<div class="row-close-buttons"> <div class="row-close-buttons">
<span class="row-button bgPrimary" ng-click="toggle_row(row)"> <span class="row-button bgPrimary" ng-click="toggleRow(row)">
<i bs-tooltip="'Expand row'" data-placement="right" class="fa fa-caret-left pointer" ></i> <i bs-tooltip="'Expand row'" data-placement="right" class="fa fa-caret-left pointer" ></i>
</span> </span>
</div> </div>
<div class="row-text pointer" ng-click="toggle_row(row)" ng-bind="row.title | interpolateTemplateVars:this"></div> <div class="row-text pointer" ng-click="toggleRow(row)" ng-bind="row.title | interpolateTemplateVars:this"></div>
</div> </div>
<div class="row-open" ng-show="!row.collapse"> <div class="row-open" ng-show="!row.collapse">
<div class='row-tab bgSuccess dropdown' ng-show="dashboardMeta.canEdit" ng-hide="dashboardViewState.fullscreen"> <div class='row-tab bgSuccess dropdown' ng-show="dashboardMeta.canEdit" ng-hide="dashboardViewState.fullscreen">
...@@ -31,53 +31,46 @@ ...@@ -31,53 +31,46 @@
</span> </span>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="drop1"> <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="drop1">
<li> <li>
<a ng-click="toggle_row(row)">Collapse row</a> <a ng-click="toggleRow(row)">Collapse row</a>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a href="javascript:void(0);">Add Panel</a> <a href="javascript:void(0);">Add Panel</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li bindonce ng-repeat="(key, value) in panels"> <li bindonce ng-repeat="(key, value) in panels">
<a ng-click="add_panel_default(key)" bo-text="value.name"></a> <a ng-click="addPanelDefault(key)" bo-text="value.name"></a>
</li> </li>
</ul> </ul>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a href="javascript:void(0);">Set height</a> <a href="javascript:void(0);">Set height</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a ng-click="set_height('25px')">25 px</a></li> <li><a ng-click="setHeight('25px')">25 px</a></li>
<li><a ng-click="set_height('100px')">100 px</a></li> <li><a ng-click="setHeight('100px')">100 px</a></li>
<li><a ng-click="set_height('150px')">150 px</a></li> <li><a ng-click="setHeight('150px')">150 px</a></li>
<li><a ng-click="set_height('200px')">200 px</a></li> <li><a ng-click="setHeight('200px')">200 px</a></li>
<li><a ng-click="set_height('250px')">250 px</a></li> <li><a ng-click="setHeight('250px')">250 px</a></li>
<li><a ng-click="set_height('300px')">300 px</a></li> <li><a ng-click="setHeight('300px')">300 px</a></li>
<li><a ng-click="set_height('350px')">350 px</a></li> <li><a ng-click="setHeight('350px')">350 px</a></li>
<li><a ng-click="set_height('450px')">450 px</a></li> <li><a ng-click="setHeight('450px')">450 px</a></li>
<li><a ng-click="set_height('500px')">500 px</a></li> <li><a ng-click="setHeight('500px')">500 px</a></li>
<li><a ng-click="set_height('600px')">600 px</a></li> <li><a ng-click="setHeight('600px')">600 px</a></li>
<li><a ng-click="set_height('700px')">700 px</a></li> <li><a ng-click="setHeight('700px')">700 px</a></li>
</ul> </ul>
</li> </li>
<li class="dropdown-submenu"> <li class="dropdown-submenu">
<a href="javascript:void(0);">Move</a> <a href="javascript:void(0);">Move</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li><a ng-click="move_row('up')">Up</a></li> <li><a ng-click="moveRow('up')">Up</a></li>
<li><a ng-click="move_row('down')">Down</a></li> <li><a ng-click="moveRow('down')">Down</a></li>
<li><a ng-click="move_row('top')">To top</a></li> <li><a ng-click="moveRow('top')">To top</a></li>
<li><a ng-click="move_row('bottom')">To Bottom</a></li> <li><a ng-click="moveRow('bottom')">To Bottom</a></li>
</ul> </ul>
</li> </li>
<li> <li>
<a dash-editor-link="app/partials/roweditor.html">Row editor</a> <a dash-editor-link="app/partials/roweditor.html">Row editor</a>
</li> </li>
<li class="dropdown-submenu">
<a href="javascript:void(0);">Insert Row</a>
<ul class="dropdown-menu">
<li><a ng-click="insert_row(0)">Above</a></li>
<li><a ng-click="insert_row(1)">Below</a></li>
</ul>
</li>
<li> <li>
<a ng-click="delete_row()">Delete row</a> <a ng-click="deleteRow()">Delete row</a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -108,7 +101,7 @@ ...@@ -108,7 +101,7 @@
<div ng-show='dashboardMeta.canEdit' class="row-fluid add-row-panel-hint" ng-hide="dashboardViewState.fullscreen"> <div ng-show='dashboardMeta.canEdit' class="row-fluid add-row-panel-hint" ng-hide="dashboardViewState.fullscreen">
<div class="span12" style="text-align:right;"> <div class="span12" style="text-align:right;">
<span style="margin-right: 10px;" ng-click="add_row_default()" class="pointer btn btn-info btn-small"> <span style="margin-right: 10px;" ng-click="addRowDefault()" class="pointer btn btn-info btn-small">
<span><i class="fa fa-plus"></i> ADD ROW</span> <span><i class="fa fa-plus"></i> ADD ROW</span>
</span> </span>
</div> </div>
......
...@@ -94,7 +94,7 @@ define([ ...@@ -94,7 +94,7 @@ define([
it('adding default should split span in half', function() { it('adding default should split span in half', function() {
dashboard.rows = [{ panels: [{ span: 12, id: 7 }] }]; dashboard.rows = [{ panels: [{ span: 12, id: 7 }] }];
dashboard.add_panel({span: 4}, dashboard.rows[0]); dashboard.addPanel({span: 4}, dashboard.rows[0]);
expect(dashboard.rows[0].panels[0].span).to.be(6); expect(dashboard.rows[0].panels[0].span).to.be(6);
expect(dashboard.rows[0].panels[1].span).to.be(6); expect(dashboard.rows[0].panels[1].span).to.be(6);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment