UniversalDashboard/UniversalDashboard.Enterprise/UniversalDashboard.Enterprise.psm1


if ($Env:EntDebug -eq $true) {
    $AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset("http://localhost:10000/enterprise.index.bundle.js")
    [UniversalDashboard.Services.AssetService]::Instance.RegisterPlugin("http://localhost:10000/enterprise.index.bundle.js")
} else {
    $IndexJs = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
    $JsFiles = Get-ChildItem "$PSScriptRoot\*.bundle.js"
    $Maps = Get-ChildItem "$PSScriptRoot\*.map"
    
    $AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($IndexJs.FullName)
    [UniversalDashboard.Services.AssetService]::Instance.RegisterPlugin($IndexJs.FullName)
    
    foreach($item in $JsFiles)
    {
        [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($item.FullName) | Out-Null
    }
    
    foreach($item in $Maps)
    {
        [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($item.FullName) | Out-Null
    }
}

# Force UD to load assemblies
[UniversalDashboard.Server]::Servers.Length | Out-Null

if ($PSEdition -eq 'Desktop')
{
    Import-Module "$PSScriptRoot/net472/UniversalDashboard.Enterprise.dll"
}
else 
{
    Import-Module "$PSScriptRoot/netstandard2.0/UniversalDashboard.Enterprise.dll"
}

[UniversalDashboard.Enterprise.DynamicParameters]::ExtendCmdlets()

function New-UDSparklines {
    param(
        [Parameter()]
        [string]$Id = (New-Guid).ToString(),
        [Parameter(Mandatory)]
        [float[]]$Data,
        [Parameter()]
        [ValidateSet('lines', 'bars', 'both')]
        [string]$Type = 'lines',
        [Parameter()]
        [int]$Width = 500,
        [Parameter()]
        [int]$Height = 100,
        [Parameter()]
        [int]$Margin = 10,
        [Parameter()]
        [float]$Minimum,
        [Parameter()]
        [float]$Maximum,
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$Color,
        [Parameter()]
        [Hashtable]$Style
    )

    Process {
        @{
            isPlugin = $true
            assetId = $AssetId
            data = $Data
            type = "sparklines"
            sparkType = $Type
            id = $Id
            width = $Width
            height = $Height
            margin = $Margin
            min = $Minimum
            max = $Maximum
            color = $Color
            style = $Style
        }
    }
}


function New-UDNivoTheme {
    param(
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$TickLineColor,
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$TickTextColor,
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$GridLineStrokeColor,
        [Parameter()]
        [int]$GridStrokeWidth
    )

    @{
        axis = @{
            ticks = @{
                line = @{
                    stoke = $TickLineColor.HtmlColor
                }
                text = @{
                    fill = $TickTextColor.HtmlColor
                }
            }
        }
        grid = @{
            line = @{
                stroke = $GridLineStrokeColor.HtmlColor
                strokeWidth = $GridStrokeWidth
            }
        }
    }
}