mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-21 05:43:19 -07:00
more work
This commit is contained in:
parent
81c492aa14
commit
6054f0d436
15 changed files with 192 additions and 23 deletions
|
@ -17,7 +17,6 @@ $("#tvSearchContent").on("keyup", function (e) {
|
|||
tvimer = setTimeout(tvSearch(), 400);
|
||||
});
|
||||
|
||||
|
||||
$("#test").click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
|
@ -104,14 +103,3 @@ function buildTvShowContext(result) {
|
|||
};
|
||||
return context;
|
||||
}
|
||||
|
||||
function generateNotify(message, type) {
|
||||
// type = danger, warning, info, successs
|
||||
$.notify({
|
||||
// options
|
||||
message: message
|
||||
}, {
|
||||
// settings
|
||||
type: type
|
||||
});
|
||||
}
|
13
RequestPlex.UI/Content/site.js
Normal file
13
RequestPlex.UI/Content/site.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
|
||||
|
||||
function generateNotify(message, type) {
|
||||
// type = danger, warning, info, successs
|
||||
$.notify({
|
||||
// options
|
||||
message: message
|
||||
}, {
|
||||
// settings
|
||||
type: type
|
||||
});
|
||||
}
|
14
RequestPlex.UI/Models/PlexAuth.cs
Normal file
14
RequestPlex.UI/Models/PlexAuth.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RequestPlex.UI.Models
|
||||
{
|
||||
public class PlexAuth
|
||||
{
|
||||
public string username { get; set; }
|
||||
public string password { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,10 +1,17 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Dynamic;
|
||||
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.ModelBinding;
|
||||
using Nancy.Security;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using RequestPlex.Api;
|
||||
using RequestPlex.Core;
|
||||
using RequestPlex.UI.Models;
|
||||
|
||||
namespace RequestPlex.UI.Modules
|
||||
{
|
||||
|
@ -12,12 +19,14 @@ namespace RequestPlex.UI.Modules
|
|||
{
|
||||
public AdminModule()
|
||||
{
|
||||
#if !DEBUG
|
||||
this.RequiresAuthentication();
|
||||
#endif
|
||||
Get["admin/"] = _ =>
|
||||
{
|
||||
dynamic model = new ExpandoObject();
|
||||
model.Errored = Request.Query.error.HasValue;
|
||||
|
||||
model.Port = null;
|
||||
var s = new SettingsService();
|
||||
var settings = s.GetSettings();
|
||||
if (settings != null)
|
||||
|
@ -42,6 +51,22 @@ namespace RequestPlex.UI.Modules
|
|||
s.SaveSettings(port);
|
||||
|
||||
|
||||
return Context.GetRedirect("~/admin");
|
||||
};
|
||||
|
||||
Post["admin/requestauth"] = _ =>
|
||||
{
|
||||
var user = this.Bind<PlexAuth>();
|
||||
|
||||
if (string.IsNullOrEmpty(user.username) || string.IsNullOrEmpty(user.password))
|
||||
{
|
||||
return Context.GetRedirect("~/admin?error=true");
|
||||
}
|
||||
|
||||
var plex = new PlexApi();
|
||||
plex.GetToken(user.username, user.password);
|
||||
|
||||
|
||||
return Context.GetRedirect("~/admin");
|
||||
};
|
||||
|
||||
|
|
|
@ -108,6 +108,7 @@
|
|||
<Content Include="Content\custom.css">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Compile Include="Models\PlexAuth.cs" />
|
||||
<Compile Include="Modules\AdminModule.cs" />
|
||||
<Compile Include="Modules\IndexModule.cs" />
|
||||
<Compile Include="Modules\LoginModule.cs" />
|
||||
|
@ -136,6 +137,9 @@
|
|||
<Content Include="Content\jquery-2.2.1.min.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\site.js">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="icon.png" />
|
||||
<None Include="app.config" />
|
||||
<Content Include="packages.config" />
|
||||
|
@ -193,7 +197,6 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Auth\" />
|
||||
<Folder Include="Models\" />
|
||||
<Folder Include="Views\Requests\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,9 +1,22 @@
|
|||
@Html.Partial("/Admin/_Sidebar")
|
||||
@{
|
||||
var port = Model.Port ?? 0;
|
||||
int port;
|
||||
if (Model.Port == null)
|
||||
{
|
||||
port = 3579;
|
||||
}
|
||||
else
|
||||
{
|
||||
port = Model.Port;
|
||||
}
|
||||
|
||||
//if (string.IsNullOrEmpty(Model.PlexAuthToken))
|
||||
//{
|
||||
// Model.PlexAuthToken = string.Empty;
|
||||
//}
|
||||
}
|
||||
<div class="col-sm-8">
|
||||
<form class="form-horizontal" method="POST">
|
||||
<form class="form-horizontal" method="POST" id="mainForm">
|
||||
<fieldset>
|
||||
<legend>Request Plex Settings</legend>
|
||||
<div class="form-group">
|
||||
|
@ -12,6 +25,32 @@
|
|||
<input type="text" class="form-control" id="portNumber" name="portNumber" placeholder="Port Number" value="@port">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="authToken" class="col-lg-2 control-label">Plex Authorization Token</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="text" class="form-control" id="authToken" name="authToken" placeholder="Plex Auth Token" value="@*@Model.PlexAuthToken*@">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="userpass" class="col-lg-2 control-label">Username and Password</label>
|
||||
<div class="col-lg-4">
|
||||
<input type="text" class="form-control" id="username" name="username" placeholder="Username">
|
||||
</div>
|
||||
<div class="col-lg-4 col-lg-push-1">
|
||||
<input type="text" class="form-control" id="password" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-10 col-lg-offset-2">
|
||||
<button id="requestToken" class="btn btn-primary">Request Token</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<small>Please note, you will have to restart after changing these settings.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="col-lg-10 col-lg-offset-2">
|
||||
<button type="reset" class="btn btn-default">Cancel</button>
|
||||
|
@ -29,4 +68,33 @@
|
|||
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-times"></i></button>
|
||||
Please enter in a correct port number
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
$('#requestToken').click(function (e) {
|
||||
var $form = $("#mainForm");
|
||||
$.ajax({
|
||||
type: $form.prop("method"),
|
||||
url: "admin/requestauth",
|
||||
data: $form.serialize(),
|
||||
dataType: "json",
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
if (response.Result === true) {
|
||||
generateNotify("Success!", "success");
|
||||
$('#authToken').val(response.authToken);
|
||||
} else {
|
||||
generateNotify(response.Message, "warning");
|
||||
}
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
generateNotify("Something went wrong!", "danger");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
|
@ -4,6 +4,5 @@
|
|||
<a class="list-group-item" href="/couchpotato">CouchPotato Settings</a>
|
||||
<a class="list-group-item" href="/sonarr">Sonarr Settings</a>
|
||||
<a class="list-group-item" href="/sickbeard">Sickbeard Settings</a>
|
||||
<a class="list-group-item" href="/userauth">Authentication</a>
|
||||
</div>
|
||||
</div>
|
|
@ -11,6 +11,7 @@
|
|||
<script src="/Content/handlebars.js"></script>
|
||||
<script src="/Content/bootstrap.min.js"></script>
|
||||
<script src="/Content/bootstrap-notify.min.js"></script>
|
||||
<script src="/Content/site.js"></script>
|
||||
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue