aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
-rw-r--r--src/hydrilla/proxy/web_ui/packages.py34
-rw-r--r--src/hydrilla/proxy/web_ui/root.py6
-rw-r--r--src/hydrilla/proxy/web_ui/templates/packages/index.html.jinja12
-rw-r--r--src/hydrilla/proxy/web_ui/templates/packages/show_single.html.jinja36
-rw-r--r--src/hydrilla/proxy/web_ui/templates/packages/show_single_version.html.jinja12
5 files changed, 65 insertions, 35 deletions
diff --git a/src/hydrilla/proxy/web_ui/packages.py b/src/hydrilla/proxy/web_ui/packages.py
index ac8b480..e14c1fd 100644
--- a/src/hydrilla/proxy/web_ui/packages.py
+++ b/src/hydrilla/proxy/web_ui/packages.py
@@ -42,6 +42,7 @@ import werkzeug
from ...exceptions import HaketiloException
from ...translations import smart_gettext as _
+from ... import item_infos
from .. import state as st
from . import _app
@@ -109,17 +110,17 @@ def show_package(mapping_id: str) -> werkzeug.Response:
mapping_ref = store.get(str(mapping_id))
version_display_infos = mapping_ref.get_version_display_infos()
- active_list = [info for info in version_display_infos if info.is_active]
+ active_version: t.Optional[st.MappingVersionDisplayInfo] = None
- active_version_ref = None if active_list == [] else active_list[0].ref
- active_version_info = None if active_list == [] else active_list[0].info
+ for info in version_display_infos:
+ if info.active != st.ActiveStatus.NOT_ACTIVE:
+ active_version = info
display_info = st.MappingDisplayInfo(
- ref = mapping_ref,
- identifier = version_display_infos[0].info.identifier,
- enabled = version_display_infos[0].mapping_enabled,
- active_version_ref = active_version_ref,
- active_version_info = active_version_info
+ ref = mapping_ref,
+ identifier = version_display_infos[0].info.identifier,
+ enabled = version_display_infos[0].mapping_enabled,
+ active_version = active_version
)
html = flask.render_template(
@@ -138,11 +139,24 @@ def show_package_version(
) -> werkzeug.Response:
try:
store = _app.get_haketilo_state().mapping_version_store()
- display_info = store.get(mapping_version_id).get_display_info()
+ version_ref = store.get(mapping_version_id)
+ display_infos = version_ref.get_all_version_display_infos()
+
+ other_infos: list[st.MappingVersionDisplayInfo] = []
+ this_info: t.Optional[st.MappingVersionDisplayInfo] = None
+
+ for info in display_infos:
+ if info.ref == version_ref:
+ this_info = info
+ else:
+ other_infos.append(info)
+
+ assert this_info is not None
html = flask.render_template(
'packages/show_single_version.html.jinja',
- display_info = display_info,
+ display_info = this_info,
+ version_display_infos = other_infos,
**errors
)
return flask.make_response(html, 200)
diff --git a/src/hydrilla/proxy/web_ui/root.py b/src/hydrilla/proxy/web_ui/root.py
index c3e0c80..a6e3151 100644
--- a/src/hydrilla/proxy/web_ui/root.py
+++ b/src/hydrilla/proxy/web_ui/root.py
@@ -76,14 +76,16 @@ class WebUIAppImpl(_app.WebUIApp):
'autoescape': jinja2.select_autoescape(['html.jinja']),
'extensions': [
*self.jinja_options.get('extensions', []),
- 'jinja2.ext.i18n'
+ 'jinja2.ext.i18n',
+ 'jinja2.ext.do'
]
}
self.jinja_env.globals['versions'] = versions
self.jinja_env.globals['get_current_endpoint'] = get_current_endpoint
- self.jinja_env.globals['InstalledStatus'] = st.InstalledStatus
self.jinja_env.globals['EnabledStatus'] = st.EnabledStatus
+ self.jinja_env.globals['InstalledStatus'] = st.InstalledStatus
+ self.jinja_env.globals['ActiveStatus'] = st.ActiveStatus
self.before_request(authenticate_by_referrer)
diff --git a/src/hydrilla/proxy/web_ui/templates/packages/index.html.jinja b/src/hydrilla/proxy/web_ui/templates/packages/index.html.jinja
index bac774e..cbdd3d9 100644
--- a/src/hydrilla/proxy/web_ui/templates/packages/index.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/packages/index.html.jinja
@@ -35,11 +35,15 @@ in a proprietary work, I am not going to enforce this in court.
<div>
{{ info.identifier }}
</div>
- {% if info.active_version_ref is not none %}
+ {%-
+ if info.active_version is not none and
+ info.active_version.active == ActiveStatus.REQUIRED
+ %}
+ {%- set ver = info.active_version.info.version %}
+ {%- set ver_str = versions.version_string(ver) %}
+ {%- set ver_desc = ver_str + '@' + info.active_version.info.repo %}
<div class="small-print">
- {{ versions.version_string(info.active_version_info.version) }}
- @
- {{ info.active_version_info.repo }}
+ {{ _('web_ui.packages.enabled_version_{}').format(ver_desc) }}
</div>
{% endif %}
</a>
diff --git a/src/hydrilla/proxy/web_ui/templates/packages/show_single.html.jinja b/src/hydrilla/proxy/web_ui/templates/packages/show_single.html.jinja
index 17f958c..e362fa9 100644
--- a/src/hydrilla/proxy/web_ui/templates/packages/show_single.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/packages/show_single.html.jinja
@@ -27,22 +27,32 @@ in a proprietary work, I am not going to enforce this in court.
{% include 'include/item_list_style.css.jinja' %}
{% endblock %}
{% block main %}
- <h3>
- {{
- _('web_ui.packages.single.heading.name_{}')
- .format(display_info.identifier)
- }}
- </h3>
- TODO: add more info...
- <h4>{{ _('web_ui.packages.single.version_list_heading') }}</h4>
+ {% block main_info %}
+ <h3>
+ {{
+ _('web_ui.packages.single.heading.name_{}')
+ .format(display_info.identifier)
+ }}
+ </h3>
+ TODO: add more info...
+ {% endblock %}
+ <h4>
+ {% if version_display_infos|length > 0 %}
+ {% block version_list_heading %}
+ {{ _('web_ui.packages.single.version_list_heading') }}
+ {% endblock %}
+ {% endif %}
+ </h4>
<ul id="item_list">
{%- for info in version_display_infos %}
- {% if info.info.repo == '<local>' -%}
- {%- set entry_classes = 'version-entry-local' -%}
- {%- else -%}
- {%- set entry_classes = '' -%}
+ {%- set entry_classes = [] %}
+ {% if info.is_local %}
+ {%- do entry_classes.append('version-entry-local') %}
{%- endif %}
- <li class="{{ entry_classes }}">
+ {%- if info.is_orphan %}
+ {%- do entry_classes.append('version-entry-orphan') %}
+ {%- endif %}
+ <li class="{{ entry_classes|join(' ') }}">
{%-
set href = url_for(
'.show_package_version',
diff --git a/src/hydrilla/proxy/web_ui/templates/packages/show_single_version.html.jinja b/src/hydrilla/proxy/web_ui/templates/packages/show_single_version.html.jinja
index 1b46da7..9943521 100644
--- a/src/hydrilla/proxy/web_ui/templates/packages/show_single_version.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/packages/show_single_version.html.jinja
@@ -19,12 +19,9 @@ I, Wojtek Kosior, thereby promise not to sue for violation of this
file's licenses. Although I request that you do not make use this code
in a proprietary work, I am not going to enforce this in court.
#}
-{% extends "base.html.jinja" %}
+{% extends "packages/show_single.html.jinja" %}
{% block title %} {{ _('web_ui.packages.single_version.title') }} {% endblock %}
-{% block style %}
- {{ super() }}
-{% endblock %}
-{% block main %}
+{% block main_info %}
{%- if uninstall_disallowed is defined %}
<aside class="error-note">
{{ _('web_ui.err.uninstall_disallowed') }}
@@ -86,4 +83,7 @@ in a proprietary work, I am not going to enforce this in court.
</form>
</div>
{%- endif %}
-{%- endblock %}
+{%- endblock main_info %}
+{% block version_list_heading %}
+ {{ _('web_ui.packages.single_version.version_list_heading') }}
+{% endblock %}