pages/dashboard.ps1

New-UDPage -Name "Dashboard" -Icon chart_bar -Content {

    New-UDHelmet -Content {
        New-UDHtmlTag -Tag 'title' -Content { "Universal Automation / Dashboard" }
    }

    New-UDRow -Endpoint {
        $Cache:Stats = Get-UAStats 

        New-UDColumn -SmallSize 12 -Content {
            New-UDRow -Columns {
                New-UDColumn -SmallSize 2 -Content {
                    New-UDCounter -Title "Run Today" -Endpoint {
                        $Cache:Stats.JobsRunToday
                    } -Icon check_circle -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                }
                New-UDColumn -SmallSize 2 -Content {
                    New-UDCounter -Title "Failed" -Endpoint {
                        $Cache:Stats.JobsFailedToday
                    } -Icon times_circle -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                }
                New-UDColumn -SmallSize 2 -Content {
                    New-UDCounter -Title "Running" -Endpoint {
                        $Cache:Stats.RunningJobs
                    } -Icon play_circle -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                } 
                New-UDColumn -SmallSize 2 -Content { 
                    New-UDCounter -Title "Upcoming" -Endpoint {
                        $CountUpcomingJobs = 0
                        Get-UASchedule | ForEach-Object {
                            $NextExecution = $_.NextExecution 
                            if ($NextExecution -lt (Get-Date).AddHours(24) -and $NextExecution -gt (Get-Date)) {
                                $CountUpcomingJobs++
                            }
                        }
                        $CountUpcomingJobs
                    } -Icon chart_bar -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                }
               
                New-UDColumn -SmallSize 2 -Content {
                    New-UDCounter -Title "Pending" -Endpoint {
                        $Cache:Stats.JobsWaitingOnFeedback
                    } -Icon question_circle -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                }

                New-UDColumn -SmallSize 2 -Content { 
                    New-UDCounter -Title "Time Saved" -Endpoint {
                        $Cache:Stats.TimeSavedSeconds / 60
                    } -Icon play_circle -TextSize Medium -BackgroundColor "#3F51B5" -FontColor  "#FFFFFF"
                } 
            }
        }
    }-AutoRefresh -RefreshInterval 30
    
    New-UDElement -Tag 'div' -Endpoint {
        New-UDTabContainer -Tabs {
            New-UDTab -Text 'Running Jobs' -Content {
                New-JobRunningGrid
            }
            New-UDTab -Text 'Past Jobs' -Content {
                New-JobHistoricalGrid
                New-UDElement -Tag 'div' -Endpoint {
                    If($Cache:UAVersion -eq "Premium")
                    {
                        <# New-UDCard -Content {
                            New-JobHistoryCalendar
                            New-JobHistoryBarChart
                        }#>

                    }
                }
            }
            New-UDTab -Text "Scripts" -Content {
                New-ScriptGrid
                New-UDButton -Text "New Script" -OnClick {
                    New-UDScriptModal
                }
            }
            New-UDTab -Text 'Schedules' -Content {
                New-JobUpcomingGrid
            }
            New-UDTab -Text "Variables" -Content {
                New-VariableGrid
                New-UDButton -Text "New Variable" -OnClick {
                    New-UDCreateVariableModal
                }
            }
            New-UDTab -Text "Secrets" -Content {
                New-UDSecretManagerGrid
                New-UDButton -Text "New Secret Manager" -OnClick {
                    New-UDCreateSecretManagerModal
                }
            }
            New-UDTab -Text "Tags" -Content {
                New-TagGrid
                New-UDButton -Text "New Tag" -OnClick {
                    New-UDCreateTagModal
                }
            }
            New-UDTab -Text "Config" -Content {
                New-UDTabContainer -Tabs {
                    
                    New-UDTab -Text 'Connect' -Content {
                        New-UAConnectionHelp 
                    }

                    New-UDTab -Text 'Git Details' -Content {
                        New-UAConfigDetails
                    }

                    New-UDTab -Text 'Identities' -Content {
                        New-UAIdentityGrid
                        New-UDButton -Text "Add Identity" -OnClick {
                            New-UACreateIdentityModal
                        }
                    }

                    New-UDTab -Text 'PowerShell Versions' -Content {
                        New-PowerShellVersionGrid
                        New-UDButton -Text "New PowerShell Version" -OnClick {
                            New-UDCreatePowerShellVersionModal
                        }
                    }

                    New-UDTab -Text 'Roles' -Content {
                        New-UARoleGrid
                    }
                    
                    New-UDTab -Text 'Swagger' -Content {
                        New-UDCard -Title "Swagger Documentation" -Content {

                            New-UDElement -Tag 'div' -Content {
                                New-UDHtml -Markup ("Use the following link to open the Swagger interactive API documentation")
                            }

                            New-UDButton -Text "Open Swagger Document" -Icon file -OnClick {
                                $SwaggerURL = "http://localhost:10000/swagger/index.html"
                                Invoke-UDRedirect -Url $SwaggerURL -OpenInNewWindow
                            }
                        }
                    }

                    New-UDTab -Text 'Help' -Content {
                        New-UDCard -Title "Help" -Content {

                            New-UDElement -Tag 'div' -Content {
                                New-UDHtml -Markup ("Have questions or need help? Try the following resources...")
                            }

                            New-UDButton -Text "Documentation" -Icon file -OnClick {
                                $DocsURL = "http://docs.universalautomation.io"
                                Invoke-UDRedirect -Url $DocsURL -OpenInNewWindow
                            }
                            " "
                            New-UDButton -Text "Community Forum" -Icon users -OnClick {
                                $ForumURL = "https://forums.universaldashboard.io/c/universal-automation"
                                Invoke-UDRedirect -Url $ForumURL -OpenInNewWindow
                            }
                            " "
                            New-UDButton -Text "Ironman Software Slack" -Icon Slack -OnClick {
                                $ForumURL = "https://ironmansoftware.slack.com/"
                                Invoke-UDRedirect -Url $ForumURL -OpenInNewWindow
                            }
                            " "
                            New-UDButton -Text "Universal Automation Homepage" -Icon home -OnClick {
                                $ForumURL = "https://ironmansoftware.com/universal-automation/"
                                Invoke-UDRedirect -Url $ForumURL -OpenInNewWindow
                            }
                        }
                    }

                }
            }
        }
    }

}