Skip to content

Commit 473b223

Browse files
committed
mark all episodes at once
1 parent ff5df1b commit 473b223

File tree

5 files changed

+82
-21
lines changed

5 files changed

+82
-21
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ You can also set options to display release date and/or genre of your own list.
105105

106106
### Further Development
107107

108-
* Mark all episodes at once
109108
* Fetch new episodes (maybe option with cron to send user an info mail)
110109
* Upcoming and trending for tv shows
111110
* Swap own TMDb service with an package

backend/app/Http/Controllers/ItemController.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ private function createItem($data, TMDB $tmdb)
164164
return $item;
165165
}
166166

167+
/**
168+
* Set an episode as seen/unseen.
169+
*
170+
* @param $id
171+
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
172+
*/
167173
public function setSeen($id)
168174
{
169175
$episode = Episode::find($id);
@@ -174,6 +180,23 @@ public function setSeen($id)
174180
}
175181
}
176182

183+
/**
184+
* Toggle all episodes of an season as seen/unseen.
185+
*/
186+
public function toggleSeason()
187+
{
188+
$tmdb_id = Input::get('tmdb_id');
189+
$season = Input::get('season');
190+
$seen = Input::get('seen');
191+
192+
$episodes = Episode::where('tmdb_id', $tmdb_id)->where('season_number', $season)->get();
193+
194+
foreach($episodes as $episode) {
195+
$episode->seen = $seen;
196+
$episode->save();
197+
}
198+
}
199+
177200
/**
178201
* Save all episodes of each season.
179202
*

backend/routes/web.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
Route::patch('/userdata', 'UserController@changeUserData');
2727
Route::patch('/set-seen/{id}', 'ItemController@setSeen');
28+
Route::patch('/toggle-season', 'ItemController@toggleSeason');
2829
Route::get('/episodes/{tmdb_id}', 'ItemController@episodes');
2930

3031
Route::get('/search-tmdb', 'TMDBController@search');

client/app/components/Modal/Season.vue

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
</span>
1919
</div>
2020

21+
<div class="item-header no-select" v-if=" ! loadingModalData">
22+
<span class="header-episode">#</span>
23+
<span class="header-name">Name</span>
24+
<span class="header-seen" @click="toggleAll()">Toggle all</span>
25+
</div>
26+
2127
<div class="modal-content" v-if=" ! loadingModalData">
22-
<!--div class="item-header">
23-
<span class="header-episode">#</span>
24-
<span class="header-name">Name</span>
25-
<span></span>
26-
</div-->
27-
<!-- todo: mark all as read -->
2828
<div @click="setSeen(episode)" class="modal-item" v-for="(episode, index) in episodes[seasonActiveModal]">
2929
<span class="modal-episode no-select">E{{ addZero(episode.episode_number) }}</span>
3030
<span class="modal-name">{{ episode.name }}</span>
@@ -44,9 +44,44 @@
4444
export default {
4545
mixins: [Helper],
4646
47+
computed: {
48+
...mapState({
49+
modalType: state => state.modalType,
50+
modalData: state => state.modalData,
51+
loadingModalData: state => state.loadingModalData,
52+
seasonActiveModal: state => state.seasonActiveModal
53+
}),
54+
55+
episodes() {
56+
return this.modalData.episodes;
57+
}
58+
},
59+
4760
methods: {
4861
...mapMutations([ 'SET_SEASON_ACTIVE_MODAL', 'CLOSE_MODAL' ]),
4962
63+
toggleAll() {
64+
const season = this.seasonActiveModal;
65+
const tmdb_id = this.modalData.episodes[1][0].tmdb_id;
66+
const seen = this.seasonCompleted(season);
67+
68+
this.markAllEpisodes(season, seen);
69+
70+
http.patch(`${config.api}/toggle-season`, {
71+
tmdb_id,
72+
season,
73+
seen: ! seen
74+
});
75+
},
76+
77+
markAllEpisodes(season, seen) {
78+
const episodes = this.episodes[season];
79+
80+
for(let episode of episodes) {
81+
episode.seen = ! seen;
82+
}
83+
},
84+
5085
setSeen(episode) {
5186
episode.seen = ! episode.seen;
5287
http.patch(`${config.api}/set-seen/${episode.id}`).catch(error => {
@@ -65,19 +100,6 @@
65100
66101
return true;
67102
}
68-
},
69-
70-
computed: {
71-
...mapState({
72-
modalType: state => state.modalType,
73-
modalData: state => state.modalData,
74-
loadingModalData: state => state.loadingModalData,
75-
seasonActiveModal: state => state.seasonActiveModal
76-
}),
77-
78-
episodes() {
79-
return this.modalData.episodes;
80-
}
81103
}
82104
}
83105
</script>

client/resources/sass/components/_modal.scss

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@
9898
.item-header {
9999
float: left;
100100
width: 100%;
101-
padding: 10px 10px 0 10px;
101+
padding: 10px;
102+
background: #2f2f2f;
102103

103104
span {
104105
float: left;
@@ -113,6 +114,21 @@
113114
text-align: right;
114115
}
115116

117+
.header-seen {
118+
float: right !important;
119+
cursor: pointer;
120+
121+
@include transition(color);
122+
123+
&:hover {
124+
color: rgba(#fff, .8);
125+
}
126+
127+
&:active {
128+
color: rgba(#fff, .4);
129+
}
130+
}
131+
116132
.modal-content-loading {
117133
padding: 100px 0;
118134
}

0 commit comments

Comments
 (0)