add old lci module
This commit is contained in:
1 parent
38a6e815f0
commit
8499631091
171 files changed
+25562
No files matched your search
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
</head>
|
||||
<body>
|
||||
log
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,35 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='features/module.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="top-bar-con">
|
||||
<button class="newBtn">新建</button>
|
||||
<button class="flushBtn">刷新</button>
|
||||
</div>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<td>模块名</td>
|
||||
<td>操作</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in modules %}
|
||||
<tr>
|
||||
<td>{{ item }}</td>
|
||||
<td>
|
||||
<button class="removeBtn" onclick="alert('暂未完成')">移除</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,199 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='features/process.css') }}">
|
||||
<!--
|
||||
<script>
|
||||
window.onload = function init() {
|
||||
const initReq = new XMLHttpRequest()
|
||||
const url = "http://qsont.xyz:8011/get-process"
|
||||
|
||||
initReq.open("get", url, true)
|
||||
initReq.send()
|
||||
addInProgessText()
|
||||
|
||||
initReq.onload = () => {
|
||||
if (initReq.status == 200 && initReq.readyState == 4) {
|
||||
const res = JSON.parse(initReq.responseText)
|
||||
let tBody = document.getElementById("tBody")
|
||||
|
||||
removeInProgessText()
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
const pid = res[i].pid
|
||||
const status = res[i].status
|
||||
const cmd = res[i].cmd
|
||||
let trEle = document.createElement("tr")
|
||||
trEle.innerHTML = `
|
||||
<td class="text">${pid}</td>
|
||||
<td class="text">${status}</td>
|
||||
<td class="text">${cmd}</td>
|
||||
<td><button class="stopBtn" onclick="stopBtn('${pid}')">stop</button></td>
|
||||
`
|
||||
tBody.append(trEle)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (initReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${initReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
initReq.onerror = () => {
|
||||
alert(`无法获取进程列表 (${initReq.status})`)
|
||||
}
|
||||
|
||||
function addInProgessText() {
|
||||
let inProgressText = document.getElementById("inProgressText")
|
||||
const dotAmount = 3
|
||||
let currDotAmount = 0
|
||||
let dot = ""
|
||||
setInterval(() => {
|
||||
dot = ""
|
||||
for (let i = 0; i < currDotAmount; i++) {
|
||||
dot = dot + "."
|
||||
}
|
||||
inProgressText.innerText = `Loading${dot}`
|
||||
if (currDotAmount >= dotAmount) {
|
||||
dot = ""
|
||||
currDotAmount = 0
|
||||
} else {
|
||||
currDotAmount++
|
||||
}
|
||||
}, 500)
|
||||
}
|
||||
|
||||
function removeInProgessText() {
|
||||
let inProgressText = document.getElementById("inProgressText")
|
||||
inProgressText.remove()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
-->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- stop, new flush -->
|
||||
<button class="newBtn" onclick="newBtn()">new</button>
|
||||
<button class="flushBtn" onclick="flushBtn()">flush</button>
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="title">PID</th>
|
||||
<th class="title">状态</th>
|
||||
<th class="title">命令</th>
|
||||
<th class="title">操作</th>
|
||||
</tr>
|
||||
{% for item in response %}
|
||||
<tr>
|
||||
<td>{{ item.pid }}</td>
|
||||
<td>{{ item.status }}</td>
|
||||
<td>{{ item.order }}</td>
|
||||
<td><button class="stopBtn" onclick="stopBtn('{{ item.pid }}')">stop</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</thead>
|
||||
<tbody id="tBody"></tbody>
|
||||
</table>
|
||||
<div id="inProgressText"></div>
|
||||
|
||||
<div class="modal-con" id="modal-con">
|
||||
<div class="window">
|
||||
<div class="top-bar">
|
||||
<div class="close-btn" onclick="closeModal()">X</div>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<div class="prompt">输入模块名:</div>
|
||||
<input id="input-area" class="input-area" type="text">
|
||||
</div>
|
||||
<button class="create-btn" onclick="createProcess()">创建</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function newBtn() {
|
||||
const modal = document.getElementById("modal-con")
|
||||
modal.style.display = "flex"
|
||||
}
|
||||
|
||||
function createProcess() {
|
||||
const moduleName = document.getElementById("input-area").value
|
||||
const createReq = new XMLHttpRequest()
|
||||
const url = `{{ url_for('process.create_process', name=0) }}`.replace('0', moduleName);
|
||||
|
||||
createReq.open("post", url, true)
|
||||
createReq.send()
|
||||
|
||||
createReq.onload = () => {
|
||||
if (createReq.status == 200 && createReq.readyState == 4) {
|
||||
const res = JSON.parse(createReq.responseText)
|
||||
if (res.status == "success") {
|
||||
flushBtn()
|
||||
return
|
||||
}
|
||||
alert(`意外错误 (${createReq.status})`)
|
||||
return
|
||||
}
|
||||
|
||||
if (createReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${createReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function flushBtn() {
|
||||
window.location = "{{ url_for('process.process') }}"
|
||||
}
|
||||
|
||||
function stopBtn(pid) {
|
||||
if (!confirm("确认停止该服务?")) {
|
||||
return
|
||||
}
|
||||
const url = `{{ url_for('process.kill_process', pid=0) }}`.replace('0', pid);
|
||||
const stopReq = new XMLHttpRequest();
|
||||
|
||||
stopReq.open("POST", url, true);
|
||||
stopReq.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||
stopReq.send();
|
||||
|
||||
stopReq.onload = () => {
|
||||
if (stopReq.status == 200 && stopReq.readyState == 4) {
|
||||
flushBtn()
|
||||
return
|
||||
}
|
||||
|
||||
if (stopReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${stopReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function closeModal() {
|
||||
const modal = document.getElementById("modal-con")
|
||||
const input = document.getElementById("input-area")
|
||||
|
||||
input.value = ""
|
||||
modal.style.display = "none"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,162 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='features/user.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="top-bar-con">
|
||||
<button class="addUserBtn" onclick="addUser()">添加用户</button>
|
||||
<button class="flushBtn" onclick="flush()">刷新</button>
|
||||
</div>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<td>用户ID</td>
|
||||
<td>用户名</td>
|
||||
<td>用户角色</td>
|
||||
<td>操作</td>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in response %}
|
||||
<tr>
|
||||
<td>{{ item.user_id}}</td>
|
||||
<td>{{ item.username }}</td>
|
||||
<td>{{ item.role }}</td>
|
||||
<td>
|
||||
{% if current_role == "admin" %}
|
||||
<button class="changePasswdBtn" onclick="changePasswd('{{ item.user_id }}')">修改密码</button>
|
||||
{% if item.username != "admin" %}
|
||||
<button class="deleteUserBtn" onclick="deleteUser('{{ item.user_id }}')">删除用户</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if current_role != "admin" and current_user_id == item.user_id %}
|
||||
<button class="changePasswdBtn" onclick="changePasswd('{{ item.user_id }}')">修改密码</button>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function addUser() {
|
||||
const url = "{{ url_for('user.add_user') }}"
|
||||
const addReq = new XMLHttpRequest()
|
||||
|
||||
let data = new URLSearchParams()
|
||||
// get user name
|
||||
const name = prompt("请输入用户名")
|
||||
if (name === null) return
|
||||
if (name === "") {
|
||||
alert("请输入用户名")
|
||||
return
|
||||
} else {
|
||||
data.append("username", name)
|
||||
}
|
||||
// get user password
|
||||
const passwd = prompt("请输入密码")
|
||||
if (passwd === null) return
|
||||
if (passwd === "") {
|
||||
alert("请输入密码")
|
||||
return
|
||||
} else {
|
||||
data.append("password", passwd)
|
||||
}
|
||||
|
||||
addReq.open("post", url, true)
|
||||
addReq.send(data)
|
||||
|
||||
addReq.onload = () => {
|
||||
if (addReq.status == 200 && addReq.readyState == 4) {
|
||||
alert(JSON.parse(addReq.responseText).message)
|
||||
flush()
|
||||
return
|
||||
}
|
||||
|
||||
if (addReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${addReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changePasswd(id) {
|
||||
const url = "{{ url_for('user.change_password') }}"
|
||||
const changeReq = new XMLHttpRequest()
|
||||
|
||||
let data = new URLSearchParams()
|
||||
data.append("user_id", id)
|
||||
|
||||
// get user password
|
||||
const passwd = prompt("请输入新密码")
|
||||
if (passwd === null) return
|
||||
if (passwd === "") {
|
||||
alert("请输入密码")
|
||||
return
|
||||
} else {
|
||||
data.append("new_password", passwd)
|
||||
}
|
||||
|
||||
changeReq.open("post", url, true)
|
||||
changeReq.send(data)
|
||||
changeReq.onload = () => {
|
||||
if (changeReq.status == 200 && changeReq.readyState == 4) {
|
||||
alert(JSON.parse(changeReq.responseText).message)
|
||||
flush()
|
||||
return
|
||||
}
|
||||
|
||||
if (changeReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${changeReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteUser(id) {
|
||||
if (!confirm("删除用户后不可恢复,确认继续?")) {
|
||||
return
|
||||
}
|
||||
const url = "{{ url_for('user.delete_user', user_id=0) }}".replace("0", id)
|
||||
const delReq = new XMLHttpRequest()
|
||||
|
||||
delReq.open("post", url, true)
|
||||
delReq.send()
|
||||
|
||||
delReq.onload = () => {
|
||||
if (delReq.status == 200 && delReq.readyState == 4) {
|
||||
alert(JSON.parse(delReq.responseText).message)
|
||||
flush()
|
||||
return
|
||||
}
|
||||
|
||||
if (delReq.status == 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${delReq.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function flush() {
|
||||
window.location = "{{ url_for('user.user') }}"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,88 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>pmc management</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="main">
|
||||
<div class="title">Welcome to pmc management system</div>
|
||||
<div class="name-con">
|
||||
<div class="user-name-text">Name: </div>
|
||||
<input class="user-name-input" id="user-name" type="text">
|
||||
</div>
|
||||
<div class="passwd-con">
|
||||
<div class="user-passwd-text">Password: </div>
|
||||
<input class="user-passwd-input" id="user-passwd" type="password">
|
||||
</div>
|
||||
<div class="login-con">
|
||||
<button onclick="login()">login</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function login() {
|
||||
const name = document.getElementById("user-name").value
|
||||
const passwd = document.getElementById("user-passwd").value
|
||||
const request = new XMLHttpRequest()
|
||||
const REQUEST_URL = "/api/login"
|
||||
|
||||
// if user not input any information
|
||||
if (name === "" || passwd === "") {
|
||||
alert("please input name or passwd")
|
||||
return
|
||||
}
|
||||
|
||||
// request api
|
||||
let requestData = new URLSearchParams()
|
||||
requestData.append("user-name", name)
|
||||
requestData.append("user-passwd", passwd)
|
||||
request.open("post", REQUEST_URL, true)
|
||||
request.send(requestData)
|
||||
|
||||
request.onload = () => {
|
||||
if (request.status === 401) {
|
||||
alert(request.responseText)
|
||||
return
|
||||
}
|
||||
|
||||
if (request.status === 404) {
|
||||
alert(request.responseText)
|
||||
return
|
||||
}
|
||||
|
||||
if (request.status === 500) {
|
||||
alert("服务端错误")
|
||||
return
|
||||
}
|
||||
|
||||
if (request.status === 200 && request.readyState === 4) {
|
||||
const token = JSON.parse(request.responseText).token
|
||||
let date = new Date()
|
||||
date.setTime(date.getTime() + (3 * 24 * 60 * 60 * 1000))
|
||||
const UTCTime = date.toUTCString()
|
||||
document.cookie = `token=${token}; path=/; expires=${UTCTime}`
|
||||
window.location = JSON.parse(request.responseText).redirect;
|
||||
return
|
||||
} else {
|
||||
alert(`意外错误 (${request.status})`)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener("keydown", (e) => {
|
||||
if (e.key != "Enter") {
|
||||
return
|
||||
}
|
||||
login()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>management page</title>
|
||||
<link rel="icon" href="data:;base64,=">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='mgmt.css') }}">
|
||||
|
||||
<script>
|
||||
window.onload = () => {
|
||||
const featureList = [
|
||||
{
|
||||
name: "进程",
|
||||
url: "{{ url_for('process.process') }}"
|
||||
},
|
||||
{
|
||||
name: "模块",
|
||||
url: "{{ url_for('module.module') }}"
|
||||
},
|
||||
// {
|
||||
// name: "日志",
|
||||
// url: "{{ url_for('log.log') }}"
|
||||
// },
|
||||
{
|
||||
name: "用户",
|
||||
url: "{{ url_for('user.user') }}"
|
||||
}
|
||||
]
|
||||
|
||||
const featureListEle = document.getElementById("feature-list")
|
||||
for (let i = 0; i < featureList.length; i++) {
|
||||
// get name and url
|
||||
const name = featureList[i].name
|
||||
const url = featureList[i].url
|
||||
|
||||
// Create a item
|
||||
let listItemEle = document.createElement("div")
|
||||
listItemEle.setAttribute("class", "item")
|
||||
listItemEle.innerText = name
|
||||
listItemEle.setAttribute("onclick", `switchPage('${url}')`)
|
||||
|
||||
// append element into feature list
|
||||
featureListEle.append(listItemEle)
|
||||
}
|
||||
|
||||
// set default page in iframe
|
||||
const DEFAULT_PAGE = "<!DOCTYPE html><h1>请在左侧选择功能</h1>"
|
||||
document.getElementById("page").contentDocument.write(DEFAULT_PAGE)
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="top-con">
|
||||
<div id="current-user">当前用户: {{ username }}</div>
|
||||
<div id="current-role">当前角色: {{ role }}</div>
|
||||
<div class="button-con">
|
||||
<button onclick="logout()">退出登陆</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="main">
|
||||
<div class="feature-list" id="feature-list"></div>
|
||||
<div class="pages">
|
||||
<iframe id="page" src="" frameborder="1" width="100%" height="100%"></iframe>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// change the iframe's url
|
||||
function switchPage(url) {
|
||||
const page = document.getElementById("page")
|
||||
page.setAttribute("src", url)
|
||||
}
|
||||
|
||||
function logout() {
|
||||
if (!confirm("确认退出?")) {
|
||||
return
|
||||
}
|
||||
document.cookie = "token=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
window.location = "/"
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user