Skip to content

Commit

Permalink
Merge pull request #102 from qJake/v1.1-prep
Browse files Browse the repository at this point in the history
Launch prep
  • Loading branch information
qJake committed Aug 11, 2020
2 parents 69bc6a3 + dbe7620 commit 770d762
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 37 deletions.
2 changes: 1 addition & 1 deletion HADotNet.CommandCenter/Controllers/AdminController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public async Task<IActionResult> ImportTheme([FromForm] IFormFile file)

await ConfigStore.ManipulateConfig(c => c.CurrentTheme = newTheme);

TempData.AddSuccess($"Successfully imported theme file '{file.FileName}' successfully! <a href=\"/\">Go check out your dashboard!</a>");
TempData.AddSuccess($"Successfully imported theme file '{file.FileName}' successfully! <a href=\"/d\" target=\"_blank\">Go check out your dashboard!</a>");
}
catch
{
Expand Down
21 changes: 10 additions & 11 deletions HADotNet.CommandCenter/HADotNet.CommandCenter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<RuntimeIdentifiers>win10;alpine.3.10-x64;debian.10-arm</RuntimeIdentifiers>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<AssemblyVersion>1.0.19.0</AssemblyVersion>
<FileVersion>1.0.19.0</FileVersion>
<AssemblyVersion>1.0.20.0</AssemblyVersion>
<FileVersion>1.0.20.0</FileVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Deterministic>false</Deterministic>
Expand Down Expand Up @@ -38,19 +38,18 @@
<ItemGroup>
<!-- Web Compiler is Windows-only. -->
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="BuildWebCompiler" Version="1.12.405" />
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="BuildBundlerMinifier" Version="3.2.435" />
<PackageReference Include="HADotNet.Core" Version="1.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.1" />
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="Microsoft.TypeScript.MSBuild" Version="3.7.4">
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="HADotNet.Core" Version="1.3.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson" Version="3.1.6" />
<PackageReference Condition="'$(OS)' == 'Windows_NT'" Include="Microsoft.TypeScript.MSBuild" Version="3.9.7">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.9.10" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Quartz" Version="3.0.7" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
</ItemGroup>

<PropertyGroup>
Expand Down
4 changes: 3 additions & 1 deletion HADotNet.CommandCenter/Hubs/TileHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ private async Task ProcessOverrides(BaseTile tile)
{
// Calendars use a special API that isn't (might not be?) exposed via the WebSocket API.
case CalendarTile ct:
await Clients.Caller.SendCalendarInfo(ct, await StatesClient.GetState(ct.EntityId), await CalendarClient.GetEvents(ct.EntityId));
var state = await StatesClient.GetState(ct.EntityId);
var calItems = await CalendarClient.GetEvents(ct.EntityId);
await Clients.Caller.SendCalendarInfo(ct, state, calItems);
break;

// Date and time are rendered server-side to verify server connection, and to enforce timezone and date format selection.
Expand Down
15 changes: 7 additions & 8 deletions HADotNet.CommandCenter/Services/JsonConfigStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
{
Expand All @@ -40,12 +40,7 @@ public class JsonConfigStore : IConfigStore
public JsonConfigStore(IOptions<HaccOptions> 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<ConfigRoot>[] changes)
Expand Down Expand Up @@ -108,6 +103,10 @@ private bool CheckPermissions()
{
if (IsValid) return true;

var di = new DirectoryInfo(ConfigDirectory);

if (!di.Exists) di.Create();

var tmpFile = Path.Combine(ConfigDirectory, ".tmp-write");

try
Expand Down
2 changes: 1 addition & 1 deletion HADotNet.CommandCenter/Views/Admin/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="ui segment">
<h2>Configuration Control</h2>
<p>Import, export, or reset your master HACC configuration here.</p>
<p><em>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.</em></p>
<p><em>Note: Exported settings do NOT contain connection information. When importing, you will need to re-setup your connection to Home Assistant.</em></p>
<div class="ui buttons">
<button type="button" id="importConfig" class="ui grey icon labeled button">
<i class="download icon"></i>
Expand Down
6 changes: 3 additions & 3 deletions HADotNet.CommandCenter/Views/Admin/Settings.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
<div class="ui icon labeled info message">
<i class="info circle icon"></i>
<div class="content">
<div class="ui large header">Managed by Hass.io</div>
<p>Your installation of HACC is managed by your Hass.io installation.</p>
<p>The only thing we need from you is a long-lived access token to get started.</p>
<div class="ui large header">Supervisor Add-on</div>
<p>HACC is being run from the Home Assistant Supervisor.</p>
<p>The only thing we need from you is a <em>long-lived access token</em> to get started. (<a href="https://hacc.dev/faqs/#why-is-a-long-lived-access-token-llat-required-in-supervisor-mode" target="_blank">Why?</a></p>
</div>
</div>

Expand Down
1 change: 1 addition & 0 deletions HADotNet.CommandCenter/Views/Admin/Themes.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<h1><i class="paint brush icon"></i> Themes</h1>

<p><em>Want more themes?</em> Check out our <b><a href="https://hacc.dev/themes/" target="_blank">Theme Gallery on hacc.dev</a></b>!</p>
<partial name="Alerts" />

@* Hidden input for file browser - driven by toolbar button below and some lightweight JS. *@
Expand Down
4 changes: 2 additions & 2 deletions HADotNet.CommandCenter/Views/Shared/_AdminLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

<environment include="Development">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.8/semantic.css" integrity="sha256-RA4g7qvjtBTtZXeL6LEnJJP0nkcy3ZsDcEFFRx3DBCE=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.0.45/css/materialdesignicons.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.css" crossorigin="anonymous" />
<link type="text/css" rel="stylesheet" href="~/css/admin.css" asp-append-version="true" />
</environment>
<environment include="Staging,Production">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.7.8/semantic.min.css" integrity="sha256-pquaucmYjfUqK251HC4uCXIKb2TQ4brXeUN2STYrJeg=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.0.45/css/materialdesignicons.min.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.min.css" crossorigin="anonymous" />
<link type="text/css" rel="stylesheet" href="~/css/admin.min.css" asp-append-version="true" />
</environment>

Expand Down
4 changes: 2 additions & 2 deletions HADotNet.CommandCenter/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
<title>@ViewData["Title"] - HA Command Center</title>

<environment include="Development">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.0.45/css/materialdesignicons.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.css" crossorigin="anonymous" />
<link type="text/css" rel="stylesheet" href="~/css/dashboard.css" asp-append-version="true" />
</environment>
<environment include="Staging,Production">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.0.45/css/materialdesignicons.min.css" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/5.3.45/css/materialdesignicons.min.css" crossorigin="anonymous" />
<link type="text/css" rel="stylesheet" href="~/css/dashboard.min.css" asp-append-version="true" />
</environment>

Expand Down
3 changes: 1 addition & 2 deletions HADotNet.CommandCenter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"@types/jquery": "3.3.31",
"@types/semantic-ui": "2.2.7",
"@aspnet/signalr": "1.1.4",
"@types/node": "12.7.1",
"@types/moment": "2.13.0"
"@types/node": "12.7.1"
}
}
9 changes: 4 additions & 5 deletions HADotNet.CommandCenter/wwwroot/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class HAConnection {
}
eventStateChanged(ev) {
var _a, _b;
console.info(`HA State Changed [${ev.data.entity_id}] ${(_b = (_a = ev.data.old_state) === null || _a === void 0 ? void 0 : _a.state, (_b !== null && _b !== void 0 ? _b : '<NULL>'))} -> ${ev.data.new_state.state}`);
console.info(`HA State Changed [${ev.data.entity_id}] ${((_b = (_a = ev.data.old_state) === null || _a === void 0 ? void 0 : _a.state) !== null && _b !== void 0 ? _b : '<NULL>')} -> ${ev.data.new_state.state}`);
this.evStateChanged.invoke(ev);
}
sendAuth() {
Expand Down Expand Up @@ -364,7 +364,6 @@ class Utils {
/// <reference path="tileoptions.ts" />
class Tile {
constructor(page, name, conn, haConn, options) {
var _a;
this.page = page;
this.name = name;
this.conn = conn;
Expand All @@ -383,7 +382,7 @@ class Tile {
this.entityIds = entityList;
}
else {
this.entityIds.push((_a = entityList) === null || _a === void 0 ? void 0 : _a.toString());
this.entityIds.push(entityList === null || entityList === void 0 ? void 0 : entityList.toString());
}
conn.on('SendSystemConfig', (tname, cfg) => {
if (name == tname) {
Expand Down Expand Up @@ -857,7 +856,7 @@ class CalendarTile extends Tile {
this.eventContainer.append(`<h3>${thisGroup}</h3>`);
lastGroup = thisGroup;
}
this.eventContainer.append(`<p><span class="summary">${evt.summary}</span><span class="time">${(!evt.start.dateTime ? 'All Day' : moment((_a = evt.start.dateTime, (_a !== null && _a !== void 0 ? _a : evt.start.date))).format('LT'))}</span></p>`);
this.eventContainer.append(`<p><span class="summary">${evt.summary}</span><span class="time">${(!evt.start.dateTime ? 'All Day' : moment((_a = evt.start.dateTime) !== null && _a !== void 0 ? _a : evt.start.date).format('LT'))}</span></p>`);
}
}
}
Expand All @@ -867,7 +866,7 @@ class CalendarTile extends Tile {
const tomorrow = moment().add(1, 'day');
let todayHeader = this.formatHeader(today);
let tomorrowHeader = this.formatHeader(tomorrow);
const mt = moment((_a = event.start.dateTime, (_a !== null && _a !== void 0 ? _a : event.start.date)));
const mt = moment((_a = event.start.dateTime) !== null && _a !== void 0 ? _a : event.start.date);
let header = this.formatHeader(mt);
if (header === todayHeader) {
header += ' (Today)';
Expand Down
2 changes: 1 addition & 1 deletion HADotNet.CommandCenter/wwwroot/js/app.min.js

Large diffs are not rendered by default.

0 comments on commit 770d762

Please sign in to comment.