-
Notifications
You must be signed in to change notification settings - Fork 824
Expand file tree
/
Copy pathInstance.Jobs.cshtml
More file actions
106 lines (104 loc) · 4.55 KB
/
Instance.Jobs.cshtml
File metadata and controls
106 lines (104 loc) · 4.55 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
@using Roles = StackExchange.Opserver.Models.Roles
@model StackExchange.Opserver.Data.SQL.SQLInstance
@{
Layout = null;
var jobs = Model.JobSummary;
var data = jobs.SafeData(true);
}
<h4 class="modal-title" title="Updated @(jobs.LastPoll?.ToRelativeTime())">
Agent Jobs
</h4>
@if (data.Any())
{
<table class="table table-striped table-hover text-nowrap table-super-condensed table-responsive">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Last Run</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
<th>Enabled</th>
@if (Current.IsInRole(Roles.SQLAdmin))
{
<th>Actions</th>
}
</tr>
</thead>
<tbody>
@foreach (var j in data.OrderByDescending(j => j.LastRunRequestedDate))
{
var lastInitiator = j.LastRunRequestedSource.HasValue ? j.LastRunRequestedSource.Value.GetDescription() : "Unknown";
<tr class="@j.RowClass()@(j.IsRunning ? " info" : null)@(j.IsEnabled ? "" : " text-muted")" data-guid="@j.JobId.ToString()" title="@if(!j.IsEnabled){<text>(DISABLED)
</text>}Job: @j.Name
@j.Description
@if(j.IsRunning) {<text>Currently Running
</text>}
Category: @j.Category
Created: @j.DateCreated.ToZuluTime()
Last Run Initiated by: @lastInitiator
Last Run Message: @j.LastRunMessage">
<td>@j.IconSpan()</td>
<td>@j.Name
@if (j.IsRunning)
{
<span class="good">(Running)</span>
}
</td>
@if (j.IsRunning)
{
<td>Running (@lastInitiator)</td>
<td>@(j.LastStartDate?.ToRelativeTimeSpan())</td>
<td></td>
<td>@(j.LastRunDuration.HasValue ? j.LastRunDuration.Value.ToTimeStringMini() : "")</td>
}
else if (j.LastRunStatus.HasValue)
{
<td>@j.LastRunMonitorStatus.IconSpan() @j.LastRunMonitorStatus.Span(j.LastRunStatus.Value.GetDescription().IsNullOrEmptyReturn("Unknown")) (@lastInitiator)</td>
<td>@(j.LastStartDate?.ToRelativeTimeSpan())</td>
<td>@(j.LastStopDate?.ToRelativeTimeSpan())</td>
<td>@(j.LastRunDuration.HasValue ? j.LastRunDuration.Value.ToTimeStringMini() : "")</td>
}
else if (j.LastStartDate.HasValue && !j.LastStopDate.HasValue)
{
<td>@j.LastRunMonitorStatus.IconSpan() @j.LastRunMonitorStatus.Span("Server Stopped whilst Running") (@lastInitiator)</td>
<td>@(j.LastStartDate?.ToRelativeTimeSpan())</td>
<td></td>
<td></td>
}
else
{
<td colspan="4" class="text-muted">no run history found</td>
}
<td class="@(j.IsEnabled ? "" : "text-warning")">@(j.IsEnabled ? "Yes" : "No")</td>
@if (Current.IsInRole(Roles.SQLAdmin))
{
<td class="actions">
@if (j.IsEnabled)
{
<a href="#" class="js-sql-job-action btn btn-xs btn-warning" data-action="toggle" data-enable="false">Disable</a>
}
else
{
<a href="#" class="js-sql-job-action btn btn-xs btn-success" data-action="toggle" data-enable="true">Enable</a>
}
@if (!j.IsRunning)
{
<a href="#" class="js-sql-job-action btn btn-xs btn-primary" data-action="start" data-guid="@j.JobId.ToString()">Start</a>
}
else
{
<a href="#" class="js-sql-job-action btn btn-xs btn-danger" data-action="stop" data-guid="@j.JobId.ToString()">Stop</a>
}
</td>
}
</tr>
}
</tbody>
</table>
}
else
{
<div class="no-content">No jobs information available</div>
}