From 243971d669397f2047c3772e65ea5e0e5eab1024 Mon Sep 17 00:00:00 2001 From: qJake Date: Mon, 10 Aug 2020 21:03:35 -0500 Subject: [PATCH 1/2] Some launch prep --- HADotNet.CommandCenter/Controllers/AdminController.cs | 2 +- HADotNet.CommandCenter/HADotNet.CommandCenter.csproj | 4 ++-- HADotNet.CommandCenter/Services/JsonConfigStore.cs | 11 +++-------- HADotNet.CommandCenter/Views/Admin/Index.cshtml | 2 +- HADotNet.CommandCenter/Views/Admin/Settings.cshtml | 6 +++--- HADotNet.CommandCenter/Views/Admin/Themes.cshtml | 1 + .../Views/Shared/_AdminLayout.cshtml | 4 ++-- HADotNet.CommandCenter/Views/Shared/_Layout.cshtml | 4 ++-- 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/HADotNet.CommandCenter/Controllers/AdminController.cs b/HADotNet.CommandCenter/Controllers/AdminController.cs index e5eb836..d924f4a 100644 --- a/HADotNet.CommandCenter/Controllers/AdminController.cs +++ b/HADotNet.CommandCenter/Controllers/AdminController.cs @@ -174,7 +174,7 @@ public async Task ImportTheme([FromForm] IFormFile file) await ConfigStore.ManipulateConfig(c => c.CurrentTheme = newTheme); - TempData.AddSuccess($"Successfully imported theme file '{file.FileName}' successfully! Go check out your dashboard!"); + TempData.AddSuccess($"Successfully imported theme file '{file.FileName}' successfully! Go check out your dashboard!"); } catch { diff --git a/HADotNet.CommandCenter/HADotNet.CommandCenter.csproj b/HADotNet.CommandCenter/HADotNet.CommandCenter.csproj index c887e32..030b5cb 100644 --- a/HADotNet.CommandCenter/HADotNet.CommandCenter.csproj +++ b/HADotNet.CommandCenter/HADotNet.CommandCenter.csproj @@ -38,8 +38,8 @@ - - + + diff --git a/HADotNet.CommandCenter/Services/JsonConfigStore.cs b/HADotNet.CommandCenter/Services/JsonConfigStore.cs index 23c6dc9..55c4afd 100644 --- a/HADotNet.CommandCenter/Services/JsonConfigStore.cs +++ b/HADotNet.CommandCenter/Services/JsonConfigStore.cs @@ -2,7 +2,6 @@ using HADotNet.CommandCenter.Models.Config; using HADotNet.CommandCenter.Models.Config.Pages; using HADotNet.CommandCenter.Models.Config.Themes; -using HADotNet.CommandCenter.Models.Config.Tiles; using HADotNet.CommandCenter.Services.Interfaces; using HADotNet.CommandCenter.Utils; using Microsoft.Extensions.Options; @@ -11,6 +10,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using System.Threading.Tasks; namespace HADotNet.CommandCenter.Services @@ -19,7 +19,7 @@ public class JsonConfigStore : IConfigStore { private const string CONFIG_FILE = "config.json"; - private const string HASSIO_CONFIG_LOC = "/data/"; + private const string LINUX_DATA_LOCATION = "/app/data/"; public static JsonSerializerSettings SerializerSettings { get; } = new JsonSerializerSettings { @@ -40,12 +40,7 @@ public class JsonConfigStore : IConfigStore public JsonConfigStore(IOptions haccOptions) { Options = haccOptions.Value; - var isHassio = !string.IsNullOrWhiteSpace(SupervisorEnvironment.GetSupervisorToken()); -#if DEBUG - ConfigDirectory = Environment.ExpandEnvironmentVariables(Options.ConfigLocation); -#else - ConfigDirectory = isHassio ? HASSIO_CONFIG_LOC : Environment.ExpandEnvironmentVariables(Options.ConfigLocation); -#endif + ConfigDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Options.ConfigLocation == "." ? LINUX_DATA_LOCATION : Environment.ExpandEnvironmentVariables(Options.ConfigLocation); } public async Task ManipulateConfig(params Action[] changes) diff --git a/HADotNet.CommandCenter/Views/Admin/Index.cshtml b/HADotNet.CommandCenter/Views/Admin/Index.cshtml index d74af47..0336d97 100644 --- a/HADotNet.CommandCenter/Views/Admin/Index.cshtml +++ b/HADotNet.CommandCenter/Views/Admin/Index.cshtml @@ -42,7 +42,7 @@

Configuration Control

Import, export, or reset your master HACC configuration here.

-

Note: Exported settings do NOT contain connection information. When importing, if you are NOT running as a Hass.io addon, you will need to re-setup your connection to Home Assistant.

+

Note: Exported settings do NOT contain connection information. When importing, you will need to re-setup your connection to Home Assistant.