From aac3c82dd84523184e06efbab8a876409d8f2aec Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 1 Feb 2021 17:40:42 -0300 Subject: [PATCH] [appimage] improvement -> allowing the property 'suggestions.expiration' to be managed through the UI --- README.md | 4 ++-- bauh/api/abstract/view.py | 17 +++++++++++++++++ bauh/gems/appimage/controller.py | 21 +++++++++++++++------ bauh/gems/appimage/resources/locale/ca | 5 +++-- bauh/gems/appimage/resources/locale/de | 5 +++-- bauh/gems/appimage/resources/locale/en | 7 ++++--- bauh/gems/appimage/resources/locale/es | 5 +++-- bauh/gems/appimage/resources/locale/fr | 8 ++++---- bauh/gems/appimage/resources/locale/it | 5 +++-- bauh/gems/appimage/resources/locale/pt | 7 ++++--- bauh/gems/appimage/resources/locale/ru | 5 +++-- bauh/gems/appimage/resources/locale/tr | 5 +++-- 12 files changed, 64 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 4d923458..d820111a 100644 --- a/README.md +++ b/README.md @@ -197,9 +197,9 @@ bauh is officially distributed through [PyPi](https://pypi.org/project/bauh) and - The configuration file is located at **~/.config/bauh/appimage.yml** and it allows the following customizations: ``` database: - expiration: 60 # defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. + expiration: 60 # defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. Default: 60. suggestions: - expiration: 24 # defines the period (in hours) in which the cached suggestions will be considered up to date. Use 0 if you always want to update them. + expiration: 24 # defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. Default: 24. ``` diff --git a/bauh/api/abstract/view.py b/bauh/api/abstract/view.py index d9155c6f..7c5940d0 100644 --- a/bauh/api/abstract/view.py +++ b/bauh/api/abstract/view.py @@ -226,6 +226,15 @@ class FormComponent(ViewComponent): raise Exception("'{}' is not a {}".format(id_, FormComponent.__class__.__name__)) return comp + def get_text_input(self, id_) -> Optional[TextInputComponent]: + comp = self.get_component(id_) + + if comp: + if not isinstance(comp, TextInputComponent): + raise Exception("'{}' is not a {}".format(id_, TextInputComponent.__class__.__name__)) + return comp + + class FileChooserComponent(ViewComponent): @@ -309,3 +318,11 @@ class PanelComponent(ViewComponent): if not isinstance(comp, FormComponent): raise Exception("'{}' is not a {}".format(id_, FormComponent.__class__.__name__)) return comp + + def get_text_input(self, id_) -> Optional[TextInputComponent]: + comp = self.get_component(id_) + + if comp: + if not isinstance(comp, TextInputComponent): + raise Exception("'{}' is not a {}".format(id_, TextInputComponent.__class__.__name__)) + return comp diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index f61a29bf..c3f13a01 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -738,22 +738,31 @@ class AppImageManager(SoftwareManager): appimage_config = self.configman.get_config() max_width = floor(screen_width * 0.15) - opts = [ + comps = [ TextInputComponent(label=self.i18n['appimage.config.database.expiration'], - value=int(appimage_config['database']['expiration']) if isinstance(appimage_config['database']['expiration'], int) else '', + value=int(appimage_config['database']['expiration']) if isinstance( + appimage_config['database']['expiration'], int) else '', tooltip=self.i18n['appimage.config.database.expiration.tip'], only_int=True, max_width=max_width, - id_='appim_db_exp') + id_='appim_db_exp'), + TextInputComponent(label=self.i18n['appimage.config.suggestions.expiration'], + value=int(appimage_config['suggestions']['expiration']) if isinstance( + appimage_config['suggestions']['expiration'], int) else '', + tooltip=self.i18n['appimage.config.suggestions.expiration.tip'], + only_int=True, + max_width=max_width, + id_='appim_sugs_exp') ] - return PanelComponent([FormComponent(opts, self.i18n['appimage.config.database'])]) + return PanelComponent([FormComponent(components=comps, id_='form')]) def save_settings(self, component: PanelComponent) -> Tuple[bool, Optional[List[str]]]: appimage_config = self.configman.get_config() - panel = component.components[0] - appimage_config['database']['expiration'] = panel.get_component('appim_db_exp').get_int_value() + form = component.get_form_component('form') + appimage_config['database']['expiration'] = form.get_text_input('appim_db_exp').get_int_value() + appimage_config['suggestions']['expiration'] = form.get_text_input('appim_sugs_exp').get_int_value() try: self.configman.save_config(appimage_config) diff --git a/bauh/gems/appimage/resources/locale/ca b/bauh/gems/appimage/resources/locale/ca index 39080488..c599010a 100644 --- a/bauh/gems/appimage/resources/locale/ca +++ b/bauh/gems/appimage/resources/locale/ca @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration +appimage.config.database.expiration=Database expiration appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=Install AppImage file appimage.custom_action.install_file.details=Installation details appimage.custom_action.install_file.invalid_file=You must define a valid AppImage file diff --git a/bauh/gems/appimage/resources/locale/de b/bauh/gems/appimage/resources/locale/de index a6fd80ef..261b4add 100644 --- a/bauh/gems/appimage/resources/locale/de +++ b/bauh/gems/appimage/resources/locale/de @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration +appimage.config.database.expiration=Database expiration appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=Install AppImage file appimage.custom_action.install_file.details=Installation details appimage.custom_action.install_file.invalid_file=You must define a valid AppImage file diff --git a/bauh/gems/appimage/resources/locale/en b/bauh/gems/appimage/resources/locale/en index cc7168d8..174e6005 100644 --- a/bauh/gems/appimage/resources/locale/en +++ b/bauh/gems/appimage/resources/locale/en @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration -appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date. Use 0 if you always want to update it. +appimage.config.database.expiration=Database expiration +appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=Install AppImage file appimage.custom_action.install_file.details=Installation details appimage.custom_action.install_file.invalid_file=You must define a valid AppImage file diff --git a/bauh/gems/appimage/resources/locale/es b/bauh/gems/appimage/resources/locale/es index 816f7a35..882852c8 100644 --- a/bauh/gems/appimage/resources/locale/es +++ b/bauh/gems/appimage/resources/locale/es @@ -1,6 +1,7 @@ -appimage.config.database=Base de datos -appimage.config.database.expiration=Expiración +appimage.config.database.expiration=Expiración de la base de datos appimage.config.database.expiration.tip=Define el período (en minutos) en el que la base de datos será considerada actualizada durante el proceso de inicialización. Use 0 si siempre desea actualizarla. +appimage.config.suggestions.expiration=Expiración de sugerencias +appimage.config.suggestions.expiration.tip=Define el período (en horas) en el que la sugerencias almacenadas en disco seran consideradas actualizadas. Use 0 si desea siempre actualizarlas. appimage.custom_action.install_file=Instalar archivo AppImage appimage.custom_action.install_file.details=Detalles de instalación appimage.custom_action.install_file.invalid_file=Debe definir un archivo AppImage válido diff --git a/bauh/gems/appimage/resources/locale/fr b/bauh/gems/appimage/resources/locale/fr index f050641e..3fa93bf8 100644 --- a/bauh/gems/appimage/resources/locale/fr +++ b/bauh/gems/appimage/resources/locale/fr @@ -1,7 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration -appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date. Use 0 if you always want to update it. -appimage.custom_action.install_file=Installer fichier AppImage +appimage.config.database.expiration=Database expiration +appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them.appimage.custom_action.install_file=Installer fichier AppImage appimage.custom_action.install_file.details=Détails d'installation appimage.custom_action.install_file.invalid_file=Vous devez définir un fichier AppImage valide appimage.custom_action.install_file.invalid_name=Vous devez choisir un nom à l'application diff --git a/bauh/gems/appimage/resources/locale/it b/bauh/gems/appimage/resources/locale/it index 351654fe..f7c4f3a5 100644 --- a/bauh/gems/appimage/resources/locale/it +++ b/bauh/gems/appimage/resources/locale/it @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration +appimage.config.database.expiration=Database expiration appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=Install AppImage file appimage.custom_action.install_file.details=Installation details appimage.custom_action.install_file.invalid_file=You must define a valid AppImage file diff --git a/bauh/gems/appimage/resources/locale/pt b/bauh/gems/appimage/resources/locale/pt index f12eb9c4..a63b7fd3 100644 --- a/bauh/gems/appimage/resources/locale/pt +++ b/bauh/gems/appimage/resources/locale/pt @@ -1,6 +1,7 @@ -appimage.config.database=Banco de dados -appimage.config.database.expiration=Expiração -appimage.config.database.expiration.tip=Define o período (em minutos) no qual o banco de dados será considerado atualizado durante o processo de inicialização. Use 0 se você quiser que ele sempre seja atualizado. +appimage.config.database.expiration=Expiração do banco de dados +appimage.config.database.expiration.tip=Define o período (em minutos) no qual o banco de dados será considerado atualizado durante o processo de inicialização. Use 0 se quiser que ele sempre seja atualizado. +appimage.config.suggestions.expiration=Expiração das sugestões +appimage.config.suggestions.expiration.tip=Define o período (em horas) no qual as sugestões armazenadas em disco serão consideradas atualizadas. Use 0 se quiser que elas sempre seja atualizadas. appimage.custom_action.install_file=Instalar arquivo AppImage appimage.custom_action.install_file.details=Detalhes de instalação appimage.custom_action.install_file.invalid_file=Você precisa definir um arquivo AppImage válido diff --git a/bauh/gems/appimage/resources/locale/ru b/bauh/gems/appimage/resources/locale/ru index c586acb0..4f4913ee 100644 --- a/bauh/gems/appimage/resources/locale/ru +++ b/bauh/gems/appimage/resources/locale/ru @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration +appimage.config.database.expiration=Database expiration appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=Установить файл AppImage appimage.custom_action.install_file.details=Детали установки appimage.custom_action.install_file.invalid_file=Вы должны определить допустимый файл AppImage diff --git a/bauh/gems/appimage/resources/locale/tr b/bauh/gems/appimage/resources/locale/tr index 98f66087..bca9a45d 100644 --- a/bauh/gems/appimage/resources/locale/tr +++ b/bauh/gems/appimage/resources/locale/tr @@ -1,6 +1,7 @@ -appimage.config.database=Database -appimage.config.database.expiration=Expiration +appimage.config.database.expiration=Database expiration appimage.config.database.expiration.tip=It defines the period (in minutes) in which the database will be considered up to date during the initialization process. Use 0 if you always want to update it. +appimage.config.suggestions.expiration=Suggestions expiration +appimage.config.suggestions.expiration.tip=It defines the period (in hours) in which the suggestions stored in disc will be considered up to date. Use 0 if you always want to update them. appimage.custom_action.install_file=AppImage dosyasını yükle appimage.custom_action.install_file.details=Kurulum detayları appimage.custom_action.install_file.invalid_file=Geçerli bir AppImage dosyası tanımlamanız gerekir