From 7ea8311e6439443fc6b7348ed469044834a4db45 Mon Sep 17 00:00:00 2001
From: Benjamin Bertrand <benjamin.bertrand@esss.se>
Date: Mon, 20 Nov 2017 23:09:34 +0100
Subject: [PATCH] Create specific items page

---
 app/main/views.py                      |  6 +++++
 app/static/js/{csentry.js => items.js} |  0
 app/templates/base.html                |  2 +-
 app/templates/index.html               | 21 +---------------
 app/templates/items.html               | 33 ++++++++++++++++++++++++++
 tests/functional/test_web.py           |  1 +
 6 files changed, 42 insertions(+), 21 deletions(-)
 rename app/static/js/{csentry.js => items.js} (100%)
 create mode 100644 app/templates/items.html

diff --git a/app/main/views.py b/app/main/views.py
index 409b1c7..1555a66 100644
--- a/app/main/views.py
+++ b/app/main/views.py
@@ -63,6 +63,12 @@ def index():
     return render_template('index.html')
 
 
+@bp.route('/items')
+@login_required
+def items_index():
+    return render_template('items.html')
+
+
 @bp.route('/view/<ics_id>')
 @login_required
 def view_item(ics_id):
diff --git a/app/static/js/csentry.js b/app/static/js/items.js
similarity index 100%
rename from app/static/js/csentry.js
rename to app/static/js/items.js
diff --git a/app/templates/base.html b/app/templates/base.html
index c60b5a8..b853c9e 100644
--- a/app/templates/base.html
+++ b/app/templates/base.html
@@ -23,7 +23,7 @@
       <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 in ("/", "/index", "/index/")) }}" href="{{ url_for('main.index') }}">Items</a>
+          <a class="nav-item nav-link {{ is_active(path.startswith("/items")) }}" href="{{ url_for('main.items_index') }}">Items</a>
           <a class="nav-item nav-link {{ is_active(path == "/hosts") }}" href="{{ url_for('main.hosts_index') }}">Hosts</a>
           <div class="dropdown {{ is_active(path.startswith("/qrcodes")) }}">
             <a class="nav-link dropdown-toggle" href="#" id="qrcodesDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
diff --git a/app/templates/index.html b/app/templates/index.html
index 43c0d82..bf37fb4 100644
--- a/app/templates/index.html
+++ b/app/templates/index.html
@@ -3,25 +3,6 @@
 {% block main %}
   <div class="jumbotron">
     <h1 class="display-4">Welcome to CSEntry!</h1>
+    <p class="lead">Control System Entry allows you to easily register items and network devices.</lead>
   </div>
-  <table id="items_table" class="table table-bordered table-hover table-sm">
-    <thead>
-      <tr>
-        <th>Id</th>
-        <th>ICS id</th>
-        <th>Created</th>
-        <th>Updated</th>
-        <th>Serial number</th>
-        <th>Manufacturer</th>
-        <th>Model</th>
-        <th>Location</th>
-        <th>Status</th>
-        <th>Parent</th>
-      </tr>
-    </thead>
-  </table>
 {%- endblock %}
-
-{% block csentry_scripts %}
-  <script src="{{ url_for('static', filename='js/csentry.js') }}"></script>
-{% endblock %}
diff --git a/app/templates/items.html b/app/templates/items.html
new file mode 100644
index 0000000..adfbdb3
--- /dev/null
+++ b/app/templates/items.html
@@ -0,0 +1,33 @@
+{%- extends "base.html" %}
+
+{% block title %}Items - CSEntry{% endblock %}
+
+{% block main %}
+  <div class="card">
+    <h4 class="card-header">Register new item</h4>
+    <div class="card-body">
+    </div>
+  </div>
+
+  <hr class="separator">
+  <table id="items_table" class="table table-bordered table-hover table-sm">
+    <thead>
+      <tr>
+        <th>Id</th>
+        <th>ICS id</th>
+        <th>Created</th>
+        <th>Updated</th>
+        <th>Serial number</th>
+        <th>Manufacturer</th>
+        <th>Model</th>
+        <th>Location</th>
+        <th>Status</th>
+        <th>Parent</th>
+      </tr>
+    </thead>
+  </table>
+{%- endblock %}
+
+{% block csentry_scripts %}
+  <script src="{{ url_for('static', filename='js/items.js') }}"></script>
+{% endblock %}
diff --git a/tests/functional/test_web.py b/tests/functional/test_web.py
index f26a201..3f85e18 100644
--- a/tests/functional/test_web.py
+++ b/tests/functional/test_web.py
@@ -60,6 +60,7 @@ def test_index(logged_client):
 
 @pytest.mark.parametrize('url', [
     '/',
+    '/items',
     '/qrcodes',
     '_retrieve_items',
 ])
-- 
GitLab