getpgdata: замена Flask на Node.js (Express + pg) приложение для доступа к PostgreSQL
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Ошибка <%= code %></title>
|
||||
<link rel="stylesheet" href="/public/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header><h1>Ошибка <%= code %></h1></header>
|
||||
<main>
|
||||
<p class="error"><%= message %></p>
|
||||
<p><a href="/">← На главную</a></p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,60 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>PostgreSQL Access</title>
|
||||
<link rel="stylesheet" href="/public/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>PostgreSQL Access</h1>
|
||||
<nav>
|
||||
<a href="/">Главная</a>
|
||||
<a href="/query">SQL-консоль</a>
|
||||
</nav>
|
||||
<% if (env === 'test') { %><span class="badge test">TEST</span><% } %>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section class="card">
|
||||
<h2>Подключение</h2>
|
||||
<table class="kv">
|
||||
<tr><th>Host</th><td><%= cfg.host %></td></tr>
|
||||
<tr><th>Port</th><td><%= cfg.port %></td></tr>
|
||||
<tr><th>Database</th><td><%= cfg.database %></td></tr>
|
||||
<tr><th>User</th><td><%= cfg.user %></td></tr>
|
||||
</table>
|
||||
<% if (error) { %>
|
||||
<p class="error"><%= error %></p>
|
||||
<% } else { %>
|
||||
<p class="ok">✓ Подключение активно</p>
|
||||
<% } %>
|
||||
</section>
|
||||
|
||||
<% if (tables && !error) { %>
|
||||
<section class="card">
|
||||
<h2>Таблицы (<%= tables.length %>)</h2>
|
||||
<% if (tables.length) { %>
|
||||
<table>
|
||||
<thead>
|
||||
<tr><th>Схема</th><th>Таблица</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% tables.forEach(function (t) { %>
|
||||
<tr>
|
||||
<td><%= t.schemaname %></td>
|
||||
<td><%= t.tablename %></td>
|
||||
<td><a href="/table?schema=<%= t.schemaname %>&name=<%= t.tablename %>">открыть</a></td>
|
||||
</tr>
|
||||
<% }); %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% } else { %>
|
||||
<p>Доступных таблиц нет.</p>
|
||||
<% } %>
|
||||
</section>
|
||||
<% } %>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,64 @@
|
||||
<!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>
|
||||
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Таблица — <%= schema %>.<%= name %></title>
|
||||
<link rel="stylesheet" href="/public/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Таблица: <%= schema %>.<%= name %></h1>
|
||||
<nav>
|
||||
<a href="/">Главная</a>
|
||||
<a href="/query">SQL-консоль</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<% if (error) { %>
|
||||
<p class="error"><%= error %></p>
|
||||
<% } else { %>
|
||||
<p>Строк всего: <strong><%= count %></strong>. Показано: <%= rows.length %> (стр. <%= page %>).</p>
|
||||
|
||||
<% if (columns && 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>
|
||||
|
||||
<nav class="pager">
|
||||
<% if (page > 1) { %>
|
||||
<a href="/table?schema=<%= schema %>&name=<%= name %>&page=<%= page - 1 %>&per_page=<%= perPage %>">← Назад</a>
|
||||
<% } %>
|
||||
<% if (page * perPage < count) { %>
|
||||
<a href="/table?schema=<%= schema %>&name=<%= name %>&page=<%= page + 1 %>&per_page=<%= perPage %>">Вперёд →</a>
|
||||
<% } %>
|
||||
</nav>
|
||||
<% } else { %>
|
||||
<p>Таблица пуста.</p>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user