Skip to content

Commit 210d96e

Browse files
authored
Merge pull request #1035 from streamaserver/1.9.2
1.9.3
2 parents 646d57b + 8d2fbf2 commit 210d96e

39 files changed

+486
-236
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
}
1515
}
1616

17-
version "1.9.1"
17+
version "1.9.3"
1818
group "streama"
1919

2020

grails-app/assets/javascripts/streama/controllers/dash-ctrl.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ angular.module('streama').controller('dashCtrl',
55
var vm = this;
66

77
var LIST_MAX = 30;
8-
vm.fetchFirstEpisodeAndPlay = fetchFirstEpisodeAndPlay;
98
vm.showDetails = showDetails;
109
vm.handleWatchlistUpdate = handleWatchlistUpdate;
11-
vm.addToWatchlist = addToWatchlist;
12-
vm.removeFromWatchlist = removeFromWatchlist;
13-
vm.markCompleted = markCompleted;
1410
vm.loadingRecommendations = true;
1511
vm.isDashSectionHidden = isDashSectionHidden;
1612
vm.isDashType = isDashType;
1713

1814
$scope.$on('changedGenre', onChangedGenre);
15+
$scope.$on('video.updateWatchlist', onVideoUpdateWatchlist);
1916

2017
init();
2118

@@ -143,18 +140,12 @@ angular.module('streama').controller('dashCtrl',
143140
vm.tvShow.setFilter();
144141
}
145142

146-
function fetchFirstEpisodeAndPlay(tvShow) {
147-
apiService.dash.firstEpisodeForShow(tvShow.id).then(function (response) {
148-
$state.go('player', {videoId: response.data.id});
149-
});
150-
}
151-
152143
function showDetails(media) {
153144
if(media.mediaType === 'episode'){
154145
modalService.mediaDetailModal({mediaId: media.tvShowId, mediaType: 'tvShow', isApiMovie: false});
155146
}else{
156147
modalService.mediaDetailModal({mediaId: media.id, mediaType: media.mediaType, isApiMovie: false}, function (response) {
157-
updateWatchlist(response.action, vm.watchlistEntry.list, media, response.watchlistEntry);
148+
updateWatchlist(response.action, _.get(vm.watchlistEntry, 'list'), media, response.watchlistEntry);
158149
});
159150
}
160151
}
@@ -173,16 +164,17 @@ angular.module('streama').controller('dashCtrl',
173164
function addToWatchlist(item) {
174165
apiService.watchlistEntry.create(item).then(function (response) {
175166
vm.watchlistEntry.list = vm.watchlistEntry.list ? vm.watchlistEntry.list : [];
176-
updateWatchlist("added", vm.watchlistEntry.list, item, response.data);
167+
updateWatchlist("added", _.get(vm.watchlistEntry, 'list'), item, response.data);
177168
});
178169
}
179170

180171
function removeFromWatchlist(item) {
172+
vm.watchlistEntry.list = vm.watchlistEntry.list ? vm.watchlistEntry.list : [];
181173
alertify.set({buttonReverse: true, labels: {ok: "Yes", cancel: "Cancel"}});
182174
alertify.confirm("Are you sure you want to remove this video from your watchlist?", function (confirmed) {
183175
if (confirmed) {
184176
apiService.watchlistEntry.delete(item).then(function (response) {
185-
updateWatchlist("removed", vm.watchlistEntry.list, item);
177+
updateWatchlist("removed", _.get(vm.watchlistEntry, 'list'), item);
186178
});
187179
}
188180
});
@@ -254,17 +246,6 @@ angular.module('streama').controller('dashCtrl',
254246
return (showItemArray.indexOf(false) < 0);
255247
}
256248

257-
function markCompleted(viewingStatus) {
258-
alertify.set({buttonReverse: true, labels: {ok: "Yes", cancel: "Cancel"}});
259-
alertify.confirm("Are you sure you want to mark this video as completed?", function (confirmed) {
260-
if (confirmed) {
261-
apiService.viewingStatus.delete(viewingStatus.id).then(function (data) {
262-
_.remove(vm.continueWatching, {'id': viewingStatus.id});
263-
});
264-
}
265-
})
266-
}
267-
268249
function isDashSectionHidden(sectionName) {
269250
var hiddenDashSectionSetting = _.find($scope.settings, {name: 'hidden_dash_sections'});
270251
if(_.get(hiddenDashSectionSetting, 'parsedValue')){
@@ -273,4 +254,9 @@ angular.module('streama').controller('dashCtrl',
273254
}
274255
}
275256

257+
function onVideoUpdateWatchlist(e, data) {
258+
vm.watchlistEntry.list = vm.watchlistEntry.list ? vm.watchlistEntry.list : [];
259+
updateWatchlist(data.action, _.get(vm.watchlistEntry, 'list'), data.media, _.get(data.response, 'data'));
260+
}
261+
276262
});

grails-app/assets/javascripts/streama/controllers/modal-media-detail-ctrl.js

+8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ angular.module('streama').controller('modalMediaDetailCtrl', [
1212
$scope.listEpisodesForSeason = listEpisodesForSeason;
1313
$scope.addToWatchlist = addToWatchlist;
1414
$scope.removeFromWatchlist = removeFromWatchlist;
15+
$scope.markAsUnviewed = markAsUnviewed;
1516

1617
if(config.mediaObject) {
1718
$scope.media = config.mediaObject;
@@ -101,4 +102,11 @@ angular.module('streama').controller('modalMediaDetailCtrl', [
101102
}
102103
})
103104
}
105+
106+
function markAsUnviewed() {
107+
apiService.video.markAsUnviewed({id: $scope.media.id}).then(function () {
108+
$scope.media.status = 'unviewed';
109+
$rootScope.$broadcast('video.markAsUnviewed', {id: $scope.media.id});
110+
});
111+
}
104112
}]);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//= wrapped
2+
3+
angular.module('streama').directive('streamaDashMediaItem', function () {
4+
return {
5+
restrict: 'E',
6+
templateUrl: '/streama/directive--streama-dash-media-item.htm',
7+
scope: {
8+
entity: '='
9+
},
10+
bindToController: true,
11+
controllerAs: 'vm',
12+
controller: controller
13+
}
14+
});
15+
16+
function controller(apiService, modalService, $rootScope, $state, $scope) {
17+
var vm = this;
18+
vm.fetchFirstEpisodeAndPlay = fetchFirstEpisodeAndPlay;
19+
vm.showDetails = showDetails;
20+
vm.handleWatchlistUpdate = handleWatchlistUpdate;
21+
vm.markCompleted = markCompleted;
22+
23+
$scope.$on('video.markAsUnviewed', onVideoMarkAsUnviewed);
24+
25+
function fetchFirstEpisodeAndPlay(tvShow) {
26+
apiService.dash.firstEpisodeForShow(tvShow.id).then(function (response) {
27+
$state.go('player', {videoId: response.data.id});
28+
});
29+
}
30+
31+
function showDetails(media) {
32+
if(media.mediaType === 'episode'){
33+
modalService.mediaDetailModal({mediaId: media.tvShowId, mediaType: 'tvShow', isApiMovie: false});
34+
}else{
35+
modalService.mediaDetailModal({mediaId: media.id, mediaType: media.mediaType, isApiMovie: false}, function (response) {
36+
$rootScope.$broadcast('video.updateWatchlist', {response: response, media: media});
37+
});
38+
}
39+
}
40+
41+
function handleWatchlistUpdate(action, item){
42+
switch (action) {
43+
case "added":
44+
addToWatchlist(item);
45+
break;
46+
case "removed":
47+
removeFromWatchlist(item);
48+
break;
49+
}
50+
}
51+
52+
function addToWatchlist(item) {
53+
apiService.watchlistEntry.create(item).then(function (response) {
54+
$rootScope.$broadcast('video.updateWatchlist', {action: 'added', response: response, media: item});
55+
});
56+
}
57+
58+
function removeFromWatchlist(item) {
59+
alertify.set({buttonReverse: true, labels: {ok: "Yes", cancel: "Cancel"}});
60+
alertify.confirm("Are you sure you want to remove this video from your watchlist?", function (confirmed) {
61+
if (confirmed) {
62+
apiService.watchlistEntry.delete(item).then(function (response) {
63+
$rootScope.$broadcast('video.updateWatchlist', {action: 'removed', media: item});
64+
});
65+
}
66+
});
67+
}
68+
69+
function markCompleted() {
70+
alertify.set({buttonReverse: true, labels: {ok: "Yes", cancel: "Cancel"}});
71+
alertify.confirm("Are you sure you want to mark this video as completed?", function (confirmed) {
72+
if (confirmed) {
73+
apiService.video.markCompleted({id: vm.entity.id}).then(function (data) {
74+
vm.entity.deleted = true;
75+
});
76+
}
77+
})
78+
}
79+
80+
function onVideoMarkAsUnviewed(e, data) {
81+
if(data.id === vm.entity.id){
82+
vm.entity.status = 'unviewed';
83+
}
84+
}
85+
}

grails-app/assets/javascripts/streama/services/api-service.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,13 @@ angular.module('streama').factory('apiService', function ($http, $rootScope, con
120120
},
121121
addLocalFile: function (params) {
122122
return $http.get('video/addLocalFile.json', {params: params});
123-
}
123+
},
124+
markAsUnviewed: function (params) {
125+
return $http.get('video/markAsUnviewed.json', {params: params});
126+
},
127+
markCompleted: function (params) {
128+
return $http.get('video/markCompleted.json', {params: params});
129+
},
124130
},
125131

126132
report: {

grails-app/assets/javascripts/streama/templates/dash.tpl.htm

+8-115
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,9 @@ <h2 class="genre-display" ng-if="$root.selectedGenre">{{'DASHBOARD.LOOKING_AT_GE
4545
<h3>{{'DASHBOARD.CONTINUE_WATCHING' | translate}}</h3>
4646

4747
<div class="media-list media-list-continue-watching">
48-
<div class="media-list-item media-poster-item" ng-repeat="viewingStatus in vm.continueWatching">
49-
<div class="media-item" >
48+
<div class="media-list-item media-poster-item" ng-repeat="viewingStatus in vm.continueWatching" ng-if="!viewingStatus.video.deleted">
5049

51-
<streama-video-image type="poster" video="viewingStatus.video" size="300"></streama-video-image>
52-
53-
<div class="play-text">
54-
<h4>Continue "<span ng-bind="::(viewingStatus.video.title || viewingStatus.video.show.name)"></span>"</h4>
55-
<button class=" btn btn-secondary btn-xss complete-watching" ng-click="vm.markCompleted(viewingStatus)">
56-
{{'DASHBOARD.MARK_COMPLETED' | translate}}</button>
57-
<p ng-show="viewingStatus.video.isEpisode"><span ng-bind="::viewingStatus.video.episodeString"></span></p>
58-
</div>
59-
<!--<div>-->
60-
<!--<i ng-class="viewingStatus.video.inWatchlist ? 'remove-icon ion-android-remove-circle' : 'add-icon ion-android-add-circle'"-->
61-
<!--ng-click="vm.handleWatchlistUpdate(viewingStatus.video.inWatchlist ? 'removed' : 'added', viewingStatus.video)"></i>-->
62-
<!--</div>-->
63-
64-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(viewingStatus.video)"></i>
65-
<a class="play-icon ion-ios-play" ui-sref="player({videoId: viewingStatus.video.id})"></a>
66-
</div>
50+
<streama-dash-media-item entity="viewingStatus.video"></streama-dash-media-item>
6751

6852
<div class="media-progress-wrapper">
6953

@@ -93,29 +77,15 @@ <h3>{{'DASHBOARD.RECOMMENDATIONS' | translate}}</h3>
9377

9478
<div class="media-list media-list-continue-watching">
9579
<div class="media-list-item media-poster-item" ng-repeat="video in vm.recommendations track by video.id">
96-
<div class="media-item" >
97-
98-
<streama-video-image type="poster" video="video"></streama-video-image>
99-
100-
<div class="play-text">
101-
<h4 ng-bind="::(video.title || video.show.name)"></h4>
102-
<p ng-show="video.isEpisode"><span ng-bind="::video.episodeString"></span></p>
103-
</div>
104-
<div>
105-
<i ng-class="video.inWatchlist ? 'remove-icon ion-android-remove-circle' : 'add-icon ion-android-add-circle'"
106-
ng-click="vm.handleWatchlistUpdate(video.inWatchlist ? 'removed' : 'added', video)"></i>
107-
</div>
10880

109-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(video)"></i>
110-
<a class="play-icon ion-ios-play" ui-sref="player({videoId: video.id})"></a>
111-
</div>
81+
<streama-dash-media-item entity="video"></streama-dash-media-item>
11282
</div>
11383
</div>
11484

11585
</div>
11686

11787
<!----------------------------------------------watchlist-------------------------------------------->
118-
<div ng-if="vm.isDashType('home') && vm.watchlistEntry.list.length && !vm.isDashSectionHidden('watchlist')">
88+
<div ng-if="(vm.isDashType('home') || vm.isDashType('watchlist')) && vm.watchlistEntry.list.length && !vm.isDashSectionHidden('watchlist')">
11989
<hr/>
12090
<h3>{{'DASHBOARD.WATCHLIST' | translate}}</h3>
12191

@@ -129,38 +99,7 @@ <h3>{{'DASHBOARD.WATCHLIST' | translate}}</h3>
12999

130100
<div class="media-list">
131101
<div class="media-list-item media-poster-item" ng-repeat="watchlistEntry in vm.watchlistEntry.list track by watchlistEntry.id">
132-
<div class="media-item" ng-if="watchlistEntry.tvShow">
133-
134-
<streama-video-image type="poster" size="300" video="watchlistEntry.tvShow"></streama-video-image>
135-
136-
<div class="play-text">
137-
<h4 ng-bind="::watchlistEntry.tvShow.name"></h4>
138-
</div>
139-
<i class="remove-icon ion-android-remove-circle" ng-click="vm.removeFromWatchlist(watchlistEntry.tvShow)"></i>
140-
<div>
141-
<i ng-class="'remove-icon ion-android-remove-circle'"
142-
ng-click="vm.handleWatchlistUpdate('removed', watchlistEntry.tvShow)"></i>
143-
</div>
144-
145-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(watchlistEntry.tvShow)"></i>
146-
<a class="play-icon ion-ios-play" ng-click="vm.fetchFirstEpisodeAndPlay(watchlistEntry.tvShow)"></a>
147-
</div>
148-
<div class="media-item" ng-if="watchlistEntry.video">
149-
150-
<streama-video-image type="poster" size="300" video="watchlistEntry.video"></streama-video-image>
151-
152-
<div class="play-text">
153-
<h4 ng-bind="::watchlistEntry.video.title"></h4>
154-
<p ng-bind="::watchlistEntry.video.release_date.substring(0,4)"></p>
155-
</div>
156-
<div>
157-
<i ng-class="'remove-icon ion-android-remove-circle'"
158-
ng-click="vm.handleWatchlistUpdate('removed', watchlistEntry.video)"></i>
159-
</div>
160-
161-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(watchlistEntry.video)"></i>
162-
<a class="play-icon ion-ios-play" ui-sref="player({videoId: watchlistEntry.video.id})"></a>
163-
</div>
102+
<streama-dash-media-item entity="watchlistEntry.tvShow || watchlistEntry.video"></streama-dash-media-item>
164103
</div>
165104
</div>
166105
</div>
@@ -215,21 +154,7 @@ <h3>
215154

216155
<div class="media-list">
217156
<div class="media-list-item media-poster-item" ng-repeat="tvShow in vm.tvShow.list | filter: vm.tvShow.filter.execute">
218-
<div class="media-item" >
219-
<streama-video-image type="poster" size="300" video="tvShow"></streama-video-image>
220-
221-
<div class="play-text">
222-
<h4 ng-bind="::tvShow.name"></h4>
223-
</div>
224-
225-
<div>
226-
<i ng-class="tvShow.inWatchlist ? 'remove-icon ion-android-remove-circle' : 'add-icon ion-android-add-circle'"
227-
ng-click="vm.handleWatchlistUpdate(tvShow.inWatchlist ? 'removed' : 'added', tvShow)"></i>
228-
</div>
229-
230-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(tvShow)"></i>
231-
<a class="play-icon ion-ios-play" ng-click="vm.fetchFirstEpisodeAndPlay(tvShow)"></a>
232-
</div>
157+
<streama-dash-media-item entity="tvShow"></streama-dash-media-item>
233158
</div>
234159
</div>
235160

@@ -285,22 +210,7 @@ <h3>
285210

286211
<div class="media-list">
287212
<div class="media-list-item media-poster-item" ng-repeat="movie in vm.movie.list | orderBy:vm.movie.sorter.sort |filter: vm.movie.filter.execute">
288-
<div class="media-item" >
289-
290-
<streama-video-image type="poster" size="300" video="movie"></streama-video-image>
291-
292-
<div class="play-text">
293-
<h4 ng-bind="::movie.title"></h4>
294-
<p ng-bind="::movie.release_date.substring(0,4)"></p>
295-
</div>
296-
<div>
297-
<i ng-class="movie.inWatchlist ? 'remove-icon ion-android-remove-circle' : 'add-icon ion-android-add-circle'"
298-
ng-click="vm.handleWatchlistUpdate(movie.inWatchlist ? 'removed' : 'added', movie)"></i>
299-
</div>
300-
301-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(movie)"></i>
302-
<a class="play-icon ion-ios-play" ui-sref="player({videoId: movie.id})"></a>
303-
</div>
213+
<streama-dash-media-item entity="movie"></streama-dash-media-item>
304214
</div>
305215
</div>
306216

@@ -341,24 +251,7 @@ <h3>
341251

342252
<div class="media-list">
343253
<div class="media-list-item media-poster-item" ng-repeat="movie in vm.genericVideo.list |filter: vm.genericVideo.filter.title">
344-
345-
<div class="media-item" >
346-
347-
348-
<streama-video-image type="poster" size="300" video="movie"></streama-video-image>
349-
350-
<div class="play-text">
351-
<h4 ng-bind="::movie.title"></h4>
352-
<p ng-bind="::movie.release_date.substring(0,4)"></p>
353-
</div>
354-
<div>
355-
<i ng-class="movie.inWatchlist ? 'remove-icon ion-android-remove-circle' : 'add-icon ion-android-add-circle'"
356-
ng-click="vm.handleWatchlistUpdate(movie.inWatchlist ? 'removed' : 'added', movie)"></i>
357-
</div>
358-
359-
<i class="info-icon ion-ios-information" ng-click="vm.showDetails(movie)"></i>
360-
<a class="play-icon ion-ios-play" ui-sref="player({videoId: movie.id})"></a>
361-
</div>
254+
<streama-dash-media-item entity="movie"></streama-dash-media-item>
362255
</div>
363256
</div>
364257
</div>

0 commit comments

Comments
 (0)