File tree Expand file tree Collapse file tree 5 files changed +114
-2
lines changed Expand file tree Collapse file tree 5 files changed +114
-2
lines changed Original file line number Diff line number Diff line change
1
+ div.row.hidden
2
+ .col-md-6
3
+ dl.dl-horizontal
4
+ dt # documents
5
+ dd( data-hook ='document_count' )
6
+ dt total document size
7
+ dd( data-hook ='document_size' )
8
+ dt average document size
9
+ dd( data-hook ='document_size_average' )
10
+ .col-md-6
11
+ dl.dl-horizontal
12
+ dt # indexes
13
+ dd( data-hook ='index_count' )
14
+ dt total index size
15
+ dd( data-hook ='index_size' )
16
+ dt average index size
17
+ dd( data-hook ='index_size_average' )
Original file line number Diff line number Diff line change
1
+ var AmpersandView = require ( 'ampersand-view' ) ;
2
+ var numeral = require ( 'numeral' ) ;
3
+
4
+ var CollectionStatsView = AmpersandView . extend ( {
5
+ bindings : {
6
+ 'model._id' : {
7
+ hook : 'name'
8
+ } ,
9
+ document_count : {
10
+ hook : 'document_count'
11
+ } ,
12
+ document_size : {
13
+ hook : 'document_size'
14
+ } ,
15
+ document_size_average : {
16
+ hook : 'document_size_average'
17
+ } ,
18
+ index_count : {
19
+ hook : 'index_count'
20
+ } ,
21
+ index_size : {
22
+ hook : 'index_size'
23
+ } ,
24
+ index_size_average : {
25
+ hook : 'index_size_average'
26
+ } ,
27
+ } ,
28
+ derived : {
29
+ document_count : {
30
+ deps : [ 'model.document_count' ] ,
31
+ fn : function ( ) {
32
+ return numeral ( this . model . document_count ) . format ( '0.0a' ) ;
33
+ }
34
+ } ,
35
+ document_size : {
36
+ deps : [ 'model.document_size' ] ,
37
+ fn : function ( ) {
38
+ return numeral ( this . model . document_size ) . format ( '0.0b' ) ;
39
+ }
40
+ } ,
41
+ document_size_average : {
42
+ deps : [ 'model.document_size_average' ] ,
43
+ fn : function ( ) {
44
+ return numeral ( this . model . document_size_average ) . format ( '0.0b' ) ;
45
+ }
46
+ } ,
47
+ index_count : {
48
+ deps : [ 'model.index_count' ] ,
49
+ fn : function ( ) {
50
+ return numeral ( this . model . index_count ) . format ( '0.0a' ) ;
51
+ }
52
+ } ,
53
+ index_size : {
54
+ deps : [ 'model.index_size' ] ,
55
+ fn : function ( ) {
56
+ return numeral ( this . model . index_size ) . format ( '0.0b' ) ;
57
+ }
58
+ } ,
59
+ index_size_average : {
60
+ deps : [ 'model.index_size_average' ] ,
61
+ fn : function ( ) {
62
+ return numeral ( this . model . index_size_average ) . format ( '0.0b' ) ;
63
+ }
64
+ }
65
+ } ,
66
+ template : require ( './index.jade' )
67
+ } ) ;
68
+
69
+ module . exports = CollectionStatsView ;
Original file line number Diff line number Diff line change 2
2
.panel
3
3
.panel-heading
4
4
h3( data-hook ='name' )
5
+ div( data-hook ='stats-container' )
5
6
.panel-body
6
7
div( data-hook ='fields-container' )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ var debug = require('debug')('scout-ui:home');
5
5
var app = require ( 'ampersand-app' ) ;
6
6
var format = require ( 'util' ) . format ;
7
7
var SidebarView = require ( '../sidebar' ) ;
8
-
8
+ var CollectionStatsView = require ( '../collection-stats' ) ;
9
9
var FieldListView = require ( '../field-list' ) ;
10
10
11
11
require ( 'bootstrap/js/dropdown' ) ;
@@ -27,13 +27,24 @@ var CollectionView = AmpersandView.extend({
27
27
this . schema . ns = this . model . _id ;
28
28
this . listenTo ( this . schema , 'error' , this . onError ) ;
29
29
this . schema . fetch ( ) ;
30
+ this . model . fetch ( ) ;
30
31
} ,
31
32
template : require ( './collection.jade' ) ,
32
33
onError : function ( schema , err ) {
33
34
// @todo : Figure out a good way to handle this (server is probably crashed).
34
35
console . error ( 'Error getting schema: ' , err ) ;
35
36
} ,
36
37
subviews : {
38
+ stats : {
39
+ hook : 'stats-container' ,
40
+ prepareView : function ( el ) {
41
+ return new CollectionStatsView ( {
42
+ el : el ,
43
+ parent : this ,
44
+ model : this . model
45
+ } ) ;
46
+ }
47
+ } ,
37
48
fields : {
38
49
waitFor : 'schema.fields' ,
39
50
hook : 'fields-container' ,
Original file line number Diff line number Diff line change @@ -44,6 +44,13 @@ var SampledSchema = Schema.extend({
44
44
wrapError ( this , options ) ;
45
45
46
46
var model = this ;
47
+ var collection ;
48
+ if ( this . parent && this . parent . model && this . parent . model . documents ) {
49
+ collection = this . parent . model . documents ;
50
+ collection . reset ( ) ;
51
+ }
52
+
53
+
47
54
window . schema = this ;
48
55
window . data = [ ] ;
49
56
var parser = this . stream ( )
@@ -52,6 +59,9 @@ var SampledSchema = Schema.extend({
52
59
} )
53
60
. on ( 'data' , function ( doc ) {
54
61
window . data . push ( doc ) ;
62
+ if ( collection ) {
63
+ collection . add ( doc ) ;
64
+ }
55
65
} )
56
66
. on ( 'end' , function ( ) {
57
67
process . nextTick ( function ( ) {
@@ -127,8 +137,11 @@ var Collection = core.Collection.extend({
127
137
}
128
138
}
129
139
}
140
+ } ,
141
+ scout : function ( ) {
142
+ return client . collection . bind ( client , this . getId ( ) ) ;
130
143
}
131
- } ) ;
144
+ } , WithScout ) ;
132
145
133
146
module . exports = {
134
147
types : brain . types ,
@@ -138,6 +151,7 @@ module.exports = {
138
151
collections : core . CollectionCollection . extend ( WithSelectable , {
139
152
model : Collection ,
140
153
parse : function ( res ) {
154
+ // Hide specialish namespaces (eg `local.*`, `*oplog*`) from sidebar.
141
155
return res . filter ( function ( d ) {
142
156
return ! types . ns ( d . _id ) . specialish ;
143
157
} ) ;
You can’t perform that action at this time.
0 commit comments