From 3ebc855fc4e2ac3143aa97369e53f2e37837b7d8 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Tue, 14 Nov 2023 23:10:11 +0100 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=A7refactor:=20Add=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/volt.css | 68 ++++++++++++++++++- .../app/base/static/assets/js/pyodide.js | 17 +++++ sld-dashboard/app/home/routes.py | 16 +++++ .../app/home/templates/deploys-list.html | 51 +++++++------- 4 files changed, 126 insertions(+), 26 deletions(-) create mode 100644 sld-dashboard/app/base/static/assets/js/pyodide.js diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index 3ec33371..524d05c4 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41746,6 +41746,70 @@ pre { position: relative; flex: 1 1 auto; padding: 1rem; - background-color: #040720; + background-color: #333; color: #fff; -} \ No newline at end of file +} + +.tag-style { + background-color: #333; /* 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-success { + background-color: var(--bs-soft-green); /* 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-failure { + background-color: var(--bs-reddit); /* 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-status { + background-color: var(--bs-purple); /* 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 */ + 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 */ +} + + + diff --git a/sld-dashboard/app/base/static/assets/js/pyodide.js b/sld-dashboard/app/base/static/assets/js/pyodide.js new file mode 100644 index 00000000..15d21e73 --- /dev/null +++ b/sld-dashboard/app/base/static/assets/js/pyodide.js @@ -0,0 +1,17 @@ +window.languagePluginUrl = 'https://cdn.jsdelivr.net/pyodide/v0.18.1/full/'; +importScripts('https://cdn.jsdelivr.net/pyodide/v0.18.1/full/pyodide.js'); + +async function main() { + await loadPyodide(); +} +main(); + +async function runPython() { + let output = await pyodide.runPythonAsync(` + import numpy as np + x = np.array([1, 2, 3, 4, 5]) + y = np.sum(x) + y + `); + document.getElementById("pythonOutput").innerText = "Suma de array: " + output; +} \ No newline at end of file diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 34ee5a93..8716f9f3 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -720,6 +720,22 @@ def deploy_stack(stack_id): except ValueError: return redirect(url_for("base_blueprint.logout")) +#status +@blueprint.route('/get-task-status/') +@login_required +def get_task_status(task_id): + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + response = request_url( + verb="GET", + uri=f"tasks/id/{task_id}", + headers={"Authorization": f"Bearer {token}"}, + ) + return render_template('deploy-list', status=response) + except: + pass # Task @blueprint.route("/task_id/") diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index ead9d178..1ff4a87e 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -5,6 +5,7 @@ {% block stylesheets %}{% endblock stylesheets %} + {% block content %}
@@ -95,8 +96,7 @@

All Deploys

Id - Deploy Name - Stack + Deploy Name| Stack | Branch Squad Environment Username @@ -112,43 +112,46 @@

All Deploys

{% for deploy in deploys %} - - - - - - + - {{ deploy.id }} +
{{ deploy.id }}
- {{ deploy.name }} + +
{{ deploy.name }}
+
stack: {{ deploy.stack_name }}
+
branch/tag: {{deploy.stack_branch }}
+
+ + copy: + + + | tfvars: + +
+
- - - {{ deploy.stack_name }} - - - {{ deploy.squad}} - {{ deploy.environment}} + {{ deploy.squad}} + {{ deploy.environment}} {{ deploy.username}} {{ deploy.start_time }} {{ deploy.destroy_time }} - {{ deploy.action}} + {{ deploy.action}} +
{% set status = task_status(deploy.task_id, token).result %} {% if status == "SUCCESS" %} - {{ status }} + {{ status }} {% elif status == "ERROR" or (status == "FAILURE") %} - {{ status }} + {{ status }} {% elif status == "RETRY" %} - {{ status }} + {{ status }} {% else %} - {{ status }} + {{ status }} {% endif %} +
From 6c964c928cd0d564303fa3d58a0254339f47c7c5 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Wed, 15 Nov 2023 08:59:11 +0100 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=94=A7refactor:=20deployment=20table?= =?UTF-8?q?=20refresh=20status?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sld-dashboard/app/home/routes.py | 53 ++++++++++++------ .../app/home/templates/deploys-list.html | 55 ++++++++++++++----- 2 files changed, 79 insertions(+), 29 deletions(-) diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 8716f9f3..eb282b43 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -3,6 +3,8 @@ import ast import json import time +from flask import jsonify, render_template, request, url_for, redirect, flash + import redis from app import login_manager @@ -40,6 +42,41 @@ def index(): "index.html", segment="index", external_api_dns=external_api_dns ) +@blueprint.route('/status/') +def status(task_id): + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + response = request_url( + verb="GET", + uri=f"tasks/id/{task_id}", + headers={"Authorization": f"Bearer {token}"} + ) + if response.get("status_code") == 200: + data = response.get("json").get("result") + return jsonify(data) + else: + return jsonify({"status": "Error"}), response.status_code + + +@blueprint.route('/output/') +@login_required +def output(task_id): + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + response = request_url( + verb="GET", + uri=f"tasks/id/{task_id}", + headers={"Authorization": f"Bearer {token}"} + ) + if response.get("status_code") == 200: + data = response.get("json").get("result") + return redirect( + url_for("home_blueprint.route_template", template="deploys-list", stdout=data) + ) + flash(response["json"]["detail"], "error") + # Start Deploy @blueprint.route("/deploys-list", defaults={"limit": 0}) @@ -720,22 +757,6 @@ def deploy_stack(stack_id): except ValueError: return redirect(url_for("base_blueprint.logout")) -#status -@blueprint.route('/get-task-status/') -@login_required -def get_task_status(task_id): - try: - token = decrypt(r.get(current_user.id)) - # Check if token no expired - check_unauthorized_token(token) - response = request_url( - verb="GET", - uri=f"tasks/id/{task_id}", - headers={"Authorization": f"Bearer {token}"}, - ) - return render_template('deploy-list', status=response) - except: - pass # Task @blueprint.route("/task_id/") diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index 1ff4a87e..ebcf6c3c 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -120,7 +120,7 @@

All Deploys

-
{{ deploy.name }}
+
{{ deploy.name }}
stack: {{ deploy.stack_name }}
branch/tag: {{deploy.stack_branch }}
@@ -140,18 +140,8 @@

All Deploys

{{ deploy.start_time }} {{ deploy.destroy_time }} {{ deploy.action}} -
- {% set status = task_status(deploy.task_id, token).result %} - {% if status == "SUCCESS" %} - {{ status }} - {% elif status == "ERROR" or (status == "FAILURE") %} - {{ status }} - {% elif status == "RETRY" %} - {{ status }} - {% else %} - {{ status }} - {% endif %} -
+ +
@@ -355,6 +345,7 @@
+
{% include 'includes/footer.html' %} @@ -368,4 +359,42 @@

All Activity

{% endif %} {{ logs.id }} - {{ logs.username }} + {{ logs.username }} {{ logs.action }} {{ logs.squad}} {{ logs.created_at }} diff --git a/sld-dashboard/app/home/templates/deploy-plan.html b/sld-dashboard/app/home/templates/deploy-plan.html index 915cefd3..5062a961 100644 --- a/sld-dashboard/app/home/templates/deploy-plan.html +++ b/sld-dashboard/app/home/templates/deploy-plan.html @@ -58,7 +58,7 @@
{{key}}
{% endfor %} diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index ebcf6c3c..a621f5d0 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -120,9 +120,9 @@

All Deploys

-
{{ deploy.name }}
+
{{ deploy.name }}
stack: {{ deploy.stack_name }}
-
branch/tag: {{deploy.stack_branch }}
+
branch: {{deploy.stack_branch }}
@@ -158,6 +158,8 @@

All Deploys

Edit Approve + + Plan delete @@ -184,11 +186,12 @@

All Deploys

{% endif %} - - - - + + + + + + @@ -235,42 +238,22 @@
- + + -
- - {% include 'includes/footer.html' %}
@@ -393,6 +373,65 @@

All Stacks

{% endif %} {{ stack.id }} - {{ stack.stack_name }} + {{ stack.stack_name }} {% if "yoda" in current_user.role or "darth_vader" in current_user.role %} {{ stack.git_repo }} {{ stack.branch }} - {{ stack.tf_version }} + {{ stack.tf_version }} {{ stack.squad_access }} {% endif %} {{ stack.description}} diff --git a/sld-dashboard/app/home/templates/tasks-logs.html b/sld-dashboard/app/home/templates/tasks-logs.html index 68e18839..3d62617d 100644 --- a/sld-dashboard/app/home/templates/tasks-logs.html +++ b/sld-dashboard/app/home/templates/tasks-logs.html @@ -93,12 +93,20 @@

All Tasks

{% else %} {% endif %} - {{ task.task_id }} + +
+ {{ task.task_id }} + + +
+ + {{ task.deploy_id }} - {{ task.action }} - {{ task.username }} + {{ task.action }} + {{ task.username }} {{ task.task_name }} - {{ task.squad}} + {{ task.squad}} {{ task.created_at }} @@ -145,4 +153,5 @@

All Tasks

{% block javascripts %} + {% endblock javascripts %} diff --git a/sld-dashboard/app/home/templates/users-list.html b/sld-dashboard/app/home/templates/users-list.html index b5d7d270..616f052c 100644 --- a/sld-dashboard/app/home/templates/users-list.html +++ b/sld-dashboard/app/home/templates/users-list.html @@ -92,12 +92,20 @@

All users

{% endif %} {{ user.id }} - {{ user.username }} + +
+ {{ user.username }} + + +
+
+ {{ user.fullname }} {{ user.email }} {{ user.squad }} {{ user.role }} - {{ user.is_active }} + {{ user.is_active }} {% if current_user.master %} {{ user.master }} {% endif %} @@ -140,4 +148,5 @@

All users

{% block javascripts %} + {% endblock javascripts %} From 5251a9abbf55e6c9795d24d0c8506798126c4975 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Fri, 17 Nov 2023 00:00:42 +0100 Subject: [PATCH 4/4] =?UTF-8?q?=E2=AC=86=20Bump=20docker=20version=20dashb?= =?UTF-8?q?oard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/sld-dashboard-docker-image.yml | 4 +- sld-dashboard/app/home/routes.py | 62 ++++++++++++------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.github/workflows/sld-dashboard-docker-image.yml b/.github/workflows/sld-dashboard-docker-image.yml index d16b9ee6..aad97345 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.16.0 + run: docker build . --file Dockerfile --tag ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.17.0 - name: Docker Push with tags #if: github.event.pull_request.merged == true - run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.16.0 + run: docker push ${{ secrets.DOCKER_USERNAME }}/sld-dashboard:2.17.0 - name: Build the Docker image working-directory: ./sld-dashboard diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 2e8ce0d9..37653ad8 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -44,35 +44,49 @@ def index(): @blueprint.route('/status/') def status(task_id): - token = decrypt(r.get(current_user.id)) - # Check if token no expired - check_unauthorized_token(token) - response = request_url( - verb="GET", - uri=f"tasks/id/{task_id}", - headers={"Authorization": f"Bearer {token}"} - ) - if response.get("status_code") == 200: - data = response.get("json").get("result") - return jsonify(data) - else: - return jsonify({"status": "Error"}), response.status_code + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + response = request_url( + verb="GET", + uri=f"tasks/id/{task_id}", + headers={"Authorization": f"Bearer {token}"} + ) + if response.get("status_code") == 200: + data = response.get("json").get("result") + return jsonify(data) + else: + return jsonify({"status": "Error"}), response.status_code + 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('/output/') @login_required def output(task_id): - token = decrypt(r.get(current_user.id)) - # Check if token no expired - check_unauthorized_token(token) - response = request_url( - verb="GET", - uri=f"tasks/id/{task_id}", - headers={"Authorization": f"Bearer {token}"} - ) - if response.get("status_code") == 200: - data = response.get("json").get("result").get("module").get("stdout") - return data + try: + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + response = request_url( + verb="GET", + uri=f"tasks/id/{task_id}", + headers={"Authorization": f"Bearer {token}"} + ) + if response.get("status_code") == 200: + data = response.get("json").get("result").get("module").get("stdout") + return data + 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 # Start Deploy