Commit 3fabd2ea by nikita-graf

basic playlist dashboards sort support

parent 5eea02b1
...@@ -86,8 +86,14 @@ ...@@ -86,8 +86,14 @@
<td style="white-space: nowrap;"> <td style="white-space: nowrap;">
{{dashboard.title}} {{dashboard.title}}
</td> </td>
<td style="text-align: center"> <td style="text-align: right">
<button class="btn btn-inverse btn-mini pull-right" ng-click="removeDashboard(dashboard)"> <button class="btn btn-inverse btn-mini" ng-click="moveDashboardUp(dashboard)">
<i class="fa fa-arrow-up"></i>
</button>
<button class="btn btn-inverse btn-mini" ng-click="moveDashboardDown(dashboard)">
<i class="fa fa-arrow-down"></i>
</button>
<button class="btn btn-inverse btn-mini" ng-click="removeDashboard(dashboard)">
<i class="fa fa-remove"></i> <i class="fa fa-remove"></i>
</button> </button>
</td> </td>
......
...@@ -107,6 +107,24 @@ function (angular, config, _) { ...@@ -107,6 +107,24 @@ function (angular, config, _) {
return $scope.loading; 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.playlist = playlist;
$scope.dashboards = dashboards; $scope.dashboards = dashboards;
$scope.timespan = config.playlist_timespan; $scope.timespan = config.playlist_timespan;
......
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