Merge remote-tracking branch 'origin/dev' into dev

pull/158/head
Drewster727 9 years ago
commit 94aee87882

@ -62,6 +62,17 @@ function finishLoading(elementId, originalCss, html) {
}
}
function createBaseUrl(base, url) {
if (base) {
if (url.charAt(0) === "/") {
url = "/" + base + url;
} else {
url = "/" + base + "/" + url;
}
}
return url;
}
var noResultsHtml = "<div class='no-search-results'>" +
"<i class='fa fa-film no-search-results-icon'></i><div class='no-search-results-text'>Sorry, we didn't find any results!</div></div>";
var noResultsMusic = "<div class='no-search-results'>" +

@ -1,7 +1,7 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: AssetHelper.cs
// File: BaseUrlHelper.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
@ -24,8 +24,10 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System.Text;
using System.IO;
using System.Text;
using Nancy;
using Nancy.ViewEngines.Razor;
using PlexRequests.Core;
@ -33,14 +35,13 @@ using PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Helpers
{
public static class AssetHelper
public static class BaseUrlHelper
{
private static ServiceLocator Locator => ServiceLocator.Instance;
public static IHtmlString LoadAssets(this HtmlHelpers helper)
{
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var sb = new StringBuilder();
var assetLocation = settings.BaseUrl;
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@ -64,9 +65,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadSearchAssets(this HtmlHelpers helper)
{
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var sb = new StringBuilder();
var assetLocation = settings.BaseUrl;
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@ -77,9 +77,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadRequestAssets(this HtmlHelpers helper)
{
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var sb = new StringBuilder();
var assetLocation = settings.BaseUrl;
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@ -90,9 +89,8 @@ namespace PlexRequests.UI.Helpers
public static IHtmlString LoadLogsAssets(this HtmlHelpers helper)
{
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var sb = new StringBuilder();
var assetLocation = settings.BaseUrl;
var assetLocation = GetBaseUrl();
var content = GetContentUrl(assetLocation);
@ -101,10 +99,46 @@ namespace PlexRequests.UI.Helpers
return helper.Raw(sb.ToString());
}
private static string GetContentUrl(string assetLocation)
public static IHtmlString GetSidebarUrl(this HtmlHelpers helper, NancyContext context, string url, string title)
{
return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"/{assetLocation}";
var returnString = string.Empty;
var content = GetLinkUrl(GetBaseUrl());
if (!string.IsNullOrEmpty(content))
{
url = $"/{content}{url}";
}
if (context.Request.Path == url)
{
returnString = $"<a class=\"list-group-item active\" href=\"{url}\">{title}</a>";
}
else
{
returnString = $"<a class=\"list-group-item\" href=\"{url}\">{title}</a>";
}
return helper.Raw(returnString);
}
public static IHtmlString GetBaseUrl(this HtmlHelpers helper)
{
return helper.Raw(GetBaseUrl());
}
private static string GetBaseUrl()
{
var settings = Locator.Resolve<ISettingsService<PlexRequestSettings>>().GetSettings();
var assetLocation = settings.BaseUrl;
return assetLocation;
}
private static string GetLinkUrl(string assetLocation)
{
return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"{assetLocation}";
}
private static string GetContentUrl(string assetLocation)
{
return string.IsNullOrEmpty(assetLocation) ? string.Empty : $"/{assetLocation}";
}
}
}

@ -164,7 +164,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstrapper.cs" />
<Compile Include="Helpers\AssetHelper.cs" />
<Compile Include="Helpers\BaseUrlHelper.cs" />
<Compile Include="Helpers\HeadphonesSender.cs" />
<Compile Include="Helpers\ServiceLocator.cs" />
<Compile Include="Helpers\StringHelper.cs" />

@ -1,7 +1,16 @@
@Html.Partial("_Sidebar")
@using PlexRequests.UI.Helpers
@Html.Partial("_Sidebar")
@{
var baseUrl = Html.GetBaseUrl();
var formAction = "/admin/authentication";
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{
formAction = "/" + baseUrl.ToHtmlString() + formAction;
}
}
<div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" action="/admin/authentication" id="mainForm">
<form class="form-horizontal" method="POST" action="@formAction" id="mainForm">
<fieldset>
<legend>Authentication Settings</legend>
@ -100,21 +109,24 @@
<script>
$(function () {
var base = '@Html.GetBaseUrl()';
if ($('#PlexAuthToken')) {
loadUserList();
}
$('#refreshUsers').click(function () {
$('#refreshUsers').click(function (e) {
e.preventDefault();
loadUserList();
});
$('#requestToken').click(function (e) {
e.preventDefault();
var url = createBaseUrl(base, "admin/requestauth");
var $form = $("#mainForm");
$.ajax({
type: $form.prop("method"),
url: "requestauth",
url: url,
data: $form.serialize(),
dataType: "json",
success: function (response) {
@ -136,9 +148,12 @@
function loadUserList() {
$('#users').html("");
var url = "admin/getusers";
url = createBaseUrl(base, url);
$.ajax({
type: "Get",
url: "getusers",
url: url,
dataType: "json",
success: function (response) {
if (response.length > 1) {

@ -1,4 +1,5 @@
@Html.Partial("_Sidebar")
@using PlexRequests.UI.Helpers
@Html.Partial("_Sidebar")
@{
int port;
if (Model.Port == 0)
@ -108,15 +109,19 @@
<script>
$(function() {
var baseUrl = '@Html.GetBaseUrl()';
@if (!string.IsNullOrEmpty(Model.ProfileId))
{
<text>
var qualitySelected = '@Model.ProfileId';
var $form = $("#mainForm");
var url = 'cpprofiles';
url = createBaseUrl(baseUrl, url);
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "cpprofiles",
url: url,
dataType: "json",
success: function(response) {
response.list.forEach(function(result) {
@ -139,10 +144,12 @@
$('#getProfiles').click(function (e) {
e.preventDefault();
var $form = $("#mainForm");
var url = "admin/cpprofiles";
url = createBaseUrl(baseUrl, url);
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: "cpprofiles",
url: url,
dataType: "json",
success: function (response) {
response.list.forEach(function (result) {
@ -159,10 +166,11 @@
$('#testCp').click(function (e) {
e.preventDefault();
var $form = $("#mainForm");
var url = createBaseUrl(baseUrl,"/test/cp");
url = createBaseUrl(baseUrl, url);
$.ajax({
type: $form.prop("method"),
url: "/test/cp",
url: url,
data: $form.serialize(),
dataType: "json",
success: function (response) {

@ -2,11 +2,19 @@
@Html.Partial("_Sidebar")
@Html.LoadLogsAssets()
@{
var baseUrl = Html.GetBaseUrl();
var formAction = "/admin/loglevel";
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
{
formAction = "/" + baseUrl.ToHtmlString() + formAction;
}
}
<div class="col-sm-8 col-sm-push-1">
<fieldset>
<legend>Logs</legend>
<form method="post" id="mainForm" action="/admin/loglevel">
<form method="post" id="mainForm" action="@formAction">
<div class="form-group">
<label for="logLevel" class="control-label">Log Level</label>
<div id="logLevel">
@ -45,9 +53,12 @@
<script>
$(function () {
var baseUrl = '@Html.GetBaseUrl()';
var logsUrl = "/admin/loadlogs";
var url = createBaseUrl(baseUrl, logsUrl);
$('#example').DataTable({
"ajax": "/admin/loadlogs",
"ajax": url,
"columns": [
{ "data": "message" },
{ "data": "logger" },
@ -58,9 +69,11 @@
});
var logUrl = "/admin/loglevel";
logUrl = createBaseUrl(baseUrl, logUrl);
$.ajax({
type: "get",
url: "/admin/loglevel",
url: logUrl,
dataType: "json",
success: function (response) {
$("#select > option").each(function (level) {

@ -1,108 +1,17 @@
<div class="col-lg-3 col-md-3 col-sm-4">
@using PlexRequests.UI.Helpers
<div class="col-lg-3 col-md-3 col-sm-4">
<div class="list-group table-of-contents">
@if (Context.Request.Path == "/admin")
{
<a class="list-group-item active" href="/admin">Plex Request</a>
}
else
{
<a class="list-group-item" href="/admin">Plex Request</a>
}
@if (Context.Request.Path == "/admin/authentication")
{
<a class="list-group-item active" href="/admin/authentication">Authentication</a>
}
else
{
<a class="list-group-item" href="/admin/authentication">Authentication</a>
}
@if (Context.Request.Path == "/admin/plex")
{
<a class="list-group-item active" href="/admin/plex">Plex</a>
}
else
{
<a class="list-group-item" href="/admin/plex">Plex</a>
}
@if (Context.Request.Path == "/admin/couchpotato")
{
<a class="list-group-item active" href="/admin/couchpotato">CouchPotato</a>
}
else
{
<a class="list-group-item" href="/admin/couchpotato">CouchPotato</a>
}
@if (Context.Request.Path == "/admin/sonarr")
{
<a class="list-group-item active" href="/admin/sonarr">Sonarr</a>
}
else
{
<a class="list-group-item" href="/admin/sonarr">Sonarr</a>
}
@if (Context.Request.Path == "/admin/sickrage")
{
<a class="list-group-item active" href="/admin/sickrage">SickRage</a>
}
else
{
<a class="list-group-item" href="/admin/sickrage">SickRage</a>
}
@if (Context.Request.Path == "/admin/headphones")
{
<a class="list-group-item active" href="/admin/headphones">Headphones (Beta)</a>
}
else
{
<a class="list-group-item" href="/admin/headphones">Headphones (Beta)</a>
}
@if (Context.Request.Path == "/admin/emailnotification")
{
<a class="list-group-item active" href="/admin/emailnotification">Email Notifications</a>
}
else
{
<a class="list-group-item" href="/admin/emailnotification">Email Notifications</a>
}
@if (Context.Request.Path == "/admin/pushbulletnotification")
{
<a class="list-group-item active" href="/admin/pushbulletnotification">Pushbullet Notifications</a>
}
else
{
<a class="list-group-item" href="/admin/pushbulletnotification">Pushbullet Notifications</a>
}
@if (Context.Request.Path == "/admin/pushovernotification")
{
<a class="list-group-item active" href="/admin/pushovernotification">Pushover Notifications</a>
}
else
{
<a class="list-group-item" href="/admin/pushovernotification">Pushover Notifications</a>
}
@if (Context.Request.Path == "/admin/logs")
{
<a class="list-group-item active" href="/admin/logs">Logs</a>
}
else
{
<a class="list-group-item" href="/admin/logs">Logs</a>
}
@if (Context.Request.Path == "/admin/status")
{
<a class="list-group-item active" href="/admin/status">Status</a>
}
else
{
<a class="list-group-item" href="/admin/status">Status</a>
}
@Html.GetSidebarUrl(Context, "/admin", "Plex Request")
@Html.GetSidebarUrl(Context, "/admin/authentication", "Authentication")
@Html.GetSidebarUrl(Context, "/admin/plex", "Plex")
@Html.GetSidebarUrl(Context, "/admin/couchpotato", "CouchPotato")
@Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr")
@Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage")
@Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (Beta)")
@Html.GetSidebarUrl(Context, "/admin/emailnotification", "Email Notifications")
@Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications")
@Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications")
@Html.GetSidebarUrl(Context, "/admin/logs", "Logs")
@Html.GetSidebarUrl(Context, "/admin/status", "Status")
</div>
</div>
Loading…
Cancel
Save