Skip to content

Commit

Permalink
Merge pull request #104 from qJake/v1.1-prep
Browse files Browse the repository at this point in the history
Debug mode and Bugfix
  • Loading branch information
qJake committed Aug 11, 2020
2 parents 45030f7 + 6e91c2a commit 866cde1
Show file tree
Hide file tree
Showing 12 changed files with 163 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Docker/BuildHaccContainers.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$version = '1.0.21'
$version = '1.0.22'

function Test-ExitCode ([int] $Expected = 0)
{
Expand Down
4 changes: 2 additions & 2 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.21.0</AssemblyVersion>
<FileVersion>1.0.21.0</FileVersion>
<AssemblyVersion>1.0.22.0</AssemblyVersion>
<FileVersion>1.0.22.0</FileVersion>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Deterministic>false</Deterministic>
Expand Down
4 changes: 2 additions & 2 deletions HADotNet.CommandCenter/Services/JsonConfigStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ public class JsonConfigStore : IConfigStore
private string OldLinuxConfigPath => Path.Combine(".", CONFIG_FILE);
private string ConfigPath => Path.Combine(ConfigDirectory, CONFIG_FILE);
private HaccOptions Options { get; }
private ILogger Log { get; }
private ILogger<JsonConfigStore> Log { get; }

public JsonConfigStore(IOptions<HaccOptions> haccOptions, ILogger log)
public JsonConfigStore(IOptions<HaccOptions> haccOptions, ILogger<JsonConfigStore> log)
{
Options = haccOptions.Value;
ConfigDirectory = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) && Options.ConfigLocation == "."
Expand Down
1 change: 1 addition & 0 deletions HADotNet.CommandCenter/Views/NavigationTile/Add.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<option value="home">Home</option>
<option value="nav">Navigate</option>
<option value="refresh">Refresh</option>
<option value="debug">Debug</option>
</select>
<span class="ui up pointing small red label" asp-validation-for="Mode"></span>
</div>
Expand Down
15 changes: 15 additions & 0 deletions HADotNet.CommandCenter/wwwroot/css/dashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ body.dashboard .tiles .tile.tile-loading:after {
background-size: 50%;
background-repeat: no-repeat;
}
body.dashboard .debug-window {
display: block !important;
position: fixed;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
font-size: 11px;
font-family: Consolas, monospace;
background-color: #F5F5F5;
color: #222222;
margin: 0;
padding: 10px;
white-space: pre-wrap;
}
.tile {
background-color: #e2e2e2;
}
Expand Down
17 changes: 17 additions & 0 deletions HADotNet.CommandCenter/wwwroot/css/dashboard.less
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,23 @@ body.dashboard
}
}
}

.debug-window
{
display: block !important;
position: fixed;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
font-size: 11px;
font-family: Consolas, monospace;
background-color: #F5F5F5;
color: #222222;
margin: 0;
padding: 10px;
white-space: pre-wrap;
}
}

// Base styling, for the utmost basic visibility of tiles
Expand Down
2 changes: 1 addition & 1 deletion HADotNet.CommandCenter/wwwroot/css/dashboard.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions HADotNet.CommandCenter/wwwroot/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,49 @@ class Utils {
NNW: 'arrow-up-thick'
}[dir];
}
/**
* Displays the debug dialog window.
*/
static displayDebugInfo() {
$('body').append(`<div class="debug-window">Home Assistant Command Center (HACC)
Debug Information:
HTML Area Resolution: ${window.innerWidth} x ${window.innerHeight}
Device pixel ratio: ${window.devicePixelRatio}
Browser Resolution: ${window.outerWidth} x ${window.outerHeight}
Platform: ${navigator.platform}
Touch points: ${navigator.maxTouchPoints}
Supports ES6: ${Utils.es5check() ? "Yes" : "NO"}
Supports ES2016: ${Utils.es2016Check() ? "Yes" : "NO"}
</div>`);
$('.debug-window').click(() => $('.debug-window').remove());
}
static es5check() {
if (typeof Symbol == "undefined") {
return false;
}
try {
eval("class Foo {}");
eval("var bar = (x) => x+1");
}
catch (_) {
return false;
}
return true;
}
static es2016Check() {
if (typeof Array.prototype.includes !== 'function') {
return false;
}
try {
eval("2**2");
}
catch (_) {
return false;
}
return true;
}
}
/// <reference path="../../../node_modules/@aspnet/signalr/dist/esm/index.d.ts" />
/// <reference path="../utils.ts" />
Expand Down Expand Up @@ -808,6 +851,9 @@ class NavigationTile extends Tile {
case 'nav':
window.location.href = `/d/${this.navTile.target}`;
return;
case 'debug':
Utils.displayDebugInfo();
return;
}
}
}
Expand Down Expand Up @@ -919,6 +965,10 @@ TileMap.ClassMap = {
/// <reference path="../../node_modules/@aspnet/signalr/dist/esm/index.d.ts" />
/// <reference path="tiles/tilemap.ts" />
/// <reference path="PageFunctions.ts" />
// Debug info - has to be one of the first things because if we fail on "class" then this won't display
if (window.location.search.toUpperCase().indexOf("DEBUG=1") > -1 && !window.location.pathname.toUpperCase().startsWith('/ADMIN')) {
Utils.displayDebugInfo();
}
class CommandCenter {
constructor() {
this.tiles = [];
Expand Down
13 changes: 12 additions & 1 deletion HADotNet.CommandCenter/wwwroot/js/app.min.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions HADotNet.CommandCenter/wwwroot/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ type TilePos = {
name: string
};

// Debug info - has to be one of the first things because if we fail on "class" then this won't display
if (window.location.search.toUpperCase().indexOf("DEBUG=1") > -1 && !window.location.pathname.toUpperCase().startsWith('/ADMIN'))
{
Utils.displayDebugInfo();
}

class CommandCenter
{
private conn: HAConnection;
Expand Down
5 changes: 5 additions & 0 deletions HADotNet.CommandCenter/wwwroot/js/tiles/navigation.tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class NavigationTile extends Tile
case 'nav':
window.location.href = `/d/${this.navTile.target}`;
return;
case 'debug':
Utils.displayDebugInfo();
return;
}
}


}
51 changes: 51 additions & 0 deletions HADotNet.CommandCenter/wwwroot/js/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,55 @@ class Utils
NNW: 'arrow-up-thick'
})[dir];
}

/**
* Displays the debug dialog window.
*/
public static displayDebugInfo(): void
{
$('body').append(`<div class="debug-window">Home Assistant Command Center (HACC)
Debug Information:
HTML Area Resolution: ${window.innerWidth} x ${window.innerHeight}
Device pixel ratio: ${window.devicePixelRatio}
Browser Resolution: ${window.outerWidth} x ${window.outerHeight}
Platform: ${navigator.platform}
Touch points: ${navigator.maxTouchPoints}
Supports ES6: ${Utils.es5check() ? "Yes" : "NO"}
Supports ES2016: ${Utils.es2016Check() ? "Yes" : "NO"}
</div>`);
$('.debug-window').click(() => $('.debug-window').remove());
}

private static es5check(): boolean {
if (typeof Symbol == "undefined") {
return false;
}

try {
eval("class Foo {}");
eval("var bar = (x) => x+1");
}
catch (_) {
return false;
}

return true;
}

private static es2016Check(): boolean {
if (typeof Array.prototype.includes !== 'function') {
return false;
}

try {
eval("2**2");
}
catch (_) {
return false;
}

return true;
}
}

0 comments on commit 866cde1

Please sign in to comment.