aboutsummaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/web_ui
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-09-01 18:44:48 +0200
committerWojtek Kosior <koszko@koszko.org>2022-09-28 12:54:55 +0200
commitd150d656bdab394f649a67490b146c5798361187 (patch)
tree4fef7b190cc4c5db625e06c5b0d76ca55bc3badd /src/hydrilla/proxy/web_ui
parentf2b91572b163099b29c940cf6fe5814a047fdc51 (diff)
downloadhaketilo-hydrilla-d150d656bdab394f649a67490b146c5798361187.tar.gz
haketilo-hydrilla-d150d656bdab394f649a67490b146c5798361187.zip
[proxy] make it possible to enable and disable mapping versions from web UI
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
-rw-r--r--src/hydrilla/proxy/web_ui/items.py14
-rw-r--r--src/hydrilla/proxy/web_ui/templates/base.html.jinja18
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja34
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja16
-rw-r--r--src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja64
5 files changed, 126 insertions, 20 deletions
diff --git a/src/hydrilla/proxy/web_ui/items.py b/src/hydrilla/proxy/web_ui/items.py
index 4bfae0a..01ae406 100644
--- a/src/hydrilla/proxy/web_ui/items.py
+++ b/src/hydrilla/proxy/web_ui/items.py
@@ -234,7 +234,19 @@ def alter_item_version(item_version_id: str, item_type: item_infos.ItemType) \
store = item_version_store(_app.get_haketilo_state(), item_type)
item_version_ref = store.get(item_version_id)
- if action == 'install_item_version':
+ if action == 'disable_item':
+ assert isinstance(item_version_ref, st.MappingVersionRef)
+ item_version_ref.update_mapping_status(st.EnabledStatus.DISABLED)
+ elif action == 'unenable_item':
+ assert isinstance(item_version_ref, st.MappingVersionRef)
+ item_version_ref.update_mapping_status(st.EnabledStatus.NO_MARK)
+ elif action == 'enable_item_version':
+ assert isinstance(item_version_ref, st.MappingVersionRef)
+ item_version_ref.update_mapping_status(
+ enabled = st.EnabledStatus.ENABLED,
+ frozen = st.FrozenStatus.EXACT_VERSION,
+ )
+ elif action == 'install_item_version':
item_version_ref.install()
elif action == 'uninstall_item_version':
item_version_ref_after = item_version_ref.uninstall()
diff --git a/src/hydrilla/proxy/web_ui/templates/base.html.jinja b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
index 8b8be4b..9520787 100644
--- a/src/hydrilla/proxy/web_ui/templates/base.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/base.html.jinja
@@ -19,6 +19,22 @@ 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.
-#}
<!DOCTYPE html>
+
+{% macro button_row(buttons_data) %}
+ <div class="button-row">
+ {% for classes, text, action in buttons_data %}
+ {% if 'disabled-button' in classes %}
+ <button class="{{ classes|join(' ') }}">{{ text }}</button>
+ {% else %}
+ <form method="POST" class="inline-form">
+ <input name="action" value="{{ action }}" type="hidden">
+ <button class="{{ classes|join(' ') }}">{{ text }}</button>
+ </form>
+ {% endif %}
+ {% endfor %}
+ </div>
+{% endmacro %}
+
<html>
<head>
{% block head %}
@@ -88,7 +104,7 @@ in a proprietary work, I am not going to enforce this in court.
background-color: #af504c;
}
- .red-button {
+ .blue-button {
background-color: #504caf;
}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
index 151a8b3..54cb3cf 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/item_viewversion.html.jinja
@@ -46,6 +46,15 @@ in a proprietary work, I am not going to enforce this in court.
TODO: add more info...
{% endblock %}
+ {% if display_info.active == ActiveStatus.REQUIRED %}
+ <div>{% block item_required_msg required %}{% endblock %}</div>
+ {% elif display_info.active == ActiveStatus.AUTO %}
+ <div>{% block item_auto_activated_msg required %}{% endblock %}</div>
+ {% else %}
+ {# display_info.active == ActiveStatus.NOT_ACTIVE #}
+ <div>{% block item_not_activated_msg required %}{% endblock %}</div>
+ {% endif %}
+
{% set install_but_classes = ['green-button', 'button-bordering-left'] %}
{% set uninstall_but_classes = ['green-button', 'button-bordering-right'] %}
{% if display_info.installed == InstalledStatus.FAILED_TO_INSTALL %}
@@ -57,7 +66,7 @@ in a proprietary work, I am not going to enforce this in court.
set uninstall_text =
_('web_ui.items.single_version.leave_uninstalled_button')
%}
- <div>{% block item_install_failed_msg %}{% endblock %}</div>
+ <div>{% block item_install_failed_msg required %}{% endblock %}</div>
{% else %}
{% set install_text = _('web_ui.items.single_version.install_button') %}
{% set uninstall_text = _('web_ui.items.single_version.uninstall_button') %}
@@ -74,21 +83,10 @@ in a proprietary work, I am not going to enforce this in court.
{% do uninstall_but_classes.append('disabled-button') %}
{% endif %}
{% endif %}{# else/ display_info.installed == InstalledStatus.FAILED_TO_I...#}
- <div class="button-row">
- {%
- for classes, text, action in [
- (uninstall_but_classes, uninstall_text, 'uninstall_item_version'),
- (install_but_classes, install_text, 'install_item_version')
- ]
- %}
- {% if 'disabled-button' in classes %}
- <button class="{{ classes|join(' ') }}">{{ text }}</button>
- {% else %}
- <form method="POST" class="inline-form">
- <input name="action" value="{{ action }}" type="hidden">
- <button class="{{ classes|join(' ') }}">{{ text }}</button>
- </form>
- {% endif %}
- {% endfor %}
- </div>
+ {{
+ button_row([
+ (uninstall_but_classes, uninstall_text, 'uninstall_item_version'),
+ (install_but_classes, install_text, 'install_item_version')
+ ])
+ }}
{% endblock main_info %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
index 2176646..30e084d 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/library_viewversion.html.jinja
@@ -19,18 +19,34 @@ 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 "items/item_viewversion.html.jinja" %}
+
{% block title %}
{{ _('web_ui.items.single_version.library.title') }}
{% endblock %}
+
{% block heading %}
{{
_('web_ui.items.single_version.library.heading.name_{}')
.format(display_info.info.long_name)
}}
{% endblock %}
+
+{% block item_required_msg %}
+ {{ _('web_ui.items.single_version.library.item_required') }}
+{% endblock %}
+
+{% block item_auto_activated_msg %}
+ {{ _('web_ui.items.single_version.library.item_auto_activated') }}
+{% endblock %}
+
+{% block item_not_activated_msg %}
+ {{ _('web_ui.items.single_version.library.item_not_activated') }}
+{% endblock %}
+
{% block item_install_failed_msg %}
{{ _('web_ui.items.single_version.library.install_failed') }}
{% endblock %}
+
{% block version_list_heading %}
{{ _('web_ui.items.single_version.library.version_list_heading') }}
{% endblock %}
diff --git a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
index 6671747..a532b5f 100644
--- a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
+++ b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja
@@ -19,18 +19,82 @@ 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 "items/item_viewversion.html.jinja" %}
+
{% block title %}
{{ _('web_ui.items.single_version.package.title') }}
{% endblock %}
+
{% block heading %}
{{
_('web_ui.items.single_version.package.heading.name_{}')
.format(display_info.info.long_name)
}}
{% endblock %}
+
+{% block item_required_msg %}
+ {{ _('web_ui.items.single_version.package.item_required') }}
+{% endblock %}
+
+{% block item_auto_activated_msg %}
+ {{ _('web_ui.items.single_version.package.item_auto_activated') }}
+{% endblock %}
+
+{% block item_not_activated_msg %}
+ {{ _('web_ui.items.single_version.package.item_not_activated') }}
+{% endblock %}
+
{% block item_install_failed_msg %}
{{ _('web_ui.items.single_version.package.install_failed') }}
{% endblock %}
+
{% block version_list_heading %}
{{ _('web_ui.items.single_version.package.version_list_heading') }}
{% endblock %}
+
+{% block main_info_bulk %}
+ TODO: add more info...
+
+ {% set enable_but_classes = ['blue-button', 'button-bordering-left'] %}
+ {%
+ set unenable_but_classes = [
+ 'green-button',
+ 'button-bordering-right',
+ 'button-bordering-left'
+ ]
+ %}
+ {% set disable_but_classes = ['red-button', 'button-bordering-right'] %}
+
+ {% set unenable_text = _('web_ui.items.single_version.unenable_button') %}
+ {% set disable_text = _('web_ui.items.single_version.disable_button') %}
+ {%
+ if display_info.mapping_enabled == EnabledStatus.ENABLED and
+ display_info.active == ActiveStatus.NOT_ACTIVE
+ %}
+ {%
+ set enable_text =
+ _('web_ui.items.single_version.freeze_to_this_button')
+ %}
+ {% else %}
+ {% set enable_text = _('web_ui.items.single_version.enable_button') %}
+ {% endif %}
+
+ {% if display_info.mapping_enabled == EnabledStatus.NO_MARK %}
+ {% do unenable_but_classes.append('disabled-button') %}
+ {% elif display_info.mapping_enabled == EnabledStatus.DISABLED %}
+ {% do disable_but_classes.append('disabled-button') %}
+ {% else %}
+ {% if display_info.active == ActiveStatus.REQUIRED %}
+ {% do enable_but_classes.append('disabled-button') %}
+ {% else %}
+ <div> {{ _('web_ui.items.single_version.other_version_enabled') }} </div>
+ {% endif %}
+ {% endif %}
+
+ {{
+ button_row([
+ (disable_but_classes, disable_text, 'disable_item'),
+ (unenable_but_classes, unenable_text, 'unenable_item'),
+ (enable_but_classes, enable_text, 'enable_item_version')
+ ])
+ }}
+{% endblock main_info_bulk %}