diff --git a/sld-api-backend/src/deploy/infrastructure/repositories.py b/sld-api-backend/src/deploy/infrastructure/repositories.py index 673d7070..c72ac30c 100644 --- a/sld-api-backend/src/deploy/infrastructure/repositories.py +++ b/sld-api-backend/src/deploy/infrastructure/repositories.py @@ -1,6 +1,7 @@ import datetime from sqlalchemy.orm import Session +from sqlalchemy import desc import src.deploy.domain.entities.deploy as schemas_deploy import src.deploy.infrastructure.models as models @@ -176,7 +177,7 @@ def get_deploy_by_name_squad( def get_all_deploys(db: Session, skip: int = 0, limit: int = 100): try: - return db.query(models.Deploy).offset(skip).limit(limit).all() + return db.query(models.Deploy).order_by(desc(models.Deploy.id)).offset(skip).limit(limit).all() except Exception as err: raise err diff --git a/sld-dashboard/app/base/static/assets/css/volt.css b/sld-dashboard/app/base/static/assets/css/volt.css index 361b11b9..3ec33371 100644 --- a/sld-dashboard/app/base/static/assets/css/volt.css +++ b/sld-dashboard/app/base/static/assets/css/volt.css @@ -41711,9 +41711,26 @@ pre { word-wrap: break-word; } -.plus { color: #54C571; } -.minus { color: #C34A2C; } -.tilde { color: #6698FF; } +.plus { + color: #54C571; + font-size: medium; + font-family: "Courier New"; + } +.minus { + color: #C34A2C; + font-size: medium; + font-family: "Courier New"; + } +.tilde { + color: #6698FF; + font-size: medium; + font-family: "Courier New"; + } +.others { + color: whitesmoke; + font-size: medium; + font-family: "Courier New"; + } .modal-black-background { background-color: black; @@ -41724,3 +41741,11 @@ pre { direction: rtl; /* Right-to-left */ text-align: right; /* For good measure, in case of LTR content */ } + +.modal-output { + position: relative; + flex: 1 1 auto; + padding: 1rem; + background-color: #040720; + color: #fff; +} \ No newline at end of file diff --git a/sld-dashboard/app/base/static/assets/js/copy_clipboard.js b/sld-dashboard/app/base/static/assets/js/copy_clipboard.js new file mode 100644 index 00000000..8f943871 --- /dev/null +++ b/sld-dashboard/app/base/static/assets/js/copy_clipboard.js @@ -0,0 +1,41 @@ +function copyToClipboard(text) { + // Create a new textarea element and give it the text to be copied + const elem = document.createElement('textarea'); + elem.value = text; + // Append it to the body + document.body.appendChild(elem); + // Select the text + elem.select(); + // Execute the copy command + document.execCommand('copy'); + // Remove the textarea element from the document + document.body.removeChild(elem); + // Show a message that the text was copied + showMessage('Copied to clipboard!'); +} + +function showMessage(message) { + // Create a message element + const messageElem = document.createElement('div'); + messageElem.textContent = message; + // Style the message element + messageElem.style.position = 'fixed'; + messageElem.style.bottom = '20px'; + messageElem.style.left = '50%'; + messageElem.style.transform = 'translateX(-50%)'; + messageElem.style.backgroundColor = 'rgba(0, 0, 0, 0.5)'; + messageElem.style.color = 'white'; + messageElem.style.padding = '10px'; + messageElem.style.borderRadius = '5px'; + messageElem.style.zIndex = '1000'; + messageElem.style.transition = 'opacity 0.5s'; + // Append the message element to the body + document.body.appendChild(messageElem); + // Remove the message after some time + setTimeout(() => { + messageElem.style.opacity = '0'; + setTimeout(() => { + document.body.removeChild(messageElem); + }, 500); // Wait for the fade out to finish before removing the element + }, 2000); // Show the message for 2 seconds +} diff --git a/sld-dashboard/app/base/static/assets/js/download_tfvars.js b/sld-dashboard/app/base/static/assets/js/download_tfvars.js new file mode 100644 index 00000000..0993603b --- /dev/null +++ b/sld-dashboard/app/base/static/assets/js/download_tfvars.js @@ -0,0 +1,35 @@ +// script.js +function downloadTFVars(element) { + // Retrieve the data-variables content, which is a string representation of a Python dictionary + var data = element.getAttribute('data-variables'); + + // Log the data for debugging + console.log('Data-variables content:', data); + + // Convert and format the string to a pretty-printed JSON string + try { + var jsonString = data + .replace(/'/g, '"') // Replace single quotes with double quotes + .replace(/False/g, 'false') // Replace Python's False with JavaScript's false + .replace(/True/g, 'true') // Replace Python's True with JavaScript's true + .replace(/None/g, 'null'); // Replace Python's None with JavaScript's null + + // Parse and re-stringify with indentation for pretty-printing + var formattedJsonString = JSON.stringify(JSON.parse(jsonString), null, 2); + + // Download the formatted JSON string as a blob + var blob = new Blob([formattedJsonString], { type: 'application/json' }); + var url = URL.createObjectURL(blob); + + // Create a link, trigger a download, and clean up + var a = document.createElement('a'); + a.download = 'terraform.tfvars.json'; + a.href = url; + document.body.appendChild(a); + a.click(); + URL.revokeObjectURL(url); + document.body.removeChild(a); + } catch (error) { + console.error('Error converting dictionary string to JSON:', error); + } +} diff --git a/sld-dashboard/app/home/templates/deploys-list.html b/sld-dashboard/app/home/templates/deploys-list.html index 6739eb0b..ead9d178 100644 --- a/sld-dashboard/app/home/templates/deploys-list.html +++ b/sld-dashboard/app/home/templates/deploys-list.html @@ -109,13 +109,20 @@

All Deploys

- {% for deploy in deploys| sort(attribute='id') %} - + {% for deploy in deploys %} + + + + + + {{ deploy.id }} + {{ deploy.name }} @@ -245,7 +252,7 @@