-
Notifications
You must be signed in to change notification settings - Fork 1
/
cronjob.html
236 lines (226 loc) · 7.84 KB
/
cronjob.html
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!--[if IE]>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<![endif]-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>U-NAS</title>
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<link
rel="stylesheet"
type="text/css"
href="/apps/cronjob/css/index.css?v=6.0.2&"
/>
<script>
window.top.UNAS.SetAppState('Cron Job', 'active');
</script>
<script type=text/javascript>
jQuery.noConflict();
(function () {
jQuery('#cron_job_table').mCustomScrollbar({
autoHideScrollbar: true,
theme: 'minimal-dark',
})
ListAllCronJobs()
})();
function ListAllCronJobs() {
jQuery('#cronjob_manager_waiting_content').attr(
'style',
'display:block'
)
jQuery('#cronjob_manager_waiting_logo').attr('style', 'display:block')
jQuery.ajax({
url: '/apps/cronjob/includes/services.php',
type: 'POST',
async: true,
contentType: 'application/json',
data: JSON.stringify({ token: UToken, action: 'listAllCronJobs' }),
timeout: 20000,
dataType: 'json',
success: function (data) {
jQuery('#cron_job_list').html('')
DisplayJobsInTable(data)
jQuery('#cronjob_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#cronjob_manager_waiting_logo').attr(
'style',
'display:none'
)
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus)
jQuery('#cronjob_manager_waiting_content').attr(
'style',
'display:none'
)
jQuery('#cronjob_manager_waiting_logo').attr(
'style',
'display:none'
)
},
})
}
function DisplayJobsInTable(data) {
var len = data.length
for (var i = 0; i < len; i++) {
if(data[i] !== undefined && data[i] !== null && data[i] !== '') {
var jobInfo = data[i].split(' /usr/bin/sudo sh ')
var tr = ''
tr += '<tr>'
tr +=
'<td width="30%" align="left"><span class="unas_table_text" id="cronjob_cron_' +
i +
'">' + jobInfo[0] + '</span></td>'
tr +=
'<td width="55%" align="left"><span class="unas_table_text" id="cronjob_script_' +
i +
'">' + jobInfo[1] + '</span></td>'
tr +='<td width="15%" align="center">'+
'<a class="unas_icon_edit" onClick="EditCronJob('+"'"+data[i]+"'"+');" title="'+UNAS._("Edit")+'" />'+
'<a class="unas_icon_delete" onClick="DeleteCronJob('+"'"+data[i]+"'"+');" title="'+UNAS._("Delete")+'" />'+
'</td>'
tr += '</tr>'
jQuery('#cron_job_list').append(tr)
}
}
jQuery('#cron_job_list tr:even').addClass('tr_even')
jQuery('#cron_job_list tr:odd').addClass('tr_odd')
jQuery('#cron_job_list tr').mouseover(function () {
jQuery(this).removeClass('tr_even tr_odd')
jQuery(this).toggleClass('tr_hover')
})
jQuery('#cron_job_list tr').mouseout(function () {
jQuery(this).toggleClass('tr_hover')
jQuery(this).removeClass('tr_even tr_odd')
jQuery('#cron_job_list tr:even').addClass('tr_even')
jQuery('#cron_job_list tr:odd').addClass('tr_odd')
})
}
function AddJob() {
var AddCronJobWindow = new MUI.Modal({
id: 'AddCronJobWindow',
title: UNAS._('Add Cron Job'),
modal: true,
width: 450,
height: 320,
modalOverlayClose: false,
contentURL: '/apps/cronjob/add_cronjob.html?v=6.0.2&'
});
AddCronJobWindow.ProcessAddCronJob = function() {
ListAllCronJobs();
}
}
function EditCronJob(cron_job){
var EditCronJobWindow = new MUI.Modal({
id: 'EditCronJobWindow',
title: UNAS._('Edit Cron Job'),
modal: true,
width: 450,
height: 320,
modalOverlayClose: false,
contentURL: '/apps/cronjob/edit_cronjob.html?v=6.0.2&cron_job='+cron_job
});
EditCronJobWindow.ProcessEditCronJob = function(){
ListAllCronJobs();
}
}
function DeleteCronJob(cron_job){
var DeleteCronJobWindow = new MUI.Modal({
id: 'DeleteCronJobWindow',
title: UNAS._('Delete Reverse Proxy Config'),
modal: true,
width: 400,
height: 130,
modalOverlayClose: false,
contentURL: '/apps/cronjob/delete_cronjob.html?v=6.0.2&cron_job='+cron_job
});
DeleteCronJobWindow.ProcessDeleteCronJob = function(){
ListAllCronJobs();
}
}
</script>
</head>
<body>
<div id="cronjob_main_page" class="cronjob_manager">
<div
id="cronjob_manager_waiting_content"
class="unas_loading_modal"
style="display: none"
></div>
<div
id="cronjob_manager_waiting_logo"
class="unas_loading"
style="display: none"
></div>
<div class="unas_title">
<div
id="poweroptions_manager_immediately_tab"
class="unas_tab_sel"
poweroptionsitemtableid="poweroptions_manager_immediately_page"
>
<span>##$@cronjob@$##Cron Job##$@cronjob@$##</span>
</div>
</div>
<div class="unas_content" style="height: calc(100% - 72px);">
<div class="unas-flex" style="justify-content: end;padding: 10px 0px 10px 14px;">
<button class="unas_button_content" onclick="AddJob();" style="margin-left:20px;">##$@cronjob@$##Add##$@cronjob@$##</button>
</div>
<div
class="unas_table"
style="overflow: auto;height: calc(100% - 46px);"
>
<table class="unas_table_title">
<tr>
<th width="30%" align="left">
<span class="unas_table_text"
>##$@cronjob@$##Cron##$@cronjob@$##</span
>
</th>
<th width="55%" align="left">
<span class="unas_table_text"
>##$@cronjob@$##Script##$@cronjob@$##</span
>
</th>
<th width="15%" align="center">
<span class="unas_table_text">##$@cronjob@$##Operation##$@cronjob@$##</span>
</th>
</tr>
</table>
<div id="cron_job_table" class="cronjob_table_content">
<table class="unas_table_content" id="cron_job_list"></table>
</div>
</div>
</div>
</div>
<script type="text/javascript">
;(function () {
var rt = document.getElementById('cronjob_main_page')
var pageTranslators = window.top.UNAS.CreateNodesTranslators(
rt.parentNode
)
var OnChangeLanguage = function (e) {
for (var i = 0; i < pageTranslators.length; i++) {
var node = pageTranslators[i].node
var p = pageTranslators[i].translateProperty
node[p] = window.top.UNAS._(pageTranslators[i].originalText)
}
}
OnChangeLanguage()
window.top.UNAS.Event.addEvent('ChangeLanguage', OnChangeLanguage)
window.addEventListener(
'unload',
function (e) {
window.top.UNAS.Event.removeEvent(
'ChangeLanguage',
OnChangeLanguage
)
window.top.UNAS.SetAppState('Cron Job', 'inactive')
},
false
)
})()
</script>
</body>
</html>