Skip to content

Commit

Permalink
Feature/vuefiy schedule (#9403)
Browse files Browse the repository at this point in the history
* Change route schedule to vueRouter.
* Added web_host to api.

* Moved schedule.mako header to schedule.vue.
* updated routes for schedule.vue.
* Added web_host to general.js.

* Add apiv2 route for schedule. (coming episodes)

* Made a start with the list layout.

* Add externals

* Use https

* Add attributes to schedule apiv2 route.

* Add search.vue component for the forced and manual searched buttons.

* Implement banner and list layouts.

* Add poster layout

* implemented calendar layout.

* Fix calendar.vue episode schedule calculation
* Add toggles for showing missed, today, soon, later.

* Improved layout for the filter buttons.

* Moved grouped and sorted functions to schedule.js

* Use _ for unsused params.

* Added styling for schedule.vue page.

* Improved sorting per category (soon, later, etc)
* Used this now for each layout.

* Moved groupedSchedule to schedule.js

* Rest of the refactor

* Fix text color on filter buttons.

* Improved styling vue-good-table columns filters.
* Reduced the margings.
* Applied same styling to home => table layouts.
* Added the select-columns filter to history layouts.

* Updated version vue-good-table

* yarn lint & yarn lint-css

* updated yarn.lock

* Fix test

* remove unused imports (lint)
  • Loading branch information
p0psicles authored May 1, 2021
1 parent a18e976 commit ebd701f
Show file tree
Hide file tree
Showing 41 changed files with 2,838 additions and 499 deletions.
4 changes: 2 additions & 2 deletions medusa/indexers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@
'xem_mapped_to': INDEXER_TVDBV2,
'icon': 'tvmaze16.png',
'scene_loc': '{base_url}/scene_exceptions/scene_exceptions_tvmaze.json'.format(base_url=app.BASE_PYMEDUSA_URL),
'show_url': 'http://www.tvmaze.com/shows/',
'base_url': 'http://api.tvmaze.com/',
'show_url': 'https://www.tvmaze.com/shows/',
'base_url': 'https://api.tvmaze.com/',
'mapped_to': 'tvmaze_id', # The attribute to which other indexers can map there tvmaze id to
'identifier': 'tvmaze', # Also used as key for the custom scenename exceptions. (_get_custom_exceptions())
},
Expand Down
2 changes: 2 additions & 0 deletions medusa/server/api/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class ConfigHandler(BaseRequestHandler):
'webInterface.username': StringField(app, 'WEB_USERNAME'),
'webInterface.password': StringField(app, 'WEB_PASSWORD'),
'webInterface.port': IntegerField(app, 'WEB_PORT'),
'webInterface.host': StringField(app, 'WEB_HOST'),
'webInterface.notifyOnLogin': BooleanField(app, 'NOTIFY_ON_LOGIN'),
'webInterface.ipv6': BooleanField(app, 'WEB_IPV6'),
'webInterface.httpsEnable': BooleanField(app, 'ENABLE_HTTPS'),
Expand Down Expand Up @@ -671,6 +672,7 @@ def data_main():
section_data['webInterface']['username'] = app.WEB_USERNAME
section_data['webInterface']['password'] = app.WEB_PASSWORD
section_data['webInterface']['port'] = int_default(app.WEB_PORT, 8081)
section_data['webInterface']['host'] = app.WEB_HOST
section_data['webInterface']['notifyOnLogin'] = bool(app.NOTIFY_ON_LOGIN)
section_data['webInterface']['ipv6'] = bool(app.WEB_IPV6)
section_data['webInterface']['httpsEnable'] = bool(app.ENABLE_HTTPS)
Expand Down
60 changes: 60 additions & 0 deletions medusa/server/api/v2/schedule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# coding=utf-8
"""Request handler for series and episodes."""
from __future__ import unicode_literals

import logging

from medusa.logger.adapters.style import BraceAdapter
from medusa.server.api.v2.base import BaseRequestHandler
from medusa.show.coming_episodes import ComingEpisodes

log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())


class ScheduleHandler(BaseRequestHandler):
"""Coming episodes request handler."""

#: resource name
name = 'schedule'
#: identifier
identifier = None
#: allowed HTTP methods
allowed_methods = ('GET',)

def get(self):
"""Query episode's history information."""
sort = self.get_argument('sort', default='desc')
categories = self.get_arguments('category[]') or ['missed']
paused = self.get_argument('paused', default=False)

grouped_coming_episodes = ComingEpisodes.get_coming_episodes(categories, sort, True, paused)
data = {section: [] for section in grouped_coming_episodes}

for section, coming_episodes in grouped_coming_episodes.items():
for coming_episode in coming_episodes:
data[section].append({
'airdate': coming_episode['airdate'],
'airs': coming_episode['airs'],
'epName': coming_episode['name'],
'epPlot': coming_episode['description'],
'season': coming_episode['season'],
'episode': coming_episode['episode'],
'episodeSlug': 's{season:02d}e{episode:02d}'.format(
season=coming_episode['season'], episode=coming_episode['episode']
),
'indexerId': coming_episode['indexer_id'],
'indexer': coming_episode['indexer'],
'network': coming_episode['network'],
'paused': coming_episode['paused'],
'quality': coming_episode['qualityValue'],
'showSlug': coming_episode['series_slug'],
'showName': coming_episode['show_name'],
'showStatus': coming_episode['status'],
'tvdbid': coming_episode['tvdbid'],
'weekday': coming_episode['weekday'],
'runtime': coming_episode['runtime'],
'externals': coming_episode['externals']
})

return self._ok(data)
4 changes: 4 additions & 0 deletions medusa/server/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from medusa.server.api.v2.log import LogHandler
from medusa.server.api.v2.postprocess import PostProcessHandler
from medusa.server.api.v2.providers import ProvidersHandler
from medusa.server.api.v2.schedule import ScheduleHandler
from medusa.server.api.v2.search import SearchHandler
from medusa.server.api.v2.series import SeriesHandler
from medusa.server.api.v2.series_asset import SeriesAssetHandler
Expand Down Expand Up @@ -93,6 +94,9 @@ def get_apiv2_handlers(base):
# /api/v2/history/tvdb1234/episode
EpisodeHistoryHandler.create_app_handler(base),

# /api/v2/schedule
ScheduleHandler.create_app_handler(base),

# /api/v2/history
HistoryHandler.create_app_handler(base),

Expand Down
19 changes: 7 additions & 12 deletions medusa/server/web/core/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@

from __future__ import unicode_literals

import datetime

from medusa import app, network_timezones
from medusa import app
from medusa.server.web.core.base import PageTemplate, WebRoot
from medusa.show.coming_episodes import ComingEpisodes

from tornroutes import route

Expand All @@ -17,14 +14,12 @@ def __init__(self, *args, **kwargs):
super(Schedule, self).__init__(*args, **kwargs)

def index(self):
next_week = datetime.date.today() + datetime.timedelta(days=7)
next_week1 = datetime.datetime.combine(next_week, datetime.time(tzinfo=network_timezones.app_timezone))
results = ComingEpisodes.get_coming_episodes(ComingEpisodes.categories, app.COMING_EPS_SORT, False)
today = datetime.datetime.now().replace(tzinfo=network_timezones.app_timezone)

t = PageTemplate(rh=self, filename='schedule.mako')
return t.render(next_week=next_week1, today=today, results=results,
layout=app.COMING_EPS_LAYOUT, controller='schedule', action='index')
"""
Render the schedule page.
[Converted to VueRouter]
"""
return PageTemplate(rh=self, filename='index.mako').render()

def toggleScheduleDisplayPaused(self):
app.COMING_EPS_DISPLAY_PAUSED = not app.COMING_EPS_DISPLAY_PAUSED
Expand Down
8 changes: 6 additions & 2 deletions medusa/show/coming_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from medusa.helpers.quality import get_quality_string
from medusa.network_timezones import parse_date_time
from medusa.sbdatetime import sbdatetime
from medusa.tv.series import SeriesIdentifier
from medusa.tv.series import Series, SeriesIdentifier


class ComingEpisodes(object):
Expand Down Expand Up @@ -129,9 +129,12 @@ def get_coming_episodes(categories, sort, group, paused=app.COMING_EPS_DISPLAY_P
)

for index, item in enumerate(results):
item['series_slug'] = str(SeriesIdentifier.from_id(int(item['indexer']), item['indexer_id']))
identifier = SeriesIdentifier.from_id(int(item['indexer']), item['indexer_id'])
show = Series.find_by_identifier(identifier)
item['series_slug'] = identifier.slug
results[index]['localtime'] = sbdatetime.convert_to_setting(
parse_date_time(item['airdate'], item['airs'], item['network']))
results[index]['externals'] = show.externals

results.sort(key=ComingEpisodes.sorts[sort])

Expand Down Expand Up @@ -162,6 +165,7 @@ def get_coming_episodes(categories, sort, group, paused=app.COMING_EPS_DISPLAY_P
if not result['network']:
result['network'] = ''

result['qualityValue'] = result['quality']
result['quality'] = get_quality_string(result['quality'])
result['airs'] = sbdatetime.sbftime(result['localtime'], t_preset=timeFormat).lstrip('0').replace(' 0', ' ')
result['weekday'] = 1 + date.fromordinal(result['airdate']).weekday()
Expand Down
1 change: 1 addition & 0 deletions tests/apiv2/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def config_main(monkeypatch, app_config):
section_data['webInterface']['log'] = bool(app.WEB_LOG)
section_data['webInterface']['username'] = app.WEB_USERNAME
section_data['webInterface']['password'] = app.WEB_PASSWORD
section_data['webInterface']['host'] = app.WEB_HOST
section_data['webInterface']['port'] = int_default(app.WEB_PORT, 8081)
section_data['webInterface']['notifyOnLogin'] = bool(app.NOTIFY_ON_LOGIN)
section_data['webInterface']['ipv6'] = bool(app.WEB_IPV6)
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"vue-async-computed": "3.9.0",
"vue-cookies": "1.7.4",
"vue-form-wizard": "0.8.4",
"vue-good-table": "p0psicles/vue-good-table#254e1f3c5274e52c019d104396549037fbea19c8",
"vue-good-table": "git+https://github.com/p0psicles/vue-good-table#7d9dbf1156679c52a2cc336ba00618ddd8248574",
"vue-images-loaded": "1.1.2",
"vue-js-modal": "2.0.0-rc.6",
"vue-js-toggle-button": "1.3.3",
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/src/components/config-general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ export default {
}
};
</script>
<style>
<style scoped>
@import '../style/modal.css';
.display-inline {
Expand Down
27 changes: 23 additions & 4 deletions themes-default/slim/src/components/display-show.vue
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ export default {
};
return {
invertTable: true,
isMobile: false,
subtitleSearchComponents: [],
columns: [{
label: 'NFO',
Expand Down Expand Up @@ -1581,9 +1580,27 @@ td.col-footer {
margin-right: 2px;
}
.displayShow >>> .vgt-dropdown > .button-group {
position: relative;
}
.displayShow >>> .dropdown-toggle {
position: absolute;
z-index: 1;
top: 0.1em;
right: 0.1em;
width: 1em;
transition: width 0.2s ease-in-out;
}
.displayShow >>> .dropdown-toggle:hover,
.displayShow >>> .dropdown-toggle:active {
width: 2em;
}
.displayShow >>> .vgt-dropdown-menu {
position: absolute;
z-index: 1000;
z-index: 1;
float: left;
min-width: 160px;
padding: 5px 0;
Expand All @@ -1592,12 +1609,14 @@ td.col-footer {
text-align: left;
list-style: none;
background-clip: padding-box;
border-radius: 4px;
border-radius: 3px;
right: 0;
top: 2em;
}
.displayShow >>> .vgt-dropdown-menu > li > span {
display: block;
padding: 3px 20px;
padding: 3px 5px;
clear: both;
font-weight: 400;
line-height: 1.42857143;
Expand Down
1 change: 1 addition & 0 deletions themes-default/slim/src/components/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export { default as PosterSizeSlider } from './poster-size-slider.vue';
export { default as QualityChooser } from './quality-chooser.vue';
export { default as QualityPill } from './quality-pill.vue';
export { default as ScrollButtons } from './scroll-buttons.vue';
export { default as Search } from './search.vue';
export { default as SelectList } from './select-list.vue';
export { default as ShowSelector } from './show-selector.vue';
export { default as SortedSelectList } from './sorted-select-list.vue';
Expand Down
Loading

0 comments on commit ebd701f

Please sign in to comment.