Merge pull request #115 from kevgliss/destinations

Fixes destination stat
This commit is contained in:
kevgliss 2015-10-06 09:48:03 -07:00
commit 4ec07a6dc7
3 changed files with 38 additions and 36 deletions

View File

@ -8,6 +8,7 @@
from sqlalchemy import func from sqlalchemy import func
from lemur import database from lemur import database
from lemur.models import certificate_destination_associations
from lemur.destinations.models import Destination from lemur.destinations.models import Destination
from lemur.certificates.models import Certificate from lemur.certificates.models import Certificate
@ -117,10 +118,9 @@ def stats(**kwargs):
:param kwargs: :param kwargs:
:return: :return:
""" """
attr = getattr(Destination, kwargs.get('metric')) items = database.db.session.query(Destination.label, func.count(certificate_destination_associations.c.certificate_id))\
query = database.db.session.query(attr, func.count(attr)) .join(certificate_destination_associations)\
.group_by(Destination.label).all()
items = query.group_by(attr).all()
keys = [] keys = []
values = [] values = []

View File

@ -84,8 +84,8 @@ angular.module('lemur')
$scope.expiring = {labels: data.items.labels, values: [data.items.values]}; $scope.expiring = {labels: data.items.labels, values: [data.items.values]};
}); });
LemurRestangular.all('destinations').customGET('stats', {metric: 'certificates'}) LemurRestangular.all('destinations').customGET('stats', {metric: 'certificate'})
.then(function (data) { .then(function (data) {
$scope.destinations = {labels: data.items.labels, values: [data.items.values]}; $scope.destinations = data.items;
}); });
}); });

View File

@ -10,43 +10,45 @@
<h3 class="panel-title">Expiring Certificates</h3> <h3 class="panel-title">Expiring Certificates</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<canvas id="expiringBar" class="chart chart-bar" data="expiring.values" labels="expiring.labels" colours="colours"></canvas> <canvas id="expiringBar" class="chart chart-bar" data="expiring.values" labels="expiring.labels"
colours="colours"></canvas>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"></div> <div class="row"></div>
<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title">Issuers</h3> <h3 class="panel-title">Issuers</h3>
</div>
<div class="panel-body">
<canvas id="issuersPie" class="chart chart-pie" data="issuers.values" labels="issuers.labels" colours="colours" legend="true"></canvas>
</div>
</div> </div>
</div> <div class="panel-body">
<div class="col-md-6"> <canvas id="issuersPie" class="chart chart-pie" data="issuers.values" labels="issuers.labels" colours="colours"
<div class="panel panel-default"> legend="true"></canvas>
<div class="panel-heading"> </div>
<h3 class="panel-title">Bit Strength</h3> </div>
</div> </div>
<div class="panel-body"> <div class="col-md-6">
<canvas id="bitsPie" class="chart chart-pie" data="bits.values" labels="bits.labels" colours="colours" legend="true"></canvas> <div class="panel panel-default">
</div> <div class="panel-heading">
<h3 class="panel-title">Bit Strength</h3>
</div>
<div class="panel-body">
<canvas id="bitsPie" class="chart chart-pie" data="bits.values" labels="bits.labels" colours="colours"
legend="true"></canvas>
</div>
</div>
</div>
<div class="row"></div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Destinations</h3>
</div>
<div class="panel-body">
<canvas id="destinationPie" class="chart chart-pie" data="destinations.values" labels="destinations.labels"
colours="colours" legend="true"></canvas>
</div> </div>
</div> </div>
<div class="row"></div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Destinations</h3>
</div>
<div class="panel-body">
<canvas id="destinationPie" class="chart chart-pie" data="destinations.values" labels="destinations.labels" colours="colours" legend="true"></canvas>
</div>
</div>
</div>
</div> </div>
<!-- /.row -->
</div> </div>