Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vueify Root Dirs #4059

Merged
merged 13 commits into from
Jun 11, 2018
1 change: 1 addition & 0 deletions medusa/server/api/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ConfigHandler(BaseRequestHandler):
'theme.name': StringField(app, 'THEME_NAME'),
'backlogOverview.period': StringField(app, 'BACKLOG_PERIOD'),
'backlogOverview.status': StringField(app, 'BACKLOG_STATUS'),
'rootDirs': ListField(app, 'ROOT_DIRS'),
}

def get(self, identifier, path_param=None):
Expand Down
41 changes: 21 additions & 20 deletions medusa/server/api/v2/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from six import itervalues

from tornado.escape import json_decode

log = BraceAdapter(logging.getLogger(__name__))


Expand Down Expand Up @@ -53,24 +51,27 @@ def get(self, resource, path_param=None):
data = resource_function()
return self._ok(data=data)

# existingSeries
def resource_existing_series(self):
"""Generate existing series folders data for adding existing shows."""
root_dirs = json_decode(self.get_argument('root-dir', '[]'))

if not root_dirs:
if app.ROOT_DIRS:
root_dirs = app.ROOT_DIRS[1:]
else:
self._not_found('No configured root dirs')

# Put the default root-dir first
try:
default_index = int(app.ROOT_DIRS[0])
default_root_dir = root_dirs[default_index]
root_dirs.remove(default_root_dir)
root_dirs.insert(0, default_root_dir)
except (IndexError, ValueError):
pass
root_dirs_indices = self.get_argument('root-dirs', '')

if root_dirs_indices:
root_dirs_indices = set(root_dirs_indices.split(','))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a biggie, but I think this can go just after line 66? One if less 🎉
The rest of the python code LGTM.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, looks like it to me too. Good catch! Thanks.
I will fix it as soon as I can.


if not app.ROOT_DIRS:
return self._not_found('No configured root dirs')

root_dirs = app.ROOT_DIRS[1:]
if root_dirs_indices:
try:
root_dirs_indices = sorted(map(int, root_dirs_indices))
except ValueError as error:
log.warning('Unable to parse root dirs indices: {indices}. Error: {error}',
{'indices': root_dirs_indices, 'error': error})
return self._bad_request('Invalid root dirs indices')

root_dirs = [root_dirs[idx] for idx in root_dirs_indices]

dir_list = []

Expand Down Expand Up @@ -107,7 +108,7 @@ def resource_existing_series(self):
cur_dir = {
'path': cur_path,
'alreadyAdded': False,
'existingInfo': {
'metadata': {
'seriesId': None,
'seriesName': None,
'indexer': None
Expand All @@ -123,7 +124,7 @@ def resource_existing_series(self):
for cur_provider in itervalues(app.metadata_provider_dict):
(series_id, series_name, indexer) = cur_provider.retrieveShowMetadata(cur_path)
if all((series_id, series_name, indexer)):
cur_dir['existingInfo'] = {
cur_dir['metadata'] = {
'seriesId': try_int(series_id),
'seriesName': series_name,
'indexer': try_int(indexer)
Expand Down
4 changes: 0 additions & 4 deletions medusa/server/web/config/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def index(self):
def generate_api_key():
return helpers.generate_api_key()

@staticmethod
def saveRootDirs(rootDirString=None):
app.ROOT_DIRS = rootDirString.split('|')

@staticmethod
def saveAddShowDefaults(default_status, allowed_qualities, preferred_qualities, default_season_folders,
subtitles=False, anime=False, scene=False, default_status_after=WANTED):
Expand Down
21 changes: 2 additions & 19 deletions themes-default/slim/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -406,24 +406,6 @@ inc_bottom.mako
display: inline;
}

/* =======================================================================
inc_rootDirs.mako
========================================================================== */
.rootdir-selectbox,
.rootdir-selectbox #rootDirs,
.rootdir-controls {
width: 100%;
max-width: 430px;
}

.rootdir-selectbox {
padding: 0 0 5px;
}

.rootdir-controls {
text-align: center;
}

/* =======================================================================
history.mako
========================================================================== */
Expand Down Expand Up @@ -3398,7 +3380,8 @@ pre {
input sizing (for config pages)
========================================================================== */

#config select {
/* Don't style root-dirs select */
#config select:not([size]) {
width: auto;
display: inline;
}
Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/static/js/add-shows/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ MEDUSA.addShows.init = function() {
});
});

$('#rootDirs').on('change', () => {
$(document.body).on('change', '#rootDirs', () => {
$.rootDirCheck();
});

Expand Down
2 changes: 1 addition & 1 deletion themes-default/slim/static/js/add-shows/new-show.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ MEDUSA.addShows.newShow = function() {
}
});

$('#rootDirText').change(updateSampleText);
$(document.body).on('change', '#rootDirText', updateSampleText);
$('#searchResults').on('change', '#whichSeries', updateSampleText);

$('#nameToSearch').keyup(event => {
Expand Down
204 changes: 0 additions & 204 deletions themes-default/slim/static/js/root-dirs.js

This file was deleted.

Loading