123 lines
4.2 KiB
HTML
123 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh">
|
||
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title>开门</title>
|
||
<link rel="stylesheet" href="layui/css/layui.css">
|
||
<meta charset="utf-8"/>
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<div class="myDiy">
|
||
<blockquote class="layui-elem-quote">舰R脚本管理器:<span id="taskStatus"></span><br/><br/><span id="taskName">当前无任务</span><br/><br/><span id="runIndex"></span><br/><br/><span id="log"></span>
|
||
</blockquote>
|
||
<button class="layui-btn layui-btn-lg layui-btn-normal" onclick="createTask()">创建任务</button>
|
||
<br/><br/><br/>
|
||
|
||
<div class="layui-bg-gray layui-row layui-col-space15" id="card" style="padding: 30px;">
|
||
</div>
|
||
</div>
|
||
|
||
</body>
|
||
<script src="layui/layui.js"></script>
|
||
<script src="layui/jquery-3.2.1.js"></script>
|
||
<script>
|
||
function createCard(name) {
|
||
let html = '<div class="layui-card layui-col-md3 layui-col-lg-offset1"><div class="layui-card-header">' + name + '</div><div class="layui-card-body"><button class="layui-btn layui-btn-radius layui-btn-normal" onclick="runTask(\'' + name + '\')"><i class="layui-icon"></i>运行</button><br/><br/><button class="layui-btn layui-btn-radius layui-btn-warm" onclick="stopTask()"><i class="layui-icon"></i>停止</button><br/><br/><button class="layui-btn layui-btn-radius layui-btn-danger" onclick="removeTask(\'' + name + '\')"><i class="layui-icon"></i>删除</button></div></div>';
|
||
$('#card').append(html)
|
||
}
|
||
|
||
function createTask() {
|
||
layer.prompt({
|
||
formType: 2,
|
||
value: '{\n' +
|
||
' "name": "",\n' +
|
||
' "device": "192.168.31.46:6666",\n' +
|
||
' "run": [\n' +
|
||
' {\n' +
|
||
' "name": "",\n' +
|
||
' "nextWaitTime": 0,\n' +
|
||
' "randomNextWaitTime": 0,\n' +
|
||
' "model": "click",\n' +
|
||
' "x": 0,\n' +
|
||
' "y": 0,\n' +
|
||
' "rx": 0,\n' +
|
||
' "ry": 0\n' +
|
||
' }\n' +
|
||
' ]\n' +
|
||
'}',
|
||
title: '创建任务',
|
||
maxlength: 99999,
|
||
area: ['800px', '350px'] //自定义文本域宽高
|
||
}, function (value, index, elem) {
|
||
$.post("http://127.0.0.1:8002/jianr/task/add.do", {task: value}, function (json) {
|
||
layer.msg(json.msg)
|
||
})
|
||
layer.close(index);
|
||
});
|
||
}
|
||
|
||
function runTask(name) {
|
||
$.post("http://127.0.0.1:8002/jianr/run.do", {task: name}, function (json) {
|
||
layer.msg(json.msg)
|
||
})
|
||
}
|
||
|
||
function stopTask() {
|
||
$.post("http://127.0.0.1:8002/jianr/stop.do", function (json) {
|
||
layer.msg(json.msg)
|
||
})
|
||
}
|
||
|
||
function removeTask(name) {
|
||
$.post("http://127.0.0.1:8002/jianr/task/remove.do", {task: name}, function (json) {
|
||
layer.msg(json.msg)
|
||
})
|
||
}
|
||
function getStatus() {
|
||
$.post("http://127.0.0.1:8002/jianr/status.do", function (json) {
|
||
if(json.data.status){
|
||
$('#taskStatus')[0].innerHTML="运行"
|
||
$('#taskStatus').css('color','#5C962C')
|
||
$('#taskName')[0].innerHTML='执行次数: '+json.data.runIndex;
|
||
$('#runIndex')[0].innerHTML='当前正在执行: '+json.data.taskName;
|
||
$('#log')[0].innerHTML=json.data.log
|
||
}else{
|
||
$('#taskStatus')[0].innerHTML="停止"
|
||
$('#taskStatus').css('color','#FF5722')
|
||
}
|
||
getStatus()
|
||
|
||
})
|
||
}
|
||
window.onload = function init() {
|
||
$.get("http://127.0.0.1:8002/jianr/task/list.do", function (json) {
|
||
json.data.forEach(function (item) {
|
||
createCard(item)
|
||
}
|
||
)
|
||
})
|
||
getStatus()
|
||
}
|
||
</script>
|
||
<style>
|
||
.myDiy {
|
||
width: 40%;
|
||
height: 300px;
|
||
margin-top: 10px;
|
||
margin-left: 25%;
|
||
}
|
||
|
||
.button {
|
||
width: 100px;
|
||
height: 100px;
|
||
font-size: 1em;
|
||
}
|
||
|
||
</style>
|
||
|
||
</html> |