-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSyncDemo.ps1
More file actions
59 lines (52 loc) · 2.14 KB
/
SyncDemo.ps1
File metadata and controls
59 lines (52 loc) · 2.14 KB
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
###Taken from https://forums.universaldashboard.io/t/simple-udelement-example-meme-factory/540
Import-Module UniversalDashboard.Community
Get-UDDashboard | Stop-UDDashboard
##Get Ready for the dashboard
$NavBarLinks = @((New-UDLink -Text "Visit My Website" -Url "https://wwww.yoursite.com" -Icon medkit))
$Link = New-UDLink -Text 'Company Website' -Url 'http://www.yourcompany.com' -Icon globe
$Footer = New-UDFooter -Copyright 'Designed by Your Name' -Links $Link
$theme = New-UDTheme -Name "Basic" -Definition @{
'.btn' = @{
'color' = "#555555"
'background-color' = "#f44336"
}
'.btn:hover' = @{
'color' = "#ffffff"
'background-color' = "#C70303"
}
UDNavBar = @{
BackgroundColor = "black"
FontColor = "white"
}
UDFooter = @{
BackgroundColor = "black"
FontColor = "white"
}
}
Function Get-RandomMeme {
$Meme = Invoke-WebRequest -Uri 'https://api.imgflip.com/get_memes'
$Memes = ($Meme.Content | ConvertFrom-Json).data.memes
$RandomMeme = ($Memes | Get-Random | Select-Object name, url, width, height, box_count)
return $RandomMeme
}
$Initialization = New-UDEndpointInitialization -Function 'Get-RandomMeme'
$Homep = New-UDPage -Name "Home Page" -Icon home -Content {
New-UDButton -Text "Get New Meme" -OnClick {
$NewRandomMeme = Get-RandomMeme
# Toast
Show-UDToast -Message "Now Loading: $($NewRandomMeme.name)"
# Set Image
Set-UDElement -Id "imgMeme" -Attributes @{
src = $NewRandomMeme.url
}
# Set Label
Set-UDElement -Id "lblMeme" -Content { $NewRandomMeme.name }
}
New-UDHtml -Markup "<br />"
New-UDElement -ID "lblMeme" -Tag "div" -Content { "" }
New-UDElement -ID "imgMeme" -Tag "img" -Attributes @{src = "" }
}
$dashboard = New-UDDashboard -Title "Sync Demo" -Pages (
$Homep
) -NavbarLinks $NavBarLinks -Footer $Footer -EndpointInitialization $Initialization -Theme $theme
Start-UDDashboard -Dashboard $dashboard -Port 8091 -Name DemoDashboard -AutoReload