From 1242b2e22e7c873564dc2e1793cbbf9c9dd05fcc Mon Sep 17 00:00:00 2001 From: ElementalCrisis Date: Wed, 28 Dec 2016 18:06:30 -0800 Subject: [PATCH] Add button to launch WebUI. --- JMMServer/MainWindow.xaml | 11 ++++- JMMServer/MainWindow.xaml.cs | 49 ++++++++++++++++++++++ JMMServer/Properties/Resources.Designer.cs | 9 ++++ JMMServer/Properties/Resources.de.resx | 3 ++ JMMServer/Properties/Resources.en-GB.resx | 3 ++ JMMServer/Properties/Resources.es.resx | 3 ++ JMMServer/Properties/Resources.fr.resx | 3 ++ JMMServer/Properties/Resources.it.resx | 3 ++ JMMServer/Properties/Resources.nl.resx | 3 ++ JMMServer/Properties/Resources.pl.resx | 3 ++ JMMServer/Properties/Resources.pt.resx | 3 ++ JMMServer/Properties/Resources.resx | 3 ++ JMMServer/Properties/Resources.ru.resx | 3 ++ 13 files changed, 97 insertions(+), 2 deletions(-) diff --git a/JMMServer/MainWindow.xaml b/JMMServer/MainWindow.xaml index 9cc27fa53..8280b44fc 100644 --- a/JMMServer/MainWindow.xaml +++ b/JMMServer/MainWindow.xaml @@ -404,8 +404,15 @@ - - + + diff --git a/JMMServer/MainWindow.xaml.cs b/JMMServer/MainWindow.xaml.cs index dcad944b4..03169c74a 100644 --- a/JMMServer/MainWindow.xaml.cs +++ b/JMMServer/MainWindow.xaml.cs @@ -37,6 +37,7 @@ using Microsoft.Win32.TaskScheduler; using Nancy.Hosting.Self; using Action = System.Action; +using System.Net.NetworkInformation; namespace JMMServer { @@ -253,6 +254,7 @@ public MainWindow() btnSyncTrakt.Click += new RoutedEventHandler(btnSyncTrakt_Click); btnImportManualLinks.Click += new RoutedEventHandler(btnImportManualLinks_Click); btnUpdateAniDBInfo.Click += new RoutedEventHandler(btnUpdateAniDBInfo_Click); + btnLaunchWebUI.Click += new RoutedEventHandler(btnLaunchWebUI_Click); btnUpdateImages.Click += new RoutedEventHandler(btnUpdateImages_Click); btnUploadAzureCache.Click += new RoutedEventHandler(btnUploadAzureCache_Click); btnUpdateTraktInfo.Click += BtnUpdateTraktInfo_Click; @@ -2077,6 +2079,53 @@ private void CommandBinding_ScanFolder(object sender, ExecutedRoutedEventArgs e) } } + void btnLaunchWebUI_Click(object sender, RoutedEventArgs e) + { + try + { + string IP = GetLocalIPv4(NetworkInterfaceType.Ethernet); + if (string.IsNullOrEmpty(IP)) + IP = "127.0.0.1"; + + string url = $"http://{IP}:{ServerSettings.JMMServerPort}"; + Process.Start(url); + } + catch (Exception ex) + { + logger.Error(ex, ex.ToString()); + } + } + + internal static string GetLocalIPv4(NetworkInterfaceType _type) + { + string output = ""; + foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) + { + if (item.NetworkInterfaceType == _type && item.OperationalStatus == OperationalStatus.Up) + { + IPInterfaceProperties adapterProperties = item.GetIPProperties(); + + if (adapterProperties.GatewayAddresses.FirstOrDefault() != null) + { + foreach (UnicastIPAddressInformation ip in adapterProperties.UnicastAddresses) + { + if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) + { + output = ip.Address.ToString(); + } + } + } + } + } + + return output; + } + + private void MsgBox(Func getLocalIPv4) + { + throw new NotImplementedException(); + } + void btnUpdateAniDBInfo_Click(object sender, RoutedEventArgs e) { try diff --git a/JMMServer/Properties/Resources.Designer.cs b/JMMServer/Properties/Resources.Designer.cs index 39b819641..6b0ac2f41 100644 --- a/JMMServer/Properties/Resources.Designer.cs +++ b/JMMServer/Properties/Resources.Designer.cs @@ -3037,6 +3037,15 @@ public static string Settings_SetDefault { } } + /// + /// Looks up a localized string similar to Launch WebUI. + /// + public static string Settings_WebUI { + get { + return ResourceManager.GetString("Settings_WebUI", resourceCulture); + } + } + /// /// Looks up a localized string similar to Start With Windows. /// diff --git a/JMMServer/Properties/Resources.de.resx b/JMMServer/Properties/Resources.de.resx index 9e9498120..82f355841 100644 --- a/JMMServer/Properties/Resources.de.resx +++ b/JMMServer/Properties/Resources.de.resx @@ -1183,4 +1183,7 @@ Du kannst nur einen Ordner aufgeführt als Drop-Ziel haben. Update verfügbar für Shoko Server! + + Starten Sie WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.en-GB.resx b/JMMServer/Properties/Resources.en-GB.resx index 450a3a50a..ef666db41 100644 --- a/JMMServer/Properties/Resources.en-GB.resx +++ b/JMMServer/Properties/Resources.en-GB.resx @@ -1183,4 +1183,7 @@ You can only have one folder listed as a Drop Destination. Update Available For Shoko Server! + + Launch WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.es.resx b/JMMServer/Properties/Resources.es.resx index b0a195d52..097df414c 100644 --- a/JMMServer/Properties/Resources.es.resx +++ b/JMMServer/Properties/Resources.es.resx @@ -1183,4 +1183,7 @@ Sólo puede tener una carpeta que aparece como un destino de la gota. ¡Actualización disponible para el servidor de Shoko! + + Lanzamiento de WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.fr.resx b/JMMServer/Properties/Resources.fr.resx index 3a4d98349..798a6f0b4 100644 --- a/JMMServer/Properties/Resources.fr.resx +++ b/JMMServer/Properties/Resources.fr.resx @@ -1183,4 +1183,7 @@ Vous ne pouvez avoir qu'un seul dossier répertorié comme une Destination de Dr Mise à disposition pour serveur Shoko ! + + Lancer le WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.it.resx b/JMMServer/Properties/Resources.it.resx index 2268f7186..94a4f8eb8 100644 --- a/JMMServer/Properties/Resources.it.resx +++ b/JMMServer/Properties/Resources.it.resx @@ -1183,4 +1183,7 @@ Si può avere solo una cartella elencata come una destinazione di Drop. Aggiornamento disponibile per Server di Shoko! + + Lanciare la WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.nl.resx b/JMMServer/Properties/Resources.nl.resx index 21734fed6..566517ce1 100644 --- a/JMMServer/Properties/Resources.nl.resx +++ b/JMMServer/Properties/Resources.nl.resx @@ -1183,4 +1183,7 @@ U kunt slechts één map vermeld als een Drop bestemming hebben. Update beschikbaar voor Shoko Server! + + Lancering WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.pl.resx b/JMMServer/Properties/Resources.pl.resx index 9903b816c..c79c53290 100644 --- a/JMMServer/Properties/Resources.pl.resx +++ b/JMMServer/Properties/Resources.pl.resx @@ -1183,4 +1183,7 @@ Możesz skonfigurować tylko jeden folder docelowym. Aktualizacja dla serwera Shoko! + + Uruchom WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.pt.resx b/JMMServer/Properties/Resources.pt.resx index c71ee1652..772ba4953 100644 --- a/JMMServer/Properties/Resources.pt.resx +++ b/JMMServer/Properties/Resources.pt.resx @@ -1183,4 +1183,7 @@ Atualização disponível para o servidor de Shoko! + + Lançar o WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.resx b/JMMServer/Properties/Resources.resx index 1054006c9..f3a4c2e2b 100644 --- a/JMMServer/Properties/Resources.resx +++ b/JMMServer/Properties/Resources.resx @@ -1232,4 +1232,7 @@ You can only have one folder listed as a Drop Destination. Update Available For Shoko Server! + + Launch WebUI + \ No newline at end of file diff --git a/JMMServer/Properties/Resources.ru.resx b/JMMServer/Properties/Resources.ru.resx index 6f597bc62..9dc27ac79 100644 --- a/JMMServer/Properties/Resources.ru.resx +++ b/JMMServer/Properties/Resources.ru.resx @@ -1183,4 +1183,7 @@ Доступно обновление для сервера Сёко! + + Запуск WebUI + \ No newline at end of file