style(playlist): rename files to match new format

This commit is contained in:
bergquist
2016-01-08 13:25:30 +01:00
parent 412e7bcdae
commit 8c05067f88
4 changed files with 3 additions and 3 deletions

View File

@@ -0,0 +1,137 @@
define([
'angular',
'app/core/config',
'lodash'
],
function (angular, config, _) {
'use strict';
var module = angular.module('grafana.controllers');
module.controller('PlaylistEditCtrl', function(
playlist,
dashboards,
$scope,
playlistSrv,
backendSrv,
$location
) {
$scope.search = function() {
var query = {starred: true, limit: 10};
if ($scope.searchQuery) {
query.query = $scope.searchQuery;
query.starred = false;
}
$scope.loading = true;
backendSrv.search(query)
.then(function(results) {
$scope.foundDashboards = results;
$scope.filterFoundDashboards();
})
.finally(function() {
$scope.loading = false;
});
};
$scope.filterFoundDashboards = function() {
$scope.filteredDashboards = _.reject($scope.foundDashboards, function(dashboard) {
return _.findWhere(dashboards, function(listDashboard) {
return listDashboard.id === dashboard.id;
});
});
};
$scope.addDashboard = function(dashboard) {
dashboards.push(dashboard);
$scope.filterFoundDashboards();
};
$scope.removeDashboard = function(dashboard) {
_.remove(dashboards, function(listedDashboard) {
return dashboard === listedDashboard;
});
$scope.filterFoundDashboards();
};
$scope.savePlaylist = function(playlist, dashboards) {
var savePromise;
playlist.data = dashboards.map(function(dashboard) {
return dashboard.id;
});
// Hardcoding playlist type for this iteration
playlist.type = "dashboards";
savePromise = playlist.id
? backendSrv.put('/api/playlists/' + playlist.id, playlist)
: backendSrv.post('/api/playlists', playlist);
savePromise
.then(function() {
$scope.appEvent('alert-success', ['Playlist saved', '']);
$location.path('/playlists');
}, function() {
$scope.appEvent('alert-success', ['Unable to save playlist', '']);
});
};
$scope.isNew = function() {
return !playlist.id;
};
$scope.startPlaylist = function(playlist, dashboards) {
playlistSrv.start(dashboards, playlist.timespan);
};
$scope.isPlaylistEmpty = function() {
return !dashboards.length;
};
$scope.isSearchResultsEmpty = function() {
return !$scope.foundDashboards.length;
};
$scope.isSearchQueryEmpty = function() {
return $scope.searchQuery === '';
};
$scope.backToList = function() {
$location.path('/playlists');
};
$scope.isLoading = function() {
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;
$scope.filteredDashboards = [];
$scope.foundDashboards = [];
$scope.searchQuery = '';
$scope.loading = false;
$scope.search();
});
});