From aa2949cdd0c4cb7a44f3496d3af33ce5137a074c Mon Sep 17 00:00:00 2001 From: tidusjar Date: Fri, 20 May 2016 13:51:25 +0100 Subject: [PATCH] I think the auto updater is finished! #29 --- PlexRequests.UI/Modules/AdminModule.cs | 15 ++++++- .../Views/Admin/Authentication.cshtml | 2 +- PlexRequests.UI/Views/Admin/Status.cshtml | 39 +++++++++++++++++-- PlexRequests.Updater/Updater.cs | 6 ++- 4 files changed, 56 insertions(+), 6 deletions(-) diff --git a/PlexRequests.UI/Modules/AdminModule.cs b/PlexRequests.UI/Modules/AdminModule.cs index 62348a269..e1673c5e0 100644 --- a/PlexRequests.UI/Modules/AdminModule.cs +++ b/PlexRequests.UI/Modules/AdminModule.cs @@ -54,6 +54,7 @@ using PlexRequests.Store.Repository; using PlexRequests.UI.Helpers; using PlexRequests.UI.Models; using System; +using System.Diagnostics; using Nancy.Json; using Nancy.Security; @@ -172,7 +173,9 @@ namespace PlexRequests.UI.Modules Get["/headphones"] = _ => Headphones(); Post["/headphones"] = _ => SaveHeadphones(); - Post ["/createapikey"] = x => CreateApiKey (); + Post["/createapikey"] = x => CreateApiKey(); + + Post["/autoupdate"] = x => AutoUpdate(); } private Negotiator Authentication() @@ -496,6 +499,16 @@ namespace PlexRequests.UI.Modules 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() { var settings = PushbulletService.GetSettings(); diff --git a/PlexRequests.UI/Views/Admin/Authentication.cshtml b/PlexRequests.UI/Views/Admin/Authentication.cshtml index 1abbd3788..129220cd6 100644 --- a/PlexRequests.UI/Views/Admin/Authentication.cshtml +++ b/PlexRequests.UI/Views/Admin/Authentication.cshtml @@ -126,7 +126,7 @@ var $form = $("#mainForm"); $.ajax({ type: $form.prop("method"), - url: "requestauth", + url: url, data: $form.serialize(), dataType: "json", success: function (response) { diff --git a/PlexRequests.UI/Views/Admin/Status.cshtml b/PlexRequests.UI/Views/Admin/Status.cshtml index 05dbf1faf..eb5f1b743 100644 --- a/PlexRequests.UI/Views/Admin/Status.cshtml +++ b/PlexRequests.UI/Views/Admin/Status.cshtml @@ -1,4 +1,5 @@ -@Html.Partial("_Sidebar") +@using PlexRequests.UI.Helpers +@Html.Partial("_Sidebar")
@@ -15,6 +16,8 @@ @if (Model.UpdateAvailable) { +
+ } else { @@ -28,11 +31,41 @@

@Model.ReleaseTitle

-
+
@Html.Raw(Model.ReleaseNotes) }
-
\ No newline at end of file + + + \ No newline at end of file diff --git a/PlexRequests.Updater/Updater.cs b/PlexRequests.Updater/Updater.cs index fce211c22..43b44007c 100644 --- a/PlexRequests.Updater/Updater.cs +++ b/PlexRequests.Updater/Updater.cs @@ -192,7 +192,11 @@ namespace PlexRequests.Updater 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); Environment.Exit(0);