diff --git a/public/app/features/dashboard/rowCtrl.js b/public/app/features/dashboard/rowCtrl.js index 27365f7bd1c..9b5de4c0a1b 100644 --- a/public/app/features/dashboard/rowCtrl.js +++ b/public/app/features/dashboard/rowCtrl.js @@ -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, rowIndex + direction); + _.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, rowsList.length - 1, newIndex); } }; diff --git a/public/app/partials/dashboard.html b/public/app/partials/dashboard.html index 78d54e1b5eb..efbc925e4b1 100644 --- a/public/app/partials/dashboard.html +++ b/public/app/partials/dashboard.html @@ -60,13 +60,22 @@
  • Row editor
  • +
  • Delete row