From 7d2842886a07ee29edc751cac1151e7e6d857313 Mon Sep 17 00:00:00 2001 From: Jeff Bryner Date: Sun, 27 Sep 2015 19:00:20 -0700 Subject: [PATCH] clean up some old-style helper routines in support of #290 --- meteor/app/client/alertsummary.js | 57 ++++++++++++++++--------------- meteor/app/client/mozdefhealth.js | 27 ++++++++------- 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/meteor/app/client/alertsummary.js b/meteor/app/client/alertsummary.js index 44fa7af7..6de5b7d7 100644 --- a/meteor/app/client/alertsummary.js +++ b/meteor/app/client/alertsummary.js @@ -14,34 +14,35 @@ if (Meteor.isClient) { Session.set('alertsSearch',null); Session.set('alertsDisplayed',0); - Template.alertssummary.selectedalerts = function () { - //console.log(moment().format(),Session.get('alertsSearch')); - - Session.set('alertsDisplayed', - alerts.find(Session.get('alertsSearch'), - {limit: Session.get('alertsrecordlimit'), - reactive:false}).count() - ); - - //return just what's needed for the summary table - return alerts.find(Session.get('alertsSearch'), - {fields:{ - _id:1, - esmetadata:1, - utctimestamp:1, - utcepoch:1, - summary:1, - severity:1, - category:1, - acknowledged:1, - acknowledgedby:1, - url:1 - }, - sort: {utcepoch: -1}, - limit: Session.get('alertsrecordlimit'), - reactive:true}) - }; - + Template.alertssummary.helpers({ + selectedalerts: function () { + //console.log(moment().format(),Session.get('alertsSearch')); + + Session.set('alertsDisplayed', + alerts.find(Session.get('alertsSearch'), + {limit: Session.get('alertsrecordlimit'), + reactive:false}).count() + ); + + //return just what's needed for the summary table + return alerts.find(Session.get('alertsSearch'), + {fields:{ + _id:1, + esmetadata:1, + utctimestamp:1, + utcepoch:1, + summary:1, + severity:1, + category:1, + acknowledged:1, + acknowledgedby:1, + url:1 + }, + sort: {utcepoch: -1}, + limit: Session.get('alertsrecordlimit'), + reactive:true}) + } + }); Template.alertssummary.events({ "click .reset": function(e,t){ diff --git a/meteor/app/client/mozdefhealth.js b/meteor/app/client/mozdefhealth.js index 89275a4f..04fd12cc 100644 --- a/meteor/app/client/mozdefhealth.js +++ b/meteor/app/client/mozdefhealth.js @@ -13,27 +13,30 @@ if (Meteor.isClient) { //elastic search cluster template functions //return es health items - Template.mozdefhealth.esclusterhealthitems = function () { - return healthescluster.find(); - }; + Template.mozdefhealth.helpers({ + + esclusterhealthitems: function () { + return healthescluster.find(); + }, - Template.mozdefhealth.frontendhealthitems = function () { - return healthfrontend.find({}, + frontendhealthitems: function () { + return healthfrontend.find({}, {fields:{}, sort: {hostname: 1} }); - }; + }, - Template.mozdefhealth.esnodeshealthitems = function () { - return healthesnodes.find({}, + esnodeshealthitems: function () { + return healthesnodes.find({}, {fields:{}, sort: {hostname: 1} }); - }; + }, - Template.mozdefhealth.eshotthreadshealthitems = function () { - return healtheshotthreads.find(); - }; + eshotthreadshealthitems: function () { + return healtheshotthreads.find(); + } + }); Template.mozdefhealth.rendered = function () { var ringChartEPS = dc.pieChart("#ringChart-EPS");