diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-09-27 13:42:55 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-09-29 10:47:17 +0200 |
commit | 00487547c4aff6bf0c94438768191960a3369365 (patch) | |
tree | b8a27aa19258a27101bc5634e87fa1f9509457f2 /src/hydrilla/proxy/web_ui | |
parent | fae35b53a4f63f60f0da96e75a0c2fc310217578 (diff) | |
download | haketilo-hydrilla-00487547c4aff6bf0c94438768191960a3369365.tar.gz haketilo-hydrilla-00487547c4aff6bf0c94438768191960a3369365.zip |
[proxy] facilitate manually pruning orphaned packages (including installed ones)
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
-rw-r--r-- | src/hydrilla/proxy/web_ui/root.py | 10 | ||||
-rw-r--r-- | src/hydrilla/proxy/web_ui/templates/index.html.jinja | 33 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py index a28fde8..24ff73f 100644 --- a/src/hydrilla/proxy/web_ui/root.py +++ b/src/hydrilla/proxy/web_ui/root.py @@ -111,7 +111,13 @@ app_lock = Lock() @app.route('/', methods=['GET']) def home(errors: t.Mapping[str, bool] = {}) -> werkzeug.Response: - html = flask.render_template('index.html.jinja', **errors) + state = _app.get_haketilo_state() + + html = flask.render_template( + 'index.html.jinja', + orphan_item_stats = state.count_orphan_items(), + **errors + ) return flask.make_response(html, 200) @app.route('/', methods=['POST']) @@ -134,6 +140,8 @@ def home_post() -> werkzeug.Response: state.update_settings(advanced_user=True) elif action == 'user_make_simple': state.update_settings(advanced_user=False) + elif action == 'prune_orphans': + state.prune_orphan_items() else: raise ValueError() diff --git a/src/hydrilla/proxy/web_ui/templates/index.html.jinja b/src/hydrilla/proxy/web_ui/templates/index.html.jinja index d95937a..ce77b24 100644 --- a/src/hydrilla/proxy/web_ui/templates/index.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/index.html.jinja @@ -129,4 +129,37 @@ code in a proprietary work, I am not going to enforce this in court. {'action': 'user_make_simple'}) ]) }} + + {% if orphan_item_stats.mappings > 0 or orphan_item_stats.resources > 0 %} + <div class="horizontal-separator"></div> + + <p> + {% if settings.advanced_user %} + {% if orphan_item_stats.mappings > 0 %} + {{ + _('web_ui.home.orphans_to_delete_{mappings}') + .format(mappings = orphan_item_stats.mappings) + }} + {% else %} + {{ _('web_ui.home.orphans_to_delete_exist') }} + {% endif %} + {% else %} + {{ + _('web_ui.home.orphans_to_delete_{mappings}_{resources}') + .format( + mappings = orphan_item_stats.mappings, + resources = orphan_item_stats.resources + ) + }} + {% endif %} + </p> + + {% set prune_but_text = _('web_ui.home.prune_orphans_button') %} + + {{ + button_row([ + (['green-button'], prune_but_text, {'action': 'prune_orphans'}) + ]) + }} + {% endif %} {% endblock %} |