From 8255e8b7b17f7f26d4f9619b4abeaf4344c79599 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Thu, 14 Dec 2017 22:56:23 +0100
Subject: [PATCH] Split UI between inventory and networks

---
 app/templates/base-fluid.html            | 33 ++++++++++++++++++++++++
 app/templates/base.html                  | 12 ++++-----
 app/templates/inventory/attributes.html  |  2 +-
 app/templates/inventory/create_item.html |  2 +-
 app/templates/inventory/edit_item.html   |  2 +-
 app/templates/inventory/items.html       |  2 +-
 app/templates/inventory/qrcodes.html     |  2 +-
 app/templates/inventory/view_item.html   |  2 +-
 app/templates/networks/create_host.html  |  2 +-
 app/templates/networks/hosts.html        |  2 +-
 10 files changed, 46 insertions(+), 15 deletions(-)
 create mode 100644 app/templates/base-fluid.html

diff --git a/app/templates/base-fluid.html b/app/templates/base-fluid.html
new file mode 100644
index 0000000..66f6708
--- /dev/null
+++ b/app/templates/base-fluid.html
@@ -0,0 +1,33 @@
+{% extends "base.html" %}
+{% from "_helpers.html" import is_active %}
+
+{# overwrite the base content block to use container-fluid instead of container #}
+{% block content %}
+<div class="container-fluid">
+  <div class="row">
+
+    <div class="col-12 col-md-2 col-xl-2">
+      {% set path = request.path %}
+      <div class="list-group">
+        {% if path.startswith("/inventory") %}
+        <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/inventory/items")) }}"
+          href="{{ url_for('inventory.list_items') }}">Items</a>
+        <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/inventory/attributes")) }}"
+          href="{{ url_for('inventory.attributes', kind='Manufacturer') }}">Attributes</a>
+        <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/inventory/qrcodes")) }}"
+          href="{{ url_for('inventory.qrcodes', kind='Action') }}">QR Codes</a>
+      {% elif path.startswith("/networks") %}
+        <a class="list-group-item list-group-item-action {{ is_active(path.startswith("/networks/hosts")) }}"
+          href="{{ url_for('networks.list_hosts') }}">Hosts</a>
+      {% endif %}
+      </div>
+    </div>
+
+    <div class="col-12 col-md-10 col-xl-10">
+      {{utils.flashed_messages(messages, container=False, dismissible=True)}}
+      {% block main %}{% endblock %}
+    </div>
+
+  </div>
+</div>
+{% endblock %}
diff --git a/app/templates/base.html b/app/templates/base.html
index 0f8c491..f398c23 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -24,10 +24,8 @@
       <div class="collapse navbar-collapse" id="navbarSupportedContent">
         <div class="navbar-nav mr-auto">
           {% set path = request.path %}
-          <a class="nav-item nav-link {{ is_active(path.startswith("/inventory/items")) }}" href="{{ url_for('inventory.list_items') }}">Items</a>
-          <a class="nav-item nav-link {{ is_active(path.startswith("/networks/hosts")) }}" href="{{ url_for('networks.list_hosts') }}">Hosts</a>
-          <a class="nav-item nav-link {{ is_active(path.startswith("/inventory/attributes")) }}" href="{{ url_for('inventory.attributes', kind='Manufacturer') }}">Attributes</a>
-          <a class="nav-item nav-link {{ is_active(path.startswith("/inventory/qrcodes")) }}" href="{{ url_for('inventory.qrcodes', kind='Action') }}">QR Codes</a>
+          <a class="nav-item nav-link {{ is_active(path.startswith("/inventory")) }}" href="{{ url_for('inventory.list_items') }}">Inventory</a>
+          <a class="nav-item nav-link {{ is_active(path.startswith("/networks")) }}" href="{{ url_for('networks.list_hosts') }}">Networks</a>
           {% if current_user.is_authenticated and current_user.is_admin %}
             <a class="nav-item nav-link" href="{{ url_for('admin.index') }}">Admin</a>
           {% endif %}
@@ -51,9 +49,9 @@
 {% endblock %}
 
 {% block content %}
-  <div class="container" id="mainContent">
-  {{utils.flashed_messages(messages, container=False, dismissible=True)}}
-  {% block main %}{% endblock %}
+  <div class="container">
+    {{utils.flashed_messages(messages, container=False, dismissible=True)}}
+    {% block main %}{% endblock %}
   </div>
 {% endblock %}
 
diff --git a/app/templates/inventory/attributes.html b/app/templates/inventory/attributes.html
index cfff079..e5c5e2d 100644
--- a/app/templates/inventory/attributes.html
+++ b/app/templates/inventory/attributes.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 {% from "_helpers.html" import render_field %}
 
 {% block title %}Attributes - CSEntry{% endblock %}
diff --git a/app/templates/inventory/create_item.html b/app/templates/inventory/create_item.html
index 340d847..4a1979e 100644
--- a/app/templates/inventory/create_item.html
+++ b/app/templates/inventory/create_item.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 {% from "_helpers.html" import render_field %}
 
 {% block title %}Register Item - CSEntry{% endblock %}
diff --git a/app/templates/inventory/edit_item.html b/app/templates/inventory/edit_item.html
index 743ecef..9ca6d2b 100644
--- a/app/templates/inventory/edit_item.html
+++ b/app/templates/inventory/edit_item.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 {% from "_helpers.html" import render_field %}
 
 {% block title %}Edit Item - CSEntry{% endblock %}
diff --git a/app/templates/inventory/items.html b/app/templates/inventory/items.html
index 43df6de..9d46616 100644
--- a/app/templates/inventory/items.html
+++ b/app/templates/inventory/items.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 
 {% block title %}Items - CSEntry{% endblock %}
 
diff --git a/app/templates/inventory/qrcodes.html b/app/templates/inventory/qrcodes.html
index eca4e46..606f135 100644
--- a/app/templates/inventory/qrcodes.html
+++ b/app/templates/inventory/qrcodes.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 
 {% block title %}QR Codes - CSEntry{% endblock %}
 
diff --git a/app/templates/inventory/view_item.html b/app/templates/inventory/view_item.html
index 4c0c0d2..39c979f 100644
--- a/app/templates/inventory/view_item.html
+++ b/app/templates/inventory/view_item.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 {% from "_helpers.html" import link_to_item, link_to_items %}
 
 {% block title %}View Item - CSEntry{% endblock %}
diff --git a/app/templates/networks/create_host.html b/app/templates/networks/create_host.html
index 6c4f8f9..b607740 100644
--- a/app/templates/networks/create_host.html
+++ b/app/templates/networks/create_host.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 {% from "_helpers.html" import render_field %}
 
 {% block title %}Hosts - CSEntry{% endblock %}
diff --git a/app/templates/networks/hosts.html b/app/templates/networks/hosts.html
index 0d0f266..e5447fa 100644
--- a/app/templates/networks/hosts.html
+++ b/app/templates/networks/hosts.html
@@ -1,4 +1,4 @@
-{%- extends "base.html" %}
+{% extends "base-fluid.html" %}
 
 {% block title %}Hosts - CSEntry{% endblock %}
 
-- 
GitLab