From 0aa7cee828b2dac7f27dac1fc78b570fdef76f79 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Wed, 18 Sep 2024 15:53:31 +0200 Subject: [PATCH 1/4] fix: cases where theme and sort cookies could be missing --- includes/getsettings.php | 5 ----- includes/header.php | 8 ++++++++ login.php | 30 ++++++++++++++++++++++-------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/includes/getsettings.php b/includes/getsettings.php index 19120cbba..1ffeaf816 100644 --- a/includes/getsettings.php +++ b/includes/getsettings.php @@ -7,14 +7,9 @@ $settings = $result->fetchArray(SQLITE3_ASSOC); if ($settings) { - $cookieExpire = time() + (30 * 24 * 60 * 60); $themeMapping = array(0 => 'light', 1 => 'dark', 2 => 'automatic'); $themeKey = isset($settings['dark_theme']) ? $settings['dark_theme'] : 2; $themeValue = $themeMapping[$themeKey]; - setcookie('theme', $themeValue, [ - 'expires' => $cookieExpire, - 'samesite' => 'Strict' - ]); $settings['update_theme_setttings'] = false; if (isset($_COOKIE['inUseTheme']) && $settings['dark_theme'] == 2) { $inUseTheme = $_COOKIE['inUseTheme']; diff --git a/includes/header.php b/includes/header.php index b132a44c8..e7b3d9294 100644 --- a/includes/header.php +++ b/includes/header.php @@ -38,6 +38,14 @@ $customCss = $settings['customCss']; } + if (isset($themeValue)) { + $cookieExpire = time() + (30 * 24 * 60 * 60); + setcookie('theme', $themeValue, [ + 'expires' => $cookieExpire, + 'samesite' => 'Strict' + ]); + } + $isAdmin = $_SESSION['userId'] == 1; function hex2rgb($hex) { diff --git a/login.php b/login.php index 7dcdb87e6..0e930020b 100644 --- a/login.php +++ b/login.php @@ -20,6 +20,8 @@ exit(); } +$cookieExpire = time() + (30 * 24 * 60 * 60); + // Check if login is disabled $adminQuery = "SELECT login_disabled FROM admin"; $adminResult = $db->query($adminQuery); @@ -50,12 +52,18 @@ $_SESSION['loggedin'] = true; $_SESSION['main_currency'] = $main_currency; $_SESSION['userId'] = $userId; - $cookieExpire = time() + (30 * 24 * 60 * 60); setcookie('language', $language, [ 'expires' => $cookieExpire, 'samesite' => 'Strict' ]); + if (!isset($_COOKIE['sortOrder'])) { + setcookie('sortOrder', 'next_payment', [ + 'expires' => $cookieExpire, + 'samesite' => 'Strict' + ]); + } + $query = "SELECT color_theme FROM settings"; $stmt = $db->prepare($query); $result = $stmt->execute(); @@ -126,22 +134,28 @@ $_SESSION['loggedin'] = true; $_SESSION['main_currency'] = $main_currency; $_SESSION['userId'] = $userId; - $cookieExpire = time() + (30 * 24 * 60 * 60); setcookie('language', $language, [ 'expires' => $cookieExpire, 'samesite' => 'Strict' ]); - if ($rememberMe) { - $query = "SELECT color_theme FROM settings"; - $stmt = $db->prepare($query); - $result = $stmt->execute(); - $settings = $result->fetchArray(SQLITE3_ASSOC); - setcookie('colorTheme', $settings['color_theme'], [ + if (!isset($_COOKIE['sortOrder'])) { + setcookie('sortOrder', 'next_payment', [ 'expires' => $cookieExpire, 'samesite' => 'Strict' ]); + } + $query = "SELECT color_theme FROM settings"; + $stmt = $db->prepare($query); + $result = $stmt->execute(); + $settings = $result->fetchArray(SQLITE3_ASSOC); + setcookie('colorTheme', $settings['color_theme'], [ + 'expires' => $cookieExpire, + 'samesite' => 'Strict' + ]); + + if ($rememberMe) { $token = bin2hex(random_bytes(32)); $addLoginTokens = "INSERT INTO login_tokens (user_id, token) VALUES (:userId, :token)"; $addLoginTokensStmt = $db->prepare($addLoginTokens); From aeb0abc699a7a8f5b1a93379ba8c8ae21aef5945 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Wed, 18 Sep 2024 15:54:06 +0200 Subject: [PATCH 2/4] feat: add button to clean up search field --- index.php | 1 + scripts/dashboard.js | 14 ++++++++++++++ styles/styles.css | 23 +++++++++++++++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 42a2a6ae2..f516c20c5 100644 --- a/index.php +++ b/index.php @@ -155,6 +155,7 @@ +
diff --git a/scripts/dashboard.js b/scripts/dashboard.js index 1d86e6e31..7db691691 100644 --- a/scripts/dashboard.js +++ b/scripts/dashboard.js @@ -442,8 +442,15 @@ document.addEventListener('DOMContentLoaded', function () { function searchSubscriptions() { const searchInput = document.querySelector("#search"); + const searchContainer = searchInput.parentElement; const searchTerm = searchInput.value.trim().toLowerCase(); + if (searchTerm.length > 0) { + searchContainer.classList.add("has-text"); + } else { + searchContainer.classList.remove("has-text"); + } + const subscriptions = document.querySelectorAll(".subscription"); subscriptions.forEach(subscription => { const name = subscription.getAttribute('data-name').toLowerCase(); @@ -455,6 +462,13 @@ function searchSubscriptions() { }); } +function clearSearch() { + const searchInput = document.querySelector("#search"); + + searchInput.value = ""; + searchSubscriptions(); +} + function closeSubMenus() { var subMenus = document.querySelectorAll('.filtermenu-submenu-content'); subMenus.forEach(subMenu => { diff --git a/styles/styles.css b/styles/styles.css index 35dedb424..3bae88717 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -277,7 +277,12 @@ button:hover svg .main-color { flex-grow: 1; } -.top-actions>.search>.search-icon { +.top-actions .search > input[type="text"] { + padding-right: 40px; +} + +.top-actions>.search>.search-icon, +.top-actions>.search>.clear-search { float: right; right: 15px; margin-top: -35px; @@ -287,7 +292,21 @@ button:hover svg .main-color { font-size: 20px; } -.rtl .top-actions>.search>.search-icon { +.top-actions>.search>.clear-search { + display: none; + cursor: pointer; +} + +.top-actions>.search.has-text>.search-icon { + display: none; +} + +.top-actions>.search.has-text>.clear-search { + display: block; +} + +.rtl .top-actions>.search>.search-icon, +.rtl .top-actions>.search>.clear-search { float: left; right: -15px; } From fff06ce52510639b9efa243bc25b3e6f9fd71276 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Wed, 18 Sep 2024 15:54:25 +0200 Subject: [PATCH 3/4] bump version --- includes/version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/version.php b/includes/version.php index a45bed749..71ad0c7f5 100644 --- a/includes/version.php +++ b/includes/version.php @@ -1,3 +1,3 @@ \ No newline at end of file From b36f2782e6540e48b1acfe67aa5509811bc37f40 Mon Sep 17 00:00:00 2001 From: Miguel Ribeiro Date: Wed, 18 Sep 2024 16:02:59 +0200 Subject: [PATCH 4/4] fix: position of dropdown on rtl layout --- styles/styles.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/styles/styles.css b/styles/styles.css index 3bae88717..64619fc39 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -383,6 +383,11 @@ button:hover svg .main-color { margin: 0px; } +.rtl .subscription-main .actions { + left: -16px; + right: auto; +} + .subscription-main .actions.is-open { display: flex; } @@ -397,6 +402,10 @@ button:hover svg .main-color { border-bottom: 1px solid #eee; } +.rtl .subscription-main .actions>li { + padding: 14px 18px 14px 35px; +} + .subscription-main .actions>li:hover { background-color: #f9f9f9; }