From 647440e7b004224d8fb8b5d3e9d9861b65e39d7b Mon Sep 17 00:00:00 2001 From: Adam Driscoll Date: Fri, 22 Feb 2019 09:18:53 -0700 Subject: [PATCH] Fixes #652 (#655) --- .../package-lock.json | 41 +++++++++++----- .../Integration/Crossplatform.Tests.ps1 | 8 +-- .../Controllers/DashboardController.cs | 49 ++++++++++++------- 3 files changed, 64 insertions(+), 34 deletions(-) diff --git a/src/UniversalDashboard.Materialize/package-lock.json b/src/UniversalDashboard.Materialize/package-lock.json index 03485e9f..545c2b9e 100644 --- a/src/UniversalDashboard.Materialize/package-lock.json +++ b/src/UniversalDashboard.Materialize/package-lock.json @@ -1853,7 +1853,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -1877,13 +1878,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -1900,19 +1903,22 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2043,7 +2049,8 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2057,6 +2064,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2073,6 +2081,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2081,13 +2090,15 @@ "version": "0.0.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", "integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -2108,6 +2119,7 @@ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2196,7 +2208,8 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2210,6 +2223,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2305,7 +2319,8 @@ "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -2347,6 +2362,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -2368,6 +2384,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -2416,13 +2433,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", - "dev": true + "dev": true, + "optional": true } } }, diff --git a/src/UniversalDashboard.UITest/Integration/Crossplatform.Tests.ps1 b/src/UniversalDashboard.UITest/Integration/Crossplatform.Tests.ps1 index f3fdc61e..26b5c4dd 100644 --- a/src/UniversalDashboard.UITest/Integration/Crossplatform.Tests.ps1 +++ b/src/UniversalDashboard.UITest/Integration/Crossplatform.Tests.ps1 @@ -2,8 +2,8 @@ param( [Switch]$Release ) -if ($ENV:APPVEYOR) { - Write-Warning "Cross platform tests do not work on AppVeyor." +if ($ENV:AGENT_JOBSTATUS) { + Write-Warning "Cross platform tests do not work on Azure Pipelines." return } @@ -24,7 +24,7 @@ $Init = [ScriptBlock]::Create("Import-Module (Join-Path $Root `"Docker/Docker.ps Describe "Ubuntu" { Context "dashboard running" { Get-DockerContainer -All -Name "TestContainer" | Remove-DockerContainer -Force - New-DockerContainer -Name "TestContainer" -Repository "microsoft/powershell" -Tag "ubuntu-16.04" -Port 10001 + New-DockerContainer -Name "TestContainer" -Repository "microsoft/powershell" -Tag "latest" -Port 10001 Start-DockerContainer -Name "TestContainer" Invoke-DockerCommand -ContainerName "TestContainer" -ScriptBlock { New-Item UniversalDashboard -ItemType directory | Out-Null @@ -33,7 +33,7 @@ Describe "Ubuntu" { Start-Job { Invoke-DockerCommand -ContainerName "TestContainer" -ScriptBlock { - Import-Module '/UniversalDashboard/output/UniversalDashboard.psd1' + Import-Module '/UniversalDashboard/output/UniversalDashboard.Community.psd1' Enable-UDLogging Start-UDDashboard -Port 10001 -Dashboard (New-UDDashboard -Title 'Hey' -Content {}) -Wait } diff --git a/src/UniversalDashboard/Controllers/DashboardController.cs b/src/UniversalDashboard/Controllers/DashboardController.cs index 9fb1692e..15fbfac2 100644 --- a/src/UniversalDashboard/Controllers/DashboardController.cs +++ b/src/UniversalDashboard/Controllers/DashboardController.cs @@ -68,25 +68,27 @@ public Page Page() [ResponseCache(NoStore = true, Location = ResponseCacheLocation.None)] public IActionResult Theme() { - var materializeCss = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "styles", "materialize.min.css"); - var siteCss = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "styles", "site.css"); + try + { + var materializeCss = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "Styles", "materialize.min.css"); + var siteCss = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "Styles", "site.css"); - var css = System.IO.File.ReadAllText(materializeCss); - css += System.IO.File.ReadAllText(siteCss); - css += _dashboard?.Themes?.FirstOrDefault()?.RenderedContent; + var css = System.IO.File.ReadAllText(materializeCss); + css += System.IO.File.ReadAllText(siteCss); + css += _dashboard?.Themes?.FirstOrDefault()?.RenderedContent; - if (_dashboard?.Navigation != null) - { - css += Environment.NewLine; - css += $@"side-nav {{ + if (_dashboard?.Navigation != null) + { + css += Environment.NewLine; + css += $@"side-nav {{ width: {_dashboard.Navigation.Width}px; }}"; - } + } - if (_dashboard?.Navigation?.Fixed == true) - { - css += Environment.NewLine; - css += $@" + if (_dashboard?.Navigation?.Fixed == true) + { + css += Environment.NewLine; + css += $@" header, main, footer {{ padding-left: {_dashboard.Navigation.Width}px; }} @@ -96,13 +98,22 @@ @media only screen and (max-width : 992px) {{ padding-left: 0; }} }}"; - } + } - return new ContentResult() + return new ContentResult() + { + Content = css, + ContentType = "text/css", + }; + } + catch (Exception ex) { - Content = css, - ContentType = "text/css", - }; + return new ContentResult() + { + Content = ex.Message, + ContentType = "text/css" + }; + } } [Route("reload")]