internal/functions/Convert-DbaTimelineStatusColor.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
function Convert-DbaTimelineStatusColor {
    <#
        .SYNOPSIS
            Converts literal string status to a html color
 
        .DESCRIPTION
            This function acceptes Agnet Job status as literal string input and covnerts to html color.
            This is internal function, part of ConvertTo-DbaTimeline
 
        .PARAMETER Status
 
            The Status input parameter must be a valid SQL Agent Job status as literal string as defined in MS Books:
                Status of the job execution:
                    Failed
                    Succeeded
                    Retry
                    Canceled
                    In Progress
 
        .NOTES
            Tags: Internal
            Author: Marcin Gminski (@marcingminski)
 
            Dependency: None
            Requirements: None
 
            Website: https://dbatools.io
            Copyright: (C) Chrissy LeMaire, clemaire@gmail.com
- License: MIT https://opensource.org/licenses/MIT
 
        .LINK
            --internal function, not exposed to end user
 
        .EXAMPLE
            Convert-DbaTimelineStatusColor ("Succeeded")
 
            Returned string: #36B300
    #>


    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [string]
        $Status
    )
   $out = switch($Status){
        "Failed" {"#FF3D3D"}
        "Succeeded" {"#36B300"}
        "Retry" {"#FFFF00"}
        "Canceled" {"#C2C2C2"}
        "In Progress" {"#00CCFF"}
        default {"#FF00CC"}
    }
    return $out
}