Rename SubDir to Base Url

This commit is contained in:
tidusjar 2016-07-26 20:05:54 +01:00
commit 5455b0076a
5 changed files with 618 additions and 618 deletions

View file

@ -83,7 +83,7 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="SubDir" class="control-label">CouchPotato SubDirectory</label> <label for="SubDir" class="control-label">CouchPotato Base Url</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir"> <input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div> </div>

View file

@ -1,159 +1,159 @@
@using PlexRequests.UI.Helpers @using PlexRequests.UI.Helpers
@Html.Partial("_Sidebar") @Html.Partial("_Sidebar")
@{ @{
int port; int port;
if (Model.Port == 0) if (Model.Port == 0)
{ {
port = 8181; port = 8181;
} }
else else
{ {
port = Model.Port; port = Model.Port;
} }
} }
<div class="col-sm-8 col-sm-push-1"> <div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm"> <form class="form-horizontal" method="POST" id="mainForm">
<fieldset> <fieldset>
<legend>Headphones Settings</legend> <legend>Headphones Settings</legend>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.Enabled) @if (Model.Enabled)
{ {
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label> <input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
} }
else else
{ {
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label> <input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.Ssl) @if (Model.Ssl)
{ {
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label> <input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
} }
else else
{ {
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label> <input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="Ip" class="control-label">Headphones Hostname or IP</label> <label for="Ip" class="control-label">Headphones Hostname or IP</label>
<div class=""> <div class="">
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip"> <input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="portNumber" class="control-label">Port</label> <label for="portNumber" class="control-label">Port</label>
<div class=""> <div class="">
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port"> <input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="ApiKey" class="control-label">Headphones API Key</label> <label for="ApiKey" class="control-label">Headphones API Key</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey"> <input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="SubDir" class="control-label">Headphones SubDirectory</label> <label for="SubDir" class="control-label">Headphones Base Url</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir"> <input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="testHeadphones" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button> <button id="testHeadphones" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button> <button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
</div> </div>
</div> </div>
</fieldset> </fieldset>
</form> </form>
</div> </div>
<script> <script>
$(function() { $(function() {
var base = '@Html.GetBaseUrl()'; var base = '@Html.GetBaseUrl()';
$('#testHeadphones').click(function (e) { $('#testHeadphones').click(function (e) {
$('#spinner').attr("class", "fa fa-spinner fa-spin"); $('#spinner').attr("class", "fa fa-spinner fa-spin");
e.preventDefault(); e.preventDefault();
var $form = $("#mainForm"); var $form = $("#mainForm");
var url = createBaseUrl(base, '/test/headphones'); var url = createBaseUrl(base, '/test/headphones');
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: url,
data: $form.serialize(), data: $form.serialize(),
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
console.log(response); console.log(response);
if (response.result === true) { if (response.result === true) {
$('#spinner').attr("class", "fa fa-check"); $('#spinner').attr("class", "fa fa-check");
generateNotify(response.message, "success"); generateNotify(response.message, "success");
} else { } else {
$('#spinner').attr("class", "fa fa-times"); $('#spinner').attr("class", "fa fa-times");
generateNotify(response.message, "warning"); generateNotify(response.message, "warning");
} }
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
$('#spinner').attr("class", "fa fa-times"); $('#spinner').attr("class", "fa fa-times");
generateNotify("Something went wrong!", "danger"); generateNotify("Something went wrong!", "danger");
} }
}); });
}); });
$('#save').click(function (e) { $('#save').click(function (e) {
e.preventDefault(); e.preventDefault();
var port = $('#portNumber').val(); var port = $('#portNumber').val();
if (isNaN(port)) { if (isNaN(port)) {
generateNotify("You must specify a Port.", "warning"); generateNotify("You must specify a Port.", "warning");
return; return;
} }
var $form = $("#mainForm"); var $form = $("#mainForm");
var qualityProfile = $("#profiles option:selected").val(); var qualityProfile = $("#profiles option:selected").val();
var data = $form.serialize(); var data = $form.serialize();
data = data + "&profileId=" + qualityProfile; data = data + "&profileId=" + qualityProfile;
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
data: data, data: data,
url: $form.prop("action"), url: $form.prop("action"),
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response.result === true) { if (response.result === true) {
generateNotify(response.message, "success"); generateNotify(response.message, "success");
} else { } else {
generateNotify(response.message, "warning"); generateNotify(response.message, "warning");
} }
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
generateNotify("Something went wrong!", "danger"); generateNotify("Something went wrong!", "danger");
} }
}); });
}); });
}); });
</script> </script>

View file

@ -63,7 +63,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="SubDir" class="control-label">Plex SubDirectory</label> <label for="SubDir" class="control-label">Plex Base Url</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir"> <input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div> </div>

View file

@ -1,184 +1,184 @@
@using PlexRequests.UI.Helpers @using PlexRequests.UI.Helpers
@Html.Partial("_Sidebar") @Html.Partial("_Sidebar")
@{ @{
int port; int port;
if (Model.Port == 0) if (Model.Port == 0)
{ {
port = 8081; port = 8081;
} }
else else
{ {
port = Model.Port; port = Model.Port;
} }
} }
<div class="col-sm-8 col-sm-push-1"> <div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm"> <form class="form-horizontal" method="POST" id="mainForm">
<fieldset> <fieldset>
<legend>SickRage Settings</legend> <legend>SickRage Settings</legend>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.Enabled) @if (Model.Enabled)
{ {
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label> <input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
} }
else else
{ {
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label> <input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="Ip" class="control-label">SickRage Hostname or IP</label> <label for="Ip" class="control-label">SickRage Hostname or IP</label>
<div class=""> <div class="">
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip"> <input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="portNumber" class="control-label">Port</label> <label for="portNumber" class="control-label">Port</label>
<div class=""> <div class="">
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port"> <input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="ApiKey" class="control-label">SickRage API Key</label> <label for="ApiKey" class="control-label">SickRage API Key</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey"> <input type="text" class="form-control form-control-custom " id="ApiKey" name="ApiKey" value="@Model.ApiKey">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="checkbox"> <div class="checkbox">
@if (Model.Ssl) @if (Model.Ssl)
{ {
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label> <input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
} }
else else
{ {
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label> <input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
} }
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="SubDir" class="control-label">SickRage SubDirectory</label> <label for="SubDir" class="control-label">SickRage Base Url</label>
<div> <div>
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir"> <input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="profiles" class="control-label ">Quality Profiles</label> <label for="profiles" class="control-label ">Quality Profiles</label>
<div id="profiles"> <div id="profiles">
<select class="form-control form-control-custom" value="selected"> <select class="form-control form-control-custom" value="selected">
@foreach (var quality in Model.Qualities) @foreach (var quality in Model.Qualities)
{ {
<option id="@quality.Key" value="@quality.Key">@quality.Value</option> <option id="@quality.Key" value="@quality.Key">@quality.Value</option>
} }
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="testSickRage" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button> <button id="testSickRage" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="save" type="submit" class="btn btn-primary-outline ">Submit</button> <button id="save" type="submit" class="btn btn-primary-outline ">Submit</button>
</div> </div>
</div> </div>
</fieldset> </fieldset>
</form> </form>
</div> </div>
<script> <script>
$(function() { $(function() {
var base = '@Html.GetBaseUrl()'; var base = '@Html.GetBaseUrl()';
@if (!string.IsNullOrEmpty(Model.QualityProfile)) @if (!string.IsNullOrEmpty(Model.QualityProfile))
{ {
<text> <text>
var qualitySelected = '@Model.QualityProfile'; var qualitySelected = '@Model.QualityProfile';
$('#' + qualitySelected).prop("selected", "selected"); $('#' + qualitySelected).prop("selected", "selected");
</text> </text>
} }
$('#save').click(function (e) { $('#save').click(function (e) {
e.preventDefault(); e.preventDefault();
var port = $('#portNumber').val(); var port = $('#portNumber').val();
if (isNaN(port)) { if (isNaN(port)) {
generateNotify("You must specify a Port.", "warning"); generateNotify("You must specify a Port.", "warning");
return; return;
} }
var qualityProfile = $("#profiles option:selected").val(); var qualityProfile = $("#profiles option:selected").val();
var $form = $("#mainForm"); var $form = $("#mainForm");
var data = $form.serialize(); var data = $form.serialize();
data = data + "&qualityProfile=" + qualityProfile; data = data + "&qualityProfile=" + qualityProfile;
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
data: data, data: data,
url: $form.prop("action"), url: $form.prop("action"),
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
if (response.result === true) { if (response.result === true) {
generateNotify("Success!", "success"); generateNotify("Success!", "success");
} else { } else {
generateNotify(response.message, "warning"); generateNotify(response.message, "warning");
} }
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
generateNotify("Something went wrong!", "danger"); generateNotify("Something went wrong!", "danger");
} }
}); });
}); });
$('#testSickRage').click(function (e) { $('#testSickRage').click(function (e) {
$('#spinner').attr("class", "fa fa-spinner fa-spin"); $('#spinner').attr("class", "fa fa-spinner fa-spin");
e.preventDefault(); e.preventDefault();
var qualityProfile = $("#profiles option:selected").val(); var qualityProfile = $("#profiles option:selected").val();
var $form = $("#mainForm"); var $form = $("#mainForm");
var data = $form.serialize(); var data = $form.serialize();
data = data + "&qualityProfile=" + qualityProfile; data = data + "&qualityProfile=" + qualityProfile;
var url = createBaseUrl(base, '/test/sickrage'); var url = createBaseUrl(base, '/test/sickrage');
$.ajax({ $.ajax({
type: $form.prop("method"), type: $form.prop("method"),
url: url, url: url,
data: data, data: data,
dataType: "json", dataType: "json",
success: function (response) { success: function (response) {
console.log(response); console.log(response);
if (response.result === true) { if (response.result === true) {
generateNotify(response.message, "success"); generateNotify(response.message, "success");
$('#spinner').attr("class", "fa fa-check"); $('#spinner').attr("class", "fa fa-check");
} else { } else {
generateNotify(response.message, "warning"); generateNotify(response.message, "warning");
$('#spinner').attr("class", "fa fa-times"); $('#spinner').attr("class", "fa fa-times");
} }
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
generateNotify("Something went wrong!", "danger"); generateNotify("Something went wrong!", "danger");
$('#spinner').attr("class", "fa fa-times"); $('#spinner').attr("class", "fa fa-times");
} }
}); });
}); });
}) })
</script> </script>

View file

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