Skip to content

Wallos: Open-source, self-hostable personal subscription tracker. Visualize your recurring expenses, manage your budget, and save money.

feat: option to hide disabled subscriptions (#286)

Miguel Ribeirob80ab4bdc662
diff --git a/endpoints/settings/hide_disabled.php b/endpoints/settings/hide_disabled.php
new file mode 100644
index 0000000..00a247c
--- /dev/null
+++ b/endpoints/settings/hide_disabled.php
@@ -0,0 +1,33 @@
+<?php
+require_once '../../includes/connect_endpoint.php';
+session_start();
+if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
+ die(json_encode([
+ "success" => false,
+ "message" => translate('session_expired', $i18n)
+ ]));
+}
+
+if ($_SERVER["REQUEST_METHOD"] === "POST") {
+ $postData = file_get_contents("php://input");
+ $data = json_decode($postData, true);
+
+ $hide_disabled = $data['value'];
+
+ $stmt = $db->prepare('UPDATE settings SET hide_disabled = :hide_disabled');
+ $stmt->bindParam(':hide_disabled', $hide_disabled, SQLITE3_INTEGER);
+
+ if ($stmt->execute()) {
+ die(json_encode([
+ "success" => true,
+ "message" => translate("success", $i18n)
+ ]));
+ } else {
+ die(json_encode([
+ "success" => false,
+ "message" => translate("error", $i18n)
+ ]));
+ }
+}
+
+?>
\ No newline at end of file
diff --git a/endpoints/subscriptions/get.php b/endpoints/subscriptions/get.php
index 1988b4a..83256a8 100644
--- a/endpoints/subscriptions/get.php
+++ b/endpoints/subscriptions/get.php
@@ -70,6 +70,9 @@
$defaultLogo = $theme == "light" ? "images/siteicons/" . $colorTheme . "/wallos.png" : "images/siteicons/" . $colorTheme . "/walloswhite.png";
foreach ($subscriptions as $subscription) {
+ if ($subscription['inactive'] == 1 && isset($settings['hideDisabledSubscriptions']) && $settings['hideDisabledSubscriptions'] === 'true') {
+ continue;
+ }
$id = $subscription['id'];
$print[$id]['id'] = $id;
$print[$id]['logo'] = $subscription['logo'] != "" ? "images/uploads/logos/".$subscription['logo'] : $defaultLogo;
diff --git a/includes/getsettings.php b/includes/getsettings.php
index 3f1ae6d..1248d35 100644
--- a/includes/getsettings.php
+++ b/includes/getsettings.php
@@ -11,6 +11,7 @@ if ($settings) {
$settings['showMonthlyPrice'] = $settings['monthly_price'] ? 'true': 'false';
$settings['convertCurrency'] = $settings['convert_currency'] ? 'true': 'false';
$settings['removeBackground'] = $settings['remove_background'] ? 'true': 'false';
+ $settings['hideDisabledSubscriptions'] = $settings['hide_disabled'] ? 'true': 'false';
}
$query = "SELECT * FROM custom_colors";
diff --git a/includes/i18n/de.php b/includes/i18n/de.php
index 636e087..c7cd0d5 100644
--- a/includes/i18n/de.php
+++ b/includes/i18n/de.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Light / Dark Theme umschalten",
"calculate_monthly_price" => "Berechne und zeige monatlichen Preis für alle Abonnements an",
"convert_prices" => "Preise immer in meine Hauptwährung umrechnen und darin anzeigen (langsamer)",
+ "hide_disabled_subscriptions" => "Deaktivierte Abonnements verstecken",
"experimental_settings" => "Experimentelle Einstellungen",
"remove_background" => "Versuchen den Hintergrund von Logos aus der Bildersuche zu entfernen (experimentell)",
"experimental_info" => "Experimentelle Einstellungen funktionieren möglicherweise nicht perfekt.",
diff --git a/includes/i18n/el.php b/includes/i18n/el.php
index 2604f43..bae9ed3 100644
--- a/includes/i18n/el.php
+++ b/includes/i18n/el.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Διακόπτης Light / Dark Theme",
"calculate_monthly_price" => "Υπολογισμός και εμφάνιση της μηνιαίας τιμής για όλες τις συνδρομές",
"convert_prices" => "Πάντα να μετατρέπει και να εμφανίζει τις τιμές στο κύριο νόμισμά μου (πιο αργό)",
+ "hide_disabled_subscriptions" => "Απόκρυψη απενεργοποιημένων συνδρομών",
"experimental_settings" => "Πειραματικές ρυθμίσεις",
"remove_background" => "Προσπάθεια αφαίρεσης του φόντου των λογότυπων από την αναζήτηση εικόνας (πειραματικά)",
"experimental_info" => "Οι πειραματικές ρυθμίσεις πιθανότατα δεν θα λειτουργούν τέλεια.",
diff --git a/includes/i18n/en.php b/includes/i18n/en.php
index a918f07..a48f241 100644
--- a/includes/i18n/en.php
+++ b/includes/i18n/en.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Switch Light / Dark Theme",
"calculate_monthly_price" => "Calculate and show monthly price for all subscriptions",
"convert_prices" => "Always convert and show prices on my main currency (slower)",
+ "hide_disabled_subscriptions" => "Hide disabled subscriptions",
"experimental_settings" => "Experimental Settings",
"remove_background" => "Attempt to remove background of logos from image search (experimental)",
"experimental_info" => "Experimental settings will probably not work perfectly.",
diff --git a/includes/i18n/es.php b/includes/i18n/es.php
index 0fe8f5d..0be9bab 100644
--- a/includes/i18n/es.php
+++ b/includes/i18n/es.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Cambiar entre Tema Claro / Oscuro",
"calculate_monthly_price" => "Calcular y mostrar el precio mensual de todas las suscripciones",
"convert_prices" => "Convertir y mostrar siempre los precios en mi moneda principal (más lento)",
+ "hide_disabled_subscriptions" => "Ocultar suscripciones desactivadas",
"experimental_settings" => "Configuraciones Experimentales",
"remove_background" => "Intentar quitar el fondo de los logotipos de la búsqueda de imágenes (experimental)",
"experimental_info" => "Las configuraciones experimentales probablemente no funcionarán perfectamente.",
diff --git a/includes/i18n/fr.php b/includes/i18n/fr.php
index 6749344..c661ea2 100644
--- a/includes/i18n/fr.php
+++ b/includes/i18n/fr.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Basculer entre le thème clair et sombre",
"calculate_monthly_price" => "Calculer et afficher le prix mensuel pour tous les abonnements",
"convert_prices" => "Convertir toujours et afficher les prix dans ma devise principale (plus lent)",
+ "hide_disabled_subscriptions" => "Masquer les abonnements désactivés",
"experimental_settings" => "Paramètres expérimentaux",
"remove_background" => "Tenter de supprimer l'arrière-plan des logos de la recherche d'images (expérimental)",
"experimental_info" => "Les paramètres expérimentaux ne fonctionneront probablement pas parfaitement.",
diff --git a/includes/i18n/it.php b/includes/i18n/it.php
index bd05f8b..d1204e2 100644
--- a/includes/i18n/it.php
+++ b/includes/i18n/it.php
@@ -150,6 +150,7 @@ $i18n = [
'switch_theme' => 'Cambia tema chiaro/scuro',
'calculate_monthly_price' => 'Calcola e mostra il prezzo mensile per tutti gli abbonamenti',
'convert_prices' => 'Converti sempre e mostra i prezzi nella mia valuta principale (più lento)',
+ "hide_disabled_subscriptions" => 'Nascondi gli abbonamenti disattivati',
'experimental_settings' => 'Impostazioni sperimentali',
'remove_background' => 'Prova a rimuovere lo sfondo dei loghi dalla ricerca delle immagini (sperimentale)',
'experimental_info' => 'Le impostazioni sperimentali potrebbero non funzioneranno perfettamente.',
diff --git a/includes/i18n/jp.php b/includes/i18n/jp.php
index 41011e3..2a4d543 100644
--- a/includes/i18n/jp.php
+++ b/includes/i18n/jp.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "ライト/ダーク テーマの切り替え",
"calculate_monthly_price" => "すべての定期購入の月額料金を計算して表示する",
"convert_prices" => "常にメイン通貨で価格を換算して表示する (遅い)",
+ "hide_disabled_subscriptions" => "無効な定期購入を非表示にする",
"experimental_settings" => "実験的な設定",
"remove_background" => "画像検索からロゴの背景を削除する (実験)",
"experimental_info" => "実験的な設定は、おそらく完全には機能しません。",
diff --git a/includes/i18n/pl.php b/includes/i18n/pl.php
index 9f3f725..7b9cfe9 100644
--- a/includes/i18n/pl.php
+++ b/includes/i18n/pl.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Przełącz na jasny/ciemny motyw",
"calculate_monthly_price" => "Oblicz i pokaż miesięczną cenę wszystkich subskrypcji",
"convert_prices" => "Zawsze przeliczaj i pokazuj ceny w mojej głównej walucie (wolniej)",
+ "hide_disabled_subscriptions" => "Ukryj wyłączone subskrypcje",
"experimental_settings" => "Ustawienia eksperymentalne",
"remove_background" => "Próba usunięcia tła logo z wyszukiwania obrazów (eksperymentalnie)",
"experimental_info" => "Ustawienia eksperymentalne prawdopodobnie nie będą działać idealnie.",
diff --git a/includes/i18n/pt.php b/includes/i18n/pt.php
index cab6b4f..00b3146 100644
--- a/includes/i18n/pt.php
+++ b/includes/i18n/pt.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Trocar Tema Claro / Escuro",
"calculate_monthly_price" => "Calcular e mostrar preço mensal para todas as subscrições",
"convert_prices" => "Converter e mostrar todas as subscrições na moeda principal (mais lento)",
+ "hide_disabled_subscriptions" => "Esconder subscrições desactivadas",
"experimental_settings" => "Definições Experimentais",
"remove_background" => "Tentar remover o fundo dos logos na pesquisa de imagem (experimental)",
"experimental_info" => "Definições experimentais provavelmente não funcionarão correctamente.",
diff --git a/includes/i18n/pt_br.php b/includes/i18n/pt_br.php
index 8ac351f..2ee754b 100644
--- a/includes/i18n/pt_br.php
+++ b/includes/i18n/pt_br.php
@@ -143,6 +143,7 @@ $i18n = [
"switch_theme" => "Alternar entre tema Claro / Escuro",
"calculate_monthly_price" => "Calcular e exibir o custo mensal para todas as assinaturas",
"convert_prices" => "Sempre converter e exibir preços na moeda principal (mais lento)",
+ "hide_disabled_subscriptions" => "Ocultar assinaturas desativadas",
"experimental_settings" => "Configurações experimentais",
"remove_background" => "Tentar remover o fundo de logos na pesquisa de imagem",
"experimental_info" => "As configurações experimentais provavelmente não funcionarão corretamente",
diff --git a/includes/i18n/sr.php b/includes/i18n/sr.php
index e517cd5..3306079 100644
--- a/includes/i18n/sr.php
+++ b/includes/i18n/sr.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Промени светлу / тамну тему",
"calculate_monthly_price" => "Израчунајте и прикажите месечну цену за све претплате",
"convert_prices" => "Увек конвертујте и прикажите цене на мојој главној валути (спорије)",
+ "hide_disabled_subscriptions" => "Сакриј онемогућене претплате",
"experimental_settings" => "Експериментална подешавања",
"remove_background" => "Покушајте уклонити позадину логотипа са слика претраге (експериментално)",
"experimental_info" => "Експериментална подешавања вероватно неће радити савршено.",
diff --git a/includes/i18n/sr_lat.php b/includes/i18n/sr_lat.php
index 6adfcc7..99db3d4 100644
--- a/includes/i18n/sr_lat.php
+++ b/includes/i18n/sr_lat.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Promeni svetli / tamni temu",
"calculate_monthly_price" => "Izračunaj i prikaži mesečnu cenu za sve pretplate",
"convert_prices" => "Uvek konvertuj i prikaži cene u mojoj glavnoj valuti (sporije)",
+ "hide_disabled_subscriptions" => "Sakrij onemogućene pretplate",
"experimental_settings" => "Eksperimentalna podešavanja",
"remove_background" => "Pokušajte ukloniti pozadinu logotipa sa pretrage slika (eksperimentalno)",
"experimental_info" => "Eksperimentalna podešavanja verovatno neće savršeno funkcionisati.",
diff --git a/includes/i18n/tr.php b/includes/i18n/tr.php
index f7bdb91..d29c3c1 100644
--- a/includes/i18n/tr.php
+++ b/includes/i18n/tr.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "Açık / Koyu Temayı Değiştir",
"calculate_monthly_price" => "Tüm aboneliklerin aylık fiyatını hesaplayın ve gösterin",
"convert_prices" => "Fiyatları her zaman ana para birimimde dönüştürün ve gösterin (daha yavaş)",
+ "hide_disabled_subscriptions" => "Devre dışı bırakılan abonelikleri gizle",
"experimental_settings" => "Deneysel Ayarlar",
"remove_background" => "Görsel aramadan logoların arka planını kaldırmayı deneyin (deneysel)",
"experimental_info" => "Deneysel ayarlar muhtemelen mükemmel çalışmayacak.",
diff --git a/includes/i18n/zh_cn.php b/includes/i18n/zh_cn.php
index d8341d5..e43fa65 100644
--- a/includes/i18n/zh_cn.php
+++ b/includes/i18n/zh_cn.php
@@ -152,6 +152,7 @@ $i18n = [
"switch_theme" => "切换浅色/深色主题",
"calculate_monthly_price" => "计算并显示所有订阅的月价格",
"convert_prices" => "始终按我的主要货币转换和显示价格(较慢)",
+ "hide_disabled_subscriptions" => "隐藏已停用的订阅",
"experimental_settings" => "实验性设置",
"remove_background" => "尝试从图片搜索中移除标志的背景(实验性)",
"experimental_info" => "实验性设置,可能存在问题。",
diff --git a/includes/i18n/zh_tw.php b/includes/i18n/zh_tw.php
index 6b69bb1..c21fd9b 100644
--- a/includes/i18n/zh_tw.php
+++ b/includes/i18n/zh_tw.php
@@ -145,6 +145,7 @@ $i18n = [
"switch_theme" => "切換淺色/深色主題",
"calculate_monthly_price" => "計算並顯示所有訂閱的每月價格",
"convert_prices" => "始終按照我的主要貨幣單位轉換和顯示價格(較慢)",
+ "hide_disabled_subscriptions" => "隱藏已停用的訂閱",
"experimental_settings" => "實驗性設定",
"remove_background" => "嘗試從圖片搜尋中移除圖示的背景顏色(實驗性)",
"experimental_info" => "實驗性設定,可能存在問題。",
diff --git a/includes/version.php b/includes/version.php
index f9d2664..09db156 100644
--- a/includes/version.php
+++ b/includes/version.php
@@ -1,3 +1,3 @@
<?php
- $version = "v1.21.1";
+ $version = "v1.22.0";
?>
diff --git a/index.php b/index.php
index 5e03393..631de00 100644
--- a/index.php
+++ b/index.php
@@ -156,6 +156,9 @@
<div class="subscriptions" id="subscriptions">
<?php
foreach ($subscriptions as $subscription) {
+ if ($subscription['inactive'] == 1 && isset($settings['hideDisabledSubscriptions']) && $settings['hideDisabledSubscriptions'] === 'true') {
+ continue;
+ }
$id = $subscription['id'];
$print[$id]['id'] = $id;
$print[$id]['logo'] = $subscription['logo'] != "" ? "images/uploads/logos/".$subscription['logo'] : $defaultLogo;
@@ -351,9 +354,9 @@
</div>
<div class="buttons">
- <input type="button" value="<?= translate('delete', $i18n) ?>" class="warning-button left thin" id="deletesub" style="display: none">
- <input type="button" value="<?= translate('cancel', $i18n) ?>" class="secondary-button thin" onClick="closeAddSubscription()">
- <input type="submit" value="<?= translate('save', $i18n) ?>" class="thin" id="save-button">
+ <input type="button" value="<?= translate('delete', $i18n) ?>" class="warning-button left thin" id="deletesub" style="display: none">
+ <input type="button" value="<?= translate('cancel', $i18n) ?>" class="secondary-button thin" onClick="closeAddSubscription()">
+ <input type="submit" value="<?= translate('save', $i18n) ?>" class="thin" id="save-button">
</div>
</form>
</section>
diff --git a/migrations/000015.php b/migrations/000015.php
new file mode 100644
index 0000000..28c55a9
--- /dev/null
+++ b/migrations/000015.php
@@ -0,0 +1,11 @@
+<?php
+// This migration adds a "hide_disabled" column to the settings table and sets to false as default.
+
+/** @noinspection PhpUndefinedVariableInspection */
+$columnQuery = $db->query("SELECT * FROM pragma_table_info('settings') where name='hide_disabled'");
+$columnRequired = $columnQuery->fetchArray(SQLITE3_ASSOC) === false;
+
+if ($columnRequired) {
+ $db->exec("ALTER TABLE settings ADD COLUMN hide_disabled BOOLEAN DEFAULT 0");
+ $db->exec('UPDATE settings SET `hide_disabled` = 0');
+}
\ No newline at end of file
diff --git a/scripts/settings.js b/scripts/settings.js
index 3bbed9c..96193cd 100644
--- a/scripts/settings.js
+++ b/scripts/settings.js
@@ -1001,6 +1001,13 @@ function setRemoveBackground() {
storeSettingsOnDB('remove_background', value);
}
+function setHideDisabled() {
+ const hideDisabledCheckbox = document.querySelector("#hidedisabled");
+ const value = hideDisabledCheckbox.checked;
+
+ storeSettingsOnDB('hide_disabled', value);
+}
+
function exportToJson() {
window.location.href = "endpoints/subscriptions/export.php";
}
diff --git a/settings.php b/settings.php
index 2d6ae1d..cce5869 100644
--- a/settings.php
+++ b/settings.php
@@ -650,6 +650,12 @@
<label for="convertcurrency"><?= translate('convert_prices', $i18n) ?></label>
</div>
</div>
+ <div>
+ <div class="form-group-inline">
+ <input type="checkbox" id="hidedisabled" name="hidedisabled" onChange="setHideDisabled()" <?php if ($settings['hide_disabled']) echo 'checked'; ?>>
+ <label for="hidedisabled"><?= translate('hide_disabled_subscriptions', $i18n) ?></label>
+ </div>
+ </div>
</div>
</section>