Skip to content

Commit

Permalink
🔧refactor: aws new account dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
D10S0VSkY-OSS committed Dec 30, 2023
1 parent f95a2cc commit 6b5b29a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 18 deletions.
42 changes: 25 additions & 17 deletions sld-dashboard/app/home/templates/aws-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,21 @@ <h1 class="h4">Edit AWS Account</h1>
<div class="col-lg-12">
<div id="inputFormRow">
<!-- Iterar sobre las variables existentes -->
{% for key, value in data_json.extra_variables.items() %}
<div class="input-group col-sm-8 mb-3 dynamic-row">
<div class="col-sm-8 mb-2">
<input type="text" name="sld_key" class="form-control m-input" value="{{ key }}" placeholder="Enter variable name" autocomplete="off" {% if data_json.extra_variables.get(key) %} readonly {% endif %}>
</div>
<div class="col-sm-8 mb-4">
<input type="text" name="sld_value" class="form-control m-input" value="{{ value }}" placeholder="Enter variable value" autocomplete="off">
</div>
<div class="input-group-append">
<button type="button" class="btn btn-danger btn-sm ml-2 removeRow">Remove</button>
</div>
</div>
{% endfor %}
{% if data_json.extra_variables %}
{% for key, value in data_json.extra_variables.items() %}
<div class="input-group col-sm-8 mb-3 dynamic-row">
<div class="col-sm-8 mb-2">
<input type="text" name="sld_key" class="form-control m-input" value="{{ key }}" placeholder="Enter variable name" autocomplete="off" {% if data_json.extra_variables.get(key) %} readonly {% endif %}>
</div>
<div class="col-sm-8 mb-4">
<input type="text" name="sld_value" class="form-control m-input" value="{{ value }}" placeholder="Enter variable value" autocomplete="off">
</div>
<div class="input-group-append">
<button type="button" class="btn btn-danger btn-sm ml-2 removeRow">Remove</button>
</div>
</div>
{% endfor %}
{% endif %}
</div>

<div id="newRow"></div>
Expand All @@ -94,10 +96,11 @@ <h1 class="h4">Edit AWS Account</h1>
</div>
<div class="border-top my-4"></div>
<!-- END Extra variables -->
<button type="submit" class="btn btn-primary w-30" name="button">

<button type="submit" class="btn btn-primary" name="button">
Update Account
</button>
<button type="button" class="btn btn-danger btn-lock w-30" id="cancelButton">
<button type="button" class="btn btn-danger" id="cancelButton">
Exit
</button>
</form>
Expand Down Expand Up @@ -129,7 +132,7 @@ <h1 class="h4">Edit AWS Account</h1>
html += '<input type="text" name="sld_value" class="form-control m-input" placeholder="Enter variable value" autocomplete="off">';
html += '</div>';
html += '<div class="input-group-append">';
html += '<button type="button" class="btn btn-danger btn-sm removeRow">Remove</button>';
html += '<button type="button" class="btn btn-danger btn-sm ml-2 removeRow">Remove</button>';
html += '</div>';
html += '</div>';
html += '</div>';
Expand All @@ -139,9 +142,14 @@ <h1 class="h4">Edit AWS Account</h1>

// remove row
$(document).on('click', '.removeRow', function () {
$(this).closest('.dynamic-row').remove();
if ($('.dynamic-row').length > 1) {
$(this).closest('.dynamic-row').remove();
} else {
$(this).closest('.dynamic-row').find('input[type="text"]').val('');
}
});
</script>

<script type="text/javascript">
document.getElementById('cancelButton').addEventListener('click', function() {
// Redirect to /aws-list when the cancel button is clicked
Expand Down
11 changes: 10 additions & 1 deletion sld-dashboard/app/home/templates/aws-new.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ <h1 class="h4">Add New AWS Account</h1>
<button type="submit" class="btn btn-primary" name="button">
Create new Account
</button>
<button type="button" class="btn btn-danger" id="cancelButton">
Exit
</button>

</form>
<!-- End Form -->
Expand Down Expand Up @@ -120,7 +123,7 @@ <h1 class="h4">Add New AWS Account</h1>
html += '<input type="text" name="sld_value" class="form-control m-input" placeholder="Enter variable value" autocomplete="off">';
html += '</div>';
html += '<div class="input-group-append">';
html += '<button id="removeRow" type="button" class="btn btn-danger btn-sm">Remove</button>';
html += '<button id="removeRow" type="button" class="btn btn-danger btn-sm ml-2">Remove</button>';
html += '</div>';
html += '</div>';

Expand All @@ -132,4 +135,10 @@ <h1 class="h4">Add New AWS Account</h1>
$(this).closest('#inputFormRow').remove();
});
</script>
<script type="text/javascript">
document.getElementById('cancelButton').addEventListener('click', function() {
// Redirect to /aws-list when the cancel button is clicked
window.location.href = '/aws-list';
});
</script>
{% endblock javascripts %}

0 comments on commit 6b5b29a

Please sign in to comment.