diff --git a/static/index.html b/static/index.html
index d572773..fd3635f 100644
--- a/static/index.html
+++ b/static/index.html
@@ -46,6 +46,11 @@
+
diff --git a/static/site.js b/static/site.js
index 1e351e9..40001a3 100644
--- a/static/site.js
+++ b/static/site.js
@@ -27,15 +27,25 @@ const processAnalyzeResult = (data) => {
for (const [query, result] of Object.entries(data.data.response)) {
queriesResult.innerHTML += renderResultMarkup(query, result);
}
+ } else if (data.data && data.data.error) {
+ queriesResult.innerHTML = `${JSON.stringify(data.data.error)}
`;
}
};
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);
+ .then(processAnalyzeResult)
+ .catch(() => {
+ alert('Произошла внутренняя ошибка.');
+ })
+ .finally(() => {
+ loaderWrapper.classList.add('d-none');
+ });
};
document.addEventListener('DOMContentLoaded', () => {
diff --git a/static/style.css b/static/style.css
index e69de29..85fa2cf 100644
--- a/static/style.css
+++ b/static/style.css
@@ -0,0 +1,11 @@
+#loaderWrapper {
+ position: absolute;
+ left: 0;
+ right: 0;
+ top: 0;
+ bottom: 0;
+ background-color: #33333333;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}