mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 21:20:06 +00:00
[dashboard 0.3.3] 添加计划任务可搜索服务器
This commit is contained in:
@@ -36,10 +36,22 @@ function showFormModal(modelSelector, formID, URL, getData) {
|
||||
form.children('.message').remove()
|
||||
btn.toggleClass('loading')
|
||||
const data = getData ? getData() : $(formID).serializeArray().reduce(function (obj, item) {
|
||||
obj[item.name] = (item.name.endsWith('_id') ||
|
||||
// ID 类的数据
|
||||
if ((item.name.endsWith('_id') ||
|
||||
item.name === 'id' || item.name === 'ID' ||
|
||||
item.name === 'RequestType' || item.name === 'RequestMethod' ||
|
||||
item.name === 'DisplayIndex' || item.name === 'Type') ? parseInt(item.value) : item.value;
|
||||
item.name === 'DisplayIndex' || item.name === 'Type')) {
|
||||
obj[item.name] = parseInt(item.value);
|
||||
} else {
|
||||
obj[item.name] = item.value;
|
||||
}
|
||||
|
||||
if (item.name == 'ServersRaw') {
|
||||
if (item.value.length > 2) {
|
||||
obj[item.name] = '[' + item.value.substr(3, item.value.length - 1) + ']'
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}, {});
|
||||
$.post(URL, JSON.stringify(data)).done(function (resp) {
|
||||
@@ -108,6 +120,7 @@ function addOrEditServer(server) {
|
||||
modal.find('input[name=name]').val(server ? server.Name : null)
|
||||
modal.find('input[name=Tag]').val(server ? server.Tag : null)
|
||||
modal.find('input[name=DisplayIndex]').val(server ? server.DisplayIndex : null)
|
||||
modal.find('textarea[name=Note]').val(server ? server.Note : null)
|
||||
if (server) {
|
||||
modal.find('.secret.field').attr('style', '')
|
||||
modal.find('input[name=secret]').val(server.Secret)
|
||||
@@ -136,7 +149,16 @@ 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('input[name=ServersRaw]').val(cron ? cron.ServersRaw : '[]')
|
||||
var servers
|
||||
if (cron) {
|
||||
servers = cron.ServersRaw
|
||||
serverList = JSON.parse(servers)
|
||||
const node = modal.find('i.dropdown.icon')
|
||||
for (let i = 0; i < serverList.length; i++) {
|
||||
node.after('<a class="ui label transition visible" data-value="' + serverList[i] + '" style="display: inline-block !important;">ID:' + serverList[i] + '<i class="delete icon"></i></a>')
|
||||
}
|
||||
}
|
||||
modal.find('input[name=ServersRaw]').val(cron ? '[],' + servers.substr(1, servers.length - 2) : '[]')
|
||||
modal.find('textarea[name=Command]').val(cron ? cron.Command : null)
|
||||
if (cron && cron.PushSuccessful) {
|
||||
modal.find('.ui.push-successful.checkbox').checkbox('set checked')
|
||||
@@ -197,3 +219,16 @@ function logout(id) {
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
try {
|
||||
$('.ui.servers.search.dropdown').dropdown({
|
||||
clearable: true,
|
||||
apiSettings: {
|
||||
url: '/api/search-server?word={query}',
|
||||
cache: false,
|
||||
},
|
||||
})
|
||||
} catch (error) {
|
||||
}
|
||||
})
|
||||
@@ -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?v202101190958"></script>
|
||||
<script src="/static/main.js?v202101202159"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -18,7 +18,12 @@
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>执行服务器ID列表</label>
|
||||
<input type="text" name="ServersRaw" placeholder="[10,7,19]">
|
||||
<div class="ui fluid multiple servers search selection dropdown">
|
||||
<input type="hidden" name="ServersRaw">
|
||||
<i class="dropdown icon"></i>
|
||||
<div class="default text">输入ID/备注以搜索</div>
|
||||
<div class="menu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<div class="ui push-successful checkbox">
|
||||
@@ -30,7 +35,8 @@
|
||||
<div class="ui warning message">
|
||||
<p>
|
||||
计划的格式为:<code>* * * * *</code> 分 时 天 月 星期,详情见 <a
|
||||
href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format" target="_blank">计划表达式格式</a><br>
|
||||
href="https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format"
|
||||
target="_blank">计划表达式格式</a><br>
|
||||
命令:Shell 命令,就像写脚本一样就可以,如果遇到 xxx 命令找不到,可能是 <code>PATH</code> 环境变量的问题,<code>source ~/.bashrc</code>
|
||||
或者使用绝对路径执行。
|
||||
</p>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
</button>
|
||||
<button class="ui button"
|
||||
onclick="showConfirm('删除计划任务','确认删除此计划任务?',deleteRequest,'/api/cron/'+{{$cron.ID}})">
|
||||
<i class="delete icon"></i>
|
||||
<i class="trash alternate outline icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<div class="field">
|
||||
<select name="Theme">
|
||||
<option value="default"{{if eq .Conf.Site.Theme "default"}} selected="selected"{{end}}>默认主题</option>
|
||||
<option value="daynight"{{if eq .Conf.Site.Theme "daynight"}} selected="selected"{{end}}>JackieSung DayNight</option>
|
||||
<option value="hotaru"{{if eq .Conf.Site.Theme "hotaru"}} selected="selected"{{end}}>CokeMine Hotaru</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user