File tree Expand file tree Collapse file tree 3 files changed +34
-7
lines changed
client/views/dashboard/charts Expand file tree Collapse file tree 3 files changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,6 @@ Template.chartsLayout.rendered = function () {
1111 index : "api-umbrella-logs-v1-" + currentYearAndMonth ,
1212 type : "log" ,
1313 limit : initialLimit ,
14- query : {
15- match_all : { }
16- } ,
1714 fields : [
1815 'request_at' ,
1916 'request_ip_country' ,
Original file line number Diff line number Diff line change @@ -23,9 +23,6 @@ Template.chartsLayout.events({
2323 index : "api-umbrella-logs-v1-" + year + "-" + month ,
2424 type : "log" ,
2525 limit : limit ,
26- query : {
27- match_all : { }
28- } ,
2926 fields : [
3027 'request_at' ,
3128 'request_ip_country' ,
Original file line number Diff line number Diff line change 11Meteor . methods ( {
22 "getChartData" : function ( data ) {
33
4+ // initialise variables
5+ var loggedInUser ;
6+ var apiKey ;
7+ var query ;
8+
9+ // get user object
10+ loggedInUser = Meteor . user ( ) ;
11+
12+ // get user role & check user role
13+ if ( Roles . userIsInRole ( loggedInUser , [ 'admin' ] ) ) {
14+
15+ // if admin - match_all
16+ // construct query
17+ query = {
18+ match_all : { }
19+ }
20+
21+ } else {
22+
23+ // else - user - match api_key: api_key
24+
25+ // get user's api_key
26+ apiKey = loggedInUser . profile . apiKey ;
27+
28+ // construct query
29+ query = {
30+ "match" : {
31+ "api_key" : apiKey
32+ }
33+ }
34+
35+ }
36+
437 var newSearch = new ElasticRest (
538 data . index ,
639 data . type ,
740 data . limit ,
8- data . query ,
41+ query ,
942 data . fields
1043 ) ;
1144
You can’t perform that action at this time.
0 commit comments