diff --git a/OpenHAB.Windows/Controls/FrameWidget.xaml b/OpenHAB.Windows/Controls/FrameWidget.xaml index b65eb902..2c3906e4 100644 --- a/OpenHAB.Windows/Controls/FrameWidget.xaml +++ b/OpenHAB.Windows/Controls/FrameWidget.xaml @@ -45,7 +45,7 @@ SelectionMode="None"> - + diff --git a/OpenHAB.Windows/Strings/en-us/Resources.resw b/OpenHAB.Windows/Strings/en-us/Resources.resw index df7a9ce1..8c7f06de 100644 --- a/OpenHAB.Windows/Strings/en-us/Resources.resw +++ b/OpenHAB.Windows/Strings/en-us/Resources.resw @@ -154,7 +154,7 @@ openHAB URL - Connection settings are not invalid. + Connection settings are not configured. Please select demo mode or configure local/remote OpenHab connection information. @@ -180,7 +180,7 @@ Go to app settings (gear icon) to check the connection configuration. Settings - went + Username No sitemaps available @@ -198,7 +198,7 @@ Go to app settings (gear icon) to check the connection configuration. Loading data... - Connection settings are not invalid. + Connection settings are invalid. Please select demo mode or configure local/remote connection. diff --git a/OpenHAB.Windows/View/MainPage.xaml b/OpenHAB.Windows/View/MainPage.xaml index 67d11f19..a7f7840b 100644 --- a/OpenHAB.Windows/View/MainPage.xaml +++ b/OpenHAB.Windows/View/MainPage.xaml @@ -111,7 +111,7 @@ Color="Black" /> - - - + + diff --git a/OpenHAB.Windows/View/SettingsPage.xaml.cs b/OpenHAB.Windows/View/SettingsPage.xaml.cs index 0eb1d533..e224f527 100644 --- a/OpenHAB.Windows/View/SettingsPage.xaml.cs +++ b/OpenHAB.Windows/View/SettingsPage.xaml.cs @@ -1,7 +1,6 @@ using System; using GalaSoft.MvvmLight.Messaging; using Microsoft.Extensions.Logging; -using OpenHAB.Core; using OpenHAB.Core.Messages; using OpenHAB.Core.Services; using OpenHAB.Core.ViewModel; @@ -38,7 +37,6 @@ public SettingsPage() private async void HandleSettingsUpdate(SettingsUpdatedMessage msg) { - try { if (msg.IsSettingsValid) diff --git a/Openhab.Core/Common/OpenHABHttpClient.cs b/Openhab.Core/Common/OpenHABHttpClient.cs index 308a1692..44238831 100644 --- a/Openhab.Core/Common/OpenHABHttpClient.cs +++ b/Openhab.Core/Common/OpenHABHttpClient.cs @@ -44,7 +44,9 @@ public static HttpClient Client(OpenHABHttpClientType connectionType, Settings s /// The HttpClient instance. public static HttpClient DisposableClient(OpenHABHttpClientType connectionType, Settings settings) { + _logger = (ILogger)DIService.Instance.Services.GetService(typeof(ILogger)); _settings = settings; + return InitClient(connectionType, true); } diff --git a/Openhab.Core/SDK/OpenHABClient.cs b/Openhab.Core/SDK/OpenHABClient.cs index e7db1351..006989b6 100644 --- a/Openhab.Core/SDK/OpenHABClient.cs +++ b/Openhab.Core/SDK/OpenHABClient.cs @@ -242,7 +242,7 @@ public async Task SendCommand(OpenHABItem item, string command) var settings = _settingsService.Load(); var client = OpenHABHttpClient.Client(_connectionType, settings); var content = new StringContent(command); - + var result = await client.PostAsync(item.Link, content); if (!result.IsSuccessStatusCode) { diff --git a/Openhab.Core/ViewModel/ConnectionConfigViewModel.cs b/Openhab.Core/ViewModel/ConnectionConfigViewModel.cs index 21b0b36c..44c380de 100644 --- a/Openhab.Core/ViewModel/ConnectionConfigViewModel.cs +++ b/Openhab.Core/ViewModel/ConnectionConfigViewModel.cs @@ -3,6 +3,8 @@ using GalaSoft.MvvmLight.Command; using OpenHAB.Core.Model; using OpenHAB.Core.SDK; +using Windows.ApplicationModel.Core; +using Windows.UI.Core; namespace OpenHAB.Core.ViewModel { @@ -59,6 +61,31 @@ public string Url SetProperty(ref _url, tempUrl); _connectionConfig.Url = _url; + + OnPropertyChanged(nameof(Subtitle)); + } + } + + /// + /// Gets the subtitle. + /// + /// The subtitle. + public string Subtitle + { + get + { + if (string.IsNullOrEmpty(_url)) + { + return "Not configured"; + } + + if (Uri.TryCreate(_url, UriKind.Absolute, out Uri uri) && + string.Compare(uri.Scheme.ToUpperInvariant(), "HTTPS", StringComparison.InvariantCulture) == 0) + { + return "Conntected to " + _url; + } + + return "Unsecure connected to" + _url; } } @@ -121,15 +148,21 @@ private async void CheckLocalUrl(object parameter) string url = parameter.ToString(); - UrlState = OpenHABUrlState.Unknown; + OpenHABUrlState urlState = OpenHABUrlState.Unknown; if (await _openHabsdk.CheckUrlReachability(url, Common.OpenHABHttpClientType.Local).ConfigureAwait(false)) { - UrlState = OpenHABUrlState.OK; + urlState = OpenHABUrlState.OK; } else { - UrlState = OpenHABUrlState.Failed; + urlState = OpenHABUrlState.Failed; } + + CoreDispatcher dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; + await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => + { + UrlState = urlState; + }); } } } diff --git a/Openhab.Core/ViewModel/MainViewModel.cs b/Openhab.Core/ViewModel/MainViewModel.cs index 53869789..65fd0e1d 100644 --- a/Openhab.Core/ViewModel/MainViewModel.cs +++ b/Openhab.Core/ViewModel/MainViewModel.cs @@ -244,6 +244,8 @@ await dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => _openHabsdk.StartItemUpdates(); OpenLastOrDefaultSitemap(); + + Subtitle = SelectedSitemap.Label; IsDataLoading = false; }); } @@ -321,7 +323,7 @@ public void WidgetGoBack() { OpenHABWidget widget = WidgetNavigationService.GoBack(); - Subtitle = widget == null ? string.Empty : widget.Label; + Subtitle = widget == null ? SelectedSitemap.Label: widget.Label; SetWidgetsOnScreen(widget != null ? widget.LinkedPage.Widgets : SelectedSitemap.Widgets); }