Skip to content

Commit

Permalink
Fixes #652 (#655)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdriscoll authored Feb 22, 2019
1 parent b1a8f1d commit 647440e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 34 deletions.
41 changes: 30 additions & 11 deletions src/UniversalDashboard.Materialize/package-lock.json

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

Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
Expand All @@ -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
}
Expand Down
49 changes: 30 additions & 19 deletions src/UniversalDashboard/Controllers/DashboardController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}}
Expand All @@ -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")]
Expand Down

0 comments on commit 647440e

Please sign in to comment.