@@ -43,7 +43,12 @@ function ConvertTo-DbaTimeline {
43
43
# need to capture calling process to know what we are being asked for i.e. JobHistory, BackupHistory etc?
44
44
# I dont know of any way apart from Get-PSCallStack but that return the whole stack but in order to the last
45
45
# function should be the one that called this one? Not sure if this is correct but it works.
46
- $caller = Get-PSCallStack | Select - Property * | Select - last 1
46
+ $caller = Get-PSCallStack | Select-Object - Property * | Select-Object - last 1
47
+ # check if we can handle the input
48
+ if ($caller.Position -NotLike " *Get-DbaAgentJobHistory*" -and `
49
+ $caller.Position -NotLike " *Get-DbaBackupHistory*" ) {
50
+ Write-Output " Ummm, we do not know how to create chart for this. Sorry.`r`n Do you want to help us understand what is that you are trying to do? Get in touch!" ; break ;
51
+ }
47
52
# build html container
48
53
@"
49
54
<html>
@@ -114,13 +119,13 @@ function ConvertTo-DbaTimeline {
114
119
# This is where do column mapping:
115
120
if ($caller.Position -Like " *Get-DbaAgentJobHistory*" ) {
116
121
$CallerName = " Get-DbaAgentJobHistory"
117
- $data = $input | Select @ { Name = " SqlInstance" ; Expression = {$_.SqlInstance }}, @ { Name = " InstanceName" ; Expression = {$_.InstanceName }}, @ { Name = " vLabel" ; Expression = {$_.Job } }, @ { Name = " hLabel" ; Expression = {$_.Status } }, @ { Name = " Style" ; Expression = {$ (Convert-DbaTimelineStatusColor ($_.Status ))} }, @ { Name = " StartDate" ; Expression = {$ (ConvertTo-JsDate ($_.StartDate ))} }, @ { Name = " EndDate" ; Expression = {$ (ConvertTo-JsDate ($_.EndDate ))} }
122
+ $data = $InputObject | Select-Object @ { Name = " SqlInstance" ; Expression = {$_.SqlInstance }}, @ { Name = " InstanceName" ; Expression = {$_.InstanceName }}, @ { Name = " vLabel" ; Expression = {$_.Job } }, @ { Name = " hLabel" ; Expression = {$_.Status } }, @ { Name = " Style" ; Expression = {$ (Convert-DbaTimelineStatusColor ($_.Status ))} }, @ { Name = " StartDate" ; Expression = {$ (ConvertTo-JsDate ($_.StartDate ))} }, @ { Name = " EndDate" ; Expression = {$ (ConvertTo-JsDate ($_.EndDate ))} }
118
123
119
124
}
120
125
121
126
if ($caller.Position -Like " *Get-DbaBackupHistory*" ) {
122
127
$CallerName = " Get-DbaBackupHistory"
123
- $data = $input | Select @ { Name = " SqlInstance" ; Expression = {$_.SqlInstance }}, @ { Name = " InstanceName" ; Expression = {$_.InstanceName }}, @ { Name = " vLabel" ; Expression = {$_.Database } }, @ { Name = " hLabel" ; Expression = {$_.Type } }, @ { Name = " StartDate" ; Expression = {$ (ConvertTo-JsDate ($_.Start ))} }, @ { Name = " EndDate" ; Expression = {$ (ConvertTo-JsDate ($_.End ))} }
128
+ $data = $InputObject | Select-Object @ { Name = " SqlInstance" ; Expression = {$_.SqlInstance }}, @ { Name = " InstanceName" ; Expression = {$_.InstanceName }}, @ { Name = " vLabel" ; Expression = {$_.Database } }, @ { Name = " hLabel" ; Expression = {$_.Type } }, @ { Name = " StartDate" ; Expression = {$ (ConvertTo-JsDate ($_.Start ))} }, @ { Name = " EndDate" ; Expression = {$ (ConvertTo-JsDate ($_.End ))} }
124
129
}
125
130
" $ ( $data | % {" ['$ ( $_.vLabel ) ','$ ( $_.hLabel ) ','$ ( $_.Style ) ',$ ( $_.StartDate ) , $ ( $_.EndDate ) ]," }) "
126
131
}
0 commit comments