From 82ec0dc862acb29c7fe47d6acc052859085092a3 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 10 Oct 2023 15:42:51 +0530 Subject: [PATCH] [ADD] GENERAL: Save filter and loading animation --- static/index/saveFilters.js | 48 +++++++++++++ templates/index.html | 134 ++++++++++++++++++++++++++++++++++-- 2 files changed, 177 insertions(+), 5 deletions(-) create mode 100644 static/index/saveFilters.js diff --git a/static/index/saveFilters.js b/static/index/saveFilters.js new file mode 100644 index 000000000..34d79967b --- /dev/null +++ b/static/index/saveFilters.js @@ -0,0 +1,48 @@ +var savedFilters = localStorage.getItem("savedFilters"); +if (savedFilters != null) { + var filterDetails = JSON.parse(savedFilters); + if (window.location.pathname == filterDetails.currentPath) { + let filterForm = $(filterDetails.formSelector); + for (var fieldName in filterDetails.filterData) { + if (filterDetails.filterData.hasOwnProperty(fieldName)) { + var value = filterDetails.filterData[fieldName]; + // Set the value of the corresponding form field + filterForm.find('[name="' + fieldName + '"]').val(value); + filterForm + .find('[name="' + fieldName + '"]') + .first() + .change(); + } + } + setTimeout(() => { + filterForm.find(".filterButton").click(); + setTimeout(() => { + $("#main-section-data:first").show(); + $("#tripple-loader-contaner:first").remove(); + }, 350); + },250 ); + }else{ + $("#main-section-data:first").show(); + $("#tripple-loader-contaner:first").remove(); + } +}else{ + $("#main-section-data:first").show(); + $("#tripple-loader-contaner:first").remove(); +} +$(document).ready(function () { + $(".filterButton").click(function (e) { + var filterForm = $(this).parents().closest("form"); + var currentPath = window.location.pathname; + var formDataArray = filterForm.serializeArray(); + var filterData = {}; + formDataArray.forEach(function (item) { + filterData[item.name] = item.value; + }); + var filterDetails = { + currentPath: currentPath, + formSelector: "form" + `[hx-get="${filterForm.attr("hx-get")}"]`, + filterData: filterData, + }; + localStorage.setItem("savedFilters", JSON.stringify(filterDetails)); + }); +}); diff --git a/templates/index.html b/templates/index.html index 92286b592..71a09b330 100755 --- a/templates/index.html +++ b/templates/index.html @@ -87,10 +87,130 @@ form label{ font-weight: 700; } - + .oh-modal .oh-modal__dialog-title{ + font-weight: 600; + color: #4f4a4a; + } + + .flexbox { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -ms-flex-wrap: wrap; + flex-wrap: wrap; + } + .flexbox > div { + width: 300px; + height: 300px; + -webkit-box-flex: 0; + -ms-flex: 0 0 25%; + flex: 0 0 25%; + border: 1px solid rgba(255, 255, 255, 0.1); + -webkit-box-sizing: border-box; + box-sizing: border-box; + margin: 0; + position: relative; + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + overflow: hidden; + } + .triple-spinner { + display: block; + position: relative; + width: 125px; + height: 125px; + border-radius: 50%; + border: 4px solid transparent; + border-top: 4px solid #FF5722; + -webkit-animation: spin 2s linear infinite; + animation: spin 2s linear infinite; + } + + .triple-spinner::before, + .triple-spinner::after { + content: ""; + position: absolute; + border-radius: 50%; + border: 4px solid transparent; + } + .triple-spinner::before { + top: 5px; + left: 5px; + right: 5px; + bottom: 5px; + border-top-color: #FF9800; + -webkit-animation: spin 3s linear infinite; + animation: spin 3.5s linear infinite; + } + .triple-spinner::after { + top: 15px; + left: 15px; + right: 15px; + bottom: 15px; + border-top-color: #FFC107; + -webkit-animation: spin 1.5s linear infinite; + animation: spin 1.75s linear infinite; + } + + -webkit-@keyframes spin { + -webkit-from { + -webkit-transform: rotate(0deg); + -ms-transform: rotate(0deg); + transform: rotate(0deg); + } + -webkit-to { + -webkit-transform: rotate(360deg); + -ms-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@-webkit-keyframes spin { + from { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + +@keyframes spin { + from { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + to { + -webkit-transform: rotate(360deg); + transform: rotate(360deg); + } +} + + + + + +{% comment %}
{% endcomment %} + + + + {% comment %}
+
+
{% endcomment %} +{% comment %}
{% endcomment %} {% if messages %}
@@ -204,7 +324,7 @@ top: 3.3px; color: green; font-size: 1.2em; - }"> + "> {% endif %}
@@ -269,6 +392,7 @@ +