Обновить query.cfm

This commit is contained in:
naeel 2026-02-17 08:31:39 +03:00
parent b9d0054f8d
commit f167adce15

110
query.cfm
View File

@ -1,66 +1,86 @@
<h1>TEST v2</h1>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Nubes Lucee CRUD</title>
<style>
body { font-family: sans-serif; margin: 30px; line-height: 1.5; }
table { border-collapse: collapse; width: 80%; margin-top: 20px; }
th, td { border: 1px solid #ccc; padding: 10px; text-align: left; }
th { background: #eee; }
.success { color: #27ae60; font-weight: bold; }
.env-box { background: #f9f9f9; padding: 10px; border: 1px dashed #999; margin-top: 30px; font-size: 0.8em; }
body { font-family: 'Segoe UI', Tahoma, sans-serif; margin: 0; padding: 40px; background: #f0f2f5; color: #1c1e21; }
.box { background: #fff; padding: 30px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.08); max-width: 900px; margin: auto; }
.header { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #005bff; padding-bottom: 15px; margin-bottom: 25px; }
.logo { height: 40px; }
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #ebedf0; }
th { background: #f8f9fa; color: #606770; font-size: 0.9em; text-transform: uppercase; }
.btn { cursor: pointer; padding: 7px 14px; border: none; border-radius: 6px; color: #fff; font-weight: 600; transition: opacity 0.2s; }
.btn:hover { opacity: 0.8; }
.btn-add { background: #005bff; }
.btn-upd { background: #28a745; }
.btn-del { background: #dc3545; }
.input-text { padding: 10px; border: 1px solid #ddd; border-radius: 6px; width: 300px; }
.input-inline { padding: 5px; border: 1px solid #eee; border-radius: 4px; width: 90%; font-family: inherit; }
.err { background: #fff1f0; border: 1px solid #ffa39e; padding: 10px; border-radius: 6px; color: #cf1322; margin-bottom: 20px; }
</style>
</head>
<body>
<h2>🛠 Тест базы данных: Запись и Чтение</h2>
<div class="box">
<div class="header">
<img src="https://nubes.ru/themes/custom/nubes_2025/logo.svg" alt="Nubes Logo" class="logo">
<h2 style="margin:0; color: #005bff;">Lucee CRUD Demo</h2>
</div>
<cftry>
<cfquery name="qCreate">
CREATE TABLE IF NOT EXISTS nubes_test_table (
id SERIAL PRIMARY KEY,
test_data TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
<cfif structKeyExists(request, "db_error")>
<div class="err"><strong>Ошибка базы данных:</strong><br><cfoutput>#request.db_error#</cfoutput></div>
</cfif>
<form method="post" style="display: flex; gap: 10px; margin-bottom: 30px;">
<input type="hidden" name="crud_action" value="insert">
<input type="text" name="txt_content" placeholder="Введите данные для записи в БД..." required class="input-text" style="flex-grow: 1;">
<button type="submit" class="btn btn-add">Добавить запись</button>
</form>
<cfquery name="qGet" datasource="#request.DS#">
SELECT * FROM nubes_test_table ORDER BY id DESC LIMIT 15
</cfquery>
<cfquery name="qInsert">
INSERT INTO nubes_test_table (test_data)
VALUES ('Проверка записи через Lucee: ' || CURRENT_TIMESTAMP);
</cfquery>
<cfquery name="qSelect">
SELECT * FROM nubes_test_table ORDER BY id DESC LIMIT 10;
</cfquery>
<p class="success">✅ Соединение активно! Данные успешно записаны в PostgreSQL.</p>
<table>
<thead>
<tr>
<th>ID</th>
<th>Сообщение из базы</th>
<th>Дата и время в БД</th>
<th style="width: 50px;">ID</th>
<th>Данные в PostgreSQL</th>
<th style="width: 120px;">Действия</th>
</tr>
</thead>
<tbody>
<cfoutput query="qSelect">
<cfoutput query="qGet">
<tr>
<td>#id#</td>
<td>#test_data#</td>
<td>#created_at#</td>
<td>
<form method="post" id="upd_#id#" style="margin:0">
<input type="hidden" name="crud_action" value="update">
<input type="hidden" name="id" value="#id#">
<input type="text" name="txt_content" value="#HTMLEditFormat(test_data)#" class="input-inline">
</form>
</td>
<td style="display: flex; gap: 5px;">
<button type="submit" form="upd_#id#" class="btn btn-upd" title="Сохранить изменения">💾</button>
<form method="post" style="margin:0" onsubmit="return confirm('Удалить эту запись?')">
<input type="hidden" name="crud_action" value="delete">
<input type="hidden" name="id" value="#id#">
<button type="submit" class="btn btn-del" title="Удалить">🗑</button>
</form>
</td>
</tr>
</cfoutput>
</tbody>
</table>
<cfcatch>
<div style="color:red; border: 1px solid red; padding: 10px;">
<strong>❌ Ошибка:</strong><br>
<cfoutput>#cfcatch.message#</cfoutput>
<div style="margin-top: 30px; padding-top: 15px; border-top: 1px solid #eee; font-size: 0.8em; color: #999; display: flex; justify-content: space-between;">
<span>DS: <strong><cfoutput>#request.DS#</cfoutput></strong></span>
<span>Pod: <cfoutput>$(kubectl get pods -l app=nifiregistry-sample -o name | head -1)</cfoutput></span>
</div>
</div>
</cfcatch>
</cftry>
<div class="env-box">
<details>
<summary style="cursor:pointer;">Показать переменные окружения (Terraform)</summary>
<cfdump var="#createObject('java', 'java.lang.System').getEnv()#" label="System Env" expand="false">
</details>
</div>
</body>
</html>