mirror of https://github.com/MISP/misp-dashboard
Fixed bug json parsing in server + continuation of trophy support in zmq
parent
f22aaee21d
commit
8eae00f6b5
|
|
@ -137,6 +137,7 @@ class Contributor_helper:
|
||||||
ContributionStatus = self.getCurrentContributionStatus(orgName)
|
ContributionStatus = self.getCurrentContributionStatus(orgName)
|
||||||
oldContributionStatus = ContributionStatus['status']
|
oldContributionStatus = ContributionStatus['status']
|
||||||
oldHonorBadges = self.getOrgHonorBadges(orgName)
|
oldHonorBadges = self.getOrgHonorBadges(orgName)
|
||||||
|
oldTrophy = self.getOrgTrophies(orgName)
|
||||||
keyname = 'CONTRIB_ORG:{org}:{orgCateg}'
|
keyname = 'CONTRIB_ORG:{org}:{orgCateg}'
|
||||||
# update total points
|
# update total points
|
||||||
totOrgPnts = self.serv_redis_db.incrby(keyname.format(org=orgName, orgCateg='points'), pnts_to_add)
|
totOrgPnts = self.serv_redis_db.incrby(keyname.format(org=orgName, orgCateg='points'), pnts_to_add)
|
||||||
|
|
@ -214,7 +215,9 @@ class Contributor_helper:
|
||||||
ContributionStatus = self.getCurrentContributionStatus(orgName)
|
ContributionStatus = self.getCurrentContributionStatus(orgName)
|
||||||
newContributionStatus = ContributionStatus['status']
|
newContributionStatus = ContributionStatus['status']
|
||||||
newHonorBadges = self.getOrgHonorBadges(orgName)
|
newHonorBadges = self.getOrgHonorBadges(orgName)
|
||||||
|
newTrophy = self.getOrgTrophies(orgName)
|
||||||
|
|
||||||
|
# awards to publish
|
||||||
awards_given = []
|
awards_given = []
|
||||||
for i in newContributionStatus.keys():
|
for i in newContributionStatus.keys():
|
||||||
if oldContributionStatus[i] < newContributionStatus[i] and i != ContributionStatus['rank']:
|
if oldContributionStatus[i] < newContributionStatus[i] and i != ContributionStatus['rank']:
|
||||||
|
|
@ -224,6 +227,17 @@ class Contributor_helper:
|
||||||
if badgeNum not in oldHonorBadges:
|
if badgeNum not in oldHonorBadges:
|
||||||
awards_given.append(['badge', badgeNum])
|
awards_given.append(['badge', badgeNum])
|
||||||
|
|
||||||
|
temp = {}
|
||||||
|
for item in oldTrophy:
|
||||||
|
categ = item['categ']
|
||||||
|
rank = item['trophy_true_rank']
|
||||||
|
temp[categ] = rank
|
||||||
|
for item in newTrophy:
|
||||||
|
categ = item['categ']
|
||||||
|
rank = item['trophy_true_rank']
|
||||||
|
if rank > temp[categ]:
|
||||||
|
awards_given.append(['trophy', [categ, rank]])
|
||||||
|
|
||||||
return awards_given
|
return awards_given
|
||||||
|
|
||||||
''' HONOR BADGES '''
|
''' HONOR BADGES '''
|
||||||
|
|
|
||||||
|
|
@ -322,12 +322,12 @@ def eventStreamAwards():
|
||||||
for msg in subscriber_lastAwards.listen():
|
for msg in subscriber_lastAwards.listen():
|
||||||
content = msg['data'].decode('utf8')
|
content = msg['data'].decode('utf8')
|
||||||
contentJson = json.loads(content)
|
contentJson = json.loads(content)
|
||||||
data = json.loads(contentJson['data'])
|
lastAwardJson = json.loads(contentJson['log'])
|
||||||
org = data['org']
|
org = lastAwardJson['org']
|
||||||
to_return = contributor_helper.getContributorFromRedis(org)
|
to_return = contributor_helper.getContributorFromRedis(org)
|
||||||
epoch = data['epoch']
|
epoch = lastAwardJson['epoch']
|
||||||
to_return['epoch'] = epoch
|
to_return['epoch'] = epoch
|
||||||
to_return['award'] = data['award']
|
to_return['award'] = lastAwardJson['award']
|
||||||
yield 'data: {}\n\n'.format(json.dumps(to_return))
|
yield 'data: {}\n\n'.format(json.dumps(to_return))
|
||||||
|
|
||||||
@app.route("/_getTopContributor")
|
@app.route("/_getTopContributor")
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ var allOrg = [];
|
||||||
var datatableTop;
|
var datatableTop;
|
||||||
var datatableFameQuant;
|
var datatableFameQuant;
|
||||||
var refresh_speed = min_between_reload*60;
|
var refresh_speed = min_between_reload*60;
|
||||||
|
var next_effect = new Date();
|
||||||
var will_reload = $("#reloadCheckbox").is(':checked');
|
var will_reload = $("#reloadCheckbox").is(':checked');
|
||||||
var sec_before_reload = refresh_speed;
|
var sec_before_reload = refresh_speed;
|
||||||
var plotLineChart;
|
var plotLineChart;
|
||||||
|
|
@ -355,6 +356,10 @@ function addLastContributor(datatable, data, update) {
|
||||||
if($(this.data()[6])[0].text == data.org) {
|
if($(this.data()[6])[0].text == data.org) {
|
||||||
var node = $(datatable.row( this ).node());
|
var node = $(datatable.row( this ).node());
|
||||||
datatable.row( this ).data( to_add );
|
datatable.row( this ).data( to_add );
|
||||||
|
if(next_effect <= new Date()) {
|
||||||
|
node.effect("slide", 500);
|
||||||
|
next_effect.setSeconds(next_effect.getSeconds() + 5);
|
||||||
|
}
|
||||||
row_added = true;
|
row_added = true;
|
||||||
}
|
}
|
||||||
datatable.draw();
|
datatable.draw();
|
||||||
|
|
@ -554,8 +559,6 @@ function updateTimer() {
|
||||||
if ($("#reloadCheckbox").is(':checked')) {
|
if ($("#reloadCheckbox").is(':checked')) {
|
||||||
sec_before_reload--;
|
sec_before_reload--;
|
||||||
if (sec_before_reload < 1) {
|
if (sec_before_reload < 1) {
|
||||||
source_lastContrib.close();
|
|
||||||
source_awards.close();
|
|
||||||
location.reload();
|
location.reload();
|
||||||
} else {
|
} else {
|
||||||
$('#labelRemainingTime').text(timeToString(sec_before_reload));
|
$('#labelRemainingTime').text(timeToString(sec_before_reload));
|
||||||
|
|
@ -575,6 +578,12 @@ $(document).ready(function() {
|
||||||
updateTimer();
|
updateTimer();
|
||||||
$('#orgName').typeahead(typeaheadOption);
|
$('#orgName').typeahead(typeaheadOption);
|
||||||
$('#btnCurrRank').popover(popOverOption);
|
$('#btnCurrRank').popover(popOverOption);
|
||||||
|
|
||||||
|
$(window).on("beforeunload", function() {
|
||||||
|
source_lastContrib.close();
|
||||||
|
source_awards.close();
|
||||||
|
});
|
||||||
|
|
||||||
datatableTop = $('#topContribTable').DataTable(optionDatatable_top);
|
datatableTop = $('#topContribTable').DataTable(optionDatatable_top);
|
||||||
datatableFameQuant = $('#fameTableQuantity').DataTable(optionDatatable_fame);
|
datatableFameQuant = $('#fameTableQuantity').DataTable(optionDatatable_fame);
|
||||||
datatableFameQual = $('#fameTableQuality').DataTable(optionDatatable_fame);
|
datatableFameQual = $('#fameTableQuality').DataTable(optionDatatable_fame);
|
||||||
|
|
@ -617,7 +626,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
if(currOrg != "") // currOrg selected
|
if(currOrg != "") // currOrg selected
|
||||||
//FIXME: timeout used to wait that all datatables are draw.
|
//FIXME: timeout used to wait that all datatables are draw.
|
||||||
setTimeout( function() { updateProgressHeader(currOrg); }, 500);
|
setTimeout( function() { updateProgressHeader(currOrg); }, 700);
|
||||||
|
|
||||||
source_lastContrib = new EventSource(url_eventStreamLastContributor);
|
source_lastContrib = new EventSource(url_eventStreamLastContributor);
|
||||||
source_lastContrib.onmessage = function(event) {
|
source_lastContrib.onmessage = function(event) {
|
||||||
|
|
@ -632,5 +641,6 @@ $(document).ready(function() {
|
||||||
source_awards.onmessage = function(event) {
|
source_awards.onmessage = function(event) {
|
||||||
var json = jQuery.parseJSON( event.data );
|
var json = jQuery.parseJSON( event.data );
|
||||||
addAwards(datatableAwards, json, true);
|
addAwards(datatableAwards, json, true);
|
||||||
|
updateProgressHeader(currOrg);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -399,7 +399,7 @@
|
||||||
|
|
||||||
<div class="panel panel-default" style="height: 100%;">
|
<div class="panel panel-default" style="height: 100%;">
|
||||||
<div class="panel-heading bg-info" style="font-weight: bold;">
|
<div class="panel-heading bg-info" style="font-weight: bold;">
|
||||||
<i class="fa fa-star" style="margin-right: 5px; color: #f0ad4e;"></i><b>Hall Of Fame - Quantity (previous month)</b>
|
<i class="fa fa-star" style="margin-right: 5px; color: #f0ad4e;"></i><b>Hall Of Fame (previous month)</b>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body" style="height: 100%;">
|
<div class="panel-body" style="height: 100%;">
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue