-
Notifications
You must be signed in to change notification settings - Fork 64
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
1 parent
cbd534f
commit cc4bb20
Showing
6 changed files
with
201 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import models, migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('server', '0016_auto_20151026_0851'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='condition', | ||
name='condition_data', | ||
field=models.TextField(), | ||
), | ||
migrations.AlterField( | ||
model_name='condition', | ||
name='condition_name', | ||
field=models.CharField(max_length=255), | ||
), | ||
migrations.AlterField( | ||
model_name='fact', | ||
name='fact_data', | ||
field=models.TextField(), | ||
), | ||
migrations.AlterField( | ||
model_name='fact', | ||
name='fact_name', | ||
field=models.CharField(max_length=255, db_index=True), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalfact', | ||
name='fact_data', | ||
field=models.TextField(), | ||
), | ||
migrations.AlterField( | ||
model_name='historicalfact', | ||
name='fact_name', | ||
field=models.CharField(max_length=255, db_index=True), | ||
), | ||
migrations.AlterField( | ||
model_name='machine', | ||
name='sal_version', | ||
field=models.CharField(db_index=True, max_length=255, null=True, blank=True), | ||
), | ||
migrations.AlterField( | ||
model_name='osquerycolumn', | ||
name='column_data', | ||
field=models.TextField(null=True, blank=True), | ||
), | ||
migrations.AlterField( | ||
model_name='osquerycolumn', | ||
name='column_name', | ||
field=models.CharField(max_length=255, db_index=True), | ||
), | ||
] |
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,49 @@ | ||
from yapsy.IPlugin import IPlugin | ||
from yapsy.PluginManager import PluginManager | ||
from django.template import loader, Context | ||
from django.db.models import Count | ||
from server.models import * | ||
from django.shortcuts import get_object_or_404 | ||
import server.utils as utils | ||
|
||
class MunkiVersion(IPlugin): | ||
def plugin_type(self): | ||
return 'builtin' | ||
|
||
def widget_width(self): | ||
return 4 | ||
|
||
def widget_content(self, page, machines=None, theid=None): | ||
# The data is data is pulled from the database and passed to a template. | ||
|
||
# There are three possible views we're going to be rendering to - front, bu_dashbaord and group_dashboard. If page is set to bu_dashboard, or group_dashboard, you will be passed a business_unit or machine_group id to use (mainly for linking to the right search). | ||
if page == 'front': | ||
t = loader.get_template('munkiversion/templates/front.html') | ||
|
||
if page == 'bu_dashboard': | ||
t = loader.get_template('munkiversion/templates/id.html') | ||
|
||
if page == 'group_dashboard': | ||
t = loader.get_template('munkiversion/templates/id.html') | ||
|
||
try: | ||
munki_info = machines.values('munki_version').annotate(count=Count('munki_version')).order_by('munki_version') | ||
except: | ||
munki_info = [] | ||
|
||
c = Context({ | ||
'title': 'Munki Version', | ||
'data': munki_info, | ||
'theid': theid, | ||
'page': page | ||
}) | ||
return t.render(c) | ||
|
||
def filter_machines(self, machines, data): | ||
# You will be passed a QuerySet of machines, you then need to perform some filtering based on the 'data' part of the url from the show_widget output. Just return your filtered list of machines and the page title. | ||
|
||
machines = machines.filter(munki_version__exact=data) | ||
|
||
title = 'Machines running version '+data+' of MSC' | ||
return machines, title | ||
|
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,9 @@ | ||
[Core] | ||
Name = MunkiVersion | ||
Module = munkiversion | ||
|
||
[Documentation] | ||
Author = Graham Gilbert | ||
Version = 0.1 | ||
Website = http://grahamgilbert.com | ||
Description = A pie chart of Munki versions |
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,37 @@ | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
{{ title }} | ||
</div> | ||
<!-- /.panel-heading --> | ||
<div class="panel-body"> | ||
<div id="munkiversiongraph" style="max-height: 250px;"></div> | ||
</div> | ||
</div> | ||
{% block script %} | ||
<!-- Morris Charts JavaScript --> | ||
<script src="/static/js/plugins/morris/raphael.min.js"></script> | ||
<script src="/static/js/plugins/morris/morris.min.js"></script> | ||
<script type="text/javascript"> | ||
$(function() { | ||
Morris.Donut({ | ||
element: 'munkiversiongraph', | ||
data: [ | ||
{% for item in data %} | ||
{% if item.munki_version %} | ||
{ | ||
label: "{{ item.munki_version }}", | ||
value: {{ item.count }} | ||
}, | ||
|
||
{% endif %} | ||
{% endfor %} | ||
], | ||
resize: true | ||
}).on('click', function(i, row){ | ||
console.log(row['label']); | ||
var url_mask = "{% url 'machine_list_front' 'MunkiVersion' 'abc123' %}".replace(/abc123/, row['label'].toString()); | ||
window.location=url_mask; | ||
}); | ||
}); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
{{ title }} | ||
</div> | ||
<!-- /.panel-heading --> | ||
<div class="panel-body"> | ||
<div id="munkiversiongraph" style="max-height: 250px;"></div> | ||
</div> | ||
</div> | ||
{% block script %} | ||
<!-- Morris Charts JavaScript --> | ||
<script src="/static/js/plugins/morris/raphael.min.js"></script> | ||
<script src="/static/js/plugins/morris/morris.min.js"></script> | ||
<script type="text/javascript"> | ||
$(function() { | ||
Morris.Donut({ | ||
element: 'munkiversiongraph', | ||
data: [ | ||
{% for item in data %} | ||
{% if item.munki_version %} | ||
{ | ||
label: "{{ item.munki_version }}", | ||
value: {{ item.count }} | ||
}, | ||
|
||
{% endif %} | ||
{% endfor %} | ||
], | ||
resize: true | ||
}).on('click', function(i, row){ | ||
console.log(row['label']); | ||
var url_mask = "{% url 'machine_list_id' 'MunkiVersion' 'abc123' page theid %}".replace(/abc123/, row['label'].toString()); | ||
window.location=url_mask; | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} |