pull/884/head
Louis Vézina 5 years ago
parent aa1b9dfcf4
commit a198250cca

@ -16,8 +16,8 @@ import ast
import hashlib import hashlib
import warnings import warnings
import queueconfig import queueconfig
import platform
import apprise import apprise
import requests
from get_args import args from get_args import args
@ -38,13 +38,12 @@ from get_languages import load_language_in_db, language_from_alpha3, language_fr
from flask import make_response, request, redirect, abort, render_template, Response, session, flash, url_for, \ from flask import make_response, request, redirect, abort, render_template, Response, session, flash, url_for, \
send_file, stream_with_context send_file, stream_with_context
from get_providers import get_providers, get_providers_auth, list_throttled_providers
from get_series import * from get_series import *
from get_episodes import * from get_episodes import *
from get_movies import * from get_movies import *
from utils import history_log, history_log_movie, get_sonarr_version, get_radarr_version
from scheduler import Scheduler from scheduler import Scheduler
from check_update import check_and_apply_update
from subliminal_patch.extensions import provider_registry as provider_manager from subliminal_patch.extensions import provider_registry as provider_manager
from functools import wraps from functools import wraps
@ -173,6 +172,7 @@ def logout():
def shutdown(): def shutdown():
doShutdown() doShutdown()
def doShutdown(): def doShutdown():
try: try:
server.stop() server.stop()
@ -598,16 +598,19 @@ def settingssonarr():
return render_template('settingssonarr.html') return render_template('settingssonarr.html')
@app.route('/check_update') @app.route('/settingsradarr/')
@login_required @login_required
def check_update(): def settingsradarr():
return render_template('settingsradarr.html')
ref = request.environ['HTTP_REFERER']
@app.route('/check_update')
@login_required
def check_update():
if not args.no_update: if not args.no_update:
check_and_apply_update() check_and_apply_update()
redirect(ref) return '', 200
@app.route('/systemtasks') @app.route('/systemtasks')
@ -640,21 +643,6 @@ def systemreleases():
return render_template('systemreleases.html') return render_template('systemreleases.html')
@app.route('/logs')
@login_required
def get_logs():
logs = []
with io.open(os.path.join(args.config_dir, 'log', 'bazarr.log'), encoding='UTF-8') as file:
for line in file.readlines():
lin = []
lin = line.split('|')
logs.append(lin)
logs.reverse()
return dict(data=logs)
def configured(): def configured():
database.execute("UPDATE system SET configured = 1") database.execute("UPDATE system SET configured = 1")
@ -719,6 +707,7 @@ def api_movies_history():
return dict(subtitles=history_subs) return dict(subtitles=history_subs)
@app.route('/test_url', methods=['GET'])
@app.route('/test_url/<protocol>/<path:url>', methods=['GET']) @app.route('/test_url/<protocol>/<path:url>', methods=['GET'])
@login_required @login_required
def test_url(protocol, url): def test_url(protocol, url):
@ -742,87 +731,10 @@ def test_notification(protocol, provider):
apobj.notify( apobj.notify(
title='Bazarr test notification', title='Bazarr test notification',
body=('Test notification') body='Test notification'
) )
@app.route('/notifications')
@login_required
def notifications():
if queueconfig.notifications:
test = queueconfig.notifications
return queueconfig.notifications.read() or ''
else:
return abort(400)
@app.route('/running_tasks')
@login_required
def running_tasks_list():
return dict(tasks=scheduler.get_running_tasks())
@app.route('/episode_history/<int:no>')
@login_required
def episode_history(no):
episode_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history "
"WHERE sonarrEpisodeId=? ORDER BY timestamp DESC", (no,))
for item in episode_history:
item['timestamp'] = "<div data-tooltip='" + \
time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + "'>" + \
pretty.date(datetime.fromtimestamp(item['timestamp'])) + "</div>"
if item['language']:
item['language'] = language_from_alpha2(item['language'])
else:
item['language'] = "<i>undefined</i>"
if item['score']:
item['score'] = str(round((int(item['score']) * 100 / 360), 2)) + "%"
return dict(data=episode_history)
@app.route('/movie_history/<int:no>')
@login_required
def movie_history(no):
movie_history = database.execute("SELECT action, timestamp, language, provider, score FROM table_history_movie "
"WHERE radarrId=? ORDER BY timestamp DESC", (no,))
for item in movie_history:
if item['action'] == 0:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"erased.' data-inverted='' data-position='top left'><i class='ui trash icon'></i></div>"
elif item['action'] == 1:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"downloaded.' data-inverted='' data-position='top left'><i class='ui download " \
"icon'></i></div>"
elif item['action'] == 2:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"manually downloaded.' data-inverted='' data-position='top left'><i class='ui user " \
"icon'></i></div>"
elif item['action'] == 3:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"upgraded.' data-inverted='' data-position='top left'><i class='ui recycle " \
"icon'></i></div>"
elif item['action'] == 4:
item['action'] = "<div class ='ui inverted basic compact icon' data-tooltip='Subtitle file has been " \
"manually uploaded.' data-inverted='' data-position='top left'><i class='ui cloud " \
"upload icon'></i></div>"
item['timestamp'] = "<div data-tooltip='" + \
time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(item['timestamp'])) + "'>" + \
pretty.date(datetime.fromtimestamp(item['timestamp'])) + "</div>"
if item['language']:
item['language'] = language_from_alpha2(item['language'])
else:
item['language'] = "<i>undefined</i>"
if item['score']:
item['score'] = str(round((int(item['score']) * 100 / 120), 2)) + '%'
return dict(data=movie_history)
# Mute DeprecationWarning # Mute DeprecationWarning
warnings.simplefilter("ignore", DeprecationWarning) warnings.simplefilter("ignore", DeprecationWarning)
# Mute Insecure HTTPS requests made to Sonarr and Radarr # Mute Insecure HTTPS requests made to Sonarr and Radarr

@ -187,7 +187,7 @@
<ul aria-expanded="false" class="collapse"> <ul aria-expanded="false" class="collapse">
<li><a href="{{ url_for('settingsgeneral') }}"> General</a></li> <li><a href="{{ url_for('settingsgeneral') }}"> General</a></li>
<li><a href="{{ url_for('settingssonarr') }}"> Sonarr</a></li> <li><a href="{{ url_for('settingssonarr') }}"> Sonarr</a></li>
<li><a href="/"> Radarr</a></li> <li><a href="{{ url_for('settingsradarr') }}"> Radarr</a></li>
<li><a href="/"> Subtitles</a></li> <li><a href="/"> Subtitles</a></li>
<li><a href="/"> Notifications</a></li> <li><a href="/"> Notifications</a></li>
</ul> </ul>

@ -1,248 +1,380 @@
<div class="ui dividing header">Connection settings</div> {% extends '_main.html' %}
<div class="twelve wide column">
<div class="ui grid"> {% block title %}Radarr - Bazarr{% endblock %}
<div class="middle aligned row">
<div class="right aligned four wide column"> {% block page_head %}
<label>Settings Validation:</label>
</div> {% endblock page_head %}
<div class="two wide column">
<button id="radarr_validate" class="test ui blue button" type="button"> {% block bcleft %}
Test <div class="">
</button> <button class="btn btn-outline" id="save_button">
<div>
<span class="fa-stack">
<i class="fas fa-save fa-stack-2x align-top text-themecolor text-center font-20" aria-hidden="true"></i>
<i id="save_button_checkmark" class="fas fa-check fa-stack-2x" style="color:green;"></i>
</span>
</div> </div>
<div class="seven wide column"> <div class="align-bottom text-themecolor small text-center">Save</div>
<div id="radarr_validated" class="ui read-only checkbox"> </button>
<input id="radarr_validated_checkbox" type="checkbox"> </div>
<label id="radarr_validation_result">Not Tested Recently</label> {% endblock bcleft %}
{% block bcright %}
{% endblock bcright %}
{% block body %}
<div class="container-fluid" style="padding-top: 3em;">
<form class="form" name="settings_form" id="settings_form">
<h4>Use Radarr</h4>
<hr/>
<div class="row">
<div class="col-sm-2 text-right">
<b>Enabled</b>
</div>
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-general-use_radarr" name="settings-general-use_radarr">
<span class="custom-control-label" for="settings-general-use_radarr"></span>
</label>
</div> </div>
</div> </div>
</div> <br>
<div class="middle aligned row"> <div id="radarr_div">
<div class="right aligned four wide column"> <h4>Host</h4>
<label>Hostname or IP Address</label> <hr/>
</div> <div class="row">
<div class="five wide column"> <div class="col-sm-2 text-right">
<div class='field'> <b>Hostname or IP Address</b>
<div class="ui fluid input"> </div>
<input id="settings_radarr_ip" name="settings_radarr_ip" type="text" class="radarr_config" <div class="col-sm-4">
value="{{ settings.radarr.ip }}"> <input type="text" class="form-control" id="settings-radarr-ip" name="settings-radarr-ip" value="{{settings.radarr.ip}}">
</div> </div>
</div> </div>
</div> <br>
<div class="collapsed center aligned column"> <div class="row">
<div class="ui basic icon" data-tooltip="Hostname or IP4 address of Radarr" data-inverted=""> <div class="col-sm-2 text-right">
<i class="help circle large icon"></i> <b>Port Number</b>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" id="settings-radarr-port" name="settings-radarr-port" value="{{settings.radarr.port}}">
</div>
</div> </div>
</div> <br>
</div> <div class="row">
<div class="col-sm-2 text-right">
<div class="middle aligned row"> <b>URL Base</b>
<div class="right aligned four wide column"> </div>
<label>Listening Port</label> <div class="col-sm-4">
</div> <input type="text" class="form-control" id="settings-radarr-base_url" name="settings-radarr-base_url" value="{{settings.radarr.base_url}}">
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<input id="settings_radarr_port" name="settings_radarr_port" type="text" class="radarr_config"
value="{{ settings.radarr.port }}">
</div> </div>
</div> </div>
</div> <br>
<div class="collapsed center aligned column"> <div class="row">
<div class="ui basic icon" data-tooltip="TCP Port of Radarr" data-inverted=""> <div class="col-sm-2 text-right">
<i class="help circle large icon"></i> <b>SSL Enabled</b>
</div>
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-radarr-ssl" name="settings-radarr-ssl">
<span class="custom-control-label" for="settings-radarr-ssl"></span>
</label>
</div>
</div> </div>
</div> <div class="row">
</div> <div class="col-sm-2 text-right">
<b>API Key</b>
<div class="middle aligned row"> </div>
<div class="right aligned four wide column"> <div class="col-sm-4">
<label>Base URL</label> <input type="text" class="form-control" id="settings-radarr-apikey" name="settings-radarr-apikey" value="{{settings.radarr.apikey}}">
</div> </div>
<div class="five wide column">
<div class="ui fluid input">
<input id="settings_radarr_baseurl" name="settings_radarr_baseurl" type="text" class="radarr_config"
value="{{ settings.radarr.base_url }}">
</div> </div>
</div> <br>
<div class="collapsed center aligned column"> <div class="row">
<div class="ui basic icon" data-tooltip="Base URL for Radarr (default: '/')" data-inverted=""> <div class="col-sm-2 text-right">
<i class="help circle large icon"></i> <button type="button" class="btn btn-secondary" id="test_radarr_connection">Test</button>
</div>
<div class="col-sm-4">
<span id="test_radarr_span"></span>
</div>
</div> </div>
</div> <br>
</div>
<div class="middle aligned row"> <h4>Options</h4>
<div class="right aligned four wide column"> <hr/>
<label>SSL Enabled</label> <div class="row">
</div> <div class="col-sm-2 text-right">
<div class="one wide column"> <b>Minimum Score</b>
<div id="radarr_ssl_div" class="ui toggle checkbox" data-ssl={{ settings.radarr.getboolean('ssl') }}> </div>
<input id="settings_radarr_ssl" name="settings_radarr_ssl" type="checkbox"> <div class="col-sm-1">
<label></label> <input type="number" min="0" max="100" step="1" onkeydown="return false" class="form-control" id="settings-general-minimum_score" name="settings-general-minimum_score" value="{{settings.general.minimum_score}}">
</div>
</div> </div>
</div> <br>
</div> <div class="row">
<div class="col-sm-2 text-right">
<b>Download Only Monitored</b>
</div>
<div class="form-group col-sm-1">
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="settings-radarr-only_monitored" name="settings-radarr-only_monitored">
<span class="custom-control-label" for="settings-radarr-only_monitored"></span>
</label>
</div>
</div>
<br>
<h4>Path Mappings</h4>
<hr/>
<div class="row">
<div class="col-sm-8">
<table class="table table-striped" id="path_mapping_movie" style="width:100%;">
<div class="middle aligned row"> </table>
<div class="right aligned four wide column">
<label>API Key</label>
</div>
<div class="five wide column">
<div class='field'>
<div class="ui fluid input">
<input id="settings_radarr_apikey" name="settings_radarr_apikey" type="text"
class="radarr_config" value="{{ settings.radarr.apikey }}">
</div> </div>
</div> </div>
<br>
</div> </div>
<div class="collapsed center aligned column"> </form>
<div class="ui basic icon" data-tooltip="API Key for Radarr (32 alphanumeric characters)" </div>
data-inverted="">
<i class="help circle large icon"></i> <div id="addModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Path Mapping</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div> </div>
<form class="form" name="add_form" id="add_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Path for Radarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_radarr" name="add_path_radarr" value="">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_bazarr" name="add_path_bazarr" value="">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="add_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div> </div>
</div> </div>
</div>
<div class="middle aligned row"> <div id="editModal" class="modal" tabindex="-1" role="dialog">
<div class="right aligned four wide column"> <div class="modal-dialog modal-lg" role="document">
<label>Download Only Monitored</label> <div class="modal-content">
</div> <div class="modal-header">
<div class="one wide column"> <h5 class="modal-title">Edit Path Mapping</h5><br>
<div id="settings_only_monitored_radarr" class="ui toggle checkbox" <button type="button" class="close" data-dismiss="modal" aria-label="Close">
data-monitored={{ settings.radarr.getboolean('only_monitored') }}> <span aria-hidden="true">&times;</span>
<input name="settings_radarr_only_monitored" type="checkbox"> </button>
<label></label>
</div> </div>
</div> <form class="form" name="edit_form" id="edit_form">
<div class="collapsed column"> <div class="modal-body">
<div class="collapsed center aligned column"> <div class="container-fluid">
<div class="ui basic icon" <div class="row">
data-tooltip="Automatic download of Subtitles will only happen for monitored Movies in Radarr." <div class="col-sm-3 text-right">
data-inverted=""> Path for Radarr
<i class="help circle large icon"></i> </div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_radarr" name="edit_path_radarr" value="">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_bazarr" name="edit_path_bazarr" value="">
</div>
</div>
</div>
</div> </div>
</div> <div class="modal-footer">
<button type="submit" id="edit_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div> </div>
</div> </div>
</div> </div>
</div>
<div id="deleteModal" class="modal" tabindex="-1" role="dialog">
<div class="ui dividing header">Synchronization</div> <div class="modal-dialog modal-lg" role="document">
<div class="twelve wide column"> <div class="modal-content">
<div class="ui grid"> <div class="modal-header">
<div class="middle aligned row"> <h5 class="modal-title">Delete Path Mapping</h5><br>
<div class="right aligned four wide column"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<label>Full Filesystem Scan</label> <span aria-hidden="true">&times;</span>
</div> </button>
<div class="three wide column">
<div class='field'>
<select name="settings_radarr_sync" id="settings_radarr_sync" class="ui fluid selection dropdown">
<option value="Manually">Manually</option>
<option value="Daily">Daily</option>
<option value="Weekly">Weekly</option>
</select>
</div> </div>
</div> <div class="modal-body">
<div id="settings_radarr_sync_day_div" class="three wide column"> Are you sure you want to delete this path mapping?
<div class='field'>
<select name="settings_radarr_sync_day" id="settings_radarr_sync_day"
class="ui fluid selection dropdown">
% import calendar
% for idx, i in enumerate(calendar.day_name):
<option value="{{ idx }}">{{ i }}</option>
%end
</select>
</div> </div>
</div> <div class="modal-footer">
<div id="settings_radarr_sync_hour_div" class="two wide column"> <button type="submit" id="delete_yes_button" class="btn btn-info">Yes</button>
<div class='field'> <button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<select name="settings_radarr_sync_hour" id="settings_radarr_sync_hour"
class="ui fluid selection dropdown">
% for i in range(24):
<option value="{{ i }}">{{ i }}:00</option>
%end
</select>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> {% endblock body %}
{% macro settings_radarr() %}
<script> {% block tail %}
if ($('#radarr_ssl_div').data("ssl") === "True") { <script>
$("#radarr_ssl_div").checkbox('check'); $(document).ready(function () {
} else { // Hide checkmark over save button
$("#radarr_ssl_div").checkbox('uncheck'); $('#save_button_checkmark').hide();
}
// Hide *_div on Select input changed to None
if ($('#settings_only_monitored_radarr').data("monitored") === "True") { $('#settings-general-use_radarr').on('change', function() {
$("#settings_only_monitored_radarr").checkbox('check'); if ($(this).prop('checked')) {
} else { $('#radarr_div').show();
$("#settings_only_monitored_radarr").checkbox('uncheck'); } else {
} $('#radarr_div').hide();
}
$('#settings_radarr_sync').dropdown('setting', 'onChange', function () { });
if ($('#settings_radarr_sync').val() === "Manually") {
$('#settings_radarr_sync_day_div').hide(); // Set Checkbox input values
$('#settings_radarr_sync_hour_div').hide(); $('#settings-general-use_radarr').prop('checked', {{'true' if settings.general.getboolean('use_radarr')}});
} else if ($('#settings_radarr_sync').val() === "Daily") { $('#settings-radarr-ssl').prop('checked', {{'true' if settings.radarr.getboolean('ssl')}});
$('#settings_radarr_sync_day_div').hide(); $('#settings-radarr-only_monitored').prop('checked', {{'true' if settings.radarr.getboolean('only_monitored')}});
$('#settings_radarr_sync_hour_div').show();
} else if ($('#settings_radarr_sync').val() === "Weekly") { $('#save_button').on('click', function() {
$('#settings_radarr_sync_day_div').show(); var formdata = new FormData(document.getElementById("settings_form"));
$('#settings_radarr_sync_hour_div').show();
} // Make sure all checkbox input are sent with true/false value
}); $('input[type=checkbox]').each(function () {
formdata.set($(this).prop('id'), $(this).prop('checked'));
$('#settings_radarr_sync').dropdown('clear'); });
$('#settings_radarr_sync').dropdown('set selected', '{{settings.radarr.full_update|safe}}');
$('#settings_radarr_sync').dropdown('refresh'); formdata.append('settings-general-path_mappings_movie', JSON.stringify(table.rows().data().toArray()));
$('#settings_radarr_sync_day').dropdown('clear');
$('#settings_radarr_sync_day').dropdown('set selected', '{{settings.radarr.full_update_day|safe}}'); $.ajax({
$('#settings_radarr_sync_day').dropdown('refresh'); url: "{{ url_for('api.savesettings') }}",
$('#settings_radarr_sync_hour').dropdown('clear'); data: formdata,
$('#settings_radarr_sync_hour').dropdown('set selected', '{{settings.radarr.full_update_hour|safe}}'); processData: false,
$('#settings_radarr_sync_hour').dropdown('refresh'); contentType: false,
type: 'POST',
$('#radarr_validate').on('click', function () { complete: function () {
if ($('#radarr_ssl_div').checkbox('is checked')) { $('#save_button_checkmark').show();
protocol = 'https'; setTimeout(
} else { function()
protocol = 'http'; {
} $('#save_button_checkmark').hide();
const radarr_url = $('#settings_radarr_ip').val() + ":" + $('#settings_radarr_port').val() + $('#settings_radarr_baseurl').val().replace(/\/$/, "") + "/api/system/status?apikey=" + $('#settings_radarr_apikey').val(); }, 2000);
}
$.getJSON("{{base_url}}test_url/" + protocol + "/" + encodeURIComponent(radarr_url), function (data) { });
if (data.status) { });
$('#radarr_validated').checkbox('check');
$('#radarr_validation_result').text('Test successful: Radarr v' + data.version).css('color', 'green'); var path_mapping_movie = jQuery.makeArray({{ settings.general.path_mappings_movie|safe }})
$('.form').form('validate form'); path_mapping_movie = $.grep(path_mapping_movie, function(v) {
$('#loader').removeClass('active'); return v[0] !== "" || v[1] !== "";
} else { });
$('#radarr_validated').checkbox('uncheck');
$('#radarr_validation_result').text('Test failed').css('color', 'red'); var table = $('#path_mapping_movie').DataTable({
$('.form').form('validate form'); data: path_mapping_movie,
$('#loader').removeClass('active'); columns: [{
} title: "Path for Radarr",
type: "text"
},
{
title: "Path for Bazarr",
type: "text"
}],
dom: 'Bfrtip',
select: {
style: 'single'
},
language: {
zeroRecords: 'No Path Mappings'
},
searching: false,
ordering: false,
lengthChange: true,
responsive: true,
paging: false,
info: false,
buttons: [{
text: 'Add',
action: function () {
$('#addModal').modal('show');
}
},
{
extend: 'selected',
text: 'Edit',
action: function () {
$('#edit_path_radarr').val(table.row( { selected: true } ).data()[0]);
$('#edit_path_bazarr').val(table.row( { selected: true } ).data()[1]);
$('#editModal').modal('show');
}
},
{
extend: 'selected',
text: 'Delete',
action: function () {
$('#deleteModal').modal('show');
}
}]
});
$('#add_save_button').on('click', function(e) {
e.preventDefault();
table.row.add([ $('#add_path_radarr').val(), $('#add_path_bazarr').val()]).draw();
$('#add_path_radarr').val('');
$('#add_path_bazarr').val('');
$('#addModal').modal('hide');
});
$('#edit_save_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).data([ $('#edit_path_radarr').val(), $('#edit_path_bazarr').val()]);
$('#editModal').modal('hide');
});
$('#delete_yes_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).remove().draw();
$('#deleteModal').modal('hide');
});
$('#test_radarr_connection').on('click', function() {
if ($('#settings-radarr-ssl').is(':checked')) {
var protocol = 'https';
} else {
var protocol = 'http';
}
var radarr_url = $('#settings-radarr-ip').val() + ":" + $('#settings-radarr-port').val() + $('#settings-radarr-base_url').val().replace(/\/$/, "") + "/api/system/status?apikey=" + $('#settings-radarr-apikey').val();
$.getJSON("{{ url_for('test_url') }}/" + protocol + "/" + encodeURIComponent(radarr_url), function (data) {
if (data.status) {
$('#test_radarr_span').text('Test Successful: Radarr v' + data.version).css('color', 'green');
} else {
$('#test_radarr_span').text('Test Failed').css('color', 'red');
}
});
});
}); });
}); </script>
{% endblock tail %}
$('.radarr_config').on('keyup', function () {
$('#radarr_validated').checkbox('uncheck');
$('#radarr_validation_result').text('You Must Test Your Radarr Connection Settings Before Saving.').css('color', 'red');
$('.form').form('validate form');
$('#loader').removeClass('active');
});
$('#settings_radarr_ssl').on('change', function () {
$('#radarr_validated').checkbox('uncheck');
$('#radarr_validation_result').text('You Must Test Your Radarr Connection Settings Before Saving.').css('color', 'red');
$('.form').form('validate form');
$('#loader').removeClass('active');
});
$("#radarr_validated").checkbox('check');
</script>
{% endmacro %}

@ -92,6 +92,15 @@
</div> </div>
</div> </div>
<br> <br>
<div class="row">
<div class="col-sm-2 text-right">
<button type="button" class="btn btn-secondary" id="test_sonarr_connection">Test</button>
</div>
<div class="col-sm-4">
<span id="test_sonarr_span"></span>
</div>
</div>
<br>
<h4>Options</h4> <h4>Options</h4>
<hr/> <hr/>
@ -116,17 +125,119 @@
</div> </div>
</div> </div>
<br> <br>
<h4>PAth Mapping</h4> <h4>Path Mappings</h4>
<hr/> <hr/>
<div class="row"> <div class="row">
<table class="dataTable table table-striped" id="path_mapping"> <div class="col-sm-8">
<table class="table table-striped" id="path_mapping" style="width:100%;">
</table> </table>
</div>
</div> </div>
<br> <br>
</div> </div>
</form> </form>
</div> </div>
<div id="addModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Add Path Mapping</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="form" name="add_form" id="add_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Path for Sonarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_sonarr" name="add_path_sonarr" value="">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="add_path_bazarr" name="add_path_bazarr" value="">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="add_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<div id="editModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Edit Path Mapping</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="form" name="edit_form" id="edit_form">
<div class="modal-body">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 text-right">
Path for Sonarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_sonarr" name="edit_path_sonarr" value="">
</div>
</div>
<br>
<div class="row">
<div class="col-sm-3 text-right">
Path for Bazarr
</div>
<div class="col-sm-8">
<input type="text" class="form-control" id="edit_path_bazarr" name="edit_path_bazarr" value="">
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" id="edit_save_button" class="btn btn-info">Save</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</form>
</div>
</div>
</div>
<div id="deleteModal" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Delete Path Mapping</h5><br>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Are you sure you want to delete this path mapping?
</div>
<div class="modal-footer">
<button type="submit" id="delete_yes_button" class="btn btn-info">Yes</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
</div>
</div>
</div>
{% endblock body %} {% endblock body %}
{% block tail %} {% block tail %}
@ -157,6 +268,8 @@
formdata.set($(this).prop('id'), $(this).prop('checked')); formdata.set($(this).prop('id'), $(this).prop('checked'));
}); });
formdata.append('settings-general-path_mappings', JSON.stringify(table.rows().data().toArray()));
$.ajax({ $.ajax({
url: "{{ url_for('api.savesettings') }}", url: "{{ url_for('api.savesettings') }}",
data: formdata, data: formdata,
@ -174,34 +287,94 @@
}); });
}); });
table = $('#path_mapping').DataTable({ var path_mapping = jQuery.makeArray({{ settings.general.path_mappings|safe }})
data: [["/tvsonarr", "/tvbazarr"]], path_mapping = $.grep(path_mapping, function(v) {
return v[0] !== "" || v[1] !== "";
});
var table = $('#path_mapping').DataTable({
data: path_mapping,
columns: [{ columns: [{
title: "Path for Sonarr", title: "Path for Sonarr",
type: "text" type: "text"
}, { },
title: "Path for Bazarr", {
type: "text" title: "Path for Bazarr",
}], type: "text"
dom: 'Bfrtip', // Needs button container }],
select: 'single', dom: 'Bfrtip',
select: {
style: 'single'
},
language: {
zeroRecords: 'No Path Mappings'
},
searching: false,
ordering: false,
lengthChange: true,
responsive: true, responsive: true,
altEditor: true, // Enable altEditor paging: false,
info: false,
buttons: [{ buttons: [{
text: 'Add', text: 'Add',
name: 'add' // do not change name action: function () {
$('#addModal').modal('show');
}
}, },
{ {
extend: 'selected', // Bind to Selected row extend: 'selected',
text: 'Edit', text: 'Edit',
name: 'edit' // do not change name action: function () {
$('#edit_path_sonarr').val(table.row( { selected: true } ).data()[0]);
$('#edit_path_bazarr').val(table.row( { selected: true } ).data()[1]);
$('#editModal').modal('show');
}
}, },
{ {
extend: 'selected', // Bind to Selected row extend: 'selected',
text: 'Delete', text: 'Delete',
name: 'delete' // do not change name action: function () {
$('#deleteModal').modal('show');
}
}] }]
}); });
$('#add_save_button').on('click', function(e) {
e.preventDefault();
table.row.add([ $('#add_path_sonarr').val(), $('#add_path_bazarr').val()]).draw();
$('#add_path_sonarr').val('');
$('#add_path_bazarr').val('');
$('#addModal').modal('hide');
});
$('#edit_save_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).data([ $('#edit_path_sonarr').val(), $('#edit_path_bazarr').val()]);
$('#editModal').modal('hide');
});
$('#delete_yes_button').on('click', function(e) {
e.preventDefault();
table.row( { selected: true } ).remove().draw();
$('#deleteModal').modal('hide');
});
$('#test_sonarr_connection').on('click', function() {
if ($('#settings-sonarr-ssl').is(':checked')) {
var protocol = 'https';
} else {
var protocol = 'http';
}
var sonarr_url = $('#settings-sonarr-ip').val() + ":" + $('#settings-sonarr-port').val() + $('#settings-sonarr-base_url').val().replace(/\/$/, "") + "/api/system/status?apikey=" + $('#settings-sonarr-apikey').val();
$.getJSON("{{ url_for('test_url') }}/" + protocol + "/" + encodeURIComponent(sonarr_url), function (data) {
if (data.status) {
$('#test_sonarr_span').text('Test Successful: Sonarr v' + data.version).css('color', 'green');
} else {
$('#test_sonarr_span').text('Test Failed').css('color', 'red');
}
});
});
}); });
</script> </script>
{% endblock tail %} {% endblock tail %}

Loading…
Cancel
Save