From 3fabd2ea1bf9ff52279be0ef3b83b34823c1ac1a Mon Sep 17 00:00:00 2001 From: nikita-graf Date: Wed, 6 Jan 2016 02:05:23 +0300 Subject: [PATCH] basic playlist dashboards sort support --- .../features/playlist/partials/playlist.html | 10 ++++++++-- .../app/features/playlist/playlistEditCtrl.js | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/public/app/features/playlist/partials/playlist.html b/public/app/features/playlist/partials/playlist.html index ed442064021..e248ea1a36a 100644 --- a/public/app/features/playlist/partials/playlist.html +++ b/public/app/features/playlist/partials/playlist.html @@ -86,8 +86,14 @@ {{dashboard.title}} - - + + diff --git a/public/app/features/playlist/playlistEditCtrl.js b/public/app/features/playlist/playlistEditCtrl.js index 819a403ac48..c4d21892d0c 100644 --- a/public/app/features/playlist/playlistEditCtrl.js +++ b/public/app/features/playlist/playlistEditCtrl.js @@ -107,6 +107,24 @@ function (angular, config, _) { return $scope.loading; }; + $scope.moveDashboard = function(dashboard, offset) { + var currentPosition = dashboards.indexOf(dashboard); + var newPosition = currentPosition + offset; + + if (newPosition >= 0 && newPosition < dashboards.length) { + dashboards.splice(currentPosition, 1); + dashboards.splice(newPosition, 0, dashboard); + } + }; + + $scope.moveDashboardUp = function(dashboard) { + $scope.moveDashboard(dashboard, -1); + }; + + $scope.moveDashboardDown = function(dashboard) { + $scope.moveDashboard(dashboard, 1); + }; + $scope.playlist = playlist; $scope.dashboards = dashboards; $scope.timespan = config.playlist_timespan;