mirror of
https://github.com/louislam/dockge.git
synced 2026-05-21 14:02:17 +00:00
wip
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
<div class="function">
|
||||
<router-link v-if="!isEditMode" class="btn btn-normal" :to="terminalRouteLink">
|
||||
<font-awesome-icon icon="terminal" />
|
||||
Terminal
|
||||
Bash
|
||||
</router-link>
|
||||
</div>
|
||||
</div>
|
||||
@@ -160,12 +160,17 @@ export default defineComponent({
|
||||
return {
|
||||
name: "containerTerminal",
|
||||
params: {
|
||||
stackName: this.stackName,
|
||||
serviceName: this.name,
|
||||
type: "logs",
|
||||
type: "bash",
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
stackName() {
|
||||
return this.$parent.$parent.stack.name;
|
||||
},
|
||||
|
||||
service() {
|
||||
return this.jsonObject.services[this.name];
|
||||
},
|
||||
|
||||
@@ -20,7 +20,17 @@ export default {
|
||||
props: {
|
||||
name: {
|
||||
type: String,
|
||||
required: true,
|
||||
require: true,
|
||||
},
|
||||
|
||||
// Require if mode is interactive
|
||||
stackName: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
// Require if mode is interactive
|
||||
serviceName: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
rows: {
|
||||
@@ -99,7 +109,8 @@ export default {
|
||||
}
|
||||
});
|
||||
} else if (this.mode === "interactive") {
|
||||
this.$root.getSocket().emit("interactiveTerminal", this.name, (res) => {
|
||||
console.debug("Create Interactive terminal:", this.name);
|
||||
this.$root.getSocket().emit("interactiveTerminal", this.stackName, this.serviceName, (res) => {
|
||||
if (!res.ok) {
|
||||
this.$root.toastRes(res);
|
||||
}
|
||||
@@ -184,7 +195,13 @@ export default {
|
||||
},
|
||||
|
||||
interactiveTerminalConfig() {
|
||||
|
||||
this.terminal.onKey(e => {
|
||||
this.$root.getSocket().emit("terminalInput", this.name, e.key, (res) => {
|
||||
if (!res.ok) {
|
||||
this.$root.toastRes(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -193,6 +210,7 @@ export default {
|
||||
<style scoped lang="scss">
|
||||
.main-terminal {
|
||||
height: 100%;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ export default defineComponent({
|
||||
socket.on("terminalWrite", (terminalName, data) => {
|
||||
const terminal = terminalMap.get(terminalName);
|
||||
if (!terminal) {
|
||||
console.error("Terminal not found: " + terminalName);
|
||||
//console.error("Terminal not found: " + terminalName);
|
||||
return;
|
||||
}
|
||||
terminal.write(data);
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
|
||||
<!-- Combined Terminal Output -->
|
||||
<div v-show="!isEditMode">
|
||||
<h4 class="mb-3">Logs</h4>
|
||||
<h4 class="mb-3">Terminal</h4>
|
||||
<Terminal
|
||||
ref="combinedTerminal"
|
||||
class="mb-3 terminal"
|
||||
@@ -135,13 +135,15 @@
|
||||
{{ yamlError }}
|
||||
</div>
|
||||
|
||||
<h4 class="mb-3">{{ $tc("network", 2) }}</h4>
|
||||
<div class="shadow-box big-padding mb-3">
|
||||
<NetworkInput />
|
||||
</div>
|
||||
<div v-if="isEditMode">
|
||||
<h4 class="mb-3">{{ $tc("network", 2) }}</h4>
|
||||
<div class="shadow-box big-padding mb-3">
|
||||
<NetworkInput />
|
||||
</div>
|
||||
|
||||
<h4 class="mb-3">{{ $tc("volume", 2) }}</h4>
|
||||
<div class="shadow-box big-padding mb-3">
|
||||
<h4 class="mb-3">{{ $tc("volume", 2) }}</h4>
|
||||
<div class="shadow-box big-padding mb-3">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="shadow-box big-padding mb-3">
|
||||
@@ -531,43 +533,6 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
combineNetworks() {
|
||||
let networks = this.jsonConfig.networks;
|
||||
|
||||
if (!networks) {
|
||||
networks = {};
|
||||
}
|
||||
|
||||
for (let serviceName in this.jsonConfig.services) {
|
||||
|
||||
let service = this.jsonConfig.services[serviceName];
|
||||
let serviceNetworks = service.networks;
|
||||
|
||||
if (!networks) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// If it is an array, it should be array of string
|
||||
if (Array.isArray(serviceNetworks)) {
|
||||
for (let n of serviceNetworks) {
|
||||
console.log(n);
|
||||
if (!n) {
|
||||
continue;
|
||||
}
|
||||
if (!networks[n]) {
|
||||
networks[n] = {};
|
||||
}
|
||||
}
|
||||
|
||||
} else if (typeof serviceNetworks === "object") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
console.debug(networks);
|
||||
|
||||
return networks;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,37 +1,39 @@
|
||||
<template>
|
||||
<transition name="slide-fade" appear>
|
||||
<div>
|
||||
<h1 class="mb-3">Console</h1>
|
||||
<h1 class="mb-3">Bash</h1>
|
||||
<p>
|
||||
Stack: {{ stackName }}<br />
|
||||
Container: {{ serviceName }}
|
||||
</p>
|
||||
|
||||
<div>
|
||||
<p>
|
||||
Allowed commands:
|
||||
<template v-for="(command, index) in allowedCommandList" :key="command">
|
||||
<code>{{ command }}</code>
|
||||
|
||||
<!-- No comma at the end -->
|
||||
<span v-if="index !== allowedCommandList.length - 1">, </span>
|
||||
</template>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<Terminal class="terminal" :rows="20" mode="mainTerminal" name="console"></Terminal>
|
||||
<Terminal class="terminal" :rows="20" mode="interactive" :name="terminalName" :stack-name="stackName" :service-name="serviceName"></Terminal>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { allowedCommandList } from "../../../backend/util-common";
|
||||
import { getContainerExecTerminalName } from "../../../backend/util-common";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
allowedCommandList,
|
||||
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
stackName() {
|
||||
return this.$route.params.stackName;
|
||||
},
|
||||
serviceName() {
|
||||
return this.$route.params.serviceName;
|
||||
},
|
||||
terminalName() {
|
||||
return getContainerExecTerminalName(this.stackName, this.serviceName, 0);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
|
||||
@@ -39,13 +39,11 @@ const routes = [
|
||||
name: "compose",
|
||||
component: Compose,
|
||||
props: true,
|
||||
children: [
|
||||
{
|
||||
path: "/compose/:stackName/terminal/:serviceName/:type",
|
||||
component: ContainerTerminal,
|
||||
name: "containerTerminal",
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: "/terminal/:stackName/:serviceName/:type",
|
||||
component: ContainerTerminal,
|
||||
name: "containerTerminal",
|
||||
},
|
||||
]
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user