Commit 932c107a authored by echel0n's avatar echel0n

Revert "Refactored main shows page to load shows via web sockets."

This reverts commit b9b280d7
parent 940d091a
......@@ -190,12 +190,6 @@
"integrity": "sha1-819bqRNmt6WLC2pPIv8JB/4AIhk=",
"dev": true
},
"@sudhanshu/radial-indicator": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@sudhanshu/radial-indicator/-/radial-indicator-2.0.0.tgz",
"integrity": "sha512-lrk4EpESjezikCumBeqAKunfhn8kV8RSebE+CWSvgewYLOm51ve/hPRkResUQVFAN4ykRaHlr8qLAfUNDGbsvQ==",
"dev": true
},
"@webassemblyjs/ast": {
"version": "1.5.13",
"resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.5.13.tgz",
......@@ -5802,6 +5796,16 @@
"integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=",
"dev": true
},
"infinite-scroll": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/infinite-scroll/-/infinite-scroll-3.0.6.tgz",
"integrity": "sha512-679gpKlS/XuAnA+spIRNFSel1dsZ44ljKVlkWHVNTtibJR0cUIC3jwZaBQUsaR1TvPFnaQijRlS8Q/lPgx1VAA==",
"dev": true,
"requires": {
"ev-emitter": "^1.1.0",
"fizzy-ui-utils": "^2.0.5"
}
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
......
......@@ -184,7 +184,7 @@ class VersionUpdater(object):
sickrage.app.config.view_changelog = True
if webui:
WebSocketMessage('redirect', {'url': '{}/home/restart/?pid={}'.format(sickrage.app.config.web_root,sickrage.app.pid)}).push()
WebSocketMessage('task', {'cmd': 'restart'}).push()
return True
......
......@@ -62,7 +62,7 @@ from sickrage.core.webserver.handlers.home import HomeHandler, IsAliveHandler, T
DeleteShowHandler, RefreshShowHandler, UpdateShowHandler, SubtitleShowHandler, UpdateKODIHandler, UpdatePLEXHandler, \
UpdateEMBYHandler, SyncTraktHandler, DeleteEpisodeHandler, SetStatusHandler, TestRenameHandler, DoRenameHandler, \
SearchEpisodeHandler, GetManualSearchStatusHandler, SearchEpisodeSubtitlesHandler, \
SetSceneNumberingHandler
SetSceneNumberingHandler, LoadShowsHandler
from sickrage.core.webserver.handlers.home.add_shows import HomeAddShowsHandler, SearchIndexersForShowNameHandler, \
MassAddTableHandler, NewShowHandler, TraktShowsHandler, PopularShowsHandler, AddShowToBlacklistHandler, \
ExistingShowsHandler, AddShowByIDHandler, AddNewShowHandler, AddExistingShowsHandler
......@@ -162,7 +162,7 @@ class WebServer(object):
# Websocket handler
self.app.add_handlers('.*$', [
(r'%s/ws' % sickrage.app.config.web_root, WebSocketUIHandler),
(r'%s/ws/ui' % sickrage.app.config.web_root, WebSocketUIHandler)
])
# Static File Handlers
......@@ -243,6 +243,7 @@ class WebServer(object):
(r'%s/browser(/?)' % sickrage.app.config.web_root, WebFileBrowserHandler),
(r'%s/browser/complete(/?)' % sickrage.app.config.web_root, WebFileBrowserCompleteHandler),
(r'%s/home(/?)' % sickrage.app.config.web_root, HomeHandler),
(r'%s/home/loadShows(/?)' % sickrage.app.config.web_root, LoadShowsHandler),
(r'%s/home/is_alive(/?)' % sickrage.app.config.web_root, IsAliveHandler),
(r'%s/home/testSABnzbd(/?)' % sickrage.app.config.web_root, TestSABnzbdHandler),
(r'%s/home/testTorrent(/?)' % sickrage.app.config.web_root, TestTorrentHandler),
......
......@@ -31,10 +31,12 @@ from mako.exceptions import RichTraceback
from mako.lookup import TemplateLookup
from requests import HTTPError
from tornado import locale
from tornado.httpclient import AsyncHTTPClient, HTTPRequest
from tornado.web import RequestHandler
import sickrage
from sickrage.core import helpers, API
from sickrage.core.databases.main import MainDB
class BaseHandler(RequestHandler, ABC):
......@@ -142,7 +144,6 @@ class BaseHandler(RequestHandler, ABC):
'request': self.request,
}
self.ui = kwargs.pop('ui_modules', self.ui)
template_kwargs.update(self.get_template_namespace())
template_kwargs.update(kwargs)
......
......@@ -18,11 +18,17 @@
# You should have received a copy of the GNU General Public License
# along with SiCKRAGE. If not, see <http://www.gnu.org/licenses/>.
# ##############################################################################
import calendar
import datetime
import os
import re
import time
from abc import ABC
from collections import OrderedDict
from functools import cmp_to_key
from urllib.parse import unquote_plus, quote_plus
import unidecode
from sqlalchemy import orm
from tornado import gen
from tornado.escape import json_encode
......@@ -38,10 +44,11 @@ from sickrage.core.databases.main import MainDB
from sickrage.core.exceptions import AnidbAdbaConnectionException, CantRefreshShowException, NoNFOException, \
CantUpdateShowException, CantRemoveShowException, EpisodeDeletedException, EpisodeNotFoundException, \
MultipleEpisodesInDatabaseException
from sickrage.core.helpers import clean_url, clean_host, clean_hosts, get_disk_space_usage, checkbox_to_value, try_int
from sickrage.core.helpers import clean_url, clean_host, clean_hosts, get_disk_space_usage, checkbox_to_value, try_int, srdatetime
from sickrage.core.helpers.anidb import get_release_groups_for_anime, short_group_names
from sickrage.core.helpers.srdatetime import SRDateTime
from sickrage.core.helpers.tornado_http import TornadoHTTP
from sickrage.core.media.util import showImage
from sickrage.core.queues.search import BacklogQueueItem, FailedQueueItem, ManualSearchQueueItem
from sickrage.core.scene_exceptions import get_scene_exceptions, update_scene_exceptions
from sickrage.core.scene_numbering import get_scene_numbering_for_show, get_xem_numbering_for_show, \
......@@ -51,7 +58,6 @@ from sickrage.core.traktapi import TraktAPI
from sickrage.core.tv.episode import TVEpisode
from sickrage.core.tv.show.helpers import find_show, get_show_list
from sickrage.core.webserver.handlers.base import BaseHandler
from sickrage.core.websocket import WebSocketMessage
from sickrage.indexers import IndexerApi
from sickrage.subtitles import Subtitles
......@@ -85,9 +91,7 @@ class HomeHandler(BaseHandler, ABC):
if not get_show_list().count():
return self.redirect('/home/addShows/')
self.run_task(self.load_shows, ui_modules=self.ui)
# showlists = OrderedDict({'Shows': []})
showlists = OrderedDict({'Shows': []})
# if sickrage.app.config.anime_split_home:
# for show in sorted(get_show_list(), key=cmp_to_key(lambda x, y: x.name < y.name)):
# if show.is_anime:
......@@ -104,31 +108,11 @@ class HomeHandler(BaseHandler, ABC):
title="Home",
header="Show List",
topmenu="home",
showlists=showlists,
controller='home',
action='index'
)
def load_shows(self, ui_modules):
show_count = get_show_list().count()
shows_loading = [int(x['indexer_id']) for x in sickrage.app.show_queue.loading_show_list]
for show in get_show_list(session=self.db_session):
if sickrage.app.config.home_layout == 'poster':
WebSocketMessage('show', {'action': ('show_grid_append', 'show_grid_prepend')[show.indexer_id in shows_loading],
'show_count': show_count,
'item': self.render_string("/templates/show-container-grid.mako", show=show, is_anime=show.is_anime,
is_loading=show.indexer_id in shows_loading, ui_modules=ui_modules)}).push()
else:
WebSocketMessage('show', {'action': ('show_list_append', 'show_list_prepend')[show.indexer_id in shows_loading],
'show_count': show_count,
'item': self.render_string("/templates/show-container-list.mako", show=show, is_anime=show.is_anime,
is_loading=show.indexer_id in shows_loading, ui_modules=ui_modules)}).push()
if sickrage.app.config.home_layout == 'poster':
WebSocketMessage('show', {'action': 'load_show_grid'}).push()
else:
WebSocketMessage('show', {'action': 'load_show_list'}).push()
def statistics(self):
show_stat = {}
......@@ -173,6 +157,27 @@ class HomeHandler(BaseHandler, ABC):
return show_stat, overall_stats
class LoadShowsHandler(BaseHandler, ABC):
@authenticated
async def get(self, *args, **kwargs):
layout = self.get_argument('layout', 'poster')
to_return = ""
loading_show_list_ids = [int(x['indexer_id']) for x in sickrage.app.show_queue.loading_show_list]
for show in get_show_list():
if show.indexer_id in loading_show_list_ids:
continue
if layout == 'poster':
to_return += self.render_string("/templates/show-container-grid.mako", show=show)
else:
to_return += self.render_string("/templates/show-container-list.mako", show=show)
return self.write(to_return)
class IsAliveHandler(BaseHandler, ABC):
def get(self, *args, **kwargs):
self.set_header('Content-Type', 'text/javascript')
......
......@@ -11,6 +11,9 @@
from sickrage.core.helpers import srdatetime, pretty_file_size
from sickrage.core.media.util import showImage
%>
## <%block name="metas">
## <meta data-var="max_download_count" data-content="${overall_stats['episodes']['total'] * 100}">
## </%block>
<%block name="sub_navbar">
<div class="row submenu">
......@@ -93,29 +96,115 @@
</%block>
<%block name="content">
<%include file="../includes/loading.mako"/>
% if sickrage.app.config.home_layout == 'poster':
<div id="container" class="show-grid clearfix mx-auto d-none"></div>
% else:
<div class="row">
<div class="col-lg-10 mx-auto">
<table class="table d-none" id="showListTableShows">
<thead class="thead-dark">
<tr>
<th>${_('Next Ep')}</th>
<th>${_('Prev Ep')}</th>
<th>${_('Show')}</th>
<th>${_('Network')}</th>
<th>${_('Quality')}</th>
<th>${_('Downloads')}</th>
<th>${_('Size')}</th>
<th>${_('Active')}</th>
<th>${_('Status')}</th>
</tr>
</thead>
<tbody></tbody>
</table>
<% loading_show_list_ids = [] %>
% for curListType, curShowlist in showlists.items():
% if curListType == "Anime":
<div class="row">
<div class="col mx-auto">
<div class="h4 card" style="text-align: center;">${_('Anime List')}</div>
</div>
</div>
</div>
% endif
% endif
% if sickrage.app.config.home_layout == 'poster':
<div id="${('container', 'container-anime')[curListType == 'Anime' and sickrage.app.config.home_layout == 'poster']}"
class="show-grid clearfix mx-auto">
% for curLoadingShow in sickrage.app.show_queue.loading_show_list:
<% loading_show_list_ids.append(curLoadingShow['indexer_id']) %>
<div class="show-container" data-name="0" data-date="010101" data-network="0"
data-progress="101">
<div class="card card-block text-white bg-dark m-1 shadow">
<img alt="" title="${curLoadingShow['name']}" class="card-img-top"
src="${srWebRoot}/images/poster.png"/>
<div class="card-body text-truncate py-1 px-1 small">
<div class="show-title">
${curLoadingShow['name']}
</div>
</div>
<div class="card-footer show-details p-1">
<div class="show-details">
<div class="show-add text-center">${_('... Loading ...')}</div>
</div>
</div>
</div>
</div>
% endfor
</div>
<div class="show-grid-loading-status text-center m-3">
<i class="fas fa-spinner fa-spin fa-fw fa-10x"></i>
</div>
% else:
<div class="row">
<div class="col-lg-10 mx-auto">
<table class="table" id="showListTable${curListType}">
<thead class="thead-dark">
<tr>
<th>${_('Next Ep')}</th>
<th>${_('Prev Ep')}</th>
<th>${_('Show')}</th>
<th>${_('Network')}</th>
<th>${_('Quality')}</th>
<th>${_('Downloads')}</th>
<th>${_('Size')}</th>
<th>${_('Active')}</th>
<th>${_('Status')}</th>
</tr>
</thead>
% if sickrage.app.show_queue.loading_show_list:
<tbody>
% for curLoadingShow in sickrage.app.show_queue.loading_show_list:
<% loading_show_list_ids.append(curLoadingShow['indexer_id']) %>
<tr>
<td class="table-fit">(${_('loading')})</td>
<td></td>
<td>
<a data-fancybox
href="displayShow?show=${curLoadingShow['indexer_id']}">${curLoadingShow['name']}</a>
</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
% endfor
</tbody>
% endif
<tbody>
<tr class="show-list-loading-status">
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
<td>
<i class="fas fa-spinner fa-spin fa-fw"></i>
</td>
</tr>
</tbody>
</table>
</div>
</div>
% endif
% endfor
</%block>
<div id="indicatorContainer" style="background-image: url('https://git.sickrage.ca/SiCKRAGE/sickrage/raw/master/sickrage/core/webserver/static/images/logo-badge.png');background-position:center;background-repeat: no-repeat;background-size: 60px"></div>
\ No newline at end of file
import json
from time import sleep
from tornado.websocket import WebSocketHandler
from tornado.websocket import WebSocketHandler, WebSocketClosedError
import sickrage
......@@ -19,6 +18,12 @@ class WebSocketUIHandler(WebSocketHandler):
"""Client connected to the WebSocket."""
clients.add(self)
for n in sickrage.app.alerts.get_notifications(self.request.remote_ip):
try:
self.write_message(WebSocketMessage('notification', n.data).json())
except WebSocketClosedError:
pass
def on_message(self, message):
"""Received a message from the client."""
sickrage.app.log.debug('WebSocket received message from {}: {}'.format(self.request.remote_ip, message))
......@@ -39,20 +44,20 @@ class WebSocketUIHandler(WebSocketHandler):
class WebSocketMessage(object):
"""Represents a WebSocket message."""
def __init__(self, message_type, data):
def __init__(self, event, data):
"""
Construct a new WebSocket message.
:param message_type: A string representing the type of message (e.g. notification)
:param event: A string representing the type of message (e.g. notification)
:param data: A JSON-serializable object containing the message data.
"""
self.type = message_type
self.event = event
self.data = data
@property
def content(self):
"""Get the message content."""
return {
'type': self.type,
'event': self.event,
'data': self.data
}
......@@ -62,8 +67,8 @@ class WebSocketMessage(object):
def push(self):
"""Push the message to all connected WebSocket clients."""
while not clients:
sleep(0.1)
if not clients:
return
for client in clients:
sickrage.app.io_loop.add_callback(client.write_message, self.json())
This diff is collapsed.
......@@ -337,12 +337,12 @@ input[type=checkbox].toggle {
.btn {
@extend .btn-primary;
@extend .shadow-lg;
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2) 49%, rgba(0, 0, 0, 0.15) 51%, rgba(0, 0, 0, 0.05));
background-image: linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(255,255,255,0.2) 49%, rgba(0,0,0,0.15) 51%, rgba(0,0,0,0.05));
background-repeat: repeat-x;
}
.badge {
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.2) 49%, rgba(0, 0, 0, 0.15) 51%, rgba(0, 0, 0, 0.05));
background-image: linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(255,255,255,0.2) 49%, rgba(0,0,0,0.15) 51%, rgba(0,0,0,0.05));
background-repeat: repeat-x;
}
......@@ -517,9 +517,8 @@ input[type=checkbox].toggle {
-webkit-tap-highlight-color: transparent;
}
#indicatorContainer {
position: relative;
display: flex;
align-items: center;
justify-content: center;
.show-container {
-webkit-transform:translate3d(0,0,0);
-moz-transform:translate3d(0,0,0);
transform:translate3d(0,0,0);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment