From b1d74bb0eb52db57048cec04184d3d41de776b12 Mon Sep 17 00:00:00 2001 From: Marina Date: Tue, 16 Apr 2024 16:20:25 +0300 Subject: [PATCH 1/3] ad js elements in results-table --- app/templates/results.html | 185 ++++++++++++++++++------------------- assets/scripts/results.js | 44 ++++++++- assets/styles/results.css | 20 ++++ 3 files changed, 151 insertions(+), 98 deletions(-) diff --git a/app/templates/results.html b/app/templates/results.html index 548ea233..16d8f85f 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -7,113 +7,112 @@ {% block main %} -
{% include "header.html" %}
-
- {% if results.is_ended %} - {% if results.is_failed %} -

- Проверка завершилась с ошибкой, попробуйте загрузить файл заново -

- {% else %} -

- Результат проверки: {{ "" if results.correct() else "не" }} пройдена! -

- {% endif %} - {% else %} -

- Производится проверка файла. Примерное время: {{ avg_process_time }} секунд (перезагрузите - страницу) -

- {% endif %} - - - +
{% include "header.html" %}
+
+ {% if results.is_ended %} + {% if results.is_failed %} +

+ Проверка завершилась с ошибкой, попробуйте загрузить файл заново +

+ {% else %} +

+ Результат проверки: {{ "" if results.correct() else "не" }} пройдена! +

+ {% endif %} + {% else %} +

+ Производится проверка файла. Примерное время: {{ avg_process_time }} секунд (перезагрузите + страницу) +

+ {% endif %} + +
+ {% for item in columns %} - + {% endfor %} - - + + + {{ (stats[0] | string)[-5:] }} {% for item in stats[1:] %} - + {% endfor %} - -
{{ item }}{{ item }}
- {{ (stats[0] | string)[-5:] }}{{ item }}{{ item }}
+ + - - {% if not current_user.is_anonymous %} - Скачать файл в исходном формате ({{ results.filename.upper().rsplit('.', 1)[-1] }}) - {% if results.conv_pdf_fs_id %} - Скачать файл в PDF-формате - {% endif %} - - Список всех загрузок пользователя - Cписок загрузок пользователя по критерию "{{current_user.criteria}}" - {% endif %} - - {% if results.is_ended and not results.is_failed %} - - - - - - - - - - - {% for criterion_info in results.enabled_checks %} - - - - - {% set colors = {0.0: 'table-danger', 1.0: 'table-success'} %} - {% set result_labels = {0.0: 'Не пройдена', 1.0: 'Пройдена'} %} - - - - + + {% endfor %} + +
#ТестРезультат
- - {{ loop.index }}{{ criterion_info['name'] }} - {{ result_labels.get(criterion_info['score'], 'Частично пройдена') }} -
-
- {% for item in criterion_info.get('verdict', ["Пройдена!"] if criterion_info.get('score')==1.0 else + + {% if not current_user.is_anonymous %} + Скачать файл в исходном формате ({{ results.filename.upper().rsplit('.', + 1)[-1] }}) + {% if results.conv_pdf_fs_id %} + Скачать файл в PDF-формате + {% endif %} + + Список всех + загрузок пользователя + Cписок загрузок пользователя по критерию "{{current_user.criteria}}" + {% endif %} + + {% if results.is_ended and not results.is_failed %} + + + + + + + + + + + {% for criterion_info in results.enabled_checks %} + + + + + {% set colors = {0.0: 'table-danger', 1.0: 'table-success'} %} + {% set result_labels = {0.0: 'Не пройдена', 1.0: 'Пройдена'} %} + + + + - - {% endfor %} - -
#ТестРезультат
{{ loop.index }}{{ criterion_info['name'] }} + {{ result_labels.get(criterion_info['score'], 'Частично пройдена') }} +
- {% endif %} + {{ item|safe }} + {% endfor %} - - {% if not current_user.is_anonymous and results.conv_pdf_fs_id %} -
-
- - - - Слайд из - -
- -
- {% endif %} +
+ {% endif %} + + {% if not current_user.is_anonymous and results.conv_pdf_fs_id %} +
+
+ + + + Слайд из + +
+
+ {% endif %} + +
{% endblock %} diff --git a/assets/scripts/results.js b/assets/scripts/results.js index 1de5eab7..a7c6a5f9 100644 --- a/assets/scripts/results.js +++ b/assets/scripts/results.js @@ -17,7 +17,7 @@ const renderPage = num => { pageIsRendering = true; pdfDoc.getPage(num).then(page => { - const viewport = page.getViewport({scale}); + const viewport = page.getViewport({ scale }); canvas.height = viewport.height; canvas.width = viewport.width; @@ -89,14 +89,48 @@ if ($("#pdf_download").length !== 0) { pdfjsLib .getDocument(href) .promise.then(pdfDoc_ => { - pdfDoc = pdfDoc_; + pdfDoc = pdfDoc_; - $('#page-count')[0].textContent = pdfDoc.numPages; - renderPage(pageNum); - }); + $('#page-count')[0].textContent = pdfDoc.numPages; + renderPage(pageNum); + }); $('#prev-page').click(showPrevPage); $('#next-page').click(showNextPage); } +document.querySelectorAll('.toggle').forEach(item => { + item.addEventListener('click', event => { + const nextRow = item.parentNode.nextElementSibling; + if (nextRow.classList.contains('hidden')) { + nextRow.classList.remove('hidden'); + nextRow.classList.add('visible'); + } else { + nextRow.classList.add('hidden'); + nextRow.classList.remove('visible'); + } + }); +}); + +const toggleButton = document.getElementById('toggleButton'); +if (toggleButton) { + toggleButton.addEventListener('click', () => { + const button = document.getElementById('toggleButton'); + if (button.innerHTML.trim() === '') { + button.innerHTML = ''; + document.querySelectorAll('.hidden').forEach(row => { + row.classList.remove('hidden'); + row.classList.add('visible'); + }); + } else { + button.innerHTML = ''; + document.querySelectorAll('.visible').forEach(row => { + row.classList.remove('visible'); + row.classList.add('hidden'); + }); + } + }); +} + + $('#showAllVerdicts').click(toggleAllVerdicts); diff --git a/assets/styles/results.css b/assets/styles/results.css index 20c5d411..55b20b3c 100644 --- a/assets/styles/results.css +++ b/assets/styles/results.css @@ -34,3 +34,23 @@ .table { margin-bottom: 0 !important; } + +.hidden { + display: none; +} + +.visible { + display: table-row; +} + +.flat-button { + border: none; + background: none; + padding: 0; + margin: 0; + cursor: pointer; +} + +.raw-button { + cursor: pointer; +} From 9ef61c5e95dc61cd78932e36ab6344f77391d1fa Mon Sep 17 00:00:00 2001 From: Marina Date: Mon, 22 Apr 2024 12:23:33 +0300 Subject: [PATCH 2/3] fix conflicts --- app/templates/results.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/templates/results.html b/app/templates/results.html index 2fe8d8a2..37aa4e4f 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -60,8 +60,8 @@

Cписок загрузок пользователя по критерию "{{current_user.criteria}}" {% endif %} - - {% if results.is_ended and not results.is_failed %} + + {% if results.is_ended and not results.is_failed %} From 26cb9b42ca31cf59620480d7e43d58f076e51381 Mon Sep 17 00:00:00 2001 From: Marina Date: Tue, 23 Apr 2024 10:51:12 +0300 Subject: [PATCH 3/3] id name changed --- app/templates/results.html | 4 ++-- assets/scripts/results.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/templates/results.html b/app/templates/results.html index 37aa4e4f..d1430fba 100644 --- a/app/templates/results.html +++ b/app/templates/results.html @@ -65,7 +65,7 @@

- + @@ -74,7 +74,7 @@

{% for criterion_info in results.enabled_checks %} - + {% set colors = {0.0: 'table-danger', 1.0: 'table-success'} %} diff --git a/assets/scripts/results.js b/assets/scripts/results.js index a7c6a5f9..0e870ea9 100644 --- a/assets/scripts/results.js +++ b/assets/scripts/results.js @@ -99,7 +99,7 @@ if ($("#pdf_download").length !== 0) { $('#next-page').click(showNextPage); } -document.querySelectorAll('.toggle').forEach(item => { +document.querySelectorAll('.toggleresult').forEach(item => { item.addEventListener('click', event => { const nextRow = item.parentNode.nextElementSibling; if (nextRow.classList.contains('hidden')) { @@ -112,10 +112,10 @@ document.querySelectorAll('.toggle').forEach(item => { }); }); -const toggleButton = document.getElementById('toggleButton'); -if (toggleButton) { - toggleButton.addEventListener('click', () => { - const button = document.getElementById('toggleButton'); +const toggleButtonResult = document.getElementById('toggleButtonResult'); +if (toggleButtonResult) { + toggleButtonResult.addEventListener('click', () => { + const button = document.getElementById('toggleButtonResult'); if (button.innerHTML.trim() === '') { button.innerHTML = ''; document.querySelectorAll('.hidden').forEach(row => {
# Тест Результат
{{ loop.index }} {{ criterion_info['name'] }}