Skip to content

Commit

Permalink
✨feat: set form edit
Browse files Browse the repository at this point in the history
  • Loading branch information
D10S0VSkY-OSS committed Nov 21, 2023
1 parent 81bd6a0 commit 3e0c04b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
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
35 changes: 34 additions & 1 deletion sld-dashboard/app/home/templates/deploy-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,18 @@ <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 is number %}
<input type="text" value="{{ value }}" name={{ key }} class='form-control'
placeholder={{key}} autocomplete="off">
<select name={{ key }} class='form-control'>
<select name="{{ key }}" id="select-{{ key }}" class="form-control">
</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 %}
Expand Down Expand Up @@ -153,4 +162,28 @@ <h6><strong>{{key}}</strong></h6>
$(this).closest('#inputFormRow').remove();
});
</script>
<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>
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('select').forEach(function (select) {
select.addEventListener('change', function () {
// Aquí puedes manejar el cambio de valor.
// Por ejemplo, imprimir el nuevo valor en la consola:
console.log('Nuevo valor para ' + this.name + ': ' + this.value);
});
});
});
</script>

{% endblock javascripts %}
13 changes: 5 additions & 8 deletions sld-dashboard/app/home/templates/deploys-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ <h2 class="h4">All Deploys</h2>
{% endif %}
<!-- Output-->
<!-- Botón para abrir el modal -->
<span class="icon icon-sm">
<a title="Output Deploy" class="nav-link icon-notifications text-dark output-button" data-task-id="{{deploy.task_id}}" data-deploy-id="{{deploy.id}}">
<span class="fab fa-searchengin mr-0"></span>
</a>
</span>
<span class="icon icon-sm">
<a title="Output Deploy" class="nav-link icon-notifications text-dark output-button" data-task-id="{{deploy.task_id}}" data-deploy-id="{{deploy.id}}">
<span class="fab fa-searchengin mr-0"></span>
</a>
</span>
<!-- Schedule -->
<span class="icon icon-sm">
<a title="Edit Schedule" class="dropdown-item" href="{{ url_for('.edit_schedule',deploy_id=deploy.id)}}">
Expand Down Expand Up @@ -268,7 +268,6 @@ <h5 class="modal-title" id="DestroyModalLongTitle-{{deploy.id}}">Destroy Deploy
<div class="modal-body">
<p><strong>This Deploy will be destroyed, could be regenerated later:</strong></p>
<p><strong>Are you sure? </strong></p>
<p> <small>Now, young Skywalker, you will die?</small></p>
</div>
<div class="modal-footer">

Expand Down Expand Up @@ -297,8 +296,6 @@ <h5 class="modal-title" id="DeleteModalLongTitle-{{deploy.id}}">Delete Deploy
This Deploy will be deleted permanently and cannot be recovered later:</strong>
</p>
<p><strong>Are you sure? </strong></p>
<p> <small>Fear is the path to the dark side. Fear leads to anger;
anger leads to hate; hate leads to suffering. I sense much fear in you</small>
</p>
</div>
<div class="modal-footer">
Expand Down
2 changes: 1 addition & 1 deletion sld-dashboard/app/home/templates/stacks-deploy.html
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ <h4>Basic Variables</h4>
<option value="false" {% if not value.get("default") %} selected {% endif %}>False</option>
</select>
{% elif field_type.startswith("map") or "object" in field_type %}
<textarea name={{ key }} class='form-control' rows="6" required>
<textarea name={{ key }} class='form-control' rows="6" required>
{{ value.get("default") | tojson | replace(",", ",\n") | replace("{", "{\n") | replace("}", "\n}") | trim | indent(4) }}
</textarea>
{% elif "passw" in key or "token" in key or "key" in key or "secret" in key %}
Expand Down

0 comments on commit 3e0c04b

Please sign in to comment.