Modules/UniversalDashboard.Materialize/Scripts/grid.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
function New-UDGrid {
    param(
        [Parameter()]
        [string]$Id = ([Guid]::NewGuid()),
        [Parameter()]
        [string]$Title,
        [Parameter()]
        [string[]]$Headers,
        [Parameter()]
        [string[]]$Properties,
        [Parameter()]
        [string]$DefaultSortColumn,
        [Parameter()]
        [Switch]$DefaultSortDescending,
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$BackgroundColor,
        [Parameter()]
        [UniversalDashboard.Models.DashboardColor]$FontColor,
        [Parameter()]
        [Hashtable[]]$Links,
        [Parameter()]
        [Switch]$ServerSideProcessing,
        [Parameter()]
        [string]$DateTimeFormat = "lll",
        [Parameter()]
        [int]$PageSize = 10,
        [Parameter()]
        [Switch]$NoPaging,
        [Parameter()]
        [string]$FilterText = "Filter",
        [Parameter()]
        [Switch]$NoFilter,
        [Parameter(Mandatory)]
        [object]$Endpoint,
        [Parameter()]
        [object[]]$ArgumentList,
        [Parameter()]
        [Switch]$AutoRefresh,
        [Parameter()]
        [int]$RefreshInterval = 5,
        [Parameter()]
        [Switch]$NoExport 
    )

    End {

        if ($null -ne $Endpoint) {
            if ($Endpoint -is [scriptblock]) {
                $Endpoint = New-UDEndpoint -Endpoint $Endpoint -Id $Id -ArgumentList $ArgumentList
            }
            elseif ($Endpoint -isnot [UniversalDashboard.Models.Endpoint]) {
                throw "Endpoint must be a script block or UDEndpoint"
            }
        }

        @{
            type = 'ud-grid'
            isPlugin = $true 
            assetId = $AssetId

            id = $id
            title = $Title
            headers = $Headers 
            properties = $Properties 
            defaultSortColumn = $DefaultSortColumn
            defaultSortDescending = $DefaultSortDescending.IsPresent
            backgroundColor = $BackgroundColor.HtmlColor
            fontColor = $FontColor.HtmlColor
            links = $Links
            serverSideProcessing = $ServerSideProcessing.IsPresent
            dateTimeFormat = $DateTimeFormat
            pageSize = $PageSize
            noPaging = $NoPaging.IsPresent
            filterText = $FilterText
            noFilter = $NoFilter.IsPresent
            autoRefresh = $AutoRefresh.IsPresent
            refreshInterval = $RefreshInterval
            noExport = $NoExport.IsPresent
        }
    }
}