Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
zcmimi committed Jun 16, 2021
1 parent 1771414 commit ca0ef01
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
10 changes: 9 additions & 1 deletion modules/servers/init.js → modules/servers/func.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ systemctl enable nekonekostatus`
await ssh.Exec(server.data.ssh,sh);
return {status:1,data:"安装成功"};
}
async function updateServer(server,neko_status_url){
var sh=
`rm -f /usr/bin/neko-status
wget ${neko_status_url} -O /usr/bin/neko-status
chmod +x /usr/bin/neko-status`
await ssh.Exec(server.data.ssh,sh);
return {status:1,data:"更新成功"};
}
module.exports={
initServer
initServer,updateServer,
}
11 changes: 8 additions & 3 deletions modules/servers/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";
const fs=require("fs"),
fetch=require("node-fetch"),
{initServer}=require("./init");
{initServer,updateServer}=require("./func");
// const config = require("../../config");
module.exports=svr=>{
const {db,config,pr,parseNumber}=svr.locals;
Expand All @@ -26,12 +26,17 @@ rt.post("/admin/servers/:sid/del",async(req,res)=>{
db.servers.del(sid);
res.json(pr(1,'删除成功'));
});
var neko_status_url=config.neko_status_url||config.site.url+'/get-neko-status';
rt.post("/admin/servers/:sid/init",async(req,res)=>{
var {sid}=req.params,
server=db.servers.get(sid);
var neko_status_url=config.neko_status_url||config.site.url+'/get-neko-status';
server=db.servers.get(sid);
res.json(await initServer(server,neko_status_url));
});
rt.post("/admin/servers/:sid/update",async(req,res)=>{
var {sid}=req.params,
server=db.servers.get(sid);
res.json(await updateServer(server,neko_status_url));
});
rt.get("/admin/servers",(req,res)=>{
res.render("admin/servers",{
servers:db.servers.all()
Expand Down
3 changes: 0 additions & 3 deletions static/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ function copy(text){
x.remove();
mdui.snackbar({message: "复制成功",position: "top"});
}
function notmail(email){return !/^\S+@\S+\.\S{2,}$/.test(email);}
function hascn(str){return /.*[\u4e00-\u9fa5]+.*$/.test(str);}

function E(id){return document.getElementById(id);}
function V(id){return E(id).value;}

Expand Down
7 changes: 7 additions & 0 deletions views/admin/servers/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ <h3>API</h3>
<div class="mdui-card-actions">
{%block actions%}
<button class="btn mdui-btn mdui-btn-dense mdui-btn-raised mdui-color-blue mdui-text-color-white" onclick="init()" mdui-tooltip="{content:'安装探针'}">安装</button>
<button class="btn mdui-btn mdui-btn-dense mdui-btn-raised mdui-color-green mdui-text-color-white" onclick="update()" mdui-tooltip="{content:'更新探针后端'}">更新</button>
{%endblock%}
</div>
</div>
Expand Down Expand Up @@ -134,5 +135,11 @@ <h3>API</h3>
notice(res.data);
endloading();
}
async function update(){
startloading();
var res=await postjson(`./update`);
notice(res.data);
endloading();
}
</script>
{%endblock%}
2 changes: 1 addition & 1 deletion views/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="mdui-col">
<div class="mdui-card mt {%if node.stat==0%}mdui-text-color-grey offline{%endif%}">
<div class="mdui-card-primary">
<div class="mdui-card-primary-title mdui-text-truncate" href="/stats/{{sid}}/">{{node.name}}</div>
<div class="mdui-card-primary-title mdui-text-truncate poh" href="/stats/{{sid}}/">{{node.name}}</div>
<!-- <div class="mdui-card-primary-subtitle">{{node.describe}}</div> -->
</div>
<div class="mdui-card-menu">
Expand Down

0 comments on commit ca0ef01

Please sign in to comment.