Commit 8305fd04 by Torkel Ödegaard

Merge branch 'master' of github.com:grafana/grafana

parents 7477667d a066d7dd
......@@ -55,9 +55,40 @@ function (angular, _, config) {
$scope.move_row = function(direction) {
var rowsList = $scope.dashboard.rows;
var rowIndex = _.indexOf(rowsList, $scope.row);
var newIndex = rowIndex + direction;
var newIndex = rowIndex;
switch(direction) {
case 'up': {
newIndex = rowIndex - 1;
break;
}
case 'down': {
newIndex = rowIndex + 1;
break;
}
case 'top': {
newIndex = 0;
break;
}
case 'bottom': {
newIndex = rowsList.length - 1;
break;
}
default: {
newIndex = rowIndex;
}
}
if (newIndex >= 0 && newIndex <= (rowsList.length - 1)) {
_.move(rowsList, rowIndex, newIndex);
}
};
$scope.insert_row = function(direction) {
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, rowIndex, rowIndex + direction);
_.move(rowsList, rowsList.length - 1, newIndex);
}
};
......
......@@ -60,13 +60,22 @@
<li class="dropdown-submenu">
<a href="javascript:void(0);">Move</a>
<ul class="dropdown-menu">
<li><a ng-click="move_row(-1)">Up</a></li>
<li><a ng-click="move_row(1)">Down</a></li>
<li><a ng-click="move_row('up')">Up</a></li>
<li><a ng-click="move_row('down')">Down</a></li>
<li><a ng-click="move_row('top')">To top</a></li>
<li><a ng-click="move_row('bottom')">To Bottom</a></li>
</ul>
</li>
<li>
<a dash-editor-link="app/partials/roweditor.html">Row editor</a>
</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>
<a ng-click="delete_row()">Delete row</a>
</li>
......
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