1
+ /*global store, countlyView, $, countlyGlobal, production, Handlebars, jQuery, app, CountlyHelpers, Backbone, DBViewerView, CountlyDrop, countlyDBviewer*/
1
2
window . DBViewerView = countlyView . extend ( {
2
3
initialize : function ( ) {
3
4
this . dbviewer_selected_app = "all" ;
@@ -16,7 +17,7 @@ window.DBViewerView = countlyView.extend({
16
17
} ) , countlyDBviewer . initialize ( self . dbviewer_selected_app ) ) . then ( function ( ) { } ) ;
17
18
}
18
19
} ,
19
- renderCommon : function ( isRefresh ) {
20
+ renderCommon : function ( ) {
20
21
var self = this ;
21
22
this . templateData = {
22
23
"page-title" : jQuery . i18n . map [ "dbviewer.title" ] ,
@@ -37,10 +38,6 @@ window.DBViewerView = countlyView.extend({
37
38
}
38
39
39
40
var prepareSwitch = function ( ) {
40
- // check is not exist dbviewer_selected_app in localStorage
41
- if ( ! store . get ( 'dbviewer_selected_app' ) ) {
42
- var app_name = $ . i18n . map [ "common.all" ] ;
43
- }
44
41
// clear app-list
45
42
$ ( '#app-list' ) . html ( "" ) ;
46
43
// prepend "all apps" link to list
@@ -59,7 +56,7 @@ window.DBViewerView = countlyView.extend({
59
56
$ ( '#app-selector' ) . html ( store . get ( 'dbviewer_selected_app' ) . name ) ;
60
57
}
61
58
else {
62
- $ ( '#app-selector' ) . html ( ( self . dbviewer_selected_app == "all" ) ? $ . i18n . map [ "common.all" ] : self . dbviewer_selected_app . name ) ;
59
+ $ ( '#app-selector' ) . html ( ( self . dbviewer_selected_app === "all" ) ? $ . i18n . map [ "common.all" ] : self . dbviewer_selected_app . name ) ;
63
60
}
64
61
65
62
} ;
@@ -72,38 +69,38 @@ window.DBViewerView = countlyView.extend({
72
69
self . dbviewer_selected_app = "all" ;
73
70
store . remove ( 'dbviewer_selected_app' ) ;
74
71
for ( var key in countlyGlobal . apps ) {
75
- if ( countlyGlobal . apps [ key ] . _id == $ ( this ) . data ( 'value' ) ) {
72
+ if ( countlyGlobal . apps [ key ] . _id === $ ( this ) . data ( 'value' ) ) {
76
73
self . dbviewer_selected_app = countlyGlobal . apps [ key ] ;
77
74
store . set ( 'dbviewer_selected_app' , self . dbviewer_selected_app ) ;
78
75
}
79
76
}
80
77
prepareSwitch ( ) ;
81
78
countlyDBviewer . initialize ( self . dbviewer_selected_app . _id )
82
- . then ( function ( response ) {
79
+ . then ( function ( ) {
83
80
var filteredData = countlyDBviewer . getData ( ) ;
84
81
filteredData . forEach ( function ( db ) {
85
82
$ ( '.dbviewer-collection-list-' + db . name ) . css ( { "height" : ( window . innerHeight - 150 ) + "px" } ) ;
86
83
var filteredCollectionListKeys = Object . keys ( filteredData [ 0 ] . collections ) ;
87
84
var filteredCollectionListValues = Object . values ( filteredData [ 0 ] . collections ) ;
88
85
89
86
filteredCollectionListValues . sort ( function ( a , b ) {
90
- if ( a < b ) {
87
+ if ( a < b ) {
91
88
return - 1 ;
92
89
}
93
- if ( a > b ) {
90
+ if ( a > b ) {
94
91
return 1 ;
95
92
}
96
- return 0 ;
93
+ return 0 ;
97
94
} ) ;
98
95
99
96
filteredCollectionListKeys . sort ( function ( a , b ) {
100
- if ( a < b ) {
97
+ if ( a < b ) {
101
98
return - 1 ;
102
99
}
103
- if ( a > b ) {
100
+ if ( a > b ) {
104
101
return 1 ;
105
102
}
106
- return 0 ;
103
+ return 0 ;
107
104
} ) ;
108
105
109
106
$ ( '.dbviewer-collection-list-' + db . name ) . html ( "" ) ;
@@ -153,7 +150,7 @@ window.DBViewerView = countlyView.extend({
153
150
var self = this ;
154
151
// r we have cache query properties for this collection?
155
152
// if collection properties is exist load them from localStorage
156
- if ( ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) == self . collection ) ) {
153
+ if ( ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) === self . collection ) ) {
157
154
// prepare projection values if it's exist on localStorage
158
155
if ( store . get ( 'dbviewer_projection_values' ) ) {
159
156
self . projection = { } ;
@@ -208,14 +205,14 @@ window.DBViewerView = countlyView.extend({
208
205
//trigger for render localizations manually
209
206
app . localize ( ) ;
210
207
self . accordion ( ) ;
211
- if ( store . get ( 'dbviewer_selected_app' ) == "all" ) {
208
+ if ( store . get ( 'dbviewer_selected_app' ) === "all" ) {
212
209
$ ( '#app-selector' ) . html ( $ . i18n . map [ "common.all" ] ) ;
213
210
}
214
211
else {
215
- $ ( '#app-selector' ) . html ( ( self . dbviewer_selected_app == "all" ) ? $ . i18n . map [ "common.all" ] : self . dbviewer_selected_app . name ) ;
212
+ $ ( '#app-selector' ) . html ( ( self . dbviewer_selected_app === "all" ) ? $ . i18n . map [ "common.all" ] : self . dbviewer_selected_app . name ) ;
216
213
}
217
214
218
- if ( self . filter != "{}" ) {
215
+ if ( self . filter !== "{}" ) {
219
216
$ ( ".dbviewer-collection-filter" ) . val ( self . filter ) ;
220
217
}
221
218
@@ -224,7 +221,7 @@ window.DBViewerView = countlyView.extend({
224
221
by the state of current collection
225
222
is that same collection before refresh? or not?
226
223
*/
227
- if ( ! ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) == self . collection ) ) {
224
+ if ( ! ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) === self . collection ) ) {
228
225
self . selected_projection = { } ;
229
226
self . sort = { } ;
230
227
store . set ( 'dbviewer_current_collection' , self . collection ) ;
@@ -273,7 +270,7 @@ window.DBViewerView = countlyView.extend({
273
270
var options = [ ] ;
274
271
// if options are exist and rendering in same collection
275
272
// load options from localStorage
276
- if ( ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) == self . collection ) && store . get ( 'countly_collectionoptions' ) ) {
273
+ if ( ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) === self . collection ) && store . get ( 'countly_collectionoptions' ) ) {
277
274
options = JSON . parse ( store . get ( 'countly_collectionoptions' ) ) ;
278
275
}
279
276
// generate new options array
@@ -305,20 +302,19 @@ window.DBViewerView = countlyView.extend({
305
302
searchField : [ 'key' ] ,
306
303
options : options ,
307
304
render : {
308
- item : function ( item , escape ) {
305
+ item : function ( item ) {
309
306
return '<div>' +
310
307
item . key +
311
308
'</div>' ;
312
309
} ,
313
- option : function ( item , escape ) {
310
+ option : function ( item ) {
314
311
var label = item . key ;
315
- var caption = item . key ;
316
312
return '<div>' +
317
313
'<span class="label">' + label + '</span>' +
318
314
'</div>' ;
319
315
}
320
316
} ,
321
- createFilter : function ( input ) {
317
+ createFilter : function ( ) {
322
318
return true ;
323
319
} ,
324
320
create : function ( input ) {
@@ -351,7 +347,7 @@ window.DBViewerView = countlyView.extend({
351
347
} ) ;
352
348
353
349
// fill inputs with projection and sort values if in the same collection
354
- if ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) == self . collection ) {
350
+ if ( store . get ( 'dbviewer_current_collection' ) && store . get ( 'dbviewer_current_collection' ) === self . collection ) {
355
351
if ( typeof self . selected_projection !== "object" && self . selected_projection !== "" ) {
356
352
self . selected_projection . split ( "," ) . forEach ( function ( tag ) {
357
353
$ ( '#dbviewer-projection' ) [ 0 ] . selectize . addOption ( { "key" : tag } ) ;
@@ -376,8 +372,8 @@ window.DBViewerView = countlyView.extend({
376
372
jsonlint = false ;
377
373
}
378
374
// show and hide json status indicator by conditions
379
- if ( jsonlint || ( $ ( this ) . val ( ) == "" && ! jsonlint ) ) {
380
- if ( ! ( $ ( this ) . val ( ) == "" ) ) {
375
+ if ( jsonlint || ( $ ( this ) . val ( ) === "" && ! jsonlint ) ) {
376
+ if ( ! ( $ ( this ) . val ( ) === "" ) ) {
381
377
$ ( this ) . val ( JSON . stringify ( o ) ) ;
382
378
}
383
379
$ ( '.dbviewer-correct-json' ) . css ( { "display" : 'block' } ) ;
@@ -408,7 +404,7 @@ window.DBViewerView = countlyView.extend({
408
404
409
405
// decide which button is active?
410
406
// and set it active
411
- if ( store . get ( 'dbviewer_sort_type' ) != null ) {
407
+ if ( store . get ( 'dbviewer_sort_type' ) !== null ) {
412
408
if ( store . get ( 'dbviewer_sort_type' ) === - 1 ) {
413
409
$ ( '#dbviewer-sort-descend' ) . addClass ( 'dbviewer-sort-active' ) ;
414
410
$ ( '#dbviewer-sort-ascend' ) . removeClass ( 'dbviewer-sort-active' ) ;
@@ -486,7 +482,7 @@ window.DBViewerView = countlyView.extend({
486
482
store . remove ( 'dbviewer_projection_values' ) ;
487
483
}
488
484
// prepare filter by input values
489
- var filter = $ ( ".dbviewer-collection-filter" ) . val ( ) == "" ? JSON . stringify ( { } ) : $ ( ".dbviewer-collection-filter" ) . val ( ) ;
485
+ var filter = $ ( ".dbviewer-collection-filter" ) . val ( ) === "" ? JSON . stringify ( { } ) : $ ( ".dbviewer-collection-filter" ) . val ( ) ;
490
486
// prepare sort by input values
491
487
self . filter = filter ;
492
488
self . projection = projection ;
@@ -538,7 +534,7 @@ window.DBViewerView = countlyView.extend({
538
534
var self = this ;
539
535
$ ( "#accordion" ) . accordion ( {
540
536
collapsible : true ,
541
- active : ( self . db == "countly_drill" ) ? 1 : 0
537
+ active : ( self . db === "countly_drill" ) ? 1 : 0
542
538
} ) ;
543
539
$ ( "#accordion a" ) . removeClass ( "selected" ) ;
544
540
$ ( "#accordion a[href='#" + Backbone . history . fragment + "']" ) . addClass ( "selected" ) ;
@@ -569,7 +565,7 @@ app.route('/manage/db/:dbs/:collection', 'dbs', function(db, collection) {
569
565
this . dbviewerView . collection = collection ;
570
566
this . dbviewerView . document = null ;
571
567
this . dbviewerView . page = null ;
572
- if ( store . get ( "countly_collection" ) != collection ) {
568
+ if ( store . get ( "countly_collection" ) !== collection ) {
573
569
store . set ( "countly_collectionfilter" , "{}" ) ;
574
570
store . set ( "countly_collection" , collection ) ;
575
571
this . dbviewerView . filter = "{}" ;
@@ -589,7 +585,7 @@ app.route('/manage/db/:dbs/:collection/page/:page', 'dbs', function(db, collecti
589
585
this . dbviewerView . collection = collection ;
590
586
this . dbviewerView . document = null ;
591
587
this . dbviewerView . page = parseInt ( page ) ;
592
- if ( store . get ( "countly_collection" ) != collection ) {
588
+ if ( store . get ( "countly_collection" ) !== collection ) {
593
589
store . set ( "countly_collectionfilter" , "{}" ) ;
594
590
this . dbviewerView . filter = "{}" ;
595
591
store . set ( "countly_collection" , collection ) ;
0 commit comments