From f95cd97e11f6d11d5412ef19704dcb6e8b9d022c Mon Sep 17 00:00:00 2001 From: Koren Lev Date: Thu, 7 Sep 2017 16:07:17 +0300 Subject: refactoring of messages Change-Id: Ia0de54892a5175194234d887e617715398c9a639 Signed-off-by: Koren Lev --- .../environment-dashboard/environment-dashboard.js | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'ui/imports/ui/components/environment-dashboard') diff --git a/ui/imports/ui/components/environment-dashboard/environment-dashboard.js b/ui/imports/ui/components/environment-dashboard/environment-dashboard.js index 82fbb52..4fb6366 100644 --- a/ui/imports/ui/components/environment-dashboard/environment-dashboard.js +++ b/ui/imports/ui/components/environment-dashboard/environment-dashboard.js @@ -26,6 +26,7 @@ import { calcIconForMessageLevel, lastMessageTimestamp, calcColorClassForMessage import { Counts } from 'meteor/tmeasday:publish-counts'; import { Roles } from 'meteor/alanning:roles'; //import { idToStr } from '/imports/lib/utilities'; +import { Configurations } from '/imports/api/configurations/configurations'; import { Counter } from 'meteor/natestrauser:publish-performant-counts'; import '/imports/ui/components/data-cubic/data-cubic'; @@ -87,6 +88,7 @@ Template.EnvironmentDashboard.onCreated(function() { _id: null, envName: null, allowEdit: false, + msgsViewBackDelta: 1, }); instance.autorun(function () { @@ -125,9 +127,11 @@ Template.EnvironmentDashboard.onCreated(function() { instance.subscribe('inventory?env+type', env.name, 'project'); instance.subscribe('inventory?env+type', env.name, 'region'); + /* instance.subscribe('messages/count?level&env', 'info', env.name); instance.subscribe('messages/count?level&env', 'warning', env.name); instance.subscribe('messages/count?level&env', 'error', env.name); + */ let vConnectorCounterName = 'inventory?env+type!counter?env=' + env.name + '&type=' + 'vconnector'; @@ -161,6 +165,22 @@ Template.EnvironmentDashboard.onCreated(function() { }); }); + + instance.autorun(function () { + instance.subscribe('configurations?user'); + Configurations.find({user_id: Meteor.userId()}).forEach((conf) => { + instance.state.set('msgsViewBackDelta', conf.messages_view_backward_delta); + }); + }); + + instance.autorun(function () { + let msgsViewBackDelta = instance.state.get('msgsViewBackDelta'); + let env = instance.state.get('envName'); + + instance.subscribe('messages/count?backDelta&level&env', msgsViewBackDelta, 'info', env); + instance.subscribe('messages/count?backDelta&level&env', msgsViewBackDelta, 'warning', env); + instance.subscribe('messages/count?backDelta&level&env', msgsViewBackDelta, 'error', env); + }); }); /* @@ -312,13 +332,16 @@ Template.EnvironmentDashboard.helpers({ argsMessagesInfoBox: function(boxDef, env) { let instance = Template.instance(); let envName = instance.state.get('envName'); + let msgsViewBackDelta = instance.state.get('msgsViewBackDelta'); + if (R.isNil(envName)) { return { title: '', count: 0, lastScanTimestamp: '', onMoreDetailsReq: function () {} }; } - let counterName = `messages/count?level=${boxDef.level}&env=${envName}`; + //let counterName = `messages/count?level=${boxDef.level}&env=${envName}`; + let counterName = `messages/count?backDelta=${msgsViewBackDelta}&level=${boxDef.level}&env=${envName}`; let count = Counter.get(counterName); //let count = Counts.get('messages?env+level!counter?env=' + -- cgit 1.2.3-korg