Compare commits
No commits in common. "8e92237fec70e716c53fd02d07d71c26faccddf5" and "354d5fdbd56e85c2a7111df1caa4221ad70190c9" have entirely different histories.
8e92237fec
...
354d5fdbd5
@ -1,8 +0,0 @@
|
|||||||
{
|
|
||||||
"semi": true,
|
|
||||||
"trailingComma": "all",
|
|
||||||
"singleQuote": true,
|
|
||||||
"printWidth": 160,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"endOfLine": "auto"
|
|
||||||
}
|
|
@ -1,62 +1,100 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" class="h-100">
|
<html lang="en" class="h-100">
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
||||||
<title>Анализ аудиторий</title>
|
|
||||||
<link
|
|
||||||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css"
|
|
||||||
rel="stylesheet"
|
|
||||||
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
/>
|
|
||||||
<script
|
|
||||||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
|
|
||||||
integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
></script>
|
|
||||||
<link rel="stylesheet" href="style.css" />
|
|
||||||
<script src="site.js"></script>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body class="bg-body-secondary h-100 d-flex align-items-center">
|
<head>
|
||||||
<div class="container py-3">
|
<meta charset="UTF-8" />
|
||||||
<div class="card">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<div class="card-body">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<div class="row">
|
<title>Анализ аудиторий</title>
|
||||||
<div class="col-lg">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
<p class="alert alert-info">Загрузите изображение в поле ниже, чтобы проверить, на фотография пустая или заполненная аудитория.</p>
|
integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous" />
|
||||||
<form id="uploadForm" action="analyze">
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"
|
||||||
<div>
|
integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz"
|
||||||
<label for="image" class="form-label">Нажмите, чтобы загрузить изображение</label>
|
crossorigin="anonymous"></script>
|
||||||
<input type="file" class="form-control" name="image" id="image" />
|
</head>
|
||||||
</div>
|
|
||||||
<div>
|
<body class="bg-body-secondary h-100 d-flex align-items-center">
|
||||||
<label for="ontology" class="form-label">Онтология предметной области</label>
|
<div class="container py-3">
|
||||||
<input type="file" class="form-control" name="ontology" id="ontology" />
|
<div class="card">
|
||||||
</div>
|
<div class="card-body">
|
||||||
<div>
|
<div class="row">
|
||||||
<label for="queries" class="form-label">Набор запросов для запуска</label>
|
<div class="col-lg">
|
||||||
<input type="text" class="form-control" name="queries" id="queries" value="QueryGetNotEmpty,QueryGetCheck,QueryGetEmpty" />
|
<p class="alert alert-info">
|
||||||
</div>
|
Загрузите изображение в поле ниже, чтобы проверить, на
|
||||||
<div class="my-3">
|
фотография пустая или заполненная аудитория.
|
||||||
<button type="submit" class="btn btn-primary">Отправить</button>
|
</p>
|
||||||
</div>
|
<form id="uploadForm" action="analyze">
|
||||||
</form>
|
<div>
|
||||||
</div>
|
<label for="image" class="form-label">Нажмите, чтобы загрузить изображение</label>
|
||||||
<div class="col-lg">
|
<input type="file" class="form-control" name="image" id="image" />
|
||||||
<div id="loaderWrapper" class="d-none">
|
|
||||||
<div class="spinner-border text-primary" role="status">
|
|
||||||
<span class="visually-hidden">Загрузка...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<img src="none.png" alt="Результат" id="imgslot" class="w-100" />
|
<div>
|
||||||
<div id="queriesResult"></div>
|
<label for="ontology" class="form-label">Онтология предметной области</label>
|
||||||
</div>
|
<input type="file" class="form-control" name="ontology" id="ontology" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="queries" class="form-label">Набор запросов для запуска</label>
|
||||||
|
<input type="text" class="form-control" name="queries" id="queries"
|
||||||
|
value="QueryGetNotEmpty,QueryGetCheck,QueryGetEmpty" />
|
||||||
|
</div>
|
||||||
|
<div class="my-3">
|
||||||
|
<button type="submit" class="btn btn-primary">
|
||||||
|
Отправить
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">
|
||||||
|
<img src="none.png" alt="Результат" id="imgslot" class="w-100" />
|
||||||
|
<div id="queriesResult"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</div>
|
||||||
</html>
|
<script>
|
||||||
|
document
|
||||||
|
.getElementById("uploadForm")
|
||||||
|
.addEventListener("submit", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const data = new FormData(event.target);
|
||||||
|
fetch("/analyze", { method: "POST", body: data })
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => {
|
||||||
|
const img = document.getElementById("imgslot");
|
||||||
|
const queriesResult = document.getElementById("queriesResult");
|
||||||
|
|
||||||
|
img.src = "none.png";
|
||||||
|
if (data.image) {
|
||||||
|
img.src = "data:image/jpg;base64," + data.image;
|
||||||
|
}
|
||||||
|
|
||||||
|
queriesResult.innerHTML = "";
|
||||||
|
if (data.data && data.data.response) {
|
||||||
|
for (const [query, result] of Object.entries(
|
||||||
|
data.data.response
|
||||||
|
)) {
|
||||||
|
// Отрисовка результата запросов.
|
||||||
|
const markup = `
|
||||||
|
<h1 class="display-6">${query}</h1>
|
||||||
|
<table class="table table-bordered table-striped">
|
||||||
|
<tr>
|
||||||
|
${result.columns.map((column) => `<th>${column}</th>`).join("")}
|
||||||
|
</tr>
|
||||||
|
${result.rows.map(
|
||||||
|
(row) =>
|
||||||
|
`<tr>${Object.entries(row)
|
||||||
|
.map(([key, value]) => `<td>${value.value}</td>`)
|
||||||
|
.join("")}</tr>`
|
||||||
|
)}
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
queriesResult.innerHTML += markup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -1,53 +0,0 @@
|
|||||||
const renderResultMarkup = (query, result) =>
|
|
||||||
`
|
|
||||||
<h1 class="display-6">${query}</h1>
|
|
||||||
<table class="table table-bordered table-striped">
|
|
||||||
<tr>
|
|
||||||
${result.columns.map((column) => `<th>${column}</th>`).join('')}
|
|
||||||
</tr>
|
|
||||||
${result.rows.map(
|
|
||||||
(row) =>
|
|
||||||
`<tr>${Object.entries(row)
|
|
||||||
.map(([key, value]) => `<td>${value.value}</td>`)
|
|
||||||
.join('')}</tr>`,
|
|
||||||
)}
|
|
||||||
</table>`;
|
|
||||||
|
|
||||||
const processAnalyzeResult = (data) => {
|
|
||||||
const img = document.getElementById('imgslot');
|
|
||||||
const queriesResult = document.getElementById('queriesResult');
|
|
||||||
|
|
||||||
img.src = 'none.png';
|
|
||||||
if (data.image) {
|
|
||||||
img.src = 'data:image/jpg;base64,' + data.image;
|
|
||||||
}
|
|
||||||
|
|
||||||
queriesResult.innerHTML = '';
|
|
||||||
if (data.data && data.data.response) {
|
|
||||||
for (const [query, result] of Object.entries(data.data.response)) {
|
|
||||||
queriesResult.innerHTML += renderResultMarkup(query, result);
|
|
||||||
}
|
|
||||||
} else if (data.data && data.data.error) {
|
|
||||||
queriesResult.innerHTML = `<div class="alert alert-danger">${JSON.stringify(data.data.error)}</div>`;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleFormSubmit = (event) => {
|
|
||||||
event.preventDefault();
|
|
||||||
const data = new FormData(event.target);
|
|
||||||
const loaderWrapper = document.getElementById('loaderWrapper');
|
|
||||||
loaderWrapper.classList.remove('d-none');
|
|
||||||
fetch('/analyze', { method: 'POST', body: data })
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then(processAnalyzeResult)
|
|
||||||
.catch(() => {
|
|
||||||
alert('Произошла внутренняя ошибка.');
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
loaderWrapper.classList.add('d-none');
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
|
||||||
document.getElementById('uploadForm').addEventListener('submit', handleFormSubmit);
|
|
||||||
});
|
|
@ -1,11 +0,0 @@
|
|||||||
#loaderWrapper {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
bottom: 0;
|
|
||||||
background-color: #33333333;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user