From d1d10d5f99caf2bfedb95c348fc40c6dc0f3081a Mon Sep 17 00:00:00 2001 From: SelfhostedPro Date: Wed, 17 Feb 2021 17:22:16 -0800 Subject: [PATCH] added edit dialog, now will edit even if the name is changed --- backend/api/actions/apps.py | 6 ++- backend/api/auth/auth.py | 2 +- backend/api/db/schemas/apps.py | 1 + .../applications/ApplicationsForm.vue | 51 ++++++++++++++++++- frontend/src/store/modules/auth.js | 5 +- 5 files changed, 57 insertions(+), 8 deletions(-) diff --git a/backend/api/actions/apps.py b/backend/api/actions/apps.py index 37b204a9..1b26c499 100644 --- a/backend/api/actions/apps.py +++ b/backend/api/actions/apps.py @@ -164,6 +164,7 @@ def deploy_app(template: schemas.DeployForm): conv_sysctls2data(template.sysctls), conv_caps2data(template.cap_add), edit=template.edit or False, + id=template.id or None ) except HTTPException as exc: raise HTTPException(status_code=exc.status_code, detail=exc.detail) @@ -217,13 +218,14 @@ def launch_app( sysctls, caps, edit, + id ): dclient = docker.from_env() if edit == True: try: - dclient.containers.get(name) + dclient.containers.get(id) try: - running_app = dclient.containers.get(name) + running_app = dclient.containers.get(id) running_app.remove(force=True) except Exception as e: raise e diff --git a/backend/api/auth/auth.py b/backend/api/auth/auth.py index b87272c9..57745c44 100644 --- a/backend/api/auth/auth.py +++ b/backend/api/auth/auth.py @@ -29,7 +29,7 @@ def generate_password() -> str: def auth_check(Authorize): - if settings.DISABLE_AUTH == "True": + if str(settings.DISABLE_AUTH).lower() == "true": return else: try: diff --git a/backend/api/db/schemas/apps.py b/backend/api/db/schemas/apps.py index 0edd1119..c51c35e8 100644 --- a/backend/api/db/schemas/apps.py +++ b/backend/api/db/schemas/apps.py @@ -51,6 +51,7 @@ class DeployForm(BaseModel): network_mode: Optional[str] network: Optional[str] edit: Optional[bool] + id: Optional[str] # LOGS # diff --git a/frontend/src/components/applications/ApplicationsForm.vue b/frontend/src/components/applications/ApplicationsForm.vue index b4ce46d9..87b5f676 100644 --- a/frontend/src/components/applications/ApplicationsForm.vue +++ b/frontend/src/components/applications/ApplicationsForm.vue @@ -407,6 +407,25 @@ +
+ Deploying + +
+
Deploy
+
+ + + + + Are you sure you want to edit this container? + + + This will remove the currently running container and deploy a new one with the settings in this form. + Please make sure your container data is persistant or backed up. + + + + + Cancel + + + Edit + + + + @@ -686,6 +732,7 @@ export default { notes: "", networks: [], volumes: [], + editDialog: false, form: { name: "", image: "", @@ -906,7 +953,6 @@ export default { } else if (this.$route.params.appName) { const appName = this.$route.params.appName; const app = await this.readApp(appName); - console.log(app); this.form = { name: app.name || "", image: app.Config.Image || "", @@ -919,7 +965,8 @@ export default { labels: this.transform_labels(app.Config.Labels) || [], sysctls: this.transform_labels(app.HostConfig.Sysctls), cap_add: app.HostConfig.CapAdd || [], - edit: true + edit: true, + id: app.Id }; } } diff --git a/frontend/src/store/modules/auth.js b/frontend/src/store/modules/auth.js index 1fab971d..183d1270 100644 --- a/frontend/src/store/modules/auth.js +++ b/frontend/src/store/modules/auth.js @@ -62,7 +62,7 @@ const actions = { resolve(resp); }) .catch(error => { - console.log(error); + console.error(error); commit(AUTH_CLEAR); }); }); @@ -85,7 +85,7 @@ const actions = { resolve(resp); }) .catch(error => { - console.log(error); + console.error(error); commit(AUTH_CLEAR); }); }); @@ -115,7 +115,6 @@ const actions = { axios .get(url) .then(resp => { - console.log(resp); if (resp.data.authDisabled == true) { localStorage.setItem("username", resp.data.username); commit(AUTH_DISABLED);