From 3e1060b32aa128c7d691270493294f491825a301 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Sat, 23 Dec 2023 17:01:49 +0100 Subject: [PATCH 01/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20stacks=20cards?= =?UTF-8?q?=20draft?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/volt.css | 29 +++++++ .../app/home/templates/stacks-cards.html | 83 +++++++++++++++++++ 2 files changed, 112 insertions(+) create mode 100644 sld-dashboard/app/home/templates/stacks-cards.html diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index c8487a4f..09718f09 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41866,3 +41866,32 @@ pre { background-size: contain; background-repeat: no-repeat; } + +.card-row { + display: flex; + justify-content: space-around; + flex-wrap: wrap; + padding-top: 20px; + +} + +.card-header { + display: flex; + align-items: center; + gap: 10px; +} + +.card-header img { + display: flex; + +} + +.card-header .title { + display: flex; + +} + +.card-columns { + display: flex; + justify-content: start; +} \ No newline at end of file diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html new file mode 100644 index 00000000..4f00f4ff --- /dev/null +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -0,0 +1,83 @@ +{% extends "layouts/base.html" %} + +{% block title %} Stacks {% endblock %} + + +{% block stylesheets %} + +{% endblock stylesheets %} + +{% block content %} + +
+ + {% include 'includes/navigation.html' %} +
+ Volt logo +
+ +
+
+ +

All Stacks

+

List all stacks for deploy

+
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+ +
+
+ {% for stack in stacks %} + {% if "aws" in stack.stack_name or "azure" in stack.stack_name or "gcp" in stack.stack_name or "custom" in stack.stack_name %} +
+
+ {% if stack.icon_path %} + Icono + {% else %} + Icono + {% endif %} + {{stack.stack_name}} +
+
+
{{ stack.stack_name }}
+

Some quick example text to build on the card title and make up the bulk of the card's content.

+ Go somewhere + +
+
+ {% endif %} + {% endfor %} +
+
+ + + + {% include 'includes/footer.html' %} + +
+ +{% endblock content %} + + +{% block javascripts %} +{% endblock javascripts %} From d98c26fa631b5e931a97ab74d3c2d4b4bd6b3429 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Sat, 23 Dec 2023 23:47:47 +0100 Subject: [PATCH 02/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20stacks=20cards?= =?UTF-8?q?=20basic=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/volt.css | 20 ++- .../app/home/templates/stacks-cards.html | 130 +++++++++++++++++- .../app/home/templates/stacks-list.html | 3 +- 3 files changed, 146 insertions(+), 7 deletions(-) diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index 09718f09..104faa1b 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41871,8 +41871,7 @@ pre { display: flex; justify-content: space-around; flex-wrap: wrap; - padding-top: 20px; - + padding-top: 20px; } .card-header { @@ -41894,4 +41893,21 @@ pre { .card-columns { display: flex; justify-content: start; +} + +.icon-with-text { + display: flex; /* Establece el contenedor como un flexbox */ + align-items: flex-end; /* Alinea verticalmente los elementos al centro */ + gap: 35px; /* Ajusta el espacio entre la imagen y el texto */ +} + +.icon-with-text img { + margin-right: 35px; /* Añade espacio a la derecha de la imagen */ + display: flex; + justify-content: flex-end; +} + +.icon-with-text span { + display: block; /* Hace que el span se comporte como un bloque */ + line-height: 1; /* Ajusta la altura de línea si es necesario */ } \ No newline at end of file diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index 4f00f4ff..e4cf44f4 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -49,6 +49,7 @@

All Stacks

{% for stack in stacks %} {% if "aws" in stack.stack_name or "azure" in stack.stack_name or "gcp" in stack.stack_name or "custom" in stack.stack_name %} +
{% if stack.icon_path %} @@ -56,13 +57,102 @@

All Stacks

{% else %} Icono {% endif %} - {{stack.stack_name}} +
{{stack.stack_name}}
+
-
{{ stack.stack_name }}
-

Some quick example text to build on the card title and make up the bulk of the card's content.

- Go somewhere + + {{ stack.description}} + +
+
+ repo: + {{ stack.git_repo.split('/')[-1] | replace('.git', '') }} + + + +
+
+ branch: + {{ stack.branch }} +
+ + Icono + + {% if "yoda" in current_user.role or "darth_vader" in current_user.role %} +
+ + + + + + + +
+
{% endif %} @@ -80,4 +170,36 @@
{{ stack.stack_name }}
{% block javascripts %} + + + + {% endblock javascripts %} diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index f9298ccd..3acc7123 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -36,7 +36,8 @@

All Stacks

- + +
From d87040bc272b704dcd8f4272ba543f76599fda16 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Sun, 24 Dec 2023 00:22:27 +0100 Subject: [PATCH 03/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Set=20borders?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sld-dashboard/app/home/templates/stacks-cards.html | 8 +++----- sld-dashboard/app/home/templates/stacks-list.html | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index e4cf44f4..783d1454 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -45,12 +45,12 @@

All Stacks

-
+
{% for stack in stacks %} {% if "aws" in stack.stack_name or "azure" in stack.stack_name or "gcp" in stack.stack_name or "custom" in stack.stack_name %} -
+
{% if stack.icon_path %} Icono @@ -61,9 +61,7 @@
{{stack.stack_name}}
- - {{ stack.description}} - +

{{stack.description}}

repo: diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index 3acc7123..f9298ccd 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -36,8 +36,7 @@

All Stacks

- - +
From a581e84b27cddd04f622ac66cff5bf8cc81376cf Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Sun, 24 Dec 2023 18:41:01 +0100 Subject: [PATCH 04/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20tf=20docs=20det?= =?UTF-8?q?ails?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/readme.css | 49 ++++++++++++++ sld-dashboard/app/helpers/parsers.py | 16 +++++ sld-dashboard/app/home/routes.py | 65 +++++++++++++++++++ .../app/home/templates/stack-details.html | 64 ++++++++++++++++++ .../app/home/templates/stacks-cards.html | 2 +- .../app/home/templates/stacks-list.html | 1 + sld-dashboard/requirements.txt | 9 +++ 7 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 sld-dashboard/app/base/static/assets/css/readme.css create mode 100644 sld-dashboard/app/helpers/parsers.py create mode 100644 sld-dashboard/app/home/templates/stack-details.html diff --git a/sld-dashboard/app/base/static/assets/css/readme.css b/sld-dashboard/app/base/static/assets/css/readme.css new file mode 100644 index 00000000..7a299ba0 --- /dev/null +++ b/sld-dashboard/app/base/static/assets/css/readme.css @@ -0,0 +1,49 @@ +table { + border-collapse: collapse; + width: 100%; +} +th, td { + border: 1px solid #ddd; + padding: 8px; + text-align: left; +} +th { + background-color: #f2f2f2; +} + + +td { + word-wrap: break-word; + max-width: 200px; /* ajusta esto según tus necesidades */ +} + + +h1, h2, h3, h4, h5, h6 { + color: #333; + margin-top: 20px; +} +p { + line-height: 1.6; +} + +a { + color: #007bff; + text-decoration: none; +} +a:hover { + text-decoration: underline; +} + +@media screen and (max-width: 600px) { + table { + width: 100%; + } + td { + max-width: 100px; /* ajusta para dispositivos móviles */ + } +} + +img { + max-width: 100%; + height: auto; +} \ No newline at end of file diff --git a/sld-dashboard/app/helpers/parsers.py b/sld-dashboard/app/helpers/parsers.py new file mode 100644 index 00000000..81114c6f --- /dev/null +++ b/sld-dashboard/app/helpers/parsers.py @@ -0,0 +1,16 @@ +def fetch_url_readme(git_repo, branch='main'): + if git_repo.endswith('.git'): + git_repo = git_repo[:-4] + + if 'github.com' in git_repo: + raw_url = git_repo.replace('github.com', 'raw.githubusercontent.com') + url_readme = f"{raw_url}/{branch}/README.md" + elif 'gitlab.com' in git_repo: + raw_url = git_repo.replace('gitlab.com', 'gitlab.com') + url_readme = f"{raw_url}/-/raw/{branch}/README.md" + else: + print("Unsupported Git repository platform.") + return None + + print(f"Fetching {url_readme}...") + return url_readme \ No newline at end of file diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 6d1d9610..f46970d1 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -6,6 +6,10 @@ import logging from flask import jsonify, render_template, request, url_for, redirect, flash, Response +import requests +import mistletoe +from app.helpers.parsers import fetch_url_readme + import redis from app import login_manager @@ -954,6 +958,67 @@ def edit_stack(stack_id): except ValueError: return redirect(url_for("base_blueprint.logout")) +@blueprint.route("/details-stack", methods=["GET", "POST"], defaults={"stack_id": None}) +@blueprint.route("/details-stack/", methods=["GET", "POST"]) +@login_required +def details_stack(stack_id): + try: + icons = list_icons() + token = decrypt(r.get(current_user.id)) + # Check if token no expired + check_unauthorized_token(token) + form = StackForm(request.form) + endpoint = f"stacks/{stack_id}" + # Get deploy data vars and set var for render + response = request_url( + verb="GET", uri=f"{endpoint}", headers={"Authorization": f"Bearer {token}"} + ) + stack = response.get("json") + readme_url = fetch_url_readme(stack["git_repo"], stack["branch"]) + response = requests.get(readme_url) + if response.status_code == 200: + readme_content = response.text + readme_html = mistletoe.markdown(readme_content) # Convierte el contenido de Markdown a HTML + else: + readme_html = "

Error al cargar el README.md

" + + # When user push data with POST verb + if request.method == "POST": + # Data dend to deploy + squad_acces_form = form.squad_access_edit.data + squad_acces_form_to_list = squad_acces_form.split(",") + update_stack = { + "stack_name": form.name.data.replace(" ",""), + "git_repo": form.git.data.replace(" ",""), + "branch": form.branch.data.replace(" ",""), + "squad_access": squad_acces_form_to_list, + "iac_type": form.iac_type.data, + "tf_version": form.tf_version.data.replace(" ",""), + "project_path": form.project_path.data.replace(" ",""), + "description": form.description.data, + "icon_path": request.form.get("icon_path"), + } + # Deploy + response = request_url( + verb="PATCH", + uri=f"{endpoint}", + headers={"Authorization": f"Bearer {token}"}, + json=update_stack, + ) + if response.get("status_code") == 200: + flash("Updating Stack") + else: + flash(response.get("json").get("detail"), "error") + return redirect( + url_for("home_blueprint.route_template", template="stacks-list") + ) + + return render_template( + "stack-details.html", name="Edit Stack", form=form, stack=stack, icons=icons, readme_html=readme_html + ) + except ValueError: + return redirect(url_for("base_blueprint.logout")) + @blueprint.route("/stack/delete/") @login_required diff --git a/sld-dashboard/app/home/templates/stack-details.html b/sld-dashboard/app/home/templates/stack-details.html new file mode 100644 index 00000000..f6d60fa3 --- /dev/null +++ b/sld-dashboard/app/home/templates/stack-details.html @@ -0,0 +1,64 @@ +{% extends "layouts/base.html" %} +{% from 'helpers/_forms.html' import render_field %} + +{% block title %} Edit Stack {% endblock %} + + +{% block stylesheets %} + + +{% endblock stylesheets %} +{% block content %} +
+ + {% include 'includes/navigation.html' %} + +
+ +
+
+

Stack Details

+
+ +
+
+ + + +

+
+
+

{{stack.name}}

+

{{stack.description}}

+

{{stack.git_repo}}

+

{{stack.branch}}

+ {{ stack.iac_type }} + {{ stack.tf_version }} + {{ stack.squads }} + {{ readme_html | safe }} + +
+ +
+
+
+
+
+ + {% include 'includes/footer.html' %} + +
+ +{% endblock content %} + + +{% block javascripts %} +{% endblock javascripts %} diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index 783d1454..b394786c 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -50,7 +50,7 @@

All Stacks

{% for stack in stacks %} {% if "aws" in stack.stack_name or "azure" in stack.stack_name or "gcp" in stack.stack_name or "custom" in stack.stack_name %} -
+
{% if stack.icon_path %} Icono diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index f9298ccd..4a69fc23 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -154,6 +154,7 @@

All Stacks

diff --git a/sld-dashboard/requirements.txt b/sld-dashboard/requirements.txt index c9b87de5..6261fab5 100644 --- a/sld-dashboard/requirements.txt +++ b/sld-dashboard/requirements.txt @@ -14,18 +14,25 @@ dnspython==2.4.2 email-validator==2.0.0.post2 fernet==1.0.1 Flask==2.3.3 +Flask-Cors==4.0.0 Flask-Login==0.6.2 Flask-Migrate==4.0.5 Flask-MySQLdb==2.0.0 Flask-SQLAlchemy==3.1.1 +Flask-SSE==1.0.0 Flask-WTF==1.2.1 +gevent==23.9.1 greenlet==3.0.0 gunicorn==21.2.0 idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.2 Mako==1.2.4 +Markdown==3.5.1 +markdown2==2.4.12 +marko==2.0.2 MarkupSafe==2.1.3 +mistletoe==1.2.1 mysqlclient==2.2.0 packaging==23.2 passlib==1.7.4 @@ -48,3 +55,5 @@ urllib3==2.0.7 Werkzeug==2.3.7 wrapt==1.15.0 WTForms==3.1.0 +zope.event==5.0 +zope.interface==6.1 From a2e86e7cb8dcafade8214b4feab54d60c0dc2615 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Mon, 25 Dec 2023 18:01:12 +0100 Subject: [PATCH 05/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20selector=20tabl?= =?UTF-8?q?e=20and=20card=20stacks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/volt.css | 4 +++ .../base/static/assets/js/selector_stacks.js | 23 ++++++++++++++ .../app/home/templates/stack-details.html | 30 ++++++++++++++----- .../app/home/templates/stacks-cards.html | 17 ++++++++--- .../app/home/templates/stacks-list.html | 9 +++++- 5 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 sld-dashboard/app/base/static/assets/js/selector_stacks.js diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index 104faa1b..2051b9c8 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41910,4 +41910,8 @@ pre { .icon-with-text span { display: block; /* Hace que el span se comporte como un bloque */ line-height: 1; /* Ajusta la altura de línea si es necesario */ +} + +.gradient-background { + background: linear-gradient(to right, #ff6e7f, #bfe9ff); /* De izquierda a derecha */ } \ No newline at end of file diff --git a/sld-dashboard/app/base/static/assets/js/selector_stacks.js b/sld-dashboard/app/base/static/assets/js/selector_stacks.js new file mode 100644 index 00000000..1799167b --- /dev/null +++ b/sld-dashboard/app/base/static/assets/js/selector_stacks.js @@ -0,0 +1,23 @@ +document.addEventListener('DOMContentLoaded', function() { + let preferredView = localStorage.getItem('preferredView'); + + // Asegúrate de que estas rutas coincidan exactamente con la ubicación de tus archivos HTML + const cardsPath = '/stacks-cards'; + const tablePath = '/stacks-list'; + + if (preferredView === 'table' && !window.location.href.endsWith(tablePath)) { + window.location.href = tablePath; + } else if (preferredView === 'cards' && !window.location.href.endsWith(cardsPath)) { + window.location.href = cardsPath; + } +}); + + +function changeView(view) { + localStorage.setItem('preferredView', view); + if (view === 'table') { + window.location.href = '/stacks-list'; + } else { + window.location.href = '/stacks-cards'; + } +} diff --git a/sld-dashboard/app/home/templates/stack-details.html b/sld-dashboard/app/home/templates/stack-details.html index f6d60fa3..59d98b7a 100644 --- a/sld-dashboard/app/home/templates/stack-details.html +++ b/sld-dashboard/app/home/templates/stack-details.html @@ -34,15 +34,29 @@

Stack Details


-
+
+
+
+
{{stack.stack_name}}
+

{{stack.description}}

+
+
+
+
+
{{stack.git_repo}}
+

{{stack.branch}}

+
+
+
+
+

{{stack.iac_type}}

+

{{stack.tf_version}}

+

{{stack.squads}}

+
+
+
-

{{stack.name}}

-

{{stack.description}}

-

{{stack.git_repo}}

-

{{stack.branch}}

- {{ stack.iac_type }} - {{ stack.tf_version }} - {{ stack.squads }} + {{ readme_html | safe }}
diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index b394786c..d918cd8d 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -31,6 +31,11 @@

All Stacks

+
+ +
@@ -45,6 +50,8 @@

All Stacks

+ +
{% for stack in stacks %} @@ -89,8 +96,6 @@
{{stack.stack_name}}
Edit sync Remove - {% endif %} -
-
+
+ {% endif %} +
@@ -199,5 +206,7 @@

All Stacks

+
+ +
@@ -38,8 +43,9 @@

All Stacks

+ -
+
@@ -256,5 +262,6 @@
{{stack.stack_name}}
+ - - {% endif %} From 219a91cebaa5f0311a39bc72002403ab450564d8 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Mon, 25 Dec 2023 19:44:51 +0100 Subject: [PATCH 07/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20deploy=20in=20?= =?UTF-8?q?=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/readme.css | 4 +- .../app/home/templates/stack-details.html | 44 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/sld-dashboard/app/base/static/assets/css/readme.css b/sld-dashboard/app/base/static/assets/css/readme.css index 7a299ba0..832c42be 100644 --- a/sld-dashboard/app/base/static/assets/css/readme.css +++ b/sld-dashboard/app/base/static/assets/css/readme.css @@ -3,7 +3,7 @@ table { width: 100%; } th, td { - border: 1px solid #ddd; + border: 1px solid #dddddd; padding: 8px; text-align: left; } @@ -14,7 +14,7 @@ th { td { word-wrap: break-word; - max-width: 200px; /* ajusta esto según tus necesidades */ + max-width: 300px; /* ajusta esto según tus necesidades */ } diff --git a/sld-dashboard/app/home/templates/stack-details.html b/sld-dashboard/app/home/templates/stack-details.html index 59d98b7a..09a7d8f2 100644 --- a/sld-dashboard/app/home/templates/stack-details.html +++ b/sld-dashboard/app/home/templates/stack-details.html @@ -33,40 +33,34 @@

Stack Details

-

-
-
-
-
{{stack.stack_name}}
-

{{stack.description}}

-
-
-
-
-
{{stack.git_repo}}
-

{{stack.branch}}

-
-
-
-
-

{{stack.iac_type}}

-

{{stack.tf_version}}

-

{{stack.squads}}

-
-
+ +

 
{{ readme_html | safe }}
-
-
-
+
- {% include 'includes/footer.html' %} From 192c1963cea2d19866333471ff204a1cb3dd682c Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Mon, 25 Dec 2023 22:54:03 +0100 Subject: [PATCH 08/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Store=20selector=20ca?= =?UTF-8?q?rds=20and=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sld-dashboard/app/home/routes.py | 41 +++++++++++++------ .../app/home/templates/deploys-list.html | 3 ++ .../app/home/templates/stack-details.html | 2 +- .../app/home/templates/stacks-cards.html | 10 +++-- .../app/home/templates/stacks-list.html | 12 +++--- 5 files changed, 46 insertions(+), 22 deletions(-) diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index f46970d1..11492447 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -1020,12 +1020,12 @@ def details_stack(stack_id): return redirect(url_for("base_blueprint.logout")) -@blueprint.route("/stack/delete/") +@blueprint.route("/stack/delete//") @login_required -def delete_stack(stack_name): +def delete_stack(view_mode, stack_name): try: token = decrypt(r.get(current_user.id)) - # Check if token no expired + # Check if token not expired check_unauthorized_token(token) response = request_url( verb="DELETE", @@ -1037,19 +1037,27 @@ def delete_stack(stack_name): flash(f"Stack {result}") else: flash(response["json"]["detail"], "error") - return redirect( - url_for("home_blueprint.route_template", template="stacks-list") - ) + + # Redirección basada en el parámetro 'view_mode' + if view_mode == "table": + return redirect(url_for("home_blueprint.route_template", template="stacks-list")) + elif view_mode == "cards": + return redirect(url_for("home_blueprint.route_template", template="stacks-cards")) + else: + flash("Invalid view mode", "error") + return redirect(url_for("home_blueprint.route_template", template="stacks-list")) + except ValueError: return redirect(url_for("base_blueprint.logout")) -@blueprint.route("/stack/resync/") + +@blueprint.route("/stack/resync//") @login_required -def resync_stack(stack_id): +def resync_stack(view_mode, stack_id): try: token = decrypt(r.get(current_user.id)) - # Check if token no expired + # Check if token not expired check_unauthorized_token(token) endpoint = f"stacks/{stack_id}" # Get deploy data vars and set var for render @@ -1075,14 +1083,21 @@ def resync_stack(stack_id): json=update_stack, ) if response.get("status_code") == 200: - flash(f"Updating Stack") + flash("Updating Stack") else: flash(response.get("json").get("detail"), "error") else: flash(response.get("json").get("detail"), "error") - return redirect( - url_for("home_blueprint.route_template", template="stacks-list") - ) + + # Redirección basada en el parámetro 'view_mode' + if view_mode == "table": + return redirect(url_for("home_blueprint.route_template", template="stacks-list")) + elif view_mode == "cards": + return redirect(url_for("home_blueprint.route_template", template="stacks-cards")) + else: + flash("Invalid view mode", "error") + return redirect(url_for("home_blueprint.route_template", template="stacks-list")) + except ValueError: return redirect(url_for("base_blueprint.logout")) diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index 8d31fb35..5ba77b90 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -65,6 +65,9 @@

All Deploys

+
+ +
diff --git a/sld-dashboard/app/home/templates/stack-details.html b/sld-dashboard/app/home/templates/stack-details.html index 09a7d8f2..8aa2c948 100644 --- a/sld-dashboard/app/home/templates/stack-details.html +++ b/sld-dashboard/app/home/templates/stack-details.html @@ -18,7 +18,7 @@
diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index 64c7ee05..13bd44c4 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -42,9 +42,12 @@

All Stacks

+
+ +
- +
@@ -83,6 +86,7 @@
{{stack.stack_name}}
Icono + {% if "yoda" in current_user.role or "darth_vader" in current_user.role %}
@@ -121,7 +125,7 @@
@@ -149,7 +153,7 @@
diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index 5e1552d9..51055895 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -39,11 +39,13 @@

All Stacks

+
+ +
- +
-
@@ -160,7 +162,6 @@

All Stacks

@@ -168,6 +169,7 @@

All Stacks

+ @@ -192,7 +194,7 @@

Stack Details

-
- - - - - Deploy Stack - - + + - {% include 'includes/footer.html' %} From 4005c3ce69729aafb5c20ae567b4adb9d4d19b54 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Tue, 26 Dec 2023 02:15:00 +0100 Subject: [PATCH 10/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20search=20hiden?= =?UTF-8?q?=20users?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/base/static/assets/css/readme.css | 2 +- sld-dashboard/app/home/routes.py | 2 +- .../app/home/templates/stacks-cards.html | 26 +++++++++++-------- .../app/home/templates/stacks-list.html | 8 +++--- .../app/home/templates/users-list.html | 3 +++ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/sld-dashboard/app/base/static/assets/css/readme.css b/sld-dashboard/app/base/static/assets/css/readme.css index 93878e3f..11804ef0 100644 --- a/sld-dashboard/app/base/static/assets/css/readme.css +++ b/sld-dashboard/app/base/static/assets/css/readme.css @@ -44,6 +44,6 @@ a:hover { } img { - max-width: 100%; + max-width: 150%; height: auto; } \ No newline at end of file diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index 11492447..bd3332c7 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -980,7 +980,7 @@ def details_stack(stack_id): readme_content = response.text readme_html = mistletoe.markdown(readme_content) # Convierte el contenido de Markdown a HTML else: - readme_html = "

Error al cargar el README.md

" + readme_html = "

Error loading the README.md file, check that it exists in the repository and on the selected branch

" # When user push data with POST verb if request.method == "POST": diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index 13bd44c4..640d08d2 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -32,7 +32,7 @@

All Stacks

-
@@ -61,7 +61,7 @@

All Stacks

{% if "aws" in stack.stack_name or "azure" in stack.stack_name or "gcp" in stack.stack_name or "custom" in stack.stack_name %}
-
+
{% if stack.icon_path %} Icono {% else %} @@ -69,10 +69,10 @@

All Stacks

{% endif %}
{{stack.stack_name}}
-
-

{{stack.description}}

-
+

{{stack.description}}

+ +
repo: {{ stack.git_repo.split('/')[-1] | replace('.git', '') }} @@ -82,12 +82,16 @@
{{stack.stack_name}}
branch: - {{ stack.branch }} + + {{ stack.branch }} + +
+
+ + +
- - Icono - - + {% if "yoda" in current_user.role or "darth_vader" in current_user.role %}
@@ -163,6 +166,7 @@
+ Icono
{% endif %} diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index 51055895..9f23176e 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -29,7 +29,7 @@

All Stacks

-
@@ -151,6 +151,9 @@

All Stacks

diff --git a/sld-dashboard/app/home/templates/users-list.html b/sld-dashboard/app/home/templates/users-list.html index 616f052c..d8bcff29 100644 --- a/sld-dashboard/app/home/templates/users-list.html +++ b/sld-dashboard/app/home/templates/users-list.html @@ -34,6 +34,9 @@

All users

+
+ +
From 94983fa804c5f23ac31e47ce9757841bc6a591ba Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Tue, 26 Dec 2023 12:38:04 +0100 Subject: [PATCH 11/14] =?UTF-8?q?=F0=9F=94=A5feat:=20Add=20redirect=20when?= =?UTF-8?q?=20edit=20stacks=20by=20localstate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sld-dashboard/app/home/routes.py | 10 +++++++--- .../app/home/templates/stack-details.html | 11 ++++++----- .../app/home/templates/stack-edit.html | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sld-dashboard/app/home/routes.py b/sld-dashboard/app/home/routes.py index bd3332c7..f935fad5 100644 --- a/sld-dashboard/app/home/routes.py +++ b/sld-dashboard/app/home/routes.py @@ -938,6 +938,8 @@ def edit_stack(stack_id): "icon_path": request.form.get("icon_path"), } # Deploy + preferred_view = request.form.get('preferredView') + response = request_url( verb="PATCH", uri=f"{endpoint}", @@ -948,9 +950,11 @@ def edit_stack(stack_id): flash("Updating Stack") else: flash(response.get("json").get("detail"), "error") - return redirect( - url_for("home_blueprint.route_template", template="stacks-list") - ) + + if preferred_view == 'cards': + return redirect(url_for("home_blueprint.route_template", template="stacks-cards")) + else: + return redirect(url_for("home_blueprint.route_template", template="stacks-list")) return render_template( "stack-edit.html", name="Edit Stack", form=form, stack=stack, icons=icons diff --git a/sld-dashboard/app/home/templates/stack-details.html b/sld-dashboard/app/home/templates/stack-details.html index b6bb43e5..1f560649 100644 --- a/sld-dashboard/app/home/templates/stack-details.html +++ b/sld-dashboard/app/home/templates/stack-details.html @@ -43,20 +43,21 @@

Stack Details

{{ stack.squads }}
--> -

+
+
 
{{ readme_html | safe }}
- -
- +
+
+ {% include 'includes/footer.html' %} diff --git a/sld-dashboard/app/home/templates/stack-edit.html b/sld-dashboard/app/home/templates/stack-edit.html index 195b6561..7f078848 100644 --- a/sld-dashboard/app/home/templates/stack-edit.html +++ b/sld-dashboard/app/home/templates/stack-edit.html @@ -86,8 +86,11 @@

{{stack.stack_name}}

+
+ + + -
@@ -109,16 +112,16 @@

{{stack.stack_name}}

{% block javascripts %} + - - - - {% endblock javascripts %} + diff --git a/sld-dashboard/app/home/templates/stacks-cards.html b/sld-dashboard/app/home/templates/stacks-cards.html index 640d08d2..65f7360c 100644 --- a/sld-dashboard/app/home/templates/stacks-cards.html +++ b/sld-dashboard/app/home/templates/stacks-cards.html @@ -74,14 +74,14 @@
{{stack.stack_name}}
- repo: + Repo: {{ stack.git_repo.split('/')[-1] | replace('.git', '') }}
- branch: + Branch: {{ stack.branch }} diff --git a/sld-dashboard/app/home/templates/stacks-list.html b/sld-dashboard/app/home/templates/stacks-list.html index 9f23176e..791e7502 100644 --- a/sld-dashboard/app/home/templates/stacks-list.html +++ b/sld-dashboard/app/home/templates/stacks-list.html @@ -194,7 +194,7 @@
@@ -222,7 +222,7 @@
From eb51e29740fde245966d22207c60f5ca29dfc675 Mon Sep 17 00:00:00 2001 From: d10s <79284025+D10S0VSkY-OSS@users.noreply.github.com> Date: Tue, 26 Dec 2023 22:42:06 +0100 Subject: [PATCH 14/14] =?UTF-8?q?=E2=AC=86Bump:=20Add=20stacks=20cards=20a?= =?UTF-8?q?nd=20details=20v3.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- play-with-sld/kubernetes/k8s/sld-api-backend.yml | 2 +- play-with-sld/kubernetes/k8s/sld-dashboard.yml | 2 +- play-with-sld/kubernetes/k8s/sld-worker-default.yml | 2 +- play-with-sld/kubernetes/k8s/sld-worker-squad1.yml | 2 +- play-with-sld/kubernetes/k8s/sld-worker-squad2.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/play-with-sld/kubernetes/k8s/sld-api-backend.yml b/play-with-sld/kubernetes/k8s/sld-api-backend.yml index f92ac18a..97af69d4 100644 --- a/play-with-sld/kubernetes/k8s/sld-api-backend.yml +++ b/play-with-sld/kubernetes/k8s/sld-api-backend.yml @@ -17,7 +17,7 @@ spec: subdomain: primary containers: - name: api-backend - image: d10s0vsky/sld-api:v3.3.1 + image: d10s0vsky/sld-api:v3.4.0 imagePullPolicy: Always command: ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"] ports: diff --git a/play-with-sld/kubernetes/k8s/sld-dashboard.yml b/play-with-sld/kubernetes/k8s/sld-dashboard.yml index 29237f35..c0820bb6 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:v3.3.1 + image: d10s0vsky/sld-dashboard:v3.4.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/play-with-sld/kubernetes/k8s/sld-worker-default.yml b/play-with-sld/kubernetes/k8s/sld-worker-default.yml index ce2e866c..a645f1cb 100644 --- a/play-with-sld/kubernetes/k8s/sld-worker-default.yml +++ b/play-with-sld/kubernetes/k8s/sld-worker-default.yml @@ -17,7 +17,7 @@ spec: subdomain: primary containers: - name: stack-deploy-worker-default - image: d10s0vsky/sld-api:v3.3.1 + image: d10s0vsky/sld-api:v3.4.0 imagePullPolicy: Always env: - name: TF_WARN_OUTPUT_ERRORS diff --git a/play-with-sld/kubernetes/k8s/sld-worker-squad1.yml b/play-with-sld/kubernetes/k8s/sld-worker-squad1.yml index 32f6ce83..fb22b664 100644 --- a/play-with-sld/kubernetes/k8s/sld-worker-squad1.yml +++ b/play-with-sld/kubernetes/k8s/sld-worker-squad1.yml @@ -17,7 +17,7 @@ spec: subdomain: primary containers: - name: stack-deploy-worker-squad1 - image: d10s0vsky/sld-api:v3.3.1 + image: d10s0vsky/sld-api:v3.4.0 imagePullPolicy: Always env: - name: TF_WARN_OUTPUT_ERRORS diff --git a/play-with-sld/kubernetes/k8s/sld-worker-squad2.yml b/play-with-sld/kubernetes/k8s/sld-worker-squad2.yml index 9cffde3f..f2b93cb1 100644 --- a/play-with-sld/kubernetes/k8s/sld-worker-squad2.yml +++ b/play-with-sld/kubernetes/k8s/sld-worker-squad2.yml @@ -17,7 +17,7 @@ spec: subdomain: primary containers: - name: stack-deploy-worker-squad2 - image: d10s0vsky/sld-api:v3.3.1 + image: d10s0vsky/sld-api:v3.4.0 imagePullPolicy: Always env: - name: TF_WARN_OUTPUT_ERRORS
+ + + {% if "yoda" in current_user.role or "darth_vader" in current_user.role %}
- - -