新增 服务端操作确认对话框

This commit is contained in:
Suwings 2021-11-09 10:54:25 +08:00
parent 625a208657
commit 71735494a9

View File

@ -1,349 +1,342 @@
<div id="ConsolePanel" class="OneContainer"> <div id="ConsolePanel" class="OneContainer">
<div class="row"> <div class="row">
<div class="col-md-3"> <div class="col-md-3">
<div class="Panel PanelBlack"> <div class="Panel PanelBlack">
<div class="PanelTitle">服务端信息</div> <div class="PanelTitle">服务端信息</div>
<div class="PanelBody"> <div class="PanelBody">
<div class="PanelItem"> <div class="PanelItem">
<span class="glyphicon glyphicon-th-large" aria-hidden="true"> </span> <span class="glyphicon glyphicon-th-large" aria-hidden="true"> </span> 名称: {{ serverData.name }}
名称: {{ serverData.name }} </div>
</div> <div class="PanelItem">
<div class="PanelItem"> <span class="glyphicon glyphicon-tasks" aria-hidden="true"> </span> CPU 使用率: {{ sysCpu }} %
<span class="glyphicon glyphicon-tasks" aria-hidden="true"> </span> </div>
CPU 使用率: {{ sysCpu }} % <div class="PanelItem">
</div> <span class="glyphicon glyphicon-equalizer" aria-hidden="true"> </span> 内存 使用率: {{ (100 - sysMonery).toFixed(1) }} %
<div class="PanelItem"> </div>
<span class="glyphicon glyphicon-equalizer" aria-hidden="true"> </span> <div class="PanelItem" v-if="run">
内存 使用率: {{ (100 - sysMonery).toFixed(1) }} % <span class="glyphicon glyphicon-ok" aria-hidden="true"> </span>
</div> <span style="color: #23970c"> 状态: 正在运行..</span>
<div class="PanelItem" v-if="run"> </div>
<span class="glyphicon glyphicon-ok" aria-hidden="true"> </span> <div class="PanelItem" v-else>
<span style="color: #23970c"> 状态: 正在运行..</span> <span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> 状态: 未运行
</div> </div>
<div class="PanelItem" v-else> </div>
<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span>
状态: 未运行
</div>
</div>
</div>
<div class="Panel" :class="run==true?'PanelGreen':'PanelYellow'">
<div class="PanelTitle">服务端操作</div>
<div class="PanelBody">
<div class="PanelItem" v-on:click="toTerminal()">
<span class="glyphicon glyphicon-unchecked" aria-hidden="true"> </span>
模拟型终端
</div>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toOpenServer()" v-show="!run">
<span class="glyphicon glyphicon-play" aria-hidden="true"> </span>
开启服务器
</div> </div>
</transition> <div class="Panel" :class="run==true?'PanelGreen':'PanelYellow'">
<transition name="slide-fade"> <div class="PanelTitle">服务端操作</div>
<div class="PanelItem" v-on:click="toCommand('__stop__')" v-show="run"> <div class="PanelBody">
<span class="glyphicon glyphicon-pause" aria-hidden="true"> </span> <div class="PanelItem" v-on:click="toTerminal()">
关闭服务器 <span class="glyphicon glyphicon-unchecked" aria-hidden="true"> </span> 模拟型终端
</div>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toOpenServer" v-show="!run">
<span class="glyphicon glyphicon-play" aria-hidden="true"> </span> 开启服务器
</div>
</transition>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toStopServer" v-show="run">
<span class="glyphicon glyphicon-pause" aria-hidden="true"> </span> 关闭服务器
</div>
</transition>
<div class="PanelItem" v-on:click="toRestartServer" v-show="run">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"> </span> 重启服务器
</div>
<div class="PanelItem" v-on:click="toKillServer" v-show="run">
<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> 强制性结束进程
</div>
</div>
</div> </div>
</transition> <div class="Panel" :class="serverData.autoRestart?'PanelGreen':'PanelGray'">
<div class="PanelItem" v-on:click="toCommand('__restart__')" v-show="run"> <div class="PanelTitle">崩溃监视与配置</div>
<span class="glyphicon glyphicon-refresh" aria-hidden="true"> </span> <div class="PanelBody">
重启服务器 <div class="PanelItem" v-on:click="toProperties()">
</div> <span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> Server.properties 配置文件
<div class="PanelItem" v-on:click="toCommand('__killserver__')" v-show="run"> </div>
<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> <transition name="slide-fade">
强制性结束进程 <div class="PanelItem" v-on:click="toAutoRestart(false)" v-show="serverData.autoRestart">
</div> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 崩溃重启:
</div> <span style="color: #29b90c">打开</span>
</div> </div>
<div class="Panel" :class="serverData.autoRestart?'PanelGreen':'PanelGray'"> </transition>
<div class="PanelTitle">崩溃监视与配置</div> <transition name="slide-fade">
<div class="PanelBody"> <div class="PanelItem" v-on:click="toAutoRestart(true)" v-show="!serverData.autoRestart">
<div class="PanelItem" v-on:click="toProperties()"> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 崩溃重启:
<span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> <span style="color: #818181">关闭</span>
Server.properties 配置文件 </div>
</div> </transition>
<transition name="slide-fade"> </div>
<div class="PanelItem" v-on:click="toAutoRestart(false)" v-show="serverData.autoRestart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span>
崩溃重启:
<span style="color: #29b90c">打开</span>
</div> </div>
</transition> <div class="Panel" :class="serverData.autoStart?'PanelGreen':'PanelGray'">
<transition name="slide-fade"> <div class="PanelTitle">启动设置</div>
<div class="PanelItem" v-on:click="toAutoRestart(true)" v-show="!serverData.autoRestart"> <div class="PanelBody">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> <transition name="slide-fade">
崩溃重启: <div class="PanelItem" v-on:click="toAutoStart(false)" v-show="serverData.autoStart">
<span style="color: #818181">关闭</span> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 服务器自启:
<span style="color: #29b90c">打开</span>
</div>
</transition>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoStart(true)" v-show="!serverData.autoStart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 服务器自启:
<span style="color: #818181">关闭</span>
</div>
</transition>
</div>
</div> </div>
</transition> <div class="Panel PanelGray" v-if="isFtpOpen">
</div> <div class="PanelTitle">FTP 链接信息</div>
</div> <div class="PanelBody">
<div class="Panel" :class="serverData.autoStart?'PanelGreen':'PanelGray'"> <div class="PanelItem">
<div class="PanelTitle">启动设置</div> <span class="glyphicon glyphicon-user" aria-hidden="true"> </span> 账号: {{ MCSERVER.username + "." + serverData.name }}
<div class="PanelBody"> </div>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoStart(false)" v-show="serverData.autoStart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span>
服务器自启:
<span style="color: #29b90c">打开</span>
</div>
</transition>
<transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoStart(true)" v-show="!serverData.autoStart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span>
服务器自启:
<span style="color: #818181">关闭</span>
</div>
</transition>
</div>
</div>
<div class="Panel PanelGray" v-if="isFtpOpen">
<div class="PanelTitle">FTP 链接信息</div>
<div class="PanelBody">
<div class="PanelItem">
<span class="glyphicon glyphicon-user" aria-hidden="true"> </span>
账号: {{ MCSERVER.username + "." + serverData.name }}
</div>
<div class="PanelItem"> <div class="PanelItem">
<span class="glyphicon glyphicon-th-list" aria-hidden="true"> </span> <span class="glyphicon glyphicon-th-list" aria-hidden="true"> </span> 端口: {{ FTP_port }}
端口: {{ FTP_port }} </div>
</div> <div class="PanelItem">
<div class="PanelItem"> <span class="glyphicon glyphicon-lock" aria-hidden="true"></span> 密码:
<span class="glyphicon glyphicon-lock" aria-hidden="true"></span> <span style="color: #666666">&lt;与登陆密码相同&gt;</span>
密码: </div>
<span style="color: #666666">&lt;与登陆密码相同&gt;</span> <div class="PanelItem">
</div> <span class="glyphicon glyphicon-send" aria-hidden="true"></span> 模式:
<div class="PanelItem"> <span style="color: #666666">&lt;被动传输模式&gt;</span>
<span class="glyphicon glyphicon-send" aria-hidden="true"></span> </div>
模式: </div>
<span style="color: #666666">&lt;被动传输模式&gt;</span> </div>
</div> <div class="Panel PanelGray">
<div class="PanelTitle">普通外置接口</div>
<div class="PanelBody">
<div class="PanelItem">
<span class="glyphicon glyphicon-barcode" aria-hidden="true"> </span>
<span v-on:click="toAPI_JSON()">格式 JSON | API 接口</span>
</div>
</div>
</div>
</div> </div>
</div> <div class="col-md-9">
<div class="Panel PanelGray"> <div class="Panel PanelBlack">
<div class="PanelTitle">普通外置接口</div> <div class="PanelTitle">服务端控制组</div>
<div class="PanelBody"> <div class="PanelBody">
<div class="PanelItem"> <div class="row">
<span class="glyphicon glyphicon-barcode" aria-hidden="true"> </span> <div class="col-md-3 col-sm-6" v-on:click="RES.redirectPage('./template/component/terminal.html', null, '')">
<span v-on:click="toAPI_JSON()">格式 JSON | API 接口</span> <div class="PanelItemBlock">
</div> <div class="LogV">
</div> <span class="glyphicon glyphicon-console" aria-hidden="true"> </span>
</div> </div>
</div> <div class="LogK">命令控制台</div>
<div class="col-md-9"> </div>
<div class="Panel PanelBlack"> </div>
<div class="PanelTitle">服务端控制组</div> <div class="col-md-3 col-sm-6" v-on:click="toOnlineFs()">
<div class="PanelBody"> <div class="PanelItemBlock">
<div class="row"> <div class="LogV">
<div class="col-md-3 col-sm-6" v-on:click="RES.redirectPage('./template/component/terminal.html', null, '')"> <span class="glyphicon glyphicon-th-list" aria-hidden="true"> </span>
<div class="PanelItemBlock"> </div>
<div class="LogV"> <div class="LogK">文件在线管理</div>
<span class="glyphicon glyphicon-console" aria-hidden="true"> </span> </div>
</div> </div>
<div class="LogK">命令控制台</div> <div class="col-md-3 col-sm-6" v-on:click="toSchedule()">
</div> <div class="PanelItemBlock">
</div> <div class="LogV">
<div class="col-md-3 col-sm-6" v-on:click="toOnlineFs()"> <span class="glyphicon glyphicon-indent-right" aria-hidden="true"> </span>
<div class="PanelItemBlock"> </div>
<div class="LogV"> <div class="LogK">计划任务项目</div>
<span class="glyphicon glyphicon-th-list" aria-hidden="true"> </span> </div>
</div> </div>
<div class="LogK">文件在线管理</div> <div class="col-md-3 col-sm-6" v-on:click="toPingMCProtocol()">
</div> <div class="PanelItemBlock">
</div> <div class="LogV" style="font-size: 18px">
<div class="col-md-3 col-sm-6" v-on:click="toSchedule()"> <!-- <span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> -->
<div class="PanelItemBlock"> <strong>
<div class="LogV">
<span class="glyphicon glyphicon-indent-right" aria-hidden="true"> </span>
</div>
<div class="LogK">计划任务项目</div>
</div>
</div>
<div class="col-md-3 col-sm-6" v-on:click="toPingMCProtocol()">
<div class="PanelItemBlock">
<div class="LogV" style="font-size: 18px">
<!-- <span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> -->
<strong>
<span> <span>
<span style="color: rgb(38, 165, 26)" v-text="mcping.current_players"></span> <span style="color: rgb(38, 165, 26)" v-text="mcping.current_players"></span>
<span style="color: rgb(0, 0, 0)">/</span> <span style="color: rgb(0, 0, 0)">/</span>
<span style="color: rgb(38, 165, 26)" v-text="mcping.max_players"></span> <span style="color: rgb(38, 165, 26)" v-text="mcping.max_players"></span>
</span> </span>
</strong> </strong>
</div>
<div class="LogK">
<span>状态监控协议</span>
</div>
</div>
</div>
</div>
</div> </div>
<div class="LogK">
<span>状态监控协议</span>
</div>
</div>
</div> </div>
</div>
</div> </div>
</div> <div class="col-md-9" id="ChartCPUFor">
</div> <div class="Panel">
<div class="col-md-9" id="ChartCPUFor"> <div class="PanelTitle">中央处理器 使用率 %</div>
<div class="Panel"> <div class="PanelBody">
<div class="PanelTitle">中央处理器 使用率 %</div> <div class="row">
<div class="PanelBody"> <div id="ChartCPU" style="height: 280px; width: 100%"></div>
<div class="row"> </div>
<div id="ChartCPU" style="height: 280px; width: 100%"></div> </div>
</div> </div>
</div> </div>
</div> <div class="col-md-3"></div>
</div> <div class="col-md-9">
<div class="col-md-3"></div> <div class="Panel">
<div class="col-md-9"> <div class="PanelTitle">物理内存 使用率 %</div>
<div class="Panel"> <div class="PanelBody">
<div class="PanelTitle">物理内存 使用率 %</div> <div class="row">
<div class="PanelBody"> <div id="ChartRAM" style="height: 280px; width: 100%"></div>
<div class="row"> </div>
<div id="ChartRAM" style="height: 280px; width: 100%"></div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
</div>
</div> </div>
<script> <script>
MI.rListener("onload", function () { MI.rListener("onload", function() {
// 定义页面地址 // 定义页面地址
TOOLS.definePage("template/component/console", "server/console", MCSERVER.listenServername); TOOLS.definePage("template/component/console", "server/console", MCSERVER.listenServername);
var serverName = MCSERVER.listenServername; var serverName = MCSERVER.listenServername;
VIEW_MODEL.newVue("ConsolePanel", { VIEW_MODEL.newVue("ConsolePanel", {
el: "#ConsolePanel", el: "#ConsolePanel",
methods: { methods: {
toAutoRestart: function () { toAutoRestart: function() {
WS.sendMsg("server/console/autorestart", serverName); WS.sendMsg("server/console/autorestart", serverName);
}, },
toAutoStart: function () { toAutoStart: function() {
WS.sendMsg("server/console/autostart", serverName); WS.sendMsg("server/console/autostart", serverName);
}, },
toOnlineFs: function () { toOnlineFs: function() {
var path = MCSERVER.URL("fs_auth/auth/" + encodeURIComponent(serverName)); var path = MCSERVER.URL("fs_auth/auth/" + encodeURIComponent(serverName));
window.open(path); window.open(path);
}, },
toOpenServer: function () { toOpenServer: function() {
this.allowedStart = !this.allowedStart; if (!confirm("是否确定执行 [开启] 操作?")) return;
WS.sendMsg("server/console/open", serverName); this.allowedStart = !this.allowedStart;
}, WS.sendMsg("server/console/open", serverName);
toCommand: function (parCommand) { },
if (parCommand && typeof parCommand == "string") this.command = parCommand; toStopServer: function() {
var data = { if (!confirm("是否确定执行 [关闭] 操作?")) return;
command: this.command, this.toCommand('__stop__');
serverName: serverName },
}; toRestartServer: function() {
if (this.command.length >= 1 || typeof parCommand == "string") { if (!confirm("是否确定执行 [重启] 操作?")) return;
WS.sendMsg("server/console/command", JSON.stringify(data)); this.toCommand('__restart__');
} },
this.command = ""; toKillServer: function() {
}, if (!confirm("是否确定执行 [终止] 操作?")) return;
toProperties: function () { this.toCommand('__killserver__');
RES.redirectPage("./template/component/properties.html", "server/properties", serverName); },
}, toCommand: function(parCommand) {
toTerminal: function () { if (parCommand && typeof parCommand == "string") this.command = parCommand;
RES.redirectPage("./template/component/terminal.html", "server/console", serverName); var data = {
}, command: this.command,
toSchedule: function () { serverName: serverName
RES.redirectPage("./template/component/schedule.html", "schedule/list", serverName); };
}, if (this.command.length >= 1 || typeof parCommand == "string") {
toAPI_JSON: function () { WS.sendMsg("server/console/command", JSON.stringify(data));
window.open("/api/status/" + serverName); }
}, this.command = "";
toAPI_PAGE: function () { },
window.open("/api/status/" + serverName); toProperties: function() {
}, RES.redirectPage("./template/component/properties.html", "server/properties", serverName);
toPingMCProtocol: function () { },
PAGE.listenServername = MCSERVER.listenServername; toTerminal: function() {
TOOLS.popWind({ RES.redirectPage("./template/component/terminal.html", "server/console", serverName);
style: { },
maxWidth: "500px", toSchedule: function() {
top: "15%" RES.redirectPage("./template/component/schedule.html", "schedule/list", serverName);
},
toAPI_JSON: function() {
window.open("/api/status/" + serverName);
},
toAPI_PAGE: function() {
window.open("/api/status/" + serverName);
},
toPingMCProtocol: function() {
PAGE.listenServername = MCSERVER.listenServername;
TOOLS.popWind({
style: {
maxWidth: "500px",
top: "15%"
},
title: "监控协议配置",
template: "template/dialog/pingmc_config.html"
});
},
toTerminal: function() {
// 打开弹窗型终端
TOOLS.listenTerminal(serverName);
}
}, },
title: "监控协议配置", data: {
template: "template/dialog/pingmc_config.html" command: "",
}); allowedStart: true,
}, runStatusClass: "",
toTerminal: function () { username: MCSERVER.listenServername
// 打开弹窗型终端 },
TOOLS.listenTerminal(serverName); watch: {
} run: function(cur, old) {}
}, }
data: { });
command: "",
allowedStart: true, // 服务器状态请求
runStatusClass: "", PAGE.timerR = setInterval(function() {
username: MCSERVER.listenServername WS.sendMsg("server/console", MCSERVER.listenServername);
}, }, 3000);
watch: {
run: function (cur, old) {} //CPU
} var CPUoption = TOOLS.charts.DefOption;
var RAMoption = TOOLS.charts.DefOption;
//表格
var ChartCPU = null;
var ChartRAM = null;
PAGE.ChartLogIs = true;
TOOLS.charts.bulider(
"ChartCPU",
24, {},
function(chart) {
ChartCPU = chart;
function doing() {
chart.replaceData(VIEW_MODEL["ConsolePanel"].CPUlog);
//chart.pushData(getNowFormatDate(), GetRandomNum(1, 40));
chart.reOption();
if (PAGE.ChartLogIs) setTimeout(doing, 4000);
}
doing();
},
CPUoption
);
//ChartRAM
TOOLS.charts.bulider(
"ChartRAM",
24, {},
function(chart) {
ChartRAM = chart;
function doing() {
chart.replaceData(VIEW_MODEL["ConsolePanel"].RAMlog);
//chart.pushData(getNowFormatDate(), GetRandomNum(1, 40));
chart.reOption();
if (PAGE.ChartLogIs) setTimeout(doing, 4000);
}
doing();
},
CPUoption
);
PAGE.chartResizeFunc = function() {
ChartCPU.chart.resize();
ChartRAM.chart.resize();
};
MI.listener("colmchangeEnd", PAGE.chartResizeFunc);
MI.listener("resize", PAGE.chartResizeFunc);
}); });
// 服务器状态请求 MI.rListener("onend", function() {
PAGE.timerR = setInterval(function () { clearInterval(PAGE.timerR);
WS.sendMsg("server/console", MCSERVER.listenServername); MI.onDestroy("colmchangeEnd", PAGE.chartResizeFunc);
}, 3000); MI.onDestroy("resize", PAGE.chartResizeFunc);
PAGE.ChartLogIs = false;
//CPU });
var CPUoption = TOOLS.charts.DefOption; </script>
var RAMoption = TOOLS.charts.DefOption;
//表格
var ChartCPU = null;
var ChartRAM = null;
PAGE.ChartLogIs = true;
TOOLS.charts.bulider(
"ChartCPU",
24,
{},
function (chart) {
ChartCPU = chart;
function doing() {
chart.replaceData(VIEW_MODEL["ConsolePanel"].CPUlog);
//chart.pushData(getNowFormatDate(), GetRandomNum(1, 40));
chart.reOption();
if (PAGE.ChartLogIs) setTimeout(doing, 4000);
}
doing();
},
CPUoption
);
//ChartRAM
TOOLS.charts.bulider(
"ChartRAM",
24,
{},
function (chart) {
ChartRAM = chart;
function doing() {
chart.replaceData(VIEW_MODEL["ConsolePanel"].RAMlog);
//chart.pushData(getNowFormatDate(), GetRandomNum(1, 40));
chart.reOption();
if (PAGE.ChartLogIs) setTimeout(doing, 4000);
}
doing();
},
CPUoption
);
PAGE.chartResizeFunc = function () {
ChartCPU.chart.resize();
ChartRAM.chart.resize();
};
MI.listener("colmchangeEnd", PAGE.chartResizeFunc);
MI.listener("resize", PAGE.chartResizeFunc);
});
MI.rListener("onend", function () {
clearInterval(PAGE.timerR);
MI.onDestroy("colmchangeEnd", PAGE.chartResizeFunc);
MI.onDestroy("resize", PAGE.chartResizeFunc);
PAGE.ChartLogIs = false;
});
</script>