mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-21 21:33:18 +01:00
feat: adds shell behind a flag or env var (#3737)
This commit is contained in:
@@ -135,19 +135,21 @@
|
|||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<li class="line" v-if="host.type === 'local'"></li>
|
<template v-if="enableShell && host.type === 'local'">
|
||||||
<li v-if="host.type === 'local'">
|
<li class="line"></li>
|
||||||
|
<li>
|
||||||
<a @click.prevent="showDrawer(Terminal, { container, action: 'attach' }, 'lg')">
|
<a @click.prevent="showDrawer(Terminal, { container, action: 'attach' }, 'lg')">
|
||||||
<ri:terminal-window-fill /> Attach
|
<ri:terminal-window-fill /> Attach
|
||||||
<KeyShortcut char="a" :modifiers="['shift', 'meta']" />
|
<KeyShortcut char="a" :modifiers="['shift', 'meta']" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li v-if="host.type === 'local'">
|
<li>
|
||||||
<a @click.prevent="showDrawer(Terminal, { container, action: 'exec' }, 'lg')">
|
<a @click.prevent="showDrawer(Terminal, { container, action: 'exec' }, 'lg')">
|
||||||
<material-symbols:terminal /> Shell
|
<material-symbols:terminal /> Shell
|
||||||
<KeyShortcut char="e" :modifiers="['shift', 'meta']" />
|
<KeyShortcut char="e" :modifiers="['shift', 'meta']" />
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -160,7 +162,7 @@ import LogAnalytics from "../LogViewer/LogAnalytics.vue";
|
|||||||
import Terminal from "@/components/Terminal.vue";
|
import Terminal from "@/components/Terminal.vue";
|
||||||
|
|
||||||
const { showSearch } = useSearchFilter();
|
const { showSearch } = useSearchFilter();
|
||||||
const { enableActions } = config;
|
const { enableActions, enableShell } = config;
|
||||||
const { streamConfig, hasComplexLogs, levels } = useLoggingContext();
|
const { streamConfig, hasComplexLogs, levels } = useLoggingContext();
|
||||||
const showDrawer = useDrawer();
|
const showDrawer = useDrawer();
|
||||||
|
|
||||||
@@ -177,20 +179,21 @@ onKeyStroke("f", (e) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (enableShell) {
|
||||||
onKeyStroke("a", (e) => {
|
onKeyStroke("a", (e) => {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
||||||
showDrawer(Terminal, { container, action: "attach" }, "lg");
|
showDrawer(Terminal, { container, action: "attach" }, "lg");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
onKeyStroke("e", (e) => {
|
onKeyStroke("e", (e) => {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
if ((e.ctrlKey || e.metaKey) && e.shiftKey) {
|
||||||
showDrawer(Terminal, { container, action: "exec" }, "lg");
|
showDrawer(Terminal, { container, action: "exec" }, "lg");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const downloadParams = computed(() =>
|
const downloadParams = computed(() =>
|
||||||
Object.entries(toValue(streamConfig))
|
Object.entries(toValue(streamConfig))
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface Config {
|
|||||||
hosts: Host[];
|
hosts: Host[];
|
||||||
authProvider: "simple" | "none" | "forward-proxy";
|
authProvider: "simple" | "none" | "forward-proxy";
|
||||||
enableActions: boolean;
|
enableActions: boolean;
|
||||||
|
enableShell: boolean;
|
||||||
user?: {
|
user?: {
|
||||||
username: string;
|
username: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ type Args struct {
|
|||||||
AuthHeaderName string `arg:"--auth-header-name,env:DOZZLE_AUTH_HEADER_NAME" default:"Remote-Name" help:"sets the HTTP Header to use for name in Forward Proxy configuration."`
|
AuthHeaderName string `arg:"--auth-header-name,env:DOZZLE_AUTH_HEADER_NAME" default:"Remote-Name" help:"sets the HTTP Header to use for name in Forward Proxy configuration."`
|
||||||
AuthHeaderFilter string `arg:"--auth-header-filter,env:DOZZLE_AUTH_HEADER_FILTER" default:"Remote-Filter" help:"sets the HTTP Header to use for filtering in Forward Proxy configuration."`
|
AuthHeaderFilter string `arg:"--auth-header-filter,env:DOZZLE_AUTH_HEADER_FILTER" default:"Remote-Filter" help:"sets the HTTP Header to use for filtering in Forward Proxy configuration."`
|
||||||
EnableActions bool `arg:"--enable-actions,env:DOZZLE_ENABLE_ACTIONS" default:"false" help:"enables essential actions on containers from the web interface."`
|
EnableActions bool `arg:"--enable-actions,env:DOZZLE_ENABLE_ACTIONS" default:"false" help:"enables essential actions on containers from the web interface."`
|
||||||
|
EnableShell bool `arg:"--enable-shell,env:DOZZLE_ENABLE_SHELL" default:"false" help:"enables shell access to containers from the web interface."`
|
||||||
FilterStrings []string `arg:"env:DOZZLE_FILTER,--filter,separate" help:"filters docker containers using Docker syntax."`
|
FilterStrings []string `arg:"env:DOZZLE_FILTER,--filter,separate" help:"filters docker containers using Docker syntax."`
|
||||||
Filter map[string][]string `arg:"-"`
|
Filter map[string][]string `arg:"-"`
|
||||||
RemoteHost []string `arg:"env:DOZZLE_REMOTE_HOST,--remote-host,separate" help:"list of hosts to connect remotely"`
|
RemoteHost []string `arg:"env:DOZZLE_REMOTE_HOST,--remote-host,separate" help:"list of hosts to connect remotely"`
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
|
|||||||
config["hostname"] = h.config.Hostname
|
config["hostname"] = h.config.Hostname
|
||||||
config["hosts"] = hosts
|
config["hosts"] = hosts
|
||||||
config["enableActions"] = h.config.EnableActions
|
config["enableActions"] = h.config.EnableActions
|
||||||
|
config["enableShell"] = h.config.EnableShell
|
||||||
}
|
}
|
||||||
|
|
||||||
if user != nil {
|
if user != nil {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type Config struct {
|
|||||||
Dev bool
|
Dev bool
|
||||||
Authorization Authorization
|
Authorization Authorization
|
||||||
EnableActions bool
|
EnableActions bool
|
||||||
|
EnableShell bool
|
||||||
Labels container.ContainerLabels
|
Labels container.ContainerLabels
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,8 +108,6 @@ func createRouter(h *handler) *chi.Mux {
|
|||||||
r.Get("/hosts/{host}/containers/{id}/logs/stream", h.streamContainerLogs)
|
r.Get("/hosts/{host}/containers/{id}/logs/stream", h.streamContainerLogs)
|
||||||
r.Get("/hosts/{host}/logs/stream", h.streamHostLogs)
|
r.Get("/hosts/{host}/logs/stream", h.streamHostLogs)
|
||||||
r.Get("/hosts/{host}/containers/{id}/logs", h.fetchLogsBetweenDates)
|
r.Get("/hosts/{host}/containers/{id}/logs", h.fetchLogsBetweenDates)
|
||||||
r.Get("/hosts/{host}/containers/{id}/attach", h.attach)
|
|
||||||
r.Get("/hosts/{host}/containers/{id}/exec", h.exec)
|
|
||||||
r.Get("/hosts/{host}/logs/mergedStream/{ids}", h.streamLogsMerged)
|
r.Get("/hosts/{host}/logs/mergedStream/{ids}", h.streamLogsMerged)
|
||||||
r.Get("/containers/{hostIds}/download", h.downloadLogs) // formatted as host:container,host:container
|
r.Get("/containers/{hostIds}/download", h.downloadLogs) // formatted as host:container,host:container
|
||||||
r.Get("/stacks/{stack}/logs/stream", h.streamStackLogs)
|
r.Get("/stacks/{stack}/logs/stream", h.streamStackLogs)
|
||||||
@@ -118,6 +117,10 @@ func createRouter(h *handler) *chi.Mux {
|
|||||||
if h.config.EnableActions {
|
if h.config.EnableActions {
|
||||||
r.Post("/hosts/{host}/containers/{id}/actions/{action}", h.containerActions)
|
r.Post("/hosts/{host}/containers/{id}/actions/{action}", h.containerActions)
|
||||||
}
|
}
|
||||||
|
if h.config.EnableShell {
|
||||||
|
r.Get("/hosts/{host}/containers/{id}/attach", h.attach)
|
||||||
|
r.Get("/hosts/{host}/containers/{id}/exec", h.exec)
|
||||||
|
}
|
||||||
r.Get("/releases", h.releases)
|
r.Get("/releases", h.releases)
|
||||||
r.Get("/profile/avatar", h.avatar)
|
r.Get("/profile/avatar", h.avatar)
|
||||||
r.Patch("/profile", h.updateProfile)
|
r.Patch("/profile", h.updateProfile)
|
||||||
|
|||||||
Reference in New Issue
Block a user