basic playlist dashboards sort support

This commit is contained in:
nikita-graf 2016-01-06 02:05:23 +03:00
parent 5eea02b17a
commit 3fabd2ea1b
2 changed files with 26 additions and 2 deletions

View File

@ -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>

View File

@ -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;