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: set form edit #189

Merged
merged 3 commits into from
Nov 21, 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
8 changes: 7 additions & 1 deletion sld-dashboard/app/base/static/assets/css/volt.css
Original file line number Diff line number Diff line change
Expand Up @@ -41812,5 +41812,11 @@ pre {
text-align: center; /* Centrar el texto dentro del tag */
}


pre {
border-width: 0px; /* Haz esto más pequeño para un borde más delgado */
border-style: solid; /* Esto define el estilo del borde (solid, dotted, dashed, etc.) */
border-color: #cccccc; /* Esto define el color del borde */
background-color: white;
padding: 10px;
}

4 changes: 4 additions & 0 deletions sld-dashboard/app/home/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ def decrypt(secreto):
external_api_dns = settings.EXTERNAL_DNS_API


def pretty_json(value):
return json.dumps(value, indent=4)


@blueprint.route("/index")
@login_required
def index():
Expand Down
51 changes: 40 additions & 11 deletions sld-dashboard/app/home/templates/deploy-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ <h1 class="h4">Deploy Edit</h1>
<div class="col-lg-4 col-sm-6">
<!-- Form -->
<div class="col-md-12 col-md-offset-1">
<h3>{{deploy.name}}</h3>
<h1>{{deploy.name}}</h1>
<form class="" method="post">
<div class="form-group">
{{ render_field(form.start_time, autocomplete="off", class='form-control', value=deploy.start_time)
{{ render_field(form.start_time, autocomplete="off", class='form-control',
value=deploy.start_time)
}}
</div>

Expand All @@ -55,14 +56,16 @@ <h3>{{deploy.name}}</h3>
</div>
<div class="form-group">
{{ render_field(form.project_path,
autocomplete="off", class='form-control',
value=deploy.project_path) }}
autocomplete="off", class='form-control',
value=deploy.project_path) }}
</div>
<div class="form-group">
{{ render_field(form.tfvar_file, autocomplete="off", class='form-control',
value=deploy.tfvar_file) }}
</div>
{% if deploy.tfvar_file == "" %}
{% if deploy.tfvar_file == "" %}
<div class="border-top my-4"></div>
<h2>Variables</h2>
<div class="border-top my-4"></div>
{% for key, value in data_json.items()|sort %}
<div class="form-group">
Expand All @@ -72,26 +75,39 @@ <h6><strong>{{key}}</strong></h6>
{% if "passw" in key %}
<input type="password" value="{{ value }}" name={{ key }} class='form-control'
placeholder={{key}} autocomplete="off">
{% else %}
{% elif value == "true" or value == "false" %}
<select name="{{ key }}" class='form-control'>
<option value="true" {% if value=="true" %} selected {% endif %}>True
</option>
<option value="false" {% if value=="false" %} selected {% endif %}>False
</option>
</select>
{% elif value is iterable and not value is string %}
<textarea id="json{{ loop.index }}" name={{ key }} class='form-control' rows="6"
required placeholder={{key}}
autocomplete="off">{{ value | tojson | safe }}</textarea>
{% elif value is string %}
<input type="text" value="{{ value }}" name={{ key }} class='form-control'
placeholder={{key}} autocomplete="off">
{% else %}
{% endif %}
</div>
{% endfor %}
<!-- Add custom variables -->
<!-- Add custom variables -->
<div class="border-top my-4"></div>
<div class="row">
<div class="col-lg-12">
<div id="inputFormRow">
</div>

<div id="newRow"></div>
<button id="addRow" type="button" class="btn btn-info btn-sm">Add Variable</button>
<button id="addRow" type="button" class="btn btn-info btn-sm">Add
Variable</button>
</div>
</div>
<div class="border-top my-4"></div>
<!-- End Add custom variables -->
{% endif %}
<!-- End Add custom variables -->
{% endif %}
{% if deploy.action == "DryRun"%}
<button type="submit" class="btn btn-success" name="button" value=plan
action="{{url_for('.list_deploys')}}">
Expand Down Expand Up @@ -153,4 +169,17 @@ <h6><strong>{{key}}</strong></h6>
$(this).closest('#inputFormRow').remove();
});
</script>
{% endblock javascripts %}
<script>
document.addEventListener('DOMContentLoaded', function () {
var textareas = document.querySelectorAll('textarea');
textareas.forEach(function (textarea) {
try {
var obj = JSON.parse(textarea.value);
textarea.value = JSON.stringify(obj, null, 4);
} catch (e) {
}
});
});
</script>

{% endblock javascripts %}
Loading
Loading