Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: settings show/hide update display #1072

Merged
merged 11 commits into from
Apr 21, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ system:
defaultLocale: 'en-US' # Set the default language (e.g. 'de-DE', 'fr-FR', etc)
googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow
customStaticFilePath: '/customFiles/static/' # Directory path for custom static files
showUpdate: true # see when a new update is available
showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'

#ui:
# appName: exampleAppName # Application's visible name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package stirling.software.SPDF.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Service
class AppUpdateService {

@Autowired(required = false)
ShowAdminInterface showAdmin;

@Bean(name = "shouldShow")
@Scope("request")
public boolean shouldShow() {
return (showAdmin != null) ? showAdmin.getShowUpdateOnlyAdmins() : true;
Ludy87 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package stirling.software.SPDF.config;

public interface ShowAdminInterface {
default boolean getShowUpdateOnlyAdmins() {
return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package stirling.software.SPDF.config.security;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;

import stirling.software.SPDF.config.ShowAdminInterface;
import stirling.software.SPDF.model.ApplicationProperties;
import stirling.software.SPDF.model.User;
import stirling.software.SPDF.repository.UserRepository;

@Service
class AppUpdateAuthService implements ShowAdminInterface {

@Autowired private UserRepository userRepository;
@Autowired private ApplicationProperties applicationProperties;

public boolean getShowUpdateOnlyAdmins() {
boolean showUpdate = applicationProperties.getSystem().getShowUpdate();
if (!showUpdate) {
return showUpdate;
}

boolean showUpdateOnlyAdmin = applicationProperties.getSystem().getShowUpdateOnlyAdmin();

Authentication authentication = SecurityContextHolder.getContext().getAuthentication();

if (authentication == null || !authentication.isAuthenticated()) {
return !showUpdateOnlyAdmin;
}

if (authentication.getName().equalsIgnoreCase("anonymousUser")) {
return !showUpdateOnlyAdmin;
}

Optional<User> user = userRepository.findByUsername(authentication.getName());
if (user.isPresent() && showUpdateOnlyAdmin) {
return "ROLE_ADMIN".equals(user.get().getRolesAsString());
}

return showUpdate;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@Controller
@Tag(name = "Misc", description = "Miscellaneous APIs")
public class OtherWebController {

@GetMapping("/compress-pdf")
@Hidden
public String compressPdfForm(Model model) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ public static class System {
private String rootURIPath;
private String customStaticFilePath;
private Integer maxFileSize;
private boolean showUpdate;
private Boolean showUpdateOnlyAdmin;

public boolean getShowUpdateOnlyAdmin() {
return showUpdateOnlyAdmin;
}

public void setShowUpdateOnlyAdmin(boolean showUpdateOnlyAdmin) {
this.showUpdateOnlyAdmin = showUpdateOnlyAdmin;
}

public boolean getShowUpdate() {
return showUpdate;
}

public void setShowUpdate(boolean showUpdate) {
this.showUpdate = showUpdate;
}

private Boolean enableAlphaFunctionality;

Expand Down Expand Up @@ -275,6 +293,10 @@ public String toString() {
+ maxFileSize
+ ", enableAlphaFunctionality="
+ enableAlphaFunctionality
+ ", showUpdate="
+ showUpdate
+ ", showUpdateOnlyAdmin="
+ showUpdateOnlyAdmin
+ "]";
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ar_AR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=إعدادات
#############
settings.title=الإعدادات
settings.update=التحديث متاح
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=إصدار التطبيق:
settings.downloadOption.title=تحديد خيار التنزيل (للتنزيلات ذات الملف الواحد غير المضغوط):
settings.downloadOption.1=فتح في نفس النافذة
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_bg_BG.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Настройки
#############
settings.title=Настройки
settings.update=Налична актуализация
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Версия на приложението:
settings.downloadOption.title=Изберете опция за изтегляне (за изтегляния на един файл без да е архивиран):
settings.downloadOption.1=Отваряне в същия прозорец
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ca_CA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Opcions
#############
settings.title=Opcions
settings.update=Actualització Disponible
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versió App:
settings.downloadOption.title=Trieu l'opció de descàrrega (per a descàrregues d'un sol fitxer no zip):
settings.downloadOption.1=Obre mateixa finestra
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Einstellungen
#############
settings.title=Einstellungen
settings.update=Update verfügbar
settings.updateAvailable={0} ist die aktuelle installierte Version. Eine neue Version ({1}) ist verfügbar.
settings.appVersion=App-Version:
settings.downloadOption.title=Download-Option wählen (für einzelne Dateien, die keine Zip-Downloads sind):
settings.downloadOption.1=Im selben Fenster öffnen
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_el_GR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Ρυθμίσεις
#############
settings.title=Ρυθμίσεις
settings.update=Υπάρχει διαθέσιμη ενημέρωση
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Έκδοση εφαρμογής:
settings.downloadOption.title=Επιλέξετε την επιλογή λήψης (Για λήψεις μεμονωμένων αρχείων χωρίς zip):
settings.downloadOption.1=Άνοιγμα στο ίδιο παράθυρο
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en_GB.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Settings
#############
settings.title=Settings
settings.update=Update available
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=App Version:
settings.downloadOption.title=Choose download option (For single file non zip downloads):
settings.downloadOption.1=Open in same window
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Settings
#############
settings.title=Settings
settings.update=Update available
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=App Version:
settings.downloadOption.title=Choose download option (For single file non zip downloads):
settings.downloadOption.1=Open in same window
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_es_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Configuración
#############
settings.title=Configuración
settings.update=Actualización disponible
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versión de la aplicación:
settings.downloadOption.title=Elegir la opción de descarga (para descargas de un solo archivo sin ZIP):
settings.downloadOption.1=Abrir en la misma ventana
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_eu_ES.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Ezarpenak
#############
settings.title=Ezarpenak
settings.update=Eguneratze eskuragarria
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Aplikazioaren bertsioa:
settings.downloadOption.title=Hautatu deskargatzeko aukera (fitxategi bakarra deskargatzeko ZIP gabe):
settings.downloadOption.1=Ireki leiho berean
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_fr_FR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Paramètres
#############
settings.title=Paramètres
settings.update=Mise à jour disponible
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Version de l’application :
settings.downloadOption.title=Choisissez l’option de téléchargement (pour les téléchargements à fichier unique non ZIP) :
settings.downloadOption.1=Ouvrir dans la même fenêtre
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_hi_IN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=सेटिंग्स
#############
settings.title=सेटिंग्स
settings.update=अपडेट उपलब्ध है
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=ऐप संस्करण:
settings.downloadOption.title=डाउनलोड विकल्प चुनें (एकल फ़ाइल गैर-ज़िप डाउनलोड के लिए):
settings.downloadOption.1=एक ही विंडो में खोलें
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_hu_HU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Beállítások
#############
settings.title=Beállítások
settings.update=Frisítés elérhető
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=App Verzió:
settings.downloadOption.title=Válassza ki a letöltési lehetőséget (Egyetlen fájl esetén a nem tömörített letöltésekhez):
settings.downloadOption.1=Nyissa meg ugyanabban az ablakban
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_id_ID.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Pengaturan
#############
settings.title=Pengaturan
settings.update=Pembaruan tersedia
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versi Aplikasi:
settings.downloadOption.title=Pilih opsi unduhan (Untuk unduhan berkas tunggal non zip):
settings.downloadOption.1=Buka di jendela yang sama
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_it_IT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Impostazioni
#############
settings.title=Impostazioni
settings.update=Aggiornamento disponibile
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versione App:
settings.downloadOption.title=Scegli opzione di download (Per file singoli non compressi):
settings.downloadOption.1=Apri in questa finestra
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ja_JP.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=設定
#############
settings.title=設定
settings.update=利用可能なアップデート
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Appバージョン:
settings.downloadOption.title=ダウンロードオプション (zip以外の単一ファイル):
settings.downloadOption.1=同じウィンドウで開く
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ko_KR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=설정
#############
settings.title=설정
settings.update=업데이트 가능
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=앱 버전:
settings.downloadOption.title=다운로드 옵션 선택 (zip 파일이 아닌 단일 파일 다운로드 시):
settings.downloadOption.1=현재 창에서 열기
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_nl_NL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Instellingen
#############
settings.title=Instellingen
settings.update=Update beschikbaar
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=App versie:
settings.downloadOption.title=Kies download optie (Voor enkelvoudige bestanddownloads zonder zip):
settings.downloadOption.1=Open in hetzelfde venster
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pl_PL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Ustawienia
#############
settings.title=Ustawienia
settings.update=Dostępna aktualizacja
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Wersia aplikacji:
settings.downloadOption.title=Wybierz opcję pobierania (w przypadku pobierania pojedynczych plików innych niż ZIP):
settings.downloadOption.1=Otwórz w tym samym oknie
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pt_BR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Configurações
#############
settings.title=Configurações
settings.update=Atualização disponível
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versão do aplicativo:
settings.downloadOption.title=Escolha a opção de download (para downloads não compactados de arquivo único):
settings.downloadOption.1=Abrir na mesma janela
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_pt_PT.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Configurações
#############
settings.title=Configurações
settings.update=Atualização disponível
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versão da aplicação:
settings.downloadOption.title=Escolha a opção de download (para downloads não compactados de ficheiro único):
settings.downloadOption.1=Abrir na mesma janela
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ro_RO.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Setări
#############
settings.title=Setări
settings.update=Actualizare disponibilă
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Versiune aplicație:
settings.downloadOption.title=Alege opțiunea de descărcare (pentru descărcarea unui singur fișier non-zip):
settings.downloadOption.1=Deschide în aceeași fereastră
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ru_RU.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Настройки
#############
settings.title=Настройки
settings.update=Доступно обновление
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Версия приложения:
settings.downloadOption.title=Выберите вариант загрузки (для загрузки одного файла без zip):
settings.downloadOption.1=Открыть в том же окне
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_sr_LATN_RS.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Podešavanja
#############
settings.title=Podešavanja
settings.update=Dostupno ažuriranje
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Verzija aplikacije:
settings.downloadOption.title=Odaberite opciju preuzimanja (Za preuzimanje pojedinačnih fajlova bez zip formata):
settings.downloadOption.1=Otvori u istom prozoru
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_sv_SE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Inställningar
#############
settings.title=Inställningar
settings.update=Uppdatering tillgänglig
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Appversion:
settings.downloadOption.title=Välj nedladdningsalternativ (för nedladdning av en fil utan zip):
settings.downloadOption.1=Öppnas i samma fönster
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_tr_TR.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Ayarlar
#############
settings.title=Ayarlar
settings.update=Güncelleme mevcut
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Uygulama Sürümü:
settings.downloadOption.title=İndirme seçeneği seçin (Zip olmayan tek dosya indirmeler için):
settings.downloadOption.1=Aynı pencerede aç
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_uk_UA.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=Налаштування
#############
settings.title=Налаштування
settings.update=Доступне оновлення
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=Версія додатку:
settings.downloadOption.title=Виберіть варіант завантаження (для завантаження одного файлу без zip):
settings.downloadOption.1=Відкрити в тому ж вікні
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=设置
#############
settings.title=设置
settings.update=可更新
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=应用程序版本:
settings.downloadOption.title=选择下载选项(单个文件非压缩文件):
settings.downloadOption.1=在同一窗口打开
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_zh_TW.properties
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ navbar.settings=設定
#############
settings.title=設定
settings.update=有更新可用
settings.updateAvailable={0} is the current installed version. A new version ({1}) is available.
settings.appVersion=應用版本:
settings.downloadOption.title=選擇下載選項(對於單一檔案非壓縮下載):
settings.downloadOption.1=在同一視窗中開啟
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/settings.yml.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ system:
defaultLocale: 'en-US' # Set the default language (e.g. 'de-DE', 'fr-FR', etc)
googlevisibility: false # 'true' to allow Google visibility (via robots.txt), 'false' to disallow
enableAlphaFunctionality: false # Set to enable functionality which might need more testing before it fully goes live (This feature might make no changes)

showUpdate: true # see when a new update is available
showUpdateOnlyAdmin: false # Only admins can see when a new update is available, depending on showUpdate it must be set to 'true'

#ui:
# appName: exampleAppName # Application's visible name
# homeDescription: I am a description # Short description or tagline shown on homepage.
Expand Down