pages/settings.ps1

New-UDPage -Url "/settings" -Endpoint {
    New-UDHelmet -Content {
        New-UDHtmlTag -Tag 'title' -Content { "Universal Automation / Settings" }
    }

    $Settings = Get-UASetting
    
    New-UDTabContainer -Tabs {
        New-UDTab -Text 'Settings' -Content {
            New-UDInput -Title 'Settings' -Content {
                New-UDInputField -Name 'ConnectionString' -Placeholder 'Database Path' -DefaultValue $Settings.ConnectionString -Type textbox
                New-UDInputField -Name 'Port' -Placeholder 'Web Server Port' -DefaultValue $Settings.Port -Type textbox
                New-UDInputField -Name 'PollingInterval' -Placeholder 'Polling Interval' -DefaultValue $Settings.PollingInterval -Type textbox
                New-UDInputField -Name 'GitRemote' -Placeholder 'Git Remote URL' -DefaultValue $Settings.GitRemote -Type textbox
                New-UDInputField -Name 'GitRemoteUserName' -Placeholder 'Git Remote User Name' -DefaultValue $Settings.GitRemoteUserName -Type textbox
                New-UDInputField -Name 'GitRemotePassword' -Placeholder 'Git Remote Password' -DefaultValue $Settings.GitRemotePassword -Type password
            } -Endpoint {
                param(
                    $ConnectionString,
                    $Port,
                    $PollingInterval, 
                    $GitRemote, 
                    $GitRemoteUserName, 
                    $GitRemotePassword
                )
        
                $Settings = Get-UASetting
                $Settings.ConnectionString = $ConnectionString 
                $Settings.Port = $Port 
                $Settings.PollingInterval = $PollingInterval
                $Settings.GitRemote = $GitRemote
                $Settings.GitRemoteUserName = $GitRemoteUserName
                $Settings.GitRemotePassword = $GitRemotePassword
        
                Set-UASetting -Setting $Settings
            }
        }

        New-UDTab -Text 'Git Status' -Content {
            New-UDGrid -Title "Git Syncs" -Headers @("Sha", "Timestamp", "Duration", "Changes") -Properties  @("CommitId", "Timestamp", "SyncTime", "Changes") -Endpoint {
                Get-UAGitStatus | ForEach-Object {
                    [PSCustomObject]@{
                        CommitId = $_.CommitId
                        Timestamp = $_.Timestamp
                        SyncTime = $_.SyncTime.ToString()
                        Changes = $_.Changes
                    }
                } | Out-UDGridData
            } -AutoRefresh
        }
    }
}