ironmansoftware / universal-dashboard

Build beautiful websites with PowerShell.
https://universaldashboard.io
GNU Lesser General Public License v3.0
449 stars 83 forks source link

UD 2.4.1 Beta - Variables inside modals #751

Open dtnyc9005 opened 5 years ago

dtnyc9005 commented 5 years ago

Hi Adam, playing around with the UD 2.4.1 beta(upgrading an existing dashboard from 2.3 [ENT], but seeing strange behavior.

Currently have a button that displays a modal ,

New-UDChart -Title is now displaying: " - index.30a8863c763093202290.bundle.js[]", looks like everything inside the modal gets zapped. (In 2.3 this works with out issues)

This is what my scheduled endpoint looks like:

   $EndpointSQLDriveSpace = New-UDEndpoint -Schedule $ScheduleSQLDriveSpace -Endpoint {

        $cache:SQLServerDrives = @(foreach ($item in $cache:GrabSQLServerDrives) {

            [pscustomobject]@{
                Date         = $item.Date
                ComputerName = $item.ComputerName
                Role         = $item.Role
                Name         = $item.Name
                Label        = $item.Label
                Capacity     = $item.Capacity

                Details      = (New-UDButton -Text "Details..." -OnClick {

                        Show-UDModal -FontColor "#FFFFFFFF" -BackgroundColor "#FF252525" -Content {

                            New-UDChart -Title "$($item.ComputerName) - $($item.Name)[$($item.Label)]" -Height 450px -Width Auto -Type Line -BackgroundColor "#FF252525" -FontColor "White"  -AutoRefresh -Endpoint {

                                $SQLQueryDisk = Invoke-DbaQuery -Query "usp_GETDiskUsageReport '$($item.computername)', '$($item.Name)', '$($Cache:Output.From)','$($Cache:Output.To)'" -ServerInstance "*********"

                                $SQLQueryDisk | Out-UDChartData -LabelProperty Date -Dataset @(
                                    New-UDChartDataset -DataProperty "Capacity" -Label "Capacity (GB)" -BackgroundColor "#40A07DFF" -BorderColor "#A07DFF" -BorderWidth 3
                                )
                            } -Options @{
                                scales = @{
                                    yAxes = @(
                                        @{
                                            ticks = @{
                                                beginAtZero = $true
                                            }
                                        }
                                    )
                                }
                            } #>
                        }#
                    } #
                ) #

            }#
        }
       )
      }
adamdriscoll commented 5 years ago

Oooo. That's no good. Will have to look into it.

dtnyc9005 commented 5 years ago

much appreciated Adam.

adamdriscoll commented 5 years ago

@dtnyc9005 Have you tried this on the latest 2.4.1 build? I know some scoping issues were fixed and wondering if this has been resolved for you.

dtnyc9005 commented 5 years ago

Hey @adamdriscoll , (issue is related to #840) yes what I had to do to get around this was to use place holder variables, strange it seems UD is ignoring the default pipe value (anything in $_ or in this case $item for this scheduled endpoint) seems to return $null until I used the placeholder, like I mentioned in #840 was working as expected in 2.3.2.

Below is a code snip:

Thanks.

@(foreach ($item in $cache:DBSpaceCheckQuery) {

        $DataSpaceUsage = [math]::round($item.DataSpaceUsage)
        $EncryptionEnabled = [bool]$item.EncryptionEnabled
        $ID = $item.ID

  [pscustomobject]@{

            DataSpaceUsage        = $DataSpaceUsage
            EncryptionEnabled     = $EncryptionEnabled
            ID                    = $ID
}
}