Guest User

Untitled

a guest
May 11th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #https://docs.universaldashboard.io/components/inputs
  2. #https://forums.universaldashboard.io/t/dynamically-update-new-udinputfield/2668/3
  3.  
  4. $UD1_user_creation = New-UDPage -Name "Home" -Icon home -Content {
  5.  
  6.     New-UDCard -Title "Account Creation Page" -Text "You are going to create a new user, please input the information provided by HR."
  7.    
  8.    
  9.     New-UDCard -Id "User information" -Content{  
  10.         New-UDCard -id "UDC_StudDept" -Content{
  11.    
  12.             New-UDRow -id "StudioDpt" {
  13.                 New-UDColumn -Size 6 {
  14.                     $StudioValue = Get-Content -Path 'D:\Scripts\UniversalDashboard\Studios.txt'
  15.                     New-UDParagraph -Text "Pick the Studio"
  16.                     New-UDSelect -Id "UD_Studio" -Option {
  17.                         foreach ($stud in $StudioValue){
  18.                             New-UDSelectOption -Name "$stud" -Value "$stud"
  19.                         }
  20.                     } -OnChange {
  21.                         $Session:studio = $EventData
  22.                         Sync-UDElement -Id "UD_Dpt"
  23.                     }
  24.                 }
  25.        
  26.                 New-UDColumn -Size 6 -Id "UD_Dpt" -Endpoint {
  27.                     if ($session:studio -eq $null){ $session:studio = "Tokyo"}
  28.                     $path = "D:\Scripts\UniversalDashboard\"
  29.                     $fullpath = ($path + $session:studio)                      
  30.                     $DptValue = Get-Content -Path $fullpath
  31.                     New-UDParagraph -Text "Pick the correct department"
  32.                     New-UDSelect -Id "UD_Dpt" -Option {
  33.                         foreach ($depart in $DptValue){
  34.                             New-UDSelectOption -Name "$depart" -Value "$depart"
  35.                         }
  36.                     } -OnChange {
  37.                          $Session:department = $EventData
  38.                     }
  39.            
  40.                 }
  41.             }
  42.         }
  43.  
  44.         New-UDInput -Title "Please fill the user information" -Content {
  45.             New-UDInputField -Type 'textbox' -Name 'FirstName' -Placeholder 'First Name'
  46.             New-UDInputField -Type 'textbox' -Name 'GivenName' -Placeholder 'Given Name'
  47.         } -Endpoint {
  48.         param($FirstName, $GivenName)
  49.         $i = 1
  50.         $Session:FirstName = $FirstName
  51.         $Session:GivenName = $GivenName
  52.         $Session:Username = $FirstName.Substring(0,$i).ToLower()+$GivenName.ToLower().replace(' ','')
  53.         New-UDInputAction -Content @(
  54.             Sync-UDElement -Id "User_Info"
  55.  
  56.         )
  57.         }
  58.  
  59.     }
  60.  
  61.     New-UDCard -Id "User_Info" -Title "Summary of the information provided" -Endpoint {  
  62.             New-UDParagraph -Text "Studio = $Session:studio"
  63.             New-UDParagraph -Text "Department = $Session:department"
  64.             New-UDParagraph -Text "First Name = $SessionFirstName"
  65.             New-UDParagraph -Text "Given Name = $SessionGivenName"
  66.             New-UDParagraph -Text "Username = $Session:Username"
  67.     }
  68.  
  69. }
  70.  
  71.  
  72. $UD1 = New-UDDashboard  -Title "User management" -Color "#252525" -Pages @(
  73. $UD1_user_creation
  74. )
  75.  
  76. Start-UDDashboard  -Dashboard $UD1 -port 10002
Add Comment
Please, Sign In to add comment