-
Notifications
You must be signed in to change notification settings - Fork 980
Expand file tree
/
Copy pathadmin-videos-ctrl.js
More file actions
38 lines (28 loc) · 980 Bytes
/
admin-videos-ctrl.js
File metadata and controls
38 lines (28 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
angular.module('streama').controller('adminVideosCtrl', ['$scope', 'apiService', 'modalService', '$state', function ($scope, apiService, modalService, $state) {
$scope.loading = true;
apiService.genericVideo.list().then(function (response) {
$scope.videos = response.data;
$scope.loading = false;
});
$scope.openGenericVideoModal = function () {
modalService.genericVideoModal(null, function (data) {
$state.go('admin.video', {videoId: data.id});
});
};
$scope.addFromSuggested = function (movie, redirect) {
var tempMovie = angular.copy(movie);
var apiId = tempMovie.id;
delete tempMovie.id;
tempMovie.apiId = apiId;
apiService.movie.save(tempMovie).then(function (response) {
if(redirect){
$state.go('admin.movie', {movieId: response.data.id});
}else{
$scope.movies.push(response.data);
}
});
};
$scope.alreadyAdded = function (movie) {
return movie.id && _.find($scope.movies, {apiId: movie.id.toString()});
};
}]);