[dashboard v0.3.9] 手动即时触发计划任务

This commit is contained in:
naiba
2021-01-24 09:41:35 +08:00
parent 175eb996d3
commit a957b21265
10 changed files with 195 additions and 116 deletions

View File

@@ -149,7 +149,7 @@ function addOrEditCron(cron) {
modal.find('input[name=ID]').val(cron ? cron.ID : null)
modal.find('input[name=Name]').val(cron ? cron.Name : null)
modal.find('input[name=Scheduler]').val(cron ? cron.Scheduler : null)
modal.find('a.ui.label.visible').each((i,el) => {
modal.find('a.ui.label.visible').each((i, el) => {
el.remove()
})
var servers
@@ -192,6 +192,42 @@ function deleteRequest(api) {
});
}
function manualTrigger(btn, cronId) {
$(btn).toggleClass('loading')
$.ajax({
url: '/api/cron/' + cronId + '/manual',
type: 'GET',
}).done(resp => {
$(btn).toggleClass('loading')
if (resp.code == 200) {
$.suiAlert({
title: '触发成功,等待执行结果',
type: 'success',
description: resp.message,
time: '3',
position: 'top-center',
});
} else {
$.suiAlert({
title: '触发失败 ',
type: 'error',
description: resp.code + '' + resp.message,
time: '3',
position: 'top-center',
});
}
}).fail(err => {
$(btn).toggleClass('loading')
$.suiAlert({
title: '触发失败 ',
type: 'error',
description: '网络错误:' + err.responseText,
time: '3',
position: 'top-center',
});
});
}
function logout(id) {
$.post('/api/logout', JSON.stringify({ id: id })).done(function (resp) {
if (resp.code == 200) {

View File

@@ -8,7 +8,7 @@
<script src="https://cdn.jsdelivr.net/npm/semantic-ui@2.4.1/dist/semantic.min.js"></script>
<script src="/static/semantic-ui-alerts.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12/dist/vue.min.js"></script>
<script src="/static/main.js?v202101220904"></script>
<script src="/static/main.js?v202101240939"></script>
</body>
</html>

View File

@@ -37,6 +37,9 @@
<td>{{$cron.LastResult}}</td>
<td>
<div class="ui mini icon buttons">
<button class="ui button" onclick="manualTrigger(this, {{$cron.ID}})">
<i class="play icon"></i>
</button>
<button class="ui button" onclick="addOrEditCron({{$cron}})">
<i class="edit icon"></i>
</button>