65 lines
2.1 KiB
Plaintext
65 lines
2.1 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="ru">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>SQL-консоль</title>
|
|
<link rel="stylesheet" href="/public/style.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>SQL-консоль (read-only)</h1>
|
|
<nav>
|
|
<a href="/">Главная</a>
|
|
<a href="/query">SQL-консоль</a>
|
|
</nav>
|
|
</header>
|
|
|
|
<main>
|
|
<section class="card">
|
|
<form method="post" action="/query">
|
|
<textarea name="sql" rows="8" placeholder="SELECT * FROM public.contracts LIMIT 100;"><%= sql %></textarea>
|
|
<button type="submit">Выполнить</button>
|
|
<p class="hint">Только SELECT. Обрезается до <%= QUERY_MAX_ROWS || 200 %> строк.</p>
|
|
</form>
|
|
</section>
|
|
|
|
<% if (error) { %>
|
|
<p class="error"><%= error %></p>
|
|
<% } %>
|
|
|
|
<% if (columns && !error) { %>
|
|
<section class="card">
|
|
<h2>Результат <% if (elapsed !== null) { %>(<%= elapsed %> c)<% } %></h2>
|
|
<% if (columns.length) { %>
|
|
<div class="table-wrap">
|
|
<table>
|
|
<thead>
|
|
<tr><% columns.forEach(function (c) { %><th><%= c %></th><% }); %></tr>
|
|
</thead>
|
|
<tbody>
|
|
<% rows.forEach(function (r) { %>
|
|
<tr>
|
|
<% columns.forEach(function (c) { %>
|
|
<td>
|
|
<% if (r[c] === null) { %><span class="null">NULL</span>
|
|
<% } else if (typeof r[c] === 'boolean') { %><%= r[c] ? 'true' : 'false' %>
|
|
<% } else if (r[c] instanceof Date) { %><%= r[c].toISOString() %>
|
|
<% } else { %><%= r[c] %><% } %>
|
|
</td>
|
|
<% }); %>
|
|
</tr>
|
|
<% }); %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<p class="hint">Строк: <%= rows.length %></p>
|
|
<% } else { %>
|
|
<p>Запрос выполнен без набора строк.</p>
|
|
<% } %>
|
|
</section>
|
|
<% } %>
|
|
</main>
|
|
</body>
|
|
</html>
|