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

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

View File

@ -5,24 +5,20 @@
<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> <span class="glyphicon glyphicon-tasks" aria-hidden="true"> </span> CPU 使用率: {{ sysCpu }} %
CPU 使用率: {{ sysCpu }} %
</div> </div>
<div class="PanelItem"> <div class="PanelItem">
<span class="glyphicon glyphicon-equalizer" aria-hidden="true"> </span> <span class="glyphicon glyphicon-equalizer" aria-hidden="true"> </span> 内存 使用率: {{ (100 - sysMonery).toFixed(1) }} %
内存 使用率: {{ (100 - sysMonery).toFixed(1) }} %
</div> </div>
<div class="PanelItem" v-if="run"> <div class="PanelItem" v-if="run">
<span class="glyphicon glyphicon-ok" aria-hidden="true"> </span> <span class="glyphicon glyphicon-ok" aria-hidden="true"> </span>
<span style="color: #23970c"> 状态: 正在运行..</span> <span style="color: #23970c"> 状态: 正在运行..</span>
</div> </div>
<div class="PanelItem" v-else> <div class="PanelItem" v-else>
<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> <span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> 状态: 未运行
状态: 未运行
</div> </div>
</div> </div>
</div> </div>
@ -30,28 +26,23 @@
<div class="PanelTitle">服务端操作</div> <div class="PanelTitle">服务端操作</div>
<div class="PanelBody"> <div class="PanelBody">
<div class="PanelItem" v-on:click="toTerminal()"> <div class="PanelItem" v-on:click="toTerminal()">
<span class="glyphicon glyphicon-unchecked" aria-hidden="true"> </span> <span class="glyphicon glyphicon-unchecked" aria-hidden="true"> </span> 模拟型终端
模拟型终端
</div> </div>
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toOpenServer()" v-show="!run"> <div class="PanelItem" v-on:click="toOpenServer" v-show="!run">
<span class="glyphicon glyphicon-play" aria-hidden="true"> </span> <span class="glyphicon glyphicon-play" aria-hidden="true"> </span> 开启服务器
开启服务器
</div> </div>
</transition> </transition>
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toCommand('__stop__')" v-show="run"> <div class="PanelItem" v-on:click="toStopServer" v-show="run">
<span class="glyphicon glyphicon-pause" aria-hidden="true"> </span> <span class="glyphicon glyphicon-pause" aria-hidden="true"> </span> 关闭服务器
关闭服务器
</div> </div>
</transition> </transition>
<div class="PanelItem" v-on:click="toCommand('__restart__')" v-show="run"> <div class="PanelItem" v-on:click="toRestartServer" v-show="run">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"> </span> <span class="glyphicon glyphicon-refresh" aria-hidden="true"> </span> 重启服务器
重启服务器
</div> </div>
<div class="PanelItem" v-on:click="toCommand('__killserver__')" v-show="run"> <div class="PanelItem" v-on:click="toKillServer" v-show="run">
<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> <span class="glyphicon glyphicon-remove" aria-hidden="true"> </span> 强制性结束进程
强制性结束进程
</div> </div>
</div> </div>
</div> </div>
@ -59,20 +50,17 @@
<div class="PanelTitle">崩溃监视与配置</div> <div class="PanelTitle">崩溃监视与配置</div>
<div class="PanelBody"> <div class="PanelBody">
<div class="PanelItem" v-on:click="toProperties()"> <div class="PanelItem" v-on:click="toProperties()">
<span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> <span class="glyphicon glyphicon-cog" aria-hidden="true"> </span> Server.properties 配置文件
Server.properties 配置文件
</div> </div>
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoRestart(false)" v-show="serverData.autoRestart"> <div class="PanelItem" v-on:click="toAutoRestart(false)" v-show="serverData.autoRestart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 崩溃重启:
崩溃重启:
<span style="color: #29b90c">打开</span> <span style="color: #29b90c">打开</span>
</div> </div>
</transition> </transition>
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoRestart(true)" v-show="!serverData.autoRestart"> <div class="PanelItem" v-on:click="toAutoRestart(true)" v-show="!serverData.autoRestart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 崩溃重启:
崩溃重启:
<span style="color: #818181">关闭</span> <span style="color: #818181">关闭</span>
</div> </div>
</transition> </transition>
@ -83,15 +71,13 @@
<div class="PanelBody"> <div class="PanelBody">
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoStart(false)" v-show="serverData.autoStart"> <div class="PanelItem" v-on:click="toAutoStart(false)" v-show="serverData.autoStart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 服务器自启:
服务器自启:
<span style="color: #29b90c">打开</span> <span style="color: #29b90c">打开</span>
</div> </div>
</transition> </transition>
<transition name="slide-fade"> <transition name="slide-fade">
<div class="PanelItem" v-on:click="toAutoStart(true)" v-show="!serverData.autoStart"> <div class="PanelItem" v-on:click="toAutoStart(true)" v-show="!serverData.autoStart">
<span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> <span class="glyphicon glyphicon-retweet" aria-hidden="true"> </span> 服务器自启:
服务器自启:
<span style="color: #818181">关闭</span> <span style="color: #818181">关闭</span>
</div> </div>
</transition> </transition>
@ -101,22 +87,18 @@
<div class="PanelTitle">FTP 链接信息</div> <div class="PanelTitle">FTP 链接信息</div>
<div class="PanelBody"> <div class="PanelBody">
<div class="PanelItem"> <div class="PanelItem">
<span class="glyphicon glyphicon-user" aria-hidden="true"> </span> <span class="glyphicon glyphicon-user" aria-hidden="true"> </span> 账号: {{ MCSERVER.username + "." + serverData.name }}
账号: {{ MCSERVER.username + "." + serverData.name }}
</div> </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> <span style="color: #666666">&lt;与登陆密码相同&gt;</span>
</div> </div>
<div class="PanelItem"> <div class="PanelItem">
<span class="glyphicon glyphicon-send" aria-hidden="true"></span> <span class="glyphicon glyphicon-send" aria-hidden="true"></span> 模式:
模式:
<span style="color: #666666">&lt;被动传输模式&gt;</span> <span style="color: #666666">&lt;被动传输模式&gt;</span>
</div> </div>
</div> </div>
@ -206,7 +188,7 @@
</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);
@ -215,21 +197,34 @@
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() {
if (!confirm("是否确定执行 [开启] 操作?")) return;
this.allowedStart = !this.allowedStart; this.allowedStart = !this.allowedStart;
WS.sendMsg("server/console/open", serverName); WS.sendMsg("server/console/open", serverName);
}, },
toCommand: function (parCommand) { toStopServer: function() {
if (!confirm("是否确定执行 [关闭] 操作?")) return;
this.toCommand('__stop__');
},
toRestartServer: function() {
if (!confirm("是否确定执行 [重启] 操作?")) return;
this.toCommand('__restart__');
},
toKillServer: function() {
if (!confirm("是否确定执行 [终止] 操作?")) return;
this.toCommand('__killserver__');
},
toCommand: function(parCommand) {
if (parCommand && typeof parCommand == "string") this.command = parCommand; if (parCommand && typeof parCommand == "string") this.command = parCommand;
var data = { var data = {
command: this.command, command: this.command,
@ -240,22 +235,22 @@
} }
this.command = ""; this.command = "";
}, },
toProperties: function () { toProperties: function() {
RES.redirectPage("./template/component/properties.html", "server/properties", serverName); RES.redirectPage("./template/component/properties.html", "server/properties", serverName);
}, },
toTerminal: function () { toTerminal: function() {
RES.redirectPage("./template/component/terminal.html", "server/console", serverName); RES.redirectPage("./template/component/terminal.html", "server/console", serverName);
}, },
toSchedule: function () { toSchedule: function() {
RES.redirectPage("./template/component/schedule.html", "schedule/list", serverName); RES.redirectPage("./template/component/schedule.html", "schedule/list", serverName);
}, },
toAPI_JSON: function () { toAPI_JSON: function() {
window.open("/api/status/" + serverName); window.open("/api/status/" + serverName);
}, },
toAPI_PAGE: function () { toAPI_PAGE: function() {
window.open("/api/status/" + serverName); window.open("/api/status/" + serverName);
}, },
toPingMCProtocol: function () { toPingMCProtocol: function() {
PAGE.listenServername = MCSERVER.listenServername; PAGE.listenServername = MCSERVER.listenServername;
TOOLS.popWind({ TOOLS.popWind({
style: { style: {
@ -266,7 +261,7 @@
template: "template/dialog/pingmc_config.html" template: "template/dialog/pingmc_config.html"
}); });
}, },
toTerminal: function () { toTerminal: function() {
// 打开弹窗型终端 // 打开弹窗型终端
TOOLS.listenTerminal(serverName); TOOLS.listenTerminal(serverName);
} }
@ -278,12 +273,12 @@
username: MCSERVER.listenServername username: MCSERVER.listenServername
}, },
watch: { watch: {
run: function (cur, old) {} run: function(cur, old) {}
} }
}); });
// 服务器状态请求 // 服务器状态请求
PAGE.timerR = setInterval(function () { PAGE.timerR = setInterval(function() {
WS.sendMsg("server/console", MCSERVER.listenServername); WS.sendMsg("server/console", MCSERVER.listenServername);
}, 3000); }, 3000);
@ -297,9 +292,8 @@
PAGE.ChartLogIs = true; PAGE.ChartLogIs = true;
TOOLS.charts.bulider( TOOLS.charts.bulider(
"ChartCPU", "ChartCPU",
24, 24, {},
{}, function(chart) {
function (chart) {
ChartCPU = chart; ChartCPU = chart;
function doing() { function doing() {
@ -315,9 +309,8 @@
//ChartRAM //ChartRAM
TOOLS.charts.bulider( TOOLS.charts.bulider(
"ChartRAM", "ChartRAM",
24, 24, {},
{}, function(chart) {
function (chart) {
ChartRAM = chart; ChartRAM = chart;
function doing() { function doing() {
@ -331,7 +324,7 @@
CPUoption CPUoption
); );
PAGE.chartResizeFunc = function () { PAGE.chartResizeFunc = function() {
ChartCPU.chart.resize(); ChartCPU.chart.resize();
ChartRAM.chart.resize(); ChartRAM.chart.resize();
}; };
@ -340,7 +333,7 @@
MI.listener("resize", PAGE.chartResizeFunc); MI.listener("resize", PAGE.chartResizeFunc);
}); });
MI.rListener("onend", function () { MI.rListener("onend", function() {
clearInterval(PAGE.timerR); clearInterval(PAGE.timerR);
MI.onDestroy("colmchangeEnd", PAGE.chartResizeFunc); MI.onDestroy("colmchangeEnd", PAGE.chartResizeFunc);
MI.onDestroy("resize", PAGE.chartResizeFunc); MI.onDestroy("resize", PAGE.chartResizeFunc);