-
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
167 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
{% extends 'base.html' %} | ||
{% load ui_extras %} | ||
|
||
{% block content %} | ||
<ol class="breadcrumb"> | ||
<li class="breadcrumb-item"><a href="/">Home</a></li> | ||
<li class="breadcrumb-item active">Jamf</li> | ||
</ol> | ||
|
||
<div class="row"> | ||
<div class="col-md-12"> | ||
<h2>Jamf</h2> | ||
</div> | ||
<div class="col-sm-6"> | ||
<canvas class="chart" | ||
data-app="jamf" | ||
data-dataset="event_count" | ||
width="200" | ||
height="120"></canvas> | ||
</div> | ||
<div class="col-sm-6"> | ||
<canvas class="chart" | ||
data-app="jamf" | ||
data-dataset="unique_msn" | ||
width="200" | ||
height="120"></canvas> | ||
</div> | ||
<div class="col-md-12"> | ||
{% if perms.jamf.view_jamfinstance %} | ||
<h3>Instance{{ instances_count|pluralize }} ({{ instances_count }})</h3> | ||
{% if instances %} | ||
<table class="table table-light table-striped align-middle table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Host</th> | ||
<th>API User</th> | ||
<th>Business unit</th> | ||
{% if perms.jamf.change_jamfinstance %} | ||
<th></th> | ||
{% endif %} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for jamf_instance in instances %} | ||
<tr class="data-row"> | ||
<td><a href="{{ jamf_instance.get_absolute_url }}">{{ jamf_instance.host }}</a></td> | ||
<td>{{ jamf_instance.user }}</td> | ||
<td> | ||
{% if jamf_instance.business_unit %} | ||
{{ jamf_instance.business_unit }} | ||
{% else %} | ||
- | ||
{% endif %} | ||
</td> | ||
{% if perms.jamf.change_jamfinstance %} | ||
<td class="text-end py-0"> | ||
{% url 'jamf:update_jamf_instance' jamf_instance.pk as url %} | ||
{% button 'UPDATE' url "Edit Instance" %} | ||
</td> | ||
{% endif %} | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% else %} | ||
{% if perms.jamf.add_jamfinstance %} | ||
{% url 'jamf:create_jamf_instance' as link %} | ||
{% no_entities 'Instances' link %} | ||
{% else %} | ||
{% no_entities 'Instances' %} | ||
{% endif %} | ||
{% endif %} | ||
{% endif %} | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block extrajs %} | ||
<script nonce="{{ request.csp_nonce }}"> | ||
function get_data_and_make_chart(url, charts) { | ||
$.getJSON(url, function(data) { | ||
for (var dataset in data.datasets) { | ||
if (data.datasets.hasOwnProperty(dataset)) { | ||
var canvas = charts[data.app][dataset]; | ||
var chart = new Chart(canvas, { | ||
type: 'bar', | ||
data: {labels: data.labels, | ||
datasets: [data.datasets[dataset]]}, | ||
options: { | ||
scales: { | ||
xAxes: [{gridLines: { color: "darkgray", zeroLineColor: "darkgray" }}], | ||
yAxes: [{gridLines: { color: "darkgray", zeroLineColor: "darkgray" }}] | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
$(document).ready(function(){ | ||
var charts = {}; | ||
var urls = Array(); | ||
$(".chart").each(function(index, canvas) { | ||
canvas = $(canvas); | ||
var app = canvas.data('app'); | ||
var dataset = canvas.data('dataset'); | ||
if(! charts.hasOwnProperty(app)) { | ||
charts[app] = {}; | ||
urls.push('/app/' + app + '/hist_data/day/14/'); | ||
} | ||
charts[app][dataset] = canvas; | ||
}); | ||
for (var idx in urls) { | ||
if (urls.hasOwnProperty(idx)) { | ||
get_data_and_make_chart(urls[idx], charts); | ||
} | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters