/
admin_maintenance.html.php
193 lines (190 loc) · 5.94 KB
/
admin_maintenance.html.php
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php defined("SYSPATH") or die("No direct script access.") ?>
<div id="gAdminMaintenance">
<h1> <?= t("Maintenance Tasks") ?> </h1>
<p>
<?= t("Occasionally your Gallery will require some maintenance. Here are some tasks you can use to keep it running smoothly.") ?>
</p>
<div id="gAvailableTasks">
<h2> <?= t("Available Tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Description") ?>
</th>
<th>
<?= t("Action") ?>
</th>
</tr>
<? $i = 0; ?>
<? foreach ($task_definitions as $task): ?>
<tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= log::severity_class($task->severity) ?>">
<td class="<?= log::severity_class($task->severity) ?>">
<?= $task->name ?>
</td>
<td>
<?= $task->description ?>
</td>
<td>
<a href="<?= url::site("admin/maintenance/start/$task->callback?csrf=$csrf") ?>"
class="gDialogLink g-button ui-icon-left ui-state-default ui-corner-all">
<?= t("run") ?>
</a>
</td>
</tr>
<? $i++ ?>
<? endforeach ?>
</table>
</div>
<? if ($running_tasks->count()): ?>
<div id="gRunningTasks">
<h2> <?= t("Running Tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Last Updated") ?>
</th>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Status") ?>
</th>
<th>
<?= t("Info") ?>
</th>
<th>
<?= t("Owner") ?>
</th>
<th>
<a href="<?= url::site("admin/maintenance/cancel_running_tasks?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<?= t("cancel all") ?></a>
<?= t("Action") ?>
</th>
</tr>
<? $i = 0; ?>
<? foreach ($running_tasks as $task): ?>
<tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "stalled" ? "gWarning" : "" ?>">
<td class="<?= $task->state == "stalled" ? "gWarning" : "" ?>">
<?= gallery::date_time($task->updated) ?>
</td>
<td>
<?= $task->name ?>
</td>
<td>
<? if ($task->done): ?>
<? if ($task->state == "cancelled"): ?>
<?= t("Cancelled") ?>
<? endif ?>
<?= t("Close") ?>
<? elseif ($task->state == "stalled"): ?>
<?= t("Stalled") ?>
<? else: ?>
<?= t("%percent_complete% Complete", array("percent_complete" => $task->percent_complete)) ?>
<? endif ?>
</td>
<td>
<?= $task->status ?>
</td>
<td>
<?= html::clean($task->owner()->name) ?>
</td>
<td>
<a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<?= t("cancel") ?>
</a>
<? if ($task->state == "stalled"): ?>
<a class="gDialogLink g-button ui-icon-left ui-state-default ui-corner-all"
href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>">
<?= t("resume") ?>
</a>
<? endif ?>
</td>
</tr>
<? $i++ ?>
<? endforeach ?>
</table>
</div>
<? endif ?>
<? if ($finished_tasks->count()): ?>
<div id="gFinishedTasks">
<h2> <?= t("Finished Tasks") ?> </h2>
<table>
<tr>
<th>
<?= t("Last Updated") ?>
</th>
<th>
<?= t("Name") ?>
</th>
<th>
<?= t("Status") ?>
</th>
<th>
<?= t("Info") ?>
</th>
<th>
<?= t("Owner") ?>
</th>
<th>
<a href="<?= url::site("admin/maintenance/remove_finished_tasks?csrf=$csrf") ?>"
class="g-button g-right ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-trash"></span><?= t("remove all finished") ?></a>
<?= t("Action") ?>
</th>
</tr>
<? $i = 0; ?>
<? foreach ($finished_tasks as $task): ?>
<tr class="<?= ($i % 2 == 0) ? "gOddRow" : "gEvenRow" ?> <?= $task->state == "success" ? "gSuccess" : "gError" ?>">
<td class="<?= $task->state == "success" ? "gSuccess" : "gError" ?>">
<?= gallery::date_time($task->updated) ?>
</td>
<td>
<?= $task->name ?>
</td>
<td>
<? if ($task->state == "success"): ?>
<?= t("Success") ?>
<? elseif ($task->state == "error"): ?>
<?= t("Failed") ?>
<? elseif ($task->state == "cancelled"): ?>
<?= t("Cancelled") ?>
<? endif ?>
</td>
<td>
<?= $task->status ?>
</td>
<td>
<?= html::clean($task->owner()->name) ?>
</td>
<td>
<? if ($task->done): ?>
<a href="<?= url::site("admin/maintenance/remove/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all">
<?= t("remove") ?>
</a>
<? if ($task->get_log()): ?>
<a href="<?= url::site("admin/maintenance/show_log/$task->id?csrf=$csrf") ?>" class="gDialogLink g-button ui-state-default ui-corner-all">
<?= t("browse log") ?>
</a>
<? endif ?>
<? else: ?>
<a href="<?= url::site("admin/maintenance/resume/$task->id?csrf=$csrf") ?>" class="gDialogLink g-button" ui-state-default ui-corner-all>
<?= t("resume") ?>
</a>
<a href="<?= url::site("admin/maintenance/cancel/$task->id?csrf=$csrf") ?>" class="g-button ui-state-default ui-corner-all">
<?= t("cancel") ?>
</a>
<? endif ?>
</ul>
</td>
</tr>
<? endforeach ?>
<? $i++ ?>
</table>
</div>
<? endif ?>
</div>