Skip to content
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

🔥feat: add plan deploy button #182

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions sld-dashboard/app/home/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,48 @@ def get_plan(deploy_id):
except ValueError:
return redirect(url_for("base_blueprint.logout"))

@blueprint.route("/plan/redeploy/<int:deploy_id>")
@login_required
def relaunch_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="deploys-list")
)
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(
"/edit-schedule", methods=["GET", "POST"], defaults={"deploy_id": None}
Expand Down
35 changes: 18 additions & 17 deletions sld-dashboard/app/home/templates/deploys-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ <h2 class="h4">All Deploys</h2>
</div>
{% else %}
<div class="dropdown-menu">
<a class="dropdown-item" href="{{ url_for('.relaunch_plan',deploy_id=deploy.id)}}">
<span class="fas fa-sync mr-2"></span>Plan</a>
<a class="dropdown-item" href="{{ url_for('.edit_deploy',deploy_id=deploy.id)}}">
<span class="fas fa-edit mr-2"></span>Edit</a>
<a class="dropdown-item" href="{{ url_for('.relaunch_deploy',deploy_id=deploy.id)}}">
<span class="fas fa-sync mr-2"></span>Apply</a>
<span class="fas fa-cloud mr-2"></span>Apply</a>
<a class="dropdown-item text-danger" data-toggle="modal"
data-target="#DestroyModalCenter-{{deploy.id}}">
<span class="fas fa-trash-alt mr-2"></span>Destroy</a>
Expand Down Expand Up @@ -238,22 +240,21 @@ <h5 class="modal-title" id="UnlockModalLongTitle-{{deploy.id}}">Unlock Deploy
</div>
</div>
<!-- Modal Output-->
<!-- Modal para mostrar los outputs -->
<div class="modal fade" id="OutputModalCenter-{{deploy.id}}" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" >
<div class="modal-content">
<div class="modal-header">
...
</div>
<div class="modal-output" id="modal-output-{{deploy.id}}">
<!-- Los outputs se renderizarán aquí -->
</div>
<div class="modal-footer">
...
</div>
</div>
</div>
</div>
<div class="modal fade" id="OutputModalCenter-{{deploy.id}}" tabindex="-1" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" >
<div class="modal-content">
<div class="modal-header">
...
</div>
<div class="modal-output" id="modal-output-{{deploy.id}}">
</div>
<div class="modal-footer">
...
</div>
</div>
</div>
</div>
<!-- end Modal Output-->
<!-- Modal Destroy-->
<div class="modal fade" id="DestroyModalCenter-{{deploy.id}}">
<div class="modal-dialog modal-dialog-centered" role="document">
Expand Down
Loading