Skip to content

Commit

Permalink
Кнопка выполнить sql
Browse files Browse the repository at this point in the history
  • Loading branch information
enovikov11 committed Oct 1, 2023
1 parent ae8126a commit 87b1981
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ https://t.me/enovikov11

### Можно ли выполнять кастомные запросы в браузере?

Это не основная фича, но да, можно: https://rtxdata.github.io/?sql
Для этого есть кнопка `Выполнить SQL`
19 changes: 14 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@

<body>
<h3>RtxData</h3>
<div class="content">Анализ данных из Райфайзен Банка (Сербия)</div>
<div class="content">
Анализ данных из Райфайзен Банка (Сербия)
<button onclick="runCustomSql()">Выполнить SQL</button>
</div>
<div class="content" id="extension" style="display: none;">
<button onclick="openRaiff()">Загрузить с raiffeisenbank.rs</button>
<button onclick="openWolt()">Загрузить с wolt.com</button>
Expand All @@ -76,6 +79,15 @@ <h3>RtxData</h3>
<input id="fileinput" type="file" accept=".json" style="display: none;" />
<div id="results"></div>
<script>
function runCustomSql() {
const customQuery = prompt("Введите SQL запрос", localStorage.sql || "SELECT * FROM TX");
if (customQuery) {
localStorage.sql = customQuery;
results.innerHTML = '';
dashboard({ [customQuery]: customQuery });
}
}

function handleGlobalError(e) {
console.error(e);
results.innerText = `Ошибка: ${e}`;
Expand Down Expand Up @@ -297,10 +309,7 @@ <h3>RtxData</h3>

const { initQuery, ...queries } = getQueries();
initDatabase(initQuery);

const customQuery = location.search === '?sql' && prompt("Введите SQL запрос", localStorage.sql || "SELECT * FROM TX");
if (customQuery) { localStorage.sql = customQuery; }
dashboard(customQuery ? { [customQuery]: customQuery } : queries);
dashboard(queries);
}

function save(key, value) {
Expand Down

0 comments on commit 87b1981

Please sign in to comment.