|
|
|
@Html.Partial("_Sidebar")
|
|
|
|
@{
|
|
|
|
int port;
|
|
|
|
if (Model.Port == 0)
|
|
|
|
{
|
|
|
|
port = 8989;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
port = Model.Port;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
<div class="col-sm-8 col-sm-push-1">
|
|
|
|
<form class="form-horizontal" method="POST" id="mainForm">
|
|
|
|
<fieldset>
|
|
|
|
<legend>Sonarr Settings</legend>
|
|
|
|
<div class="form-group">
|
|
|
|
<div class="checkbox">
|
|
|
|
<label>
|
|
|
|
@if (Model.Enabled)
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><text>Enabled</text>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="Enabled" name="Enabled"><text>Enabled</text>
|
|
|
|
}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="Ip" class="control-label">Sonarr Hostname or IP</label>
|
|
|
|
<div class="">
|
|
|
|
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="portNumber" class="control-label">Port</label>
|
|
|
|
|
|
|
|
<div class="">
|
|
|
|
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="ApiKey" class="control-label">Sonarr API Key</label>
|
|
|
|
<div>
|
|
|
|
<input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<div class="checkbox">
|
|
|
|
<label>
|
|
|
|
@if (Model.Ssl)
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><text>SSL</text>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="Ssl" name="Ssl"><text>SSL</text>
|
|
|
|
}
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="SubDir" class="control-label">Sonarr SubDirectory</label>
|
|
|
|
<div>
|
|
|
|
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<div>
|
|
|
|
<button type="submit" id="getProfiles" class="btn btn-primary-outline">Get Quality Profiles</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="select" class="control-label">Quality Profiles</label>
|
|
|
|
<div id="profiles">
|
|
|
|
<select class="form-control form-control-custom" id="select"></select>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="RootPath" class="control-label">Root save directory for TV shows</label>
|
|
|
|
<div>
|
|
|
|
<input type="text" class="form-control form-control-custom " placeholder="C:\Media\Tv" id="RootPath" name="RootPath" value="@Model.RootPath">
|
|
|
|
<label>Enter the root folder where tv shows are saved. For example <strong>C:\Media\TV</strong>.</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<div class="checkbox">
|
|
|
|
<label>
|
|
|
|
@if (Model.SeasonFolders)
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="SeasonFolders" name="SeasonFolders" checked="checked">
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<input type="checkbox" id="SeasonFolders" name="SeasonFolders">
|
|
|
|
}
|
|
|
|
<label>Enable season folders</label>
|
|
|
|
<label>Enabled Season Folders to organize seasons into individual folders within a show.</label>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
|
|
<div>
|
|
|
|
<button id="testSonarr" type="submit" class="btn btn-primary-outline">Test Connectivity</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<div>
|
|
|
|
<button id="save" type="submit" class="btn btn-primary-outline ">Submit</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</fieldset>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
$(function () {
|
|
|
|
|
|
|
|
@if (!string.IsNullOrEmpty(Model.QualityProfile))
|
|
|
|
{
|
|
|
|
<text>
|
|
|
|
var qualitySelected = @Model.QualityProfile;
|
|
|
|
var $form = $("#mainForm");
|
|
|
|
$.ajax({
|
|
|
|
type: $form.prop("method"),
|
|
|
|
data: $form.serialize(),
|
|
|
|
url: "sonarrprofiles",
|
|
|
|
dataType: "json",
|
|
|
|
success: function(response) {
|
|
|
|
response.forEach(function(result) {
|
|
|
|
if (result.id == qualitySelected) {
|
|
|
|
|
|
|
|
$("#select").append("<option selected='selected' value='" + result.id + "'>" + result.name + "</option>");
|
|
|
|
} else {
|
|
|
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function(e) {
|
|
|
|
console.log(e);
|
|
|
|
generateNotify("Something went wrong!", "danger");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</text>
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#save').click(function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var port = $('#portNumber').val();
|
|
|
|
if (isNaN(port)) {
|
|
|
|
generateNotify("You must specify a Port.", "warning");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var qualityProfile = $("#profiles option:selected").val();
|
|
|
|
|
|
|
|
var $form = $("#mainForm");
|
|
|
|
|
|
|
|
var data = $form.serialize();
|
|
|
|
data = data + "&qualityProfile=" + qualityProfile;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: $form.prop("method"),
|
|
|
|
data: data,
|
|
|
|
url: $form.prop("action"),
|
|
|
|
dataType: "json",
|
|
|
|
success: function (response) {
|
|
|
|
if (response.result === true) {
|
|
|
|
generateNotify("Success!", "success");
|
|
|
|
} else {
|
|
|
|
generateNotify(response.message, "warning");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function (e) {
|
|
|
|
console.log(e);
|
|
|
|
generateNotify("Something went wrong!", "danger");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#getProfiles').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (!$('#Ip').val()) {
|
|
|
|
generateNotify("Please enter a valid IP/Hostname.", "warning");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!$('#portNumber').val()) {
|
|
|
|
generateNotify("Please enter a valid Port Number.", "warning");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!$('#ApiKey').val()) {
|
|
|
|
generateNotify("Please enter a valid ApiKey.", "warning");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var $form = $("#mainForm");
|
|
|
|
$.ajax({
|
|
|
|
type: $form.prop("method"),
|
|
|
|
data: $form.serialize(),
|
|
|
|
url: "sonarrprofiles",
|
|
|
|
dataType: "json",
|
|
|
|
success: function (response) {
|
|
|
|
response.forEach(function (result) {
|
|
|
|
$("#select").append("<option value='" + result.id + "'>" + result.name + "</option>");
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function (e) {
|
|
|
|
console.log(e);
|
|
|
|
generateNotify("Something went wrong!", "danger");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#testSonarr').click(function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
var $form = $("#mainForm");
|
|
|
|
$.ajax({
|
|
|
|
type: $form.prop("method"),
|
|
|
|
url: "/test/sonarr",
|
|
|
|
data: $form.serialize(),
|
|
|
|
dataType: "json",
|
|
|
|
success: function (response) {
|
|
|
|
console.log(response);
|
|
|
|
if (response.result === true) {
|
|
|
|
generateNotify(response.message, "success");
|
|
|
|
} else {
|
|
|
|
generateNotify(response.message, "warning");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function (e) {
|
|
|
|
console.log(e);
|
|
|
|
generateNotify("Something went wrong!", "danger");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
</script>
|