Skip to content

Container control buttons #649

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mizady
Copy link

@mizady mizady commented Oct 28, 2024

⚠️⚠️⚠️ Since we do not accept all types of pull requests and do not want to waste your time. Please be sure that you have read pull request rules:
https://github.com/louislam/dockge/blob/master/CONTRIBUTING.md

Tick the checkbox if you understand [x]:

  • I have read and understand the pull request rules.

Description

New Feature - Control of individual containers for starting, stopping, and restarting.

Fixes #(issue)
Fixes having to restart or stop and start the entire stack when you just want to do one container

Type of change

  • User interface (UI)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (only to change a screenshot so the service buttons are shown)

Checklist

  • My code follows the style guidelines of this project
  • I ran ESLint and other linters for modified files (I didn't run it but the minor modifications kept to already used patterns and practices)
  • I have performed a self-review of my own code and tested it
  • I have commented my code, particularly in hard-to-understand areas
    (including JSDoc for methods)
  • My changes generate no new warnings
  • My code needed automated testing. I have added them (this is optional task)

Screenshots (if any)

Screenshot 2024-10-28 091747
Screenshot 2024-10-28 091922

mizady added 4 commits August 8, 2024 13:30
Added start and stop service buttons for each service in a stack by changes to the container and compose components as well as the socket handler and the stack class.
added restart service/container button as well as fixed start/stop buttons for correct statuses of healthy/unhealthy
@mizady
Copy link
Author

mizady commented Oct 28, 2024

I didn't have any of the errors coming up in the checks when i built it or when i ran the built docker container on my end. Most all of those errors appear to be code I did not modify so I'm not sure if that is relevant to these modifications.

swapped to double quotes from singles on service functions
@Chathula
Copy link

Waiting for this!

@Chathula
Copy link

Chathula commented Nov 14, 2024

@louislam why we don't merge this pr?

@xHyperElectric
Copy link

@louislam please merge this, this feature is the only feature I think is missing from dockge

@m3baid
Copy link

m3baid commented Dec 2, 2024

Waiting for this to be in the Image.

@cmcooper1980
Copy link

@Chathula, @m3baid I was curious about this being merged too...however, if you haven't forked and merged this yourself and curious to see controls, feel free to pull from my fork...I merged a bunch of PRs that looked interesting or at least the ones I was interested in...

@louislam louislam added this to the 1.6.0 milestone Dec 27, 2024
@wsw70
Copy link

wsw70 commented Feb 17, 2025

Could this please be merged? This is a very much required feature that will really make dockge stand out.

@Triskae
Copy link

Triskae commented Feb 24, 2025

I tried this when merged on my fork, and seem to have no effect on the containers ...

@mizady
Copy link
Author

mizady commented Feb 25, 2025

@Triskae not sure if anything changed as there has been some version changes to a lot of packages and I have not updated and tested my dockge docker build as I spent far longer than i'd like to admit getting it to build on my test system at the time. I did put a docker image up on docker hub thejericko/dockge:latest but like I said it's not the latest dockge version since the update was released right after I built that.

@Triskae
Copy link

Triskae commented Feb 25, 2025

@Triskae not sure if anything changed as there has been some version changes to a lot of packages and I have not updated and tested my dockge docker build as I spent far longer than i'd like to admit getting it to build on my test system at the time. I did put a docker image up on docker hub thejericko/dockge:latest but like I said it's not the latest dockge version since the update was released right after I built that.

I understand, I will take a look if can make it work ! Or if you want, you can take a look too.

I spent far longer than i'd like to admit getting it to build on my test system

Ooooh yeah me too .... on macos with M2 Chip impossible for me to getting it to build, had to create a linux VM ....

cmcooper1980 added a commit to cmcooper1980/dockge that referenced this pull request Feb 26, 2025
tobi1449 added a commit to tobi1449/dockge that referenced this pull request Feb 26, 2025
tobi1449 added a commit to tobi1449/dockge that referenced this pull request Mar 1, 2025
@tobi1449
Copy link

tobi1449 commented Mar 1, 2025

FYI, when testing this I noticed that I'm getting quite a few JS warnings in my browser.
Add the new "processing" prop and the "start-service", "stop-service" and "restart-service" events to the container component seemed to fix them (see tobi1449@ee0c54b).

stack.joinCombinedTerminal(socket); // Ensure the combined terminal is joined
callbackResult({
ok: true,
msg: "Service" + serviceName + " started"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg: "Service" + serviceName + " started"
msg: "Service " + serviceName + " started"

await stack.stopService(socket, serviceName);
callbackResult({
ok: true,
msg: "Service" + serviceName + " stopped"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg: "Service" + serviceName + " stopped"
msg: "Service " + serviceName + " stopped"

await stack.restartService(socket, serviceName);
callbackResult({
ok: true,
msg: "Service" + serviceName + " restarted"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
msg: "Service" + serviceName + " restarted"
msg: "Service " + serviceName + " restarted"

@wsw70
Copy link

wsw70 commented Apr 29, 2025

It would be awesome to merge this

Dracrius added a commit to Dracrius/dockge that referenced this pull request Jun 2, 2025
Merge @mizady's pull request adding sub container control buttons.
Dracrius added a commit to Dracrius/dockge that referenced this pull request Jun 2, 2025
Merge @mizady's pull request adding sub container control buttons.
Dracrius added a commit to Dracrius/dockge that referenced this pull request Jun 6, 2025
Merged @mizady's pull request adding container control buttons.
Dracrius added a commit to Dracrius/dockge that referenced this pull request Jun 6, 2025
- switch to a button group and matched existing UI style (no more eye searing stop and restart buttons)
- Fixed message output to include a space after Service
- Added Processing prop and Start,Stop,Restart events
Comment on lines 19 to +43
<router-link v-if="!isEditMode" class="btn btn-normal" :to="terminalRouteLink" disabled="">
<font-awesome-icon icon="terminal" />
Bash
</router-link>
<button v-if="status !== 'running' && status !== 'healthy'"
class="btn btn-primary me-2"
:disabled="processing"
@click="startService">
<font-awesome-icon icon="play" class="me-1" />
Start
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-danger me-2"
:disabled="processing"
@click="stopService">
<font-awesome-icon icon="stop" class="me-1" />
Stop
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-warning me-2"
:disabled="processing"
@click="restartService">
<font-awesome-icon icon="sync" class="me-1" />
Restart
</button>
Copy link

@Dracrius Dracrius Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A much cleaner and more consistent look would be to use a button group like the existing set for the entire stack. This can be done like so. This also hides the bash button when a container isn't running if used as written as it does nothing but tell you the container isn't running.

Suggested change
<router-link v-if="!isEditMode" class="btn btn-normal" :to="terminalRouteLink" disabled="">
<font-awesome-icon icon="terminal" />
Bash
</router-link>
<button v-if="status !== 'running' && status !== 'healthy'"
class="btn btn-primary me-2"
:disabled="processing"
@click="startService">
<font-awesome-icon icon="play" class="me-1" />
Start
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-danger me-2"
:disabled="processing"
@click="stopService">
<font-awesome-icon icon="stop" class="me-1" />
Stop
</button>
<button v-if="status === 'running' || status === 'healthy' || status === 'unhealthy'"
class="btn btn-warning me-2"
:disabled="processing"
@click="restartService">
<font-awesome-icon icon="sync" class="me-1" />
Restart
</button>
<div class="btn-group me-2" role="group">
<router-link v-if="!isEditMode && (status === 'running' || status === 'healthy')" class="btn btn-normal" :to="terminalRouteLink" disabled="">
<font-awesome-icon icon="terminal" />
Bash
</router-link>
<button v-if="!isEditMode && status !== 'running' && status !== 'healthy'"
class="btn btn-primary"
:disabled="processing"
@click="startService">
<font-awesome-icon icon="play" class="me-1" />
{{ $t("startStack") }}
</button>
<button v-if="!isEditMode && (status === 'running' || status === 'healthy' || status === 'unhealthy')"
class="btn btn-normal"
:disabled="processing"
@click="restartService">
<font-awesome-icon icon="rotate" class="me-1" />
{{ $t("restartStack") }}
</button>
<button v-if="!isEditMode && (status === 'running' || status === 'healthy' || status === 'unhealthy')"
class="btn btn-normal"
:disabled="processing"
@click="stopService">
<font-awesome-icon icon="stop" class="me-1" />
{{ $t("stopStack") }}
</button>
</div>

image

Copy link

@Dracrius Dracrius Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I forgot this also uses the localized names for Play, Restart and Stop. Bash uses a hard coded label because it doesn't get localized being a name not a word.

@Dracrius
Copy link

Dracrius commented Jun 6, 2025

I'm also working on trying to get it to hide the buttons when there is only one container in a stack so I'll post the code if I do. It is much less intrusive without the bright yellow and red but it's also very redundant if the stack only has one container.

Dracrius added a commit to Dracrius/dockge that referenced this pull request Jun 7, 2025
Final change to louislam#649 as there is no need for the container controls if there is only a single container.
@Dracrius
Copy link

Dracrius commented Jun 7, 2025

I figured out a pretty simple method to hide the controls in single container stacks. You can find the changes in Commit 789f25a on my fork.

Simply put by adding serviceCount() to compute:

        serviceCount() {
            return Object.keys(this.jsonObject.services).length;
        },

we can add this.serviceCount > 1 to the v-if for each button and they will automatically hide in instances where a stack only has a single container.

Single Container Active:

image

Single Container Inactive:

image

Multi Container Active:

image

Multi Container Inactive:

image

@Dracrius
Copy link

Dracrius commented Jun 7, 2025

@Triskae did you ever find a cause for the buttons not doing anything? I can't believe I didn't test them more before modifying it haha I kind of figured @tobi1449 changes were enough to make them work properly. Unfortunatly it didnt, pressing any of the buttons just greys them out.

My changes only effect button style and hiding the buttons when not needed so reverting those still gives me the same result as you.

Edit: I was attempting to use the buttons on containers controlled by an agent without this PR. Having this PR on each agent allows you to control containers from any agent without issue.

@cmcooper1980
Copy link

@Triskae did you ever find a cause for the buttons not doing anything? I can't believe I didn't test them more before modifying it haha I kind of figured @tobi1449 changes were enough to make them work properly. Unfortunatly it didnt, pressing any of the buttons just greys them out.

My changes only effect button style and hiding the buttons when not needed so reverting those still gives me the same result as you.

The buttons work in my fork:

oz1Boy

Before I rebased to the newer 1.50, the v1.41 of my fork did have this problem and I can't remember but I believe whatever @tobi1449 did did fix it but other stuff was broken such as PR #623 and there was one other that wasn't working so instead of trying to fix and not knowing what else would break or was broken, I just started over and rebased to 1.50 only merging PRs I knew 100% worked or I could get working after merge.

@Dracrius
Copy link

Dracrius commented Jun 7, 2025

@Triskae did you ever find a cause for the buttons not doing anything? I can't believe I didn't test them more before modifying it haha I kind of figured @tobi1449 changes were enough to make them work properly. Unfortunatly it didnt, pressing any of the buttons just greys them out.
My changes only effect button style and hiding the buttons when not needed so reverting those still gives me the same result as you.

The buttons work in my fork:

Before I rebased to the newer 1.50, the v1.41 of my fork did have this problem and I can't remember but I believe whatever @tobi1449 did did fix it but other stuff was broken such as PR #623 and there was one other that wasn't working so instead of trying to fix and not knowing what else would break or was broken, I just started over and rebased to 1.50 only merging PRs I knew 100% worked or I could get working after merge.

Oh Interesting, let me clarify after seeing your example I enabled the buttons on single container stacks and yes they work great there. It seem the bug is in stacks with multiple containers do you have any to test with on your end?

SingleContainer

MultiContainer

Note: I've also done test with just this commit and see the same results. Works for a single container stack but not any of my multi container stacks.

@cmcooper1980
Copy link

@Dracrius yes, my buttons work fine with single and multi container stacks:

brave_Cbo2XC

@Dracrius
Copy link

Dracrius commented Jun 9, 2025

@Dracrius yes, my buttons work fine with single and multi container stacks:

Interestingly I have found a stack that also works perfectly fine. My own combo stack of headscale, headscale ui and tailscale works without issue with the independent control buttons. I'm curious what could be causing it to not work on others.

Edit: I'm a fool it was a stack managed by another agent. I updated my other agent with the same image and this will solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants