mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
I think the auto updater is finished! #29
This commit is contained in:
parent
0601f04582
commit
aa2949cdd0
4 changed files with 56 additions and 6 deletions
|
@ -54,6 +54,7 @@ using PlexRequests.Store.Repository;
|
||||||
using PlexRequests.UI.Helpers;
|
using PlexRequests.UI.Helpers;
|
||||||
using PlexRequests.UI.Models;
|
using PlexRequests.UI.Models;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
using Nancy.Json;
|
using Nancy.Json;
|
||||||
using Nancy.Security;
|
using Nancy.Security;
|
||||||
|
@ -172,7 +173,9 @@ namespace PlexRequests.UI.Modules
|
||||||
Get["/headphones"] = _ => Headphones();
|
Get["/headphones"] = _ => Headphones();
|
||||||
Post["/headphones"] = _ => SaveHeadphones();
|
Post["/headphones"] = _ => SaveHeadphones();
|
||||||
|
|
||||||
Post ["/createapikey"] = x => CreateApiKey ();
|
Post["/createapikey"] = x => CreateApiKey();
|
||||||
|
|
||||||
|
Post["/autoupdate"] = x => AutoUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Negotiator Authentication()
|
private Negotiator Authentication()
|
||||||
|
@ -496,6 +499,16 @@ namespace PlexRequests.UI.Modules
|
||||||
return View["Status", status];
|
return View["Status", status];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Response AutoUpdate()
|
||||||
|
{
|
||||||
|
var url = Request.Form["url"];
|
||||||
|
var startInfo = new ProcessStartInfo("PlexRequests.Updater.exe") { Arguments = url};
|
||||||
|
Process.Start(startInfo);
|
||||||
|
|
||||||
|
Environment.Exit(0);
|
||||||
|
return Nancy.Response.NoBody;
|
||||||
|
}
|
||||||
|
|
||||||
private Negotiator PushbulletNotifications()
|
private Negotiator PushbulletNotifications()
|
||||||
{
|
{
|
||||||
var settings = PushbulletService.GetSettings();
|
var settings = PushbulletService.GetSettings();
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
var $form = $("#mainForm");
|
var $form = $("#mainForm");
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: $form.prop("method"),
|
type: $form.prop("method"),
|
||||||
url: "requestauth",
|
url: url,
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function (response) {
|
success: function (response) {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
@Html.Partial("_Sidebar")
|
@using PlexRequests.UI.Helpers
|
||||||
|
@Html.Partial("_Sidebar")
|
||||||
|
|
||||||
<div class="col-sm-8 col-sm-push-1">
|
<div class="col-sm-8 col-sm-push-1">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -15,6 +16,8 @@
|
||||||
@if (Model.UpdateAvailable)
|
@if (Model.UpdateAvailable)
|
||||||
{
|
{
|
||||||
<label class="control-label"><a href="@Model.UpdateUri" target="_blank"><i class="fa fa-check"></i></a></label>
|
<label class="control-label"><a href="@Model.UpdateUri" target="_blank"><i class="fa fa-check"></i></a></label>
|
||||||
|
<br />
|
||||||
|
<button id="autoUpdate" class="btn btn-success-outline">Automatic Update <i class="fa fa-download"></i></button>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -28,11 +31,41 @@
|
||||||
<h2>
|
<h2>
|
||||||
<a href="@Model.DownloadUri">@Model.ReleaseTitle</a>
|
<a href="@Model.DownloadUri">@Model.ReleaseTitle</a>
|
||||||
</h2>
|
</h2>
|
||||||
<hr/>
|
<hr />
|
||||||
<label>Release Notes:</label>
|
<label>Release Notes:</label>
|
||||||
@Html.Raw(Model.ReleaseNotes)
|
@Html.Raw(Model.ReleaseNotes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var base = '@Html.GetBaseUrl()';
|
||||||
|
$('#autoUpdate')
|
||||||
|
.click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$('body').append("<i class=\"fa fa-spinner fa-spin fa-5x fa-fw\" style=\"position: absolute; top: 20%; left: 50%;\"></i>");
|
||||||
|
$('#autoUpdate').prop("disabled", "disabled");
|
||||||
|
var count = 0;
|
||||||
|
setInterval(function () {
|
||||||
|
count++;
|
||||||
|
var dots = new Array(count % 10).join('.');
|
||||||
|
document.getElementById('autoUpdate').innerHTML = "Updating" + dots;
|
||||||
|
}, 1000);
|
||||||
|
var url = createBaseUrl(base, "autoupdate");
|
||||||
|
$.ajax({
|
||||||
|
type: "Post",
|
||||||
|
url: url,
|
||||||
|
data: { url: "@Model.DownloadUri" },
|
||||||
|
dataType: "json",
|
||||||
|
error: function () {
|
||||||
|
setTimeout(
|
||||||
|
function () {
|
||||||
|
location.reload();
|
||||||
|
}, 30000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -192,7 +192,11 @@ namespace PlexRequests.Updater
|
||||||
|
|
||||||
private void FinishUpdate()
|
private void FinishUpdate()
|
||||||
{
|
{
|
||||||
var startInfo = new ProcessStartInfo("PlexRequests.exe") { Arguments = Error ? "-u 2" : "-u 1" };
|
ProcessStartInfo startInfo;
|
||||||
|
startInfo = Type.GetType("Mono.Runtime") != null
|
||||||
|
? new ProcessStartInfo("mono PlexRequests.exe") { Arguments = Error ? "-u 2" : "-u 1" }
|
||||||
|
: new ProcessStartInfo("PlexRequests.exe") { Arguments = Error ? "-u 2" : "-u 1" };
|
||||||
|
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
|
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue