Skip to content

Commit

Permalink
Vueify header (#4519)
Browse files Browse the repository at this point in the history
* Convert header.mako to a Vue component

* Improve tools badge and implement mobile view badge

* Replace Python values with store equivalents

* Update app.SHOWS_RECENT and header component

* Fix navigation

- Move javascript to component
- Fix dropdown hover not firing
- Fix having to click twice on nav with dropdown (old bug)
- Fix restart and shutdown confirmation dialogs
- Add logout confirmation dialog

* Wrap in `<%text>` to enable JS template literals

* Remove Emby API key check to make SFC possible

* Convert to SFC

* Remove all `topmenu` arguments 🎉

* Update changelog

* Add failing test

* add app-link to app-header test

* stub app-link until we remove jQuery from app-link
  • Loading branch information
sharkykh authored and OmgImAlexis committed Jul 13, 2018
1 parent aaca61c commit 49f4f98
Show file tree
Hide file tree
Showing 40 changed files with 1,033 additions and 556 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- Removed the old `/ui` route ([#4565](https://github.com/pymedusa/Medusa/pull/4565))
- Added a simple "Loading..." message while the page is loading ([#4629](https://github.com/pymedusa/Medusa/pull/4629))
- Expanded episode status management capabilities, added support for Downloaded, Archived ([#4647](https://github.com/pymedusa/Medusa/pull/4647))
- Converted the header to Vue ([#4519](https://github.com/pymedusa/Medusa/pull/4519))
- _Simple message describing the improvement, and a link to the pull request._

**Fixes**
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def index(self):

t = PageTemplate(rh=self, filename='config_anime.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='anime')

def saveAnime(self, use_anidb=None, anidb_username=None, anidb_password=None, anidb_use_mylist=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/backup_restore.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs):
def index(self):
t = PageTemplate(rh=self, filename='config_backuprestore.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='backupRestore')

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, *args, **kwargs):
def index(self):
t = PageTemplate(rh=self, filename='config_general.mako')

return t.render(topmenu='config', submenu=self.ConfigMenu(),
return t.render(submenu=self.ConfigMenu(),
controller='config', action='index')

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def index(self):
[Converted to VueRouter]
"""
t = PageTemplate(rh=self, filename='index.mako')
return t.render(submenu=self.ConfigMenu(), topmenu='config')
return t.render(submenu=self.ConfigMenu())
2 changes: 1 addition & 1 deletion medusa/server/web/config/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def index(self):
"""
t = PageTemplate(rh=self, filename='config_notifications.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='notifications')

def saveNotifications(self, use_kodi=None, kodi_always_on=None, kodi_notify_onsnatch=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def index(self):
"""
t = PageTemplate(rh=self, filename='config_postProcessing.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='postProcessing')

def savePostProcessing(self, kodi_data=None, kodi_12plus_data=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def index(self):
"""Render the Provider configuration page."""
t = PageTemplate(rh=self, filename='config_providers.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='providers')

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def index(self):
"""
t = PageTemplate(rh=self, filename='config_search.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='search')

def saveSearch(self, use_nzbs=None, use_torrents=None, nzb_dir=None, sab_username=None, sab_password=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/config/subtitles.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def index(self):
"""
t = PageTemplate(rh=self, filename='config_subtitles.mako')

return t.render(submenu=self.ConfigMenu(), topmenu='config',
return t.render(submenu=self.ConfigMenu(),
controller='config', action='subtitlesPage')

def saveSubtitles(self, use_subtitles=None, subtitles_plugins=None, subtitles_languages=None, subtitles_dir=None, subtitles_perfect_match=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/core/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def get(self, *args, **kwargs):
self.redirect('/{page}/'.format(page=app.DEFAULT_PAGE))
else:
t = PageTemplate(rh=self, filename='index.mako')
self.finish(t.render(topmenu='login'))
self.finish(t.render())

def post(self, *args, **kwargs):
"""
Expand Down
22 changes: 0 additions & 22 deletions medusa/server/web/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from medusa import (
app,
classes,
db,
exception_handler,
helpers,
Expand Down Expand Up @@ -88,19 +87,13 @@ def __init__(self, rh, filename):
'sbDefaultPage': app.DEFAULT_PAGE,
'loggedIn': rh.get_current_user(),
'sbStartTime': rh.startTime,
'numErrors': len(classes.ErrorViewer.errors),
'numWarnings': len(classes.WarningViewer.errors),
'sbPID': str(app.PID),
'title': 'FixME',
'header': 'FixME',
'topmenu': 'FixME',
'submenu': [],
'controller': 'FixME',
'action': 'FixME',
'show': UNDEFINED,
'newsBadge': '',
'toolsBadge': '',
'toolsBadgeClass': '',
'base_url': base_url + app.WEB_ROOT + '/',
'realpage': '',
'full_url': base_url + rh.request.uri
Expand All @@ -117,21 +110,6 @@ def __init__(self, rh, filename):
if 'X-Forwarded-Proto' in rh.request.headers:
self.arguments['sbHttpsEnabled'] = True if rh.request.headers['X-Forwarded-Proto'] == 'https' else False

error_count = len(classes.ErrorViewer.errors)
warning_count = len(classes.WarningViewer.errors)

if app.NEWS_UNREAD:
self.arguments['newsBadge'] = ' <span class="badge">{news}</span>'.format(news=app.NEWS_UNREAD)

num_combined = error_count + warning_count + app.NEWS_UNREAD
if num_combined:
if error_count:
self.arguments['toolsBadgeClass'] = ' btn-danger'
elif warning_count:
self.arguments['toolsBadgeClass'] = ' btn-warning'
self.arguments['toolsBadge'] = ' <span class="badge{type}">{number}</span>'.format(
type=self.arguments['toolsBadgeClass'], number=num_combined)

def render(self, *args, **kwargs):
"""Render the Page template."""
for key in self.arguments:
Expand Down
4 changes: 2 additions & 2 deletions medusa/server/web/core/error_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def index(self, level=logging.ERROR, **kwargs):
level = logging.ERROR

t = PageTemplate(rh=self, filename='errorlogs.mako')
return t.render(topmenu='system', submenu=self._create_menu(level), logLevel=level,
return t.render(submenu=self._create_menu(level), logLevel=level,
controller='errorlogs', action='index')

@staticmethod
Expand Down Expand Up @@ -146,7 +146,7 @@ def viewlog(self, min_level=logging.INFO, log_filter=None, log_search=None, max_
search_query=log_search))]

if not text_view:
return t.render(topmenu='system', log_lines='\n'.join([html_escape(line) for line in data]),
return t.render(log_lines='\n'.join([html_escape(line) for line in data]),
min_level=min_level, log_name_filters=log_name_filters, log_filter=log_filter, log_search=log_search, log_period=log_period,
controller='errorlogs', action='viewlogs')
else:
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/core/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def index(self, limit=None):
]

return t.render(historyResults=history.detailed, compactResults=history.compact, limit=limit,
submenu=submenu[::-1], topmenu='history', controller='history', action='index')
submenu=submenu[::-1], controller='history', action='index')

def clearHistory(self):
# @TODO: Replace this with DELETE /api/v2/history
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/core/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def index(self):
t = PageTemplate(rh=self, filename='schedule.mako')
return t.render(submenu=submenu[::-1], next_week=next_week1, today=today, results=results,
layout=app.COMING_EPS_LAYOUT,
topmenu='schedule', controller='schedule', action='index')
controller='schedule', action='index')

def toggleScheduleDisplayPaused(self):
app.COMING_EPS_DISPLAY_PAUSED = not app.COMING_EPS_DISPLAY_PAUSED
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/home/add_recommended.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ def index(self):
[Converted to VueRouter]
"""
t = PageTemplate(rh=self, filename="index.mako")
return t.render(topmenu='home', controller="addShows", action="index")
return t.render(controller="addShows", action="index")
10 changes: 5 additions & 5 deletions medusa/server/web/home/add_shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def index(self):
[Converted to VueRouter]
"""
t = PageTemplate(rh=self, filename='index.mako')
return t.render(topmenu='home', controller='addShows', action='index')
return t.render(controller='addShows', action='index')

def newShow(self, show_to_add=None, other_shows=None, search_string=None):
"""
Expand Down Expand Up @@ -108,7 +108,7 @@ def newShow(self, show_to_add=None, other_shows=None, search_string=None):
provided_show_dir=show_dir, provided_indexer_id=provided_indexer_id,
provided_indexer_name=provided_indexer_name, provided_indexer=provided_indexer,
indexers=indexerApi().indexers, whitelist=[], blacklist=[], groups=[],
topmenu='home', controller='addShows', action='newShow'
controller='addShows', action='newShow'
)

def trendingShows(self, traktList=None):
Expand Down Expand Up @@ -205,7 +205,7 @@ def popularShows(self):

return t.render(title="Popular Shows", header="Popular Shows",
recommended_shows=recommended_shows, exception=e, groups=[],
topmenu="home", enable_anime_options=True, blacklist=[], whitelist=[],
enable_anime_options=True, blacklist=[], whitelist=[],
controller="addShows", action="recommendedShows", realpage="popularShows")

def popularAnime(self, list_type=REQUEST_HOT):
Expand All @@ -223,7 +223,7 @@ def popularAnime(self, list_type=REQUEST_HOT):

return t.render(title="Popular Anime Shows", header="Popular Anime Shows",
recommended_shows=recommended_shows, exception=e, groups=[],
topmenu="home", enable_anime_options=True, blacklist=[], whitelist=[],
enable_anime_options=True, blacklist=[], whitelist=[],
controller="addShows", action="recommendedShows", realpage="popularAnime")

def addShowToBlacklist(self, seriesid):
Expand Down Expand Up @@ -254,7 +254,7 @@ def existingShows(self):
"""
t = PageTemplate(rh=self, filename='addShows_addExistingShow.mako')
return t.render(enable_anime_options=True, blacklist=[], whitelist=[], groups=[],
topmenu='home', controller='addShows', action='addExistingShow')
controller='addShows', action='addExistingShow')

def addShowByID(self, indexername=None, seriesid=None, show_name=None, which_series=None,
indexer_lang=None, root_dir=None, default_status=None,
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/home/change_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ def index(self):
changes if changes else 'The was a problem connecting to github, please refresh and try again', extras=['header-ids']
)

return t.render(title='Changelog', header='Changelog', topmenu='system', data=data, controller='changes', action='index')
return t.render(title='Changelog', header='Changelog', data=data, controller='changes', action='index')
26 changes: 14 additions & 12 deletions medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
IndexerException,
IndexerShowNotFoundInLanguage,
)
from medusa.indexers.utils import indexer_name_to_id
from medusa.indexers.utils import indexer_id_to_name, indexer_name_to_id
from medusa.providers.generic_provider import GenericProvider
from medusa.sbdatetime import sbdatetime
from medusa.scene_exceptions import (
Expand Down Expand Up @@ -132,7 +132,7 @@ def __init__(self, *args, **kwargs):

def _genericMessage(self, subject, message):
t = PageTemplate(rh=self, filename='genericMessage.mako')
return t.render(message=message, subject=subject, topmenu='home', title='')
return t.render(message=message, subject=subject, title='')

def index(self):
t = PageTemplate(rh=self, filename='home.mako')
Expand Down Expand Up @@ -168,7 +168,7 @@ def index(self):
show_lists = [['Series', series]]

stats = self.show_statistics()
return t.render(topmenu='home', show_lists=show_lists, show_stat=stats[0],
return t.render(show_lists=show_lists, show_stat=stats[0],
max_download_count=stats[1], controller='home', action='index')

@staticmethod
Expand Down Expand Up @@ -695,7 +695,7 @@ def status(self):
root_dir[subject] = helpers.get_disk_space_usage(subject)

t = PageTemplate(rh=self, filename='status.mako')
return t.render(title='Status', header='Status', topmenu='system',
return t.render(title='Status', header='Status',
tvdirFree=tv_dir_free, rootDir=root_dir,
controller='home', action='status')

Expand All @@ -714,7 +714,7 @@ def restart(self, pid=None):

t = PageTemplate(rh=self, filename='restart.mako')

return t.render(title='Home', header='Restarting Medusa', topmenu='system',
return t.render(title='Home', header='Restarting Medusa',
controller='home', action='restart')

def updateCheck(self, pid=None):
Expand All @@ -739,7 +739,7 @@ def update(self, pid=None, branch=None):

# @FIXME: Pre-render the restart page. This is a workaround to stop errors on updates.
t = PageTemplate(rh=self, filename='restart.mako')
restart_rendered = t.render(title='Home', header='Restarting Medusa', topmenu='home',
restart_rendered = t.render(title='Home', header='Restarting Medusa',
controller='home', action='restart')

if checkversion.updater.need_update() and checkversion.updater.update():
Expand Down Expand Up @@ -960,17 +960,18 @@ def displayShow(self, indexername=None, seriesid=None, ):
series_id = int(series_obj.series_id)

# Delete any previous occurrances
indexer_name = indexer_id_to_name(indexer_id)
for index, recentShow in enumerate(app.SHOWS_RECENT):
if recentShow['indexer'] == indexer_id and recentShow['indexerid'] == series_id:
if recentShow['indexerName'] == indexer_name and recentShow['showId'] == series_id:
del app.SHOWS_RECENT[index]

# Only track 5 most recent shows
del app.SHOWS_RECENT[4:]

# Insert most recent show
app.SHOWS_RECENT.insert(0, {
'indexer': indexer_id,
'indexerid': series_id,
'indexerName': indexer_name,
'showId': series_id,
'name': series_obj.name,
})

Expand Down Expand Up @@ -1236,17 +1237,18 @@ def snatchSelection(self, indexername, seriesid, season=None, episode=None, manu
series_id = int(series_obj.series_id)

# Delete any previous occurrances
indexer_name = indexer_id_to_name(indexer_id)
for index, recentShow in enumerate(app.SHOWS_RECENT):
if recentShow['indexer'] == indexer_id and recentShow['indexerid'] == series_id:
if recentShow['indexerName'] == indexer_name and recentShow['showId'] == series_id:
del app.SHOWS_RECENT[index]

# Only track 5 most recent shows
del app.SHOWS_RECENT[4:]

# Insert most recent show
app.SHOWS_RECENT.insert(0, {
'indexer': indexer_id,
'indexerid': series_id,
'indexerName': indexer_name,
'showId': series_id,
'name': series_obj.name,
})

Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/home/irc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ def __init__(self, *args, **kwargs):
def index(self):

t = PageTemplate(rh=self, filename='IRC.mako')
return t.render(topmenu='system', header='IRC', title='IRC', controller='IRC', action='index')
return t.render(header='IRC', title='IRC', controller='IRC', action='index')
2 changes: 1 addition & 1 deletion medusa/server/web/home/news.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def index(self):
t = PageTemplate(rh=self, filename='markdown.mako')
data = markdown2.markdown(news if news else 'The was a problem connecting to GitHub, please refresh and try again', extras=['header-ids'])

return t.render(title='News', header='News', topmenu='system', data=data, controller='news', action='index')
return t.render(title='News', header='News', data=data, controller='news', action='index')
2 changes: 1 addition & 1 deletion medusa/server/web/home/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, *args, **kwargs):

def index(self):
t = PageTemplate(rh=self, filename='home_postprocess.mako')
return t.render(topmenu='home', controller='home', action='postProcess')
return t.render(controller='home', action='postProcess')

def processEpisode(self, proc_dir=None, nzbName=None, jobName=None, quiet=None, process_method=None, force=None,
is_priority=None, delete_on='0', failed='0', proc_type='auto', ignore_subs=None, *args, **kwargs):
Expand Down
Loading

0 comments on commit 49f4f98

Please sign in to comment.