From 14f3a6821552e4a874deb5df05fc592704856f97 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Fri, 9 Oct 2015 03:06:52 +0530 Subject: [PATCH 1/2] Added move row to top and bottom. --- public/app/features/dashboard/rowCtrl.js | 25 ++++++++++++++++++++++-- public/app/partials/dashboard.html | 6 ++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/public/app/features/dashboard/rowCtrl.js b/public/app/features/dashboard/rowCtrl.js index 27365f7bd1c..02cb59721a3 100644 --- a/public/app/features/dashboard/rowCtrl.js +++ b/public/app/features/dashboard/rowCtrl.js @@ -55,9 +55,30 @@ 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); } }; diff --git a/public/app/partials/dashboard.html b/public/app/partials/dashboard.html index 156da97e50a..4edbb816eeb 100644 --- a/public/app/partials/dashboard.html +++ b/public/app/partials/dashboard.html @@ -60,8 +60,10 @@
  • From 9185c94a2d4c14cebd0acd727486d128da3a4001 Mon Sep 17 00:00:00 2001 From: ubhatnagar Date: Wed, 14 Oct 2015 13:45:47 -0700 Subject: [PATCH 2/2] Added insert row option in the row menu. --- public/app/features/dashboard/rowCtrl.js | 10 ++++++++++ public/app/partials/dashboard.html | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/public/app/features/dashboard/rowCtrl.js b/public/app/features/dashboard/rowCtrl.js index 02cb59721a3..9b5de4c0a1b 100644 --- a/public/app/features/dashboard/rowCtrl.js +++ b/public/app/features/dashboard/rowCtrl.js @@ -82,6 +82,16 @@ function (angular, _, config) { } }; + $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); + } + }; + $scope.add_panel_default = function(type) { var defaultSpan = 12; var _as = 12 - $scope.dashboard.rowSpan($scope.row); diff --git a/public/app/partials/dashboard.html b/public/app/partials/dashboard.html index 4edbb816eeb..668363b111c 100644 --- a/public/app/partials/dashboard.html +++ b/public/app/partials/dashboard.html @@ -69,6 +69,13 @@
  • Row editor
  • +
  • Delete row