forked from mirror/MCSManager
新增 Docker Config 存储
This commit is contained in:
parent
da63c8e4ca
commit
a09307fc6f
@ -32,9 +32,15 @@ class MinecraftServer extends ServerProcess {
|
||||
this.properties = undefined; //服务端配置表
|
||||
|
||||
//Docker 容器是否启用
|
||||
this.isDocker = false;
|
||||
// this.isDocker = false;
|
||||
//Docker 配置项目
|
||||
this.dockerConfig = {};
|
||||
this.dataModel.dockerConfig = {
|
||||
dockerCommand: 'docker run -i -m ${xmx} -v ${serverpath}:/mcsd/ ${ports} ${imagename} ${commande}',
|
||||
dockerImageName: "mcsd",
|
||||
dockerXmx: "",
|
||||
dockerPorts: "",
|
||||
isDocker: false
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,8 @@
|
||||
},
|
||||
methods: {
|
||||
toDocker: function () {
|
||||
var that = this;
|
||||
// var that = this;
|
||||
PAGE.selectServerName = this.oldServerName;
|
||||
TOOLS.popWind({
|
||||
style: {
|
||||
maxWidth: "600px",
|
||||
@ -152,8 +153,8 @@
|
||||
title: "Minecraft Docker 配置",
|
||||
template: "template/dialog/docker_config.html",
|
||||
callback: function (result) {
|
||||
if (!result) return;
|
||||
console.log(result)
|
||||
// if (!result) return;
|
||||
// console.log(result)
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -9,7 +9,7 @@
|
||||
<b> 启用 Docker 容器</b>
|
||||
</p>
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-addon" id="sizing-addon3">启动命令</span>
|
||||
<span class="input-group-addon" id="sizing-addon3">命令模板</span>
|
||||
<input type="text" class="form-control" placeholder="不推荐修改,Docker run -i -v /xxxxx:/xxxxx -p xxxx:xxxx /bin/bash" aria-describedby="sizing-addon3"
|
||||
v-model="dockerCommand">
|
||||
</div>
|
||||
@ -35,23 +35,27 @@
|
||||
|
||||
</div>
|
||||
<script>
|
||||
new Vue({
|
||||
el: "#DialogDockerConfig",
|
||||
data: {
|
||||
dockerCommand: "",
|
||||
dockerImageName: "",
|
||||
dockerXmx: "",
|
||||
dockerPorts: "",
|
||||
isDocker: false
|
||||
},
|
||||
methods: {
|
||||
ok: function () {
|
||||
TOOLS.popWindClose({
|
||||
dockerCommand: this.dockerCommand,
|
||||
dockerImageName: this.dockerImageName,
|
||||
isDocker: this.isDocker
|
||||
});
|
||||
console.log(PAGE.selectServerName)
|
||||
WS.sendMsg('docker/config', PAGE.selectServerName, function (obj) {
|
||||
|
||||
new Vue({
|
||||
el: "#DialogDockerConfig",
|
||||
data: obj.ResponseValue,
|
||||
methods: {
|
||||
ok: function () {
|
||||
WS.sendMsg('docker/setconfig', JSON.stringify({
|
||||
serverName: PAGE.selectServerName,
|
||||
dockerConfig: {
|
||||
dockerCommand: this.dockerCommand,
|
||||
dockerImageName: this.dockerImageName,
|
||||
dockerXmx: this.dockerXmx,
|
||||
dockerPorts: this.dockerPorts,
|
||||
isDocker: this.isDocker
|
||||
}
|
||||
}));
|
||||
TOOLS.popWindClose();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
@ -80,4 +80,32 @@ WebSocketObserver().listener('docker/new', (data) => {
|
||||
WebSocketObserver().listener('docker/res', (data) => {
|
||||
if (!permssion.isMaster(data.WsSession)) return;
|
||||
response.wsSend(data.ws, 'docker/res', MCSERVER.PAGE.DockerRes);
|
||||
})
|
||||
})
|
||||
|
||||
//获取配置
|
||||
WebSocketObserver().listener('docker/config', (data) => {
|
||||
if (!permssion.isMaster(data.WsSession)) return;
|
||||
let serverName = data.body || "";
|
||||
if (serverName) {
|
||||
let mcserver = serverModel.ServerManager().getServer(serverName);
|
||||
response.wsSend(data.ws, 'docker/config', mcserver.dataModel.dockerConfig);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//设置配置
|
||||
WebSocketObserver().listener('docker/setconfig', (data) => {
|
||||
if (!permssion.isMaster(data.WsSession)) return;
|
||||
// {
|
||||
// serverName: "xxxx",
|
||||
// dockerConfig: { ... }
|
||||
// }
|
||||
let jsonObj = JSON.parse(data.body);
|
||||
if (jsonObj.serverName) {
|
||||
let serverName = jsonObj.serverName;
|
||||
let mcserver = serverModel.ServerManager().getServer(serverName);
|
||||
mcserver.dataModel.dockerConfig = jsonObj.dockerConfig;
|
||||
mcserver.dataModel.save();
|
||||
response.wsMsgWindow(data.ws, '操作成功,数据已保存');
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user