aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy')
-rw-r--r--src/hydrilla/proxy/state.py5
-rw-r--r--src/hydrilla/proxy/state_impl/concrete_state.py32
-rw-r--r--src/hydrilla/proxy/web_ui/root.py7
-rw-r--r--src/hydrilla/proxy/web_ui/templates/index.html.jinja26
4 files changed, 68 insertions, 2 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py
index 1a2d344..f73d01f 100644
--- a/src/hydrilla/proxy/state.py
+++ b/src/hydrilla/proxy/state.py
@@ -545,6 +545,7 @@ class HaketiloGlobalSettings:
advanced_user: bool
repo_refresh_seconds: int
locale: t.Optional[str]
+ update_waiting: bool
default_popup_jsallowed: PopupSettings
default_popup_jsblocked: PopupSettings
@@ -633,6 +634,10 @@ class HaketiloState(ABC):
) -> None:
...
+ @abstractmethod
+ def upate_all_items(self) -> None:
+ ...
+
@property
@abstractmethod
def listen_host(self) -> str:
diff --git a/src/hydrilla/proxy/state_impl/concrete_state.py b/src/hydrilla/proxy/state_impl/concrete_state.py
index e97514a..89a2eb2 100644
--- a/src/hydrilla/proxy/state_impl/concrete_state.py
+++ b/src/hydrilla/proxy/state_impl/concrete_state.py
@@ -79,6 +79,14 @@ def _add_locale_column(cursor: sqlite3.Cursor) -> None:
'''
)
+def _add_update_waiting_column(cursor: sqlite3.Cursor) -> None:
+ cursor.execute(
+ '''
+ ALTER TABLE general ADD COLUMN
+ update_waiting BOOLEAN NOT NULL DEFAULT TRUE;
+ '''
+ )
+
def _prepare_database(connection: sqlite3.Connection) -> None:
cursor = connection.cursor()
@@ -120,6 +128,7 @@ def _prepare_database(connection: sqlite3.Connection) -> None:
popup_settings_columns_present = False
locale_column_present = False
+ update_waiting_column_present = False
cursor.execute("PRAGMA TABLE_INFO('general')")
for __cid, name, __type, __notnull, __dflt_value, __pk \
@@ -130,12 +139,18 @@ def _prepare_database(connection: sqlite3.Connection) -> None:
if name == 'locale':
locale_column_present = True
+ if name == 'update_waiting':
+ update_waiting_column_present = True
+
if not popup_settings_columns_present:
_add_popup_settings_columns(cursor)
if not locale_column_present:
_add_locale_column(cursor)
+ if not update_waiting_column_present:
+ _add_update_waiting_column(cursor)
+
cursor.execute('COMMIT TRANSACTION;')
except:
cursor.execute('ROLLBACK TRANSACTION;')
@@ -158,14 +173,15 @@ def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings:
advanced_user,
repo_refresh_seconds,
mapping_use_mode,
- locale
+ locale,
+ update_waiting
FROM
general;
'''
)
(default_allow_scripts, advanced_user, repo_refresh_seconds,
- mapping_use_mode, locale), = cursor.fetchall()
+ mapping_use_mode, locale, update_waiting), = cursor.fetchall()
popup_settings_dict = {}
@@ -196,6 +212,7 @@ def load_settings(cursor: sqlite3.Cursor) -> st.HaketiloGlobalSettings:
repo_refresh_seconds = repo_refresh_seconds,
mapping_use_mode = st.MappingUseMode(mapping_use_mode),
locale = locale,
+ update_waiting = update_waiting,
**popup_settings_dict
)
@@ -221,6 +238,9 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
repo_id = repo_id
)
+ cursor.execute('UPDATE general SET update_waiting = TRUE;')
+ self.settings = dc.replace(self.settings, update_waiting=True)
+
self.rebuild_structures(rules=False)
def count_orphan_items(self) -> st.OrphanItemsStats:
@@ -267,8 +287,16 @@ class ConcreteHaketiloState(base.HaketiloStateWithFields):
unlocked_required_mappings = unlocked_required_mappings
)
+ if unlocked_required_mappings == 'all_mappings_unlocked':
+ cursor.execute('UPDATE general SET update_waiting = FALSE;')
+ self.settings = dc.replace(self.settings, update_waiting=False)
+
self.rebuild_structures(rules=False)
+ def upate_all_items(self) -> None:
+ with self.cursor(transaction=True):
+ self.recompute_dependencies('all_mappings_unlocked')
+
def pull_missing_files(self) -> None:
with self.cursor() as cursor:
assert self.connection.in_transaction
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index 6f9e349..9a14268 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -195,6 +195,13 @@ def home_post() -> werkzeug.Response:
state.update_settings(advanced_user=True)
elif action == 'user_make_simple':
state.update_settings(advanced_user=False)
+ elif action == 'upate_all_items':
+ try:
+ state.upate_all_items()
+ except st.FileInstallationError:
+ return home({'file_installation_error': True})
+ except st.ImpossibleSituation:
+ return home({'impossible_situation_error': True})
elif action == 'prune_orphans':
state.prune_orphan_items()
else:
diff --git a/src/hydrilla/proxy/web_ui/templates/index.html.jinja b/src/hydrilla/proxy/web_ui/templates/index.html.jinja
index fe9c5d5..d6a47f0 100644
--- a/src/hydrilla/proxy/web_ui/templates/index.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/index.html.jinja
@@ -31,6 +31,14 @@ code in a proprietary work, I am not going to enforce this in court.
{% import 'import/checkbox_tricks.html.jinja' as tricks %}
{% block main %}
+ {% if file_installation_error is defined %}
+ {{ error_note(_('web_ui.err.file_installation_error')) }}
+ {% endif %}
+
+ {% if impossible_situation_error is defined %}
+ {{ error_note(_('web_ui.err.impossible_situation_error')) }}
+ {% endif %}
+
<h3>
{{ _('web_ui.home.heading.welcome_to_haketilo') }}
</h3>
@@ -187,6 +195,24 @@ code in a proprietary work, I am not going to enforce this in court.
])
}}
+ {% if settings.update_waiting %}
+ <div class="horizontal-separator"></div>
+
+ {{ label(_('web_ui.home.update_waiting_label')) }}
+
+ <p>
+ {{ _('web_ui.home.update_is_awaiting') }}
+ </p>
+
+ {% set update_but_text = _('web_ui.home.update_items_button') %}
+
+ {{
+ button_row([
+ (['green-button'], update_but_text, {'action': 'upate_all_items'})
+ ])
+ }}
+ {% endif %}
+
{% if orphan_item_stats.mappings > 0 or orphan_item_stats.resources > 0 %}
<div class="horizontal-separator"></div>