From 7bf22705ce0e604a923c6f2bba95a0883a1ca52e Mon Sep 17 00:00:00 2001 From: Armingol Date: Thu, 26 Oct 2023 17:21:03 +0200 Subject: [PATCH 1/3] Visual inventory management --- src/webui/service/device/routes.py | 12 ++ .../service/templates/device/detail.html | 36 ----- src/webui/service/templates/device/home.html | 9 ++ .../service/templates/device/inventory.html | 153 ++++++++++++++++++ 4 files changed, 174 insertions(+), 36 deletions(-) create mode 100644 src/webui/service/templates/device/inventory.html diff --git a/src/webui/service/device/routes.py b/src/webui/service/device/routes.py index 110a19b40..366393fe2 100644 --- a/src/webui/service/device/routes.py +++ b/src/webui/service/device/routes.py @@ -149,6 +149,18 @@ def detail(device_uuid: str): return render_template( 'device/detail.html', device=device_obj, dde=DeviceDriverEnum, dose=DeviceOperationalStatusEnum) + +@device.route('inventory/', methods=['GET', 'POST']) +def inventory(device_uuid: str): + context_client.connect() + device_obj = get_device(context_client, device_uuid, rw_copy=False) + if device_obj is None: + flash('Device({:s}) not found'.format(str(device_uuid)), 'danger') + device_obj = Device() + context_client.close() + + return render_template( + 'device/inventory.html', device=device_obj, dde=DeviceDriverEnum, dose=DeviceOperationalStatusEnum) @device.get('/delete') def delete(device_uuid): diff --git a/src/webui/service/templates/device/detail.html b/src/webui/service/templates/device/detail.html index b02be6f4d..a9c069ac3 100644 --- a/src/webui/service/templates/device/detail.html +++ b/src/webui/service/templates/device/detail.html @@ -86,42 +86,6 @@ - {% if device.components|length > 0 %} -
- - - - - - - - - - - - {% for component in device.components %} - - - - - - - - {% endfor %} - -
Component UUIDNameTypeParentAttributes
- {{ component.component_uuid.uuid }} - - {{ component.name }} - - {{ component.type }} - - {{ component.parent }} - - {{ component.attributes }} -
-
- {% endif %} Configurations: diff --git a/src/webui/service/templates/device/home.html b/src/webui/service/templates/device/home.html index 53434196f..e356fd4fb 100644 --- a/src/webui/service/templates/device/home.html +++ b/src/webui/service/templates/device/home.html @@ -50,6 +50,7 @@ Status Config Rules + @@ -74,6 +75,14 @@ + + + + + + + + {% endfor %} {% else %} diff --git a/src/webui/service/templates/device/inventory.html b/src/webui/service/templates/device/inventory.html new file mode 100644 index 000000000..01b8347a3 --- /dev/null +++ b/src/webui/service/templates/device/inventory.html @@ -0,0 +1,153 @@ + + +{% extends 'base.html' %} + +{% block content %} + + +

Device {{ device.name }} ({{ device.device_id.device_uuid.uuid }})

+ +
+
+ +
+
+ +
+
+
+
    +
  • >Components +
      + {% for item in (device.components|sort(true, attribute='name'))%} + {%if item.parent |length < 1 or item.type=='CHASSIS' %} +
    • {{item.name}} +
        + {%for comp in (device.components|sort(true, attribute='name'))%} + {%if item.name == comp.parent%} +
      • {{comp.name}}
      • + {%endif%} + {%endfor%} +
      +
    • + {%endif%} + {%endfor%} +
    +
  • +
+ + + +
+ {% if device.components|length > 1 %} +
+ + + + + + + + + + + + {% for component in (device.components|sort(true, attribute='name'))%} + + + + + + + + {% endfor %} + +
Component UUIDNameTypeParentAttributes
+ {{ component.component_uuid.uuid }} + + {{ component.name }} + + {{ component.type }} + + {{ component.parent }} + + {{ component.attributes }} +
+
+ {% endif %} +
+ + + +{% endblock %} \ No newline at end of file -- GitLab From 64c83de1a5ac7c97093c954b940bdf1f0d914b18 Mon Sep 17 00:00:00 2001 From: Armingol Date: Mon, 30 Oct 2023 17:30:53 +0100 Subject: [PATCH 2/3] code cleanup --- src/webui/service/device/routes.py | 4 +--- .../service/templates/device/inventory.html | 22 +++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/webui/service/device/routes.py b/src/webui/service/device/routes.py index 366393fe2..ce15c7aba 100644 --- a/src/webui/service/device/routes.py +++ b/src/webui/service/device/routes.py @@ -158,9 +158,7 @@ def inventory(device_uuid: str): flash('Device({:s}) not found'.format(str(device_uuid)), 'danger') device_obj = Device() context_client.close() - - return render_template( - 'device/inventory.html', device=device_obj, dde=DeviceDriverEnum, dose=DeviceOperationalStatusEnum) + return render_template('device/inventory.html', device=device_obj) @device.get('/delete') def delete(device_uuid): diff --git a/src/webui/service/templates/device/inventory.html b/src/webui/service/templates/device/inventory.html index 01b8347a3..f740742f8 100644 --- a/src/webui/service/templates/device/inventory.html +++ b/src/webui/service/templates/device/inventory.html @@ -78,21 +78,21 @@
    -
  • >Components +
  • Components
      - {% for item in (device.components|sort(true, attribute='name'))%} - {%if item.parent |length < 1 or item.type=='CHASSIS' %} + {% for item in (device.components|sort(true, attribute='name')) %} + {% if item.parent |length < 1 or item.type=='CHASSIS' %}
    • {{item.name}}
        - {%for comp in (device.components|sort(true, attribute='name'))%} - {%if item.name == comp.parent%} + {% for comp in (device.components|sort(true, attribute='name')) %} + {% if item.name == comp.parent %}
      • {{comp.name}}
      • - {%endif%} - {%endfor%} + {% endif %} + {% endfor %}
    • - {%endif%} - {%endfor%} + {% endif %} + {% endfor %}
@@ -148,6 +148,4 @@ {% endif %}
- - -{% endblock %} \ No newline at end of file +{% endblock %} -- GitLab From 4fa5f2b0a2966ea83cd3f034bb87f41bebed6fa9 Mon Sep 17 00:00:00 2001 From: Armingol Date: Mon, 30 Oct 2023 17:32:32 +0100 Subject: [PATCH 3/3] code cleanup --- src/webui/service/templates/device/inventory.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webui/service/templates/device/inventory.html b/src/webui/service/templates/device/inventory.html index f740742f8..17c14785a 100644 --- a/src/webui/service/templates/device/inventory.html +++ b/src/webui/service/templates/device/inventory.html @@ -123,7 +123,7 @@ - {% for component in (device.components|sort(true, attribute='name'))%} + {% for component in (device.components|sort(true, attribute='name')) %} {{ component.component_uuid.uuid }} -- GitLab