diff --git a/.github/workflows/sld-dashboard-docker-image.yml b/.github/workflows/sld-dashboard-docker-image.yml index 19ddbec9..65e657e1 100644 --- a/.github/workflows/sld-dashboard-docker-image.yml +++ b/.github/workflows/sld-dashboard-docker-image.yml @@ -24,11 +24,11 @@ jobs: - name: Build the Docker image with tags working-directory: ./sld-dashboard - run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.28.0 + run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.29.0 - name: Docker Push with tags #if: github.event.pull_request.merged == true - run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.28.0 + run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.29.0 - name: Build the Docker image working-directory: ./sld-dashboard run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:latest diff --git a/play-with-sld/kubernetes/k8s/sld-dashboard.yml b/play-with-sld/kubernetes/k8s/sld-dashboard.yml index a489702e..1191f757 100644 --- a/play-with-sld/kubernetes/k8s/sld-dashboard.yml +++ b/play-with-sld/kubernetes/k8s/sld-dashboard.yml @@ -17,7 +17,7 @@ spec: subdomain: primary containers: - name: sld-dashboard - image: d10s0vsky/sld-dashboard:2.28.0 + image: d10s0vsky/sld-dashboard:2.29.0 env: - name: PATH value: "/home/sld/.asdf/shims:/home/sld/.asdf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index e79cf86b..159054bb 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41800,6 +41800,20 @@ pre { text-align: center; /* Centrar el texto dentro del tag */ } + +.tag-style-apply { + background-color:#172d34; /* Un gris oscuro */ + color: white; /* Texto en color blanco para contraste */ + padding: 5px 10px; /* Espaciado interno para dar forma al tag */ + border-radius: 5px; /* Bordes redondeados para la apariencia de un tag */ + font-weight: normal; /* Peso de la fuente, ajusta según necesidad */ + display: inline-block; /* Para asegurar que el estilo se aplique correctamente */ + margin: 2px; /* Un pequeño margen alrededor del tag */ + width: 100px; /* Ancho fijo para el tag */ + text-align: center; /* Centrar el texto dentro del tag */ +} + + .tag-style-retry { background-color: var(--bs-warning); /* Un gris oscuro */ color: white; /* Texto en color blanco para contraste */ diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 5755aa78..2e90a05b 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -48,10 +48,21 @@ def index(): ) # stream SSE -@blueprint.route('/deploy-stream/') +@blueprint.route('/deploy-stream/') @login_required -def deploy_stream(task_id): - return render_template('deploy-stream.html', task_id=task_id) +def deploy_stream(deploy_id): + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + # Get defaults vars by deploy + endpoint = f"deploy/{deploy_id}" + # Get deploy data vars and set var for render + response = request_url( + verb="GET", uri=f"{endpoint}", headers={"Authorization": f"Bearer {token}"} + ) + deploy = response.get("json") + return render_template('deploy-stream.html', deploy=deploy) + @blueprint.route('/stream/') @login_required @@ -207,6 +218,32 @@ def destroy_deploy(deploy_id): return render_template("page-500.html"), 500 +@blueprint.route("/deploys/destroy_console/") +@login_required +def destroy_deploy_console(deploy_id): + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + endpoint = f"deploy/{deploy_id}" + response = request_url( + verb="PUT", uri=f"{endpoint}", headers={"Authorization": f"Bearer {token}"} + ) + if response.get("status_code") == 202: + flash(f"Destroying infra") + else: + flash(response["json"]["detail"], "error") + return redirect( + url_for("home_blueprint.route_template", template=f"deploy-stream/{deploy_id}") + ) + except TemplateNotFound: + return render_template("page-404.html"), 404 + except TypeError: + return redirect(url_for("base_blueprint.logout")) + except Exception: + return render_template("page-500.html"), 500 + + @blueprint.route("/deploys/unlock/") @login_required def unlock_deploy(deploy_id): @@ -275,6 +312,44 @@ def relaunch_deploy(deploy_id): except Exception: return render_template("page-500.html"), 500 +@blueprint.route("/deploys/console/redeploy/") +@login_required +def relaunch_console_deploy(deploy_id): + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + endpoint = f"deploy/{deploy_id}" + + response = request_url( + verb="GET", uri=f"{endpoint}", headers={"Authorization": f"Bearer {token}"} + ) + content = response.get("json") + data = { + "start_time": content["start_time"], + "destroy_time": content["destroy_time"], + "stack_branch": content["stack_branch"], + "tfvar_file": content["tfvar_file"], + "project_path": content["project_path"], + "variables": content["variables"], + } + response = request_url( + verb="PATCH", + uri=f"{endpoint}", + headers={"Authorization": f"Bearer {token}"}, + json=data, + ) + + if response.get("status_code") == 202: + flash("Re-Launch Deploy") + else: + flash(response["json"]["detail"], "error") + return redirect( + url_for("home_blueprint.route_template", template=f"deploy-stream/{deploy_id}") + ) + except Exception as err: + raise err + @blueprint.route("/edit-deploy", methods=["GET", "POST"], defaults={"deploy_id": None}) @blueprint.route("/edit-deploy/", methods=["GET", "POST"]) @@ -458,6 +533,7 @@ def get_plan(deploy_id): except ValueError: return redirect(url_for("base_blueprint.logout")) + @blueprint.route("/plan/redeploy/") @login_required def relaunch_plan(deploy_id): @@ -488,7 +564,7 @@ def relaunch_plan(deploy_id): ) if response.get("status_code") == 202: - flash(f"planning deploy") + flash("planning deploy") else: flash(response["json"]["detail"], "error") return redirect( @@ -502,6 +578,49 @@ def relaunch_plan(deploy_id): return render_template("page-500.html"), 500 +@blueprint.route("/plan/console/redeploy/") +@login_required +def relaunch_console_plan(deploy_id): + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + endpoint = f"deploy/{deploy_id}" + + response = request_url( + verb="GET", uri=f"{endpoint}", headers={"Authorization": f"Bearer {token}"} + ) + content = response.get("json") + data = { + "start_time": content["start_time"], + "destroy_time": content["destroy_time"], + "stack_branch": content["stack_branch"], + "tfvar_file": content["tfvar_file"], + "project_path": content["project_path"], + "variables": content["variables"], + } + endpoint = f"plan/{deploy_id}" + response = request_url( + verb="PATCH", + uri=f"{endpoint}", + headers={"Authorization": f"Bearer {token}"}, + json=data, + ) + + if response.get("status_code") == 202: + flash(f"planning deploy") + else: + flash(response["json"]["detail"], "error") + return redirect( + url_for("home_blueprint.route_template", template=f"deploy-stream/{deploy_id}") + ) + except TemplateNotFound: + return render_template("page-404.html"), 404 + except TypeError: + return redirect(url_for("base_blueprint.logout")) + except Exception: + return render_template("page-500.html"), 500 + @blueprint.route("/clone-deploy", methods=["GET", "POST"], defaults={"deploy_id": None}) @blueprint.route("/clone-deploy/", methods=["GET", "POST"]) @login_required diff --git a/sld-dashboard/app/home/templates/deploy-stream.html b/sld-dashboard/app/home/templates/deploy-stream.html index 0b78a7db..74189399 100644 --- a/sld-dashboard/app/home/templates/deploy-stream.html +++ b/sld-dashboard/app/home/templates/deploy-stream.html @@ -11,7 +11,7 @@ border-radius: 4px; margin-top: 20px; overflow-y: auto; - max-height: 600px; + max-height: 530px; } #console-container h2 { @@ -29,6 +29,24 @@ margin-top: 5px; /* Top margin */ overflow-y: auto; } +.acciones-lineales .dropdown-item { + display: inline-block; + margin-right: 10px; + margin: 0 20px; +} +.acciones-lineales a { + display: inline-block; + margin-right: 10px; /* Ajusta el margen según tus necesidades */ +} + +.linea-divisoria { + display: inline-block; + width: 1px; /* Ancho de la línea */ + height: 20px; /* Altura de la línea, ajusta según tus necesidades */ + background-color: #000; /* Color de la línea */ + margin-right: 10px; /* Espacio después de la línea, ajusta según tus necesidades */ + vertical-align: middle; /* Alinea verticalmente con los enlaces */ +} {% endblock stylesheets %} @@ -47,8 +65,27 @@ + + + + + + + {% include 'includes/footer.html' %} + {% endblock content %} {% block javascripts %} + + {% endblock javascripts %} diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index ed0593f0..6224a1d3 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -268,7 +268,7 @@

All Deploys

- +