Open JLogan3o13 opened 2 years ago
An update, if I move the $Layout var inside the New-UDGridLayout -Content bracket, the error does not occur, even with both If statements. It does not, however, seem to honor the Layout in this case:
I can't how the formatting was accomplished and this doesn't happen to me any more. I can reproduce it with your first example.
New-UDDashboard -Title "Stock Tracker" -Content {
$Layout = '{"lg":[{"w":5,"h":2,"x":4,"y":0,"i":"grid-element-BlankLine1","moved":false,"static":false},{"w":12,"h":1,"x":0,"y":2,"i":"grid-element-BlankLine2","moved":false,"static":false},{"w":12,"h":15,"x":0,"y":3,"i":"grid-element-stocksTable","moved":false,"static":false}]}'
$aCSV = @(
[PSCustomObject]@{
Name = "Google"
Symbol = "GOOG"
OldPrice = 100
NewPrice = 200
Change = 100
}
)
New-UDGridLayout -Content {
New-UDTypography -Id "BlankLine1" -Text "Stock Tracker for $((Get-Date -format 'MM/dd/yyyy'))" -Style @{
"font-size" = "48px" }
New-UDTypography -Id "BlankLine2" -Text ''
$Data = @()
foreach($row in $aCSV) {
$lastPrice = $row.OldPrice
$currentPrice = $row.NewPrice
$change = $row.NewPrice - $row.OldPrice
$Data += @{Company = $row.Name; Symbol = $row.Symbol; OldPrice = $lastPrice.ToString("C"); CurrentPrice = $currentPrice.ToString("C"); Change = $change}
}
$Columns = @(
New-UDTableColumn -Property Company -Title "Company Name"
New-UDTableColumn -Property Symbol -Title "Symbol"
New-UDTableColumn -Property OldPrice -Title "Yesterday's Price"
New-UDTableColumn -Property CurrentPrice -Title "Today's Price"
New-UDTableColumn -Property Change -Title Change
)
New-UDTable -Id 'stocksTable' -Data $Data -Columns $Columns
} -Layout $Layout
}
Steps to Reproduce
I am creating a demo site that uses info from both a local CSV and Google finance to provide stock prices. The CSV has five columns total: Name, Symbol, OldPrice, CurrentPrice, and Change. The code for the dashboard is below:
`New-UDDashboard -Title "Stock Tracker" -Content { $Layout = '{"lg":[{"w":5,"h":2,"x":4,"y":0,"i":"grid-element-BlankLine1","moved":false,"static":false},{"w":12,"h":1,"x":0,"y":2,"i":"grid-element-BlankLine2","moved":false,"static":false},{"w":12,"h":15,"x":0,"y":3,"i":"grid-element-stocksTable","moved":false,"static":false}]}'
Because the csv truncates a result like 23.00 as 23, I have the two If statements, that if the length is less than 4, add ".00" to the end of the string. As you can see, one of them is commented out. But if I attempt to run them both, I get the following:
The log does not show any errors. I have removed the ud-grid-layout component, and the page loads just fine. I have also confirmed this issue from 2.9.2 all the way back to 2.5.1 at least, and confirmed it happens whether using PS 5.1 or 7.2.1.
Expected behavior
Actual behavior
Environment data
Windows 10 Professional (Azure VM) 2.5.1 - 2.9.2 of PowerShell Universal PS 5.1 and 7.2.1
Visuals
No response