Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cb9b2df

Browse files
Revert "Revert "Input validation and cosmetics""
This reverts commit 982a4a6.
1 parent 982a4a6 commit cb9b2df

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎functions/ConvertTo-DbaTimeline.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ function ConvertTo-DbaTimeline {
4343
#need to capture calling process to know what we are being asked for i.e. JobHistory, BackupHistory etc?
4444
#I dont know of any way apart from Get-PSCallStack but that return the whole stack but in order to the last
4545
#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`nDo you want to help us understand what is that you are trying to do? Get in touch!"; break;
51+
}
4752
#build html container
4853
@"
4954
<html>
@@ -114,13 +119,13 @@ function ConvertTo-DbaTimeline {
114119
#This is where do column mapping:
115120
if ($caller.Position -Like "*Get-DbaAgentJobHistory*") {
116121
$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))} }
118123

119124
}
120125

121126
if ($caller.Position -Like "*Get-DbaBackupHistory*") {
122127
$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))} }
124129
}
125130
"$( $data | %{"['$($_.vLabel)','$($_.hLabel)','$($_.Style)',$($_.StartDate), $($_.EndDate)],"})"
126131
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /