aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2019-03-19 16:22:31 -0400
committerSawyer Bergeron <sbergeron@iol.unh.edu>2019-03-28 15:48:21 -0400
commit31dc78ea35cf207cb88a4e0cba93c89bc7010886 (patch)
treee0184fbb3f3af33d26868e83424fdc431db60c8c
parent4816475aecde4d949e1a4d37b4f494573d7257bd (diff)
Add host detail view
Change-Id: Ie385fe3f2fbe3b178f00928914d47a34b181d05e Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
-rw-r--r--src/dashboard/views.py2
-rw-r--r--src/resource_inventory/urls.py5
-rw-r--r--src/resource_inventory/views.py17
-rw-r--r--src/templates/dashboard/lab_detail.html2
-rw-r--r--src/templates/resource/hostprofile_detail.html116
-rw-r--r--src/templates/resource/hosts.html2
6 files changed, 139 insertions, 5 deletions
diff --git a/src/dashboard/views.py b/src/dashboard/views.py
index c4a6685..aaad7ab 100644
--- a/src/dashboard/views.py
+++ b/src/dashboard/views.py
@@ -46,7 +46,7 @@ def lab_detail_view(request, lab_name):
'title': "Lab Overview",
'lab': lab,
'hostprofiles': lab.hostprofiles.all(),
- 'images': images
+ 'images': images,
}
)
diff --git a/src/resource_inventory/urls.py b/src/resource_inventory/urls.py
index 4e159ba..a72871b 100644
--- a/src/resource_inventory/urls.py
+++ b/src/resource_inventory/urls.py
@@ -25,10 +25,11 @@ Including another URLconf
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
-from resource_inventory.views import HostView
+from resource_inventory.views import HostView, hostprofile_detail_view
app_name = "resource"
urlpatterns = [
- url(r'^hosts$', HostView.as_view(), name='hosts')
+ url(r'^hosts$', HostView.as_view(), name='hosts'),
+ url(r'^profiles/(?P<hostprofile_id>.+)/$', hostprofile_detail_view, name='host_detail'),
]
diff --git a/src/resource_inventory/views.py b/src/resource_inventory/views.py
index 2937bd7..8c3d899 100644
--- a/src/resource_inventory/views.py
+++ b/src/resource_inventory/views.py
@@ -9,8 +9,10 @@
from django.views.generic import TemplateView
+from django.shortcuts import get_object_or_404
+from django.shortcuts import render
-from resource_inventory.models import Host
+from resource_inventory.models import HostProfile, Host
class HostView(TemplateView):
@@ -21,3 +23,16 @@ class HostView(TemplateView):
hosts = Host.objects.filter(working=True)
context.update({'hosts': hosts, 'title': "Hardware Resources"})
return context
+
+
+def hostprofile_detail_view(request, hostprofile_id):
+ hostprofile = get_object_or_404(HostProfile, id=hostprofile_id)
+
+ return render(
+ request,
+ "resource/hostprofile_detail.html",
+ {
+ 'title': "Host Type: " + str(hostprofile.name),
+ 'hostprofile': hostprofile
+ }
+ )
diff --git a/src/templates/dashboard/lab_detail.html b/src/templates/dashboard/lab_detail.html
index a30ac9e..7d018ca 100644
--- a/src/templates/dashboard/lab_detail.html
+++ b/src/templates/dashboard/lab_detail.html
@@ -62,6 +62,8 @@
<tr>
<td>{{profile.name}}</td>
<td>{{profile.description}}</td>
+ <td>{{profile.labs}}</td>
+ <td><a href="/resource/profiles/{{ profile.id }}" class="btn btn-primary">Profile</a></td>
</tr>
{% endfor %}
</table>
diff --git a/src/templates/resource/hostprofile_detail.html b/src/templates/resource/hostprofile_detail.html
new file mode 100644
index 0000000..0776b9e
--- /dev/null
+++ b/src/templates/resource/hostprofile_detail.html
@@ -0,0 +1,116 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+
+{% block content %}
+<div class="row">
+ <div class="col-lg-6">
+ <div class="panel panel-default">
+ <div class="panel-heading clearfix">
+ <h4 style="display: inline;">Available at</h4>
+ <a data-toggle="collapse" data-target="#panel_overview" class="btn pull-right" style="line-height: 1;" >Expand</a>
+ </div>
+ <div class="panel-body" id="panel_overview">
+ <table class="table">
+ <tr>
+ <td>
+ <ul>
+ {% for lab in hostprofile.labs.all %}
+ <li>{{lab.name}}</li>
+ {% endfor %}
+ </ul>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading clearfix">
+ <h4 style="display: inline;">RAM</h4>
+ <a data-toggle="collapse" data-target="#panel_overview" class="btn pull-right" style="line-height: 1;" >Expand</a>
+ </div>
+ <div class="panel-body" id="panel_overview">
+ <table class="table">
+ <tr>
+ <td>{{hostprofile.ramprofile.first.amount}}G,
+ {{hostprofile.ramprofile.first.channels}} channels</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div class="panel panel-default">
+ <div class="panel-heading clearfix">
+ <h4 style="display: inline;">CPU</h4>
+ <a data-toggle="collapse" data-target="#panel_overview" class="btn pull-right" style="line-height: 1;" >Expand</a>
+ </div>
+ <div class="panel-body" id="panel_overview">
+ <table class="table">
+ <tr>
+ <td>Arch:</td>
+ <td>{{hostprofile.cpuprofile.first.architecture}}</td>
+ </tr>
+ <tr>
+ <td>Cores:</td>
+ <td>{{hostprofile.cpuprofile.first.cores}}</td>
+ </tr>
+ <tr>
+ <td>Sockets:</td>
+ <td>{{hostprofile.cpuprofile.first.cpus}}</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </div>
+ <div class="col-lg-6">
+ <div class="panel panel-default">
+ <div class="panel-heading clearfix">
+ <h4 style="display: inline;">Interfaces</h4>
+ <a data-toggle="collapse" data-target="#panel_overview" class="btn pull-right" style="line-height: 1;" >Expand</a>
+ </div>
+ <div class="panel-body" id="panel_overview">
+ <table class="table">
+ {% for intprof in hostprofile.interfaceprofile.all %}
+ <tr>
+ <td>
+ <table class="table borderless">
+ <tr>
+ <td>Name:</td>
+ <td>{{intprof.name}}</td>
+ </tr>
+ <tr>
+ <td>Speed:</td>
+ <td>{{intprof.speed}}</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ {% endfor %}
+ </table>
+ </div>
+ </div>
+ </div>
+ <div class="col-lg-6">
+ <div class="panel panel-default">
+ <div class="panel-heading clearfix">
+ <h4 style="display: inline;">Disk</h4>
+ <a data-toggle="collapse" data-target="#panel_overview" class="btn pull-right" style="line-height: 1;" >Expand</a>
+ </div>
+ <div class="panel-body" id="panel_overview">
+ <table class="table">
+ <tr>
+ <td>Size:</td>
+ <td>{{hostprofile.storageprofile.first.size}} GiB</td>
+ </tr>
+ <tr>
+ <td>Type:</td>
+ <td>{{hostprofile.storageprofile.first.media_type}}</td>
+ </tr>
+ <tr>
+ <td>Mount Point:</td>
+ <td>{{hostprofile.storageprofile.first.name}}</td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ </div>
+</div>
+{% endblock content %}
diff --git a/src/templates/resource/hosts.html b/src/templates/resource/hosts.html
index 4bf64e0..69b7231 100644
--- a/src/templates/resource/hosts.html
+++ b/src/templates/resource/hosts.html
@@ -17,7 +17,7 @@
{{ host.name }}
</td>
<td>
- {{ host.profile }}
+ <a href="profiles/{{ host.profile.id }}">{{ host.profile }}</a>
</td>
<td>
{{ host.booked }}