mongo3 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/HISTORY +6 -1
  2. data/README.rdoc +2 -0
  3. data/Rakefile +0 -1
  4. data/data/populate +4 -4
  5. data/lib/controllers/collections.rb +42 -8
  6. data/lib/controllers/databases.rb +11 -1
  7. data/lib/controllers/explore.rb +49 -12
  8. data/lib/helpers/collection_helper.rb +18 -0
  9. data/lib/helpers/crumb_helper.rb +4 -4
  10. data/lib/helpers/database_helper.rb +17 -0
  11. data/lib/helpers/explore_helper.rb +30 -0
  12. data/lib/helpers/flash_helper.rb +7 -0
  13. data/lib/helpers/main_helper.rb +12 -30
  14. data/lib/helpers/paths_helper.rb +40 -0
  15. data/lib/mongo3.rb +1 -1
  16. data/lib/mongo3/connection.rb +95 -34
  17. data/lib/mongo3/node.rb +43 -28
  18. data/lib/public/images/edit.png +0 -0
  19. data/lib/public/images/selected_bg.png +0 -0
  20. data/lib/public/stylesheets/mongo3.css +87 -76
  21. data/lib/views/collections/_index_form.erb +35 -0
  22. data/lib/views/collections/_index_rows.erb +54 -0
  23. data/lib/views/collections/_indexes.erb +3 -0
  24. data/lib/views/collections/_results.erb +1 -2
  25. data/lib/views/collections/_rows.erb +26 -22
  26. data/lib/views/collections/_search_form.erb +2 -3
  27. data/lib/views/collections/list.erb +18 -6
  28. data/lib/views/collections/update.js.erb +2 -0
  29. data/lib/views/collections/update_indexes.js.erb +3 -0
  30. data/lib/views/databases/_results.erb +30 -26
  31. data/lib/views/databases/list.erb +7 -3
  32. data/lib/views/explore/_node_info.erb +131 -0
  33. data/lib/views/explore/center_js.erb +1 -0
  34. data/lib/views/explore/explore.erb +11 -80
  35. data/lib/views/explore/more_data_js.erb +1 -0
  36. data/lib/views/explore/update.js.erb +5 -0
  37. data/lib/views/explore/update_crumb_js.erb +2 -1
  38. data/lib/views/layout.erb +2 -2
  39. data/lib/views/shared/flash.js.erb +9 -7
  40. data/spec/landscape.yml +3 -0
  41. data/spec/mongo3/connection_spec.rb +146 -0
  42. data/spec/mongo3/node_spec.rb +26 -8
  43. data/spec/spec_helper.rb +4 -1
  44. data/tasks/rdoc.rake +2 -2
  45. metadata +23 -2
@@ -0,0 +1,35 @@
1
+ <script src="/javascripts/jquery.example.js" type="text/javascript"></script>
2
+
3
+ <form id="index" onsubmit="index_submit();return false;" action="/collections/create_index/" method="post" style="text-align:center">
4
+ <fieldset>
5
+ <input id="index" type="text" name="index" class="search" value=""/>
6
+ <button type="submit" id="submit_button" class="button search" style="display:none">create</button>
7
+ <img id="create_load" src="/images/loading.gif" style="width:25px;height:25px;vertical-align:sub;display:none"></img>
8
+ </fieldset>
9
+ </form>
10
+
11
+ <script>
12
+ $( function() {
13
+ $('input#index').example("[['field1', 1], ['field2', -1]] | {'unique':1}", { className: 'no_input' } );
14
+ $('input#index').hover(
15
+ function() { $(this).css( "border-color", "#92b948") },
16
+ function() { $(this).css( "border-color", "#434343") }
17
+ );
18
+ });
19
+
20
+ function index_submit()
21
+ {
22
+ $.ajax({
23
+ data: $.param( $("form#index").serializeArray() ),
24
+ dataType: 'script',
25
+ type: 'post',
26
+ url: '/collections/create_index/',
27
+ beforeSend: function() {
28
+ $('img#create_load').show();
29
+ },
30
+ complete: function() {
31
+ $('img#create_load').hide();
32
+ }
33
+ });
34
+ }
35
+ </script>
@@ -0,0 +1,54 @@
1
+ <%= partial :'collections/index_form' %>
2
+
3
+ <div class="borders" style="padding:10px">
4
+ <table id="indexes" class="cltn" border="0" cellpadding="10" cellspacing="20">
5
+ <thead>
6
+ <th width="2%">&nbsp;</td>
7
+ <th>Name</th>
8
+ <th>Settings</th>
9
+ </thead>
10
+ <tbody>
11
+ <% @indexes.keys.sort.each do |name| %>
12
+ <tr id="<%=name%>" valign="top">
13
+ <td id="<%=name%>">
14
+ <img class="del_index" id="<%=name%>" src="/images/delete.png" title="delete this index"/>
15
+ <img class="wait" id="wait_<%=name%>" src="/images/loading.gif"></img>
16
+ </td>
17
+ <td><%=name%></td>
18
+ <% buff = [];@indexes[name].each do |pair| %>
19
+ <% buff << format_index( pair )%>
20
+ <% end %>
21
+ <td><%= buff.join( ", " ) %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ </div>
27
+
28
+ <script>
29
+ $( function() {
30
+ $("table#indexes tr" ).hover(
31
+ function() {
32
+ $(this).addClass( 'highlight' );
33
+ $("td#" + $(this).attr('id') + " img.del_index" ).show();
34
+ },
35
+ function() {
36
+ $(this).removeClass( 'highlight' );
37
+ $("td#" + $(this).attr('id') + " img.del_index" ).hide();
38
+ });
39
+ $( "img.del_index" ).click( function() {
40
+ var id = $(this).attr('id');
41
+ $.ajax({
42
+ data: {id: id},
43
+ dataType: 'script',
44
+ type: 'post',
45
+ url: '/collections/drop_index/',
46
+ beforeSend: function() { $('img#_wait_' + id ).show(); },
47
+ complete: function() {
48
+ $('img#_wait_' + id ).hide();
49
+ $('tr#' + id ).fadeOut();
50
+ }
51
+ });
52
+ });
53
+ });
54
+ </script>
@@ -0,0 +1,3 @@
1
+ <div id="indexes">
2
+ <%= partial :'collections/index_rows'%>
3
+ </div>
@@ -2,8 +2,7 @@
2
2
  <div id="fields">
3
3
  <%= partial :'collections/fields_form' %>
4
4
  </div>
5
- <%= partial :'collections/search_form' %>
6
-
5
+
7
6
  <div class="table">
8
7
  <%= partial :'collections/rows' %>
9
8
  </div>
@@ -2,28 +2,32 @@
2
2
  <%= page_entries_info @cltn, :entry_name => 'item' %>
3
3
  </div>
4
4
 
5
- <table id="cltn" class="cltn" border="0" cellpadding="10" cellspacing="20">
6
- <thead>
7
- <th width="2%">&nbsp;</td>
8
- <% @selected_cols.each do |col| %>
9
- <th><%=col%></th>
10
- <% end %>
11
- </thead>
12
- <tbody>
13
- <% @cltn.each do |cltn| %>
14
- <% id = cltn['_id'] %>
15
- <tr id="<%=id%>" valign="top">
16
- <td id="<%=id%>">
17
- <img class="delete" id="<%=id%>" src="/images/delete.png" title="delete this record"/>
18
- <img class="wait" id="wait_<%=id%>" src="/images/loading.gif"></img>
19
- </td>
20
- <% @selected_cols.each do |k| %>
21
- <td><%= format_number(cltn[k]) %></td>
22
- <% end %>
23
- </tr>
24
- <% end %>
25
- </tbody>
26
- </table>
5
+ <%= partial :'collections/search_form' %>
6
+
7
+ <div class="borders" style="padding:10px;">
8
+ <table id="cltn" class="cltn" border="0" cellpadding="10" cellspacing="20">
9
+ <thead>
10
+ <th width="2%">&nbsp;</td>
11
+ <% @selected_cols.each do |col| %>
12
+ <th><%=col%></th>
13
+ <% end %>
14
+ </thead>
15
+ <tbody>
16
+ <% @cltn.each do |cltn| %>
17
+ <% id = cltn['_id'] %>
18
+ <tr id="<%=id%>" valign="top">
19
+ <td id="<%=id%>">
20
+ <img class="delete" id="<%=id%>" src="/images/delete.png" title="delete this record"/>
21
+ <img class="wait" id="wait_<%=id%>" src="/images/loading.gif"></img>
22
+ </td>
23
+ <% @selected_cols.each do |k| %>
24
+ <td><%= format_number(cltn[k]) %></td>
25
+ <% end %>
26
+ </tr>
27
+ <% end %>
28
+ </tbody>
29
+ </table>
30
+ </div>
27
31
 
28
32
  <div id="links">
29
33
  <%= will_paginate @cltn, :params => { :url => '/collections' } %>
@@ -1,18 +1,17 @@
1
1
  <script src="/javascripts/jquery.example.js" type="text/javascript"></script>
2
2
 
3
- <form id="search" onsubmit="search_submit();return false;" action="/collections/search/" method="post" style="text-align:center;margin:10px">
3
+ <form id="search" onsubmit="search_submit();return false;" action="/collections/search/" method="post" style="text-align:center">
4
4
  <fieldset>
5
5
  <input id="search" type="text" name="search" class="search" value="<%=@query%>"/>
6
6
  <button type="submit" id="submit_button" class="button search" style="display:none">search</button>
7
7
  <img id="search_load" src="/images/loading.gif" style="width:25px;height:25px;vertical-align:sub;display:none"></img>
8
8
  </fieldset>
9
- <fieldset style="">
10
- </fieldset>
11
9
  </form>
12
10
 
13
11
  <script>
14
12
  $( function() {
15
13
  $('input#search').example("{'name':'franky'} | [['count',-1]]", { className: 'no_input' } );
14
+ $('input#search').hover( function() { $(this).css( "border-color", "#92b948") }, function() { $(this).css( "border-color", "#434343") })
16
15
  });
17
16
 
18
17
  function search_submit()
@@ -1,18 +1,30 @@
1
+ <%=zone_locator%>
2
+
1
3
  <div class="cltn">
2
- <div class="title"><%=@title%></div>
3
4
  <a class="back" href="<%=@back_url%>">&laquo;&nbsp;back</a>
4
5
 
6
+ <div class="title"><%=title_for( session[:path_names] )%></div>
7
+
5
8
  <div id="mgmt_actions">
6
9
  <img id="action_load" src="/images/loading.gif" style="width:25px;height:25px;vertical-align:sub;display:none"></img>
7
10
  <button class="action clear" rel="#confirm_clear" title="Delete all records from collection">clear</button>
8
11
  <button class="action drop" rel="#confirm_drop" title="Drop the entire collection">drop</button>
9
12
  </div>
10
- <div id="results">
11
- <%= partial :'collections/results' %>
12
- </div>
13
+ <fieldset class="sep">
14
+ <legend> indexes </legend>
15
+ <div id="indexes">
16
+ <%= partial :'collections/indexes' %>
17
+ </div>
18
+ </fieldset>
19
+ <fieldset class="sep">
20
+ <legend> records </legend>
21
+ <div id="results">
22
+ <%= partial :'collections/results' %>
23
+ </div>
24
+ </fieldset>
13
25
  <div>
14
26
 
15
- <div class="modal" id="confirm_clear">
27
+ <div class="modal" id="confirm_clear" style="font-size:1em">
16
28
  <p>Clearing out the whole collection. Are you sure?</p>
17
29
  <p style="margin:10px">
18
30
  <button class="close yes" id="clear"> Yes </button>
@@ -20,7 +32,7 @@
20
32
  </p>
21
33
  </div>
22
34
 
23
- <div class="modal" id="confirm_drop">
35
+ <div class="modal" id="confirm_drop" style="font-size:1em">
24
36
  <p>Dropping the whole collection. Are you sure?</p>
25
37
  <p style="margin:10px">
26
38
  <button class="close yes" id="drop"> Yes </button>
@@ -1 +1,3 @@
1
+ <%= erb :'shared/flash.js', :layout => false %>
2
+
1
3
  $('div.table').html( "<%=escape_javascript(partial(:'collections/rows'))%>" );
@@ -0,0 +1,3 @@
1
+ <%= erb :'shared/flash.js', :layout => false %>
2
+
3
+ $('div#indexes').html( "<%=escape_javascript(partial(:'collections/index_rows'))%>" );
@@ -2,33 +2,37 @@
2
2
  <%= page_entries_info @cltns, :entry_name => 'item' %>
3
3
  </div>
4
4
 
5
- <table id="cltn" class="cltn" border="0" cellpadding="10" cellspacing="20">
6
- <thead>
7
- <th width="2%">&nbsp;</th>
8
- <% cols = @cltns.first.keys %>
9
- <% cols.each do |col| %>
10
- <th align="<%=align_for( @cltns.first[col] )%>"><%=col%></th>
11
- <% end %>
12
- </thead>
13
- <tbody>
14
- <% count = 0; @cltns.each do |cltn| %>
15
- <% path = "#{session[:path_names]}|#{cltn[:name]}"%>
16
- <tr id="<%=count%>" valign="top">
17
- <td id="<%=count%>">
18
- <img class="delete" id="<%=path%>" rel="<%=count%>" src="/images/delete.png" title="drop this collection"/>
19
- <img class="wait" id="wait_<%=count%>" src="/images/loading.gif"></img>
20
- </td>
21
- <% cltn.each_pair do |k, v| %>
22
- <td align="<%=align_for( v )%>"><%= format_number(v) %></td>
5
+ <% unless @cltns.empty? %>
6
+ <div class="borders" style="padding:10px">
7
+ <table id="cltn" class="cltn" border="0" cellpadding="10" cellspacing="20">
8
+ <thead>
9
+ <th width="2%">&nbsp;</th>
10
+ <% cols = @cltns.first.keys %>
11
+ <% cols.each do |col| %>
12
+ <th align="<%=align_for( @cltns.first[col] )%>"><%=col%></th>
23
13
  <% end %>
24
- </tr>
25
- <% count+=1;end %>
26
- </tbody>
27
- </table>
28
-
29
- <div id="links">
30
- <%= will_paginate @cltns, :params => { :url => "/databases" } %>
31
- </div>
14
+ </thead>
15
+ <tbody>
16
+ <% count = 0; @cltns.each do |cltn| %>
17
+ <% path = "#{session[:path_names]}|#{cltn[:name]}"%>
18
+ <tr id="<%=count%>" valign="top">
19
+ <td id="<%=count%>">
20
+ <img class="delete" id="<%=path%>" rel="<%=count%>" src="/images/delete.png" title="drop this collection"/>
21
+ <img class="wait" id="wait_<%=count%>" src="/images/loading.gif"></img>
22
+ </td>
23
+ <td><a href="/databases/collection/<%=cltn[:name]%>/"><%= cltn[:name] %></a></td>
24
+ <td align="<%=align_for( cltn[:count] )%>"><%= format_number(cltn[:count]) %></td>
25
+ </tr>
26
+ <% count+=1;end %>
27
+ </tbody>
28
+ </table>
29
+ </div>
30
+ <div id="links">
31
+ <%= will_paginate @cltns, :params => { :url => "/databases" } %>
32
+ </div>
33
+ <% else %>
34
+ <div class="no_items">Oh snap! No collections found...</span>
35
+ <% end %>
32
36
 
33
37
  <script>
34
38
  $( function() {
@@ -1,8 +1,12 @@
1
+ <%= zone_locator %>
2
+
1
3
  <div class="cltn">
2
- <div class="title"><%=@title%></div>
3
- <a class="back" href="<%=@back_url%>">&laquo;&nbsp;back</a>
4
+ <a class="back" href="<%=@back_url%>">&laquo;&nbsp;back</a>
5
+ <div class="title"><%=title_for( session[:path_names] )%></div>
6
+ </div>
4
7
 
8
+ <div class="cltn" style="padding:10px;">
5
9
  <div id="results">
6
10
  <%= partial :'databases/results'%>
7
11
  </div>
8
- <div>
12
+ </div>
@@ -0,0 +1,131 @@
1
+ <style>
2
+ div.item img {
3
+ z-index:100;
4
+ display:none;
5
+ float:left;
6
+ margin-right:10px;
7
+ }
8
+
9
+ div#legend {
10
+ border-bottom: 1px #434343 solid;
11
+ font-size: 0.5em;
12
+ color: #92b948;
13
+ overflow: hidden;
14
+ }
15
+ div#legend_link {
16
+ text-align: right;
17
+ width: 30%;
18
+ float: right;
19
+ font-size: .7em;
20
+ padding-top: 7px;
21
+ }
22
+
23
+ div.items {
24
+ margin-top:10px;
25
+ }
26
+
27
+ div.item {
28
+ border-top: 1px #bcffca solid;
29
+ height: 30px;
30
+ width: 100%;
31
+ font-size: .4em;
32
+ cursor: pointer;
33
+ z-index: 1;
34
+ }
35
+ div.selected {
36
+ background-image: url(/images/selected_bg.png);
37
+ color: #92b948;
38
+ }
39
+ </style>
40
+
41
+ <% legend = path_type( session[:path_names] ) %>
42
+ <div id="legend">
43
+ <div style="width:60%;float:left">
44
+ @ <%= truncate( legend_title( session[:path_names] ), 30 ) %>
45
+ </div>
46
+ <% unless zone_path?( session[:path_names] ) %>
47
+ <div id="legend_link">
48
+ <a href="#" onclick="$('img.drop').animate({width:'toggle'});return false;">edit</a>
49
+ </div>
50
+ <% end %>
51
+ </div>
52
+
53
+ <p style="font-size:0.6em;color:#fff"><%=legend_for( session[:path_names], @nodes.size )%></p>
54
+
55
+ <div id="actions">
56
+ <a class="prevPage">&laquo; back</a>
57
+ <a class="nextPage">more &raquo;</a>
58
+ </div>
59
+
60
+ <div class="scrollable vertical">
61
+ <div class="items">
62
+ <% count=0;@nodes.sort{|a,b| a.name <=> b.name}.each do |node| %>
63
+ <div id="<%=count%>" class="item">
64
+ <% unless zone_path?( session[:path_names] ) %>
65
+ <img id="<%=count%>" rel="div#confirm_drop" class="drop" href="/explore/database/<%=node.oid%>/<%=node.name%>/drop" title="drop <%=legend%>..." src="/images/delete.png"/>
66
+ <% end %>
67
+ <p rel="div#details" href="/explore/show/<%=node.data[:path_ids]%>/<%=node.data[:path_names]%>" class="info">
68
+ <%=truncate(node.name, 30)%>
69
+ </p>
70
+ </div>
71
+ <% count+=1; end %>
72
+ </div>
73
+ </div>
74
+
75
+ <div class="modal" id="confirm_drop">
76
+ <p>Dropping <%=legend%>. Are you sure?</p>
77
+ <p style="margin:10px">
78
+ <button class="close yes">Yes</button>
79
+ <button class="close">No</button>
80
+ </p>
81
+ </div>
82
+
83
+ <script>
84
+ $( function() {
85
+ $("div.scrollable").scrollable({
86
+ vertical:true,
87
+ size: 14,
88
+ }).mousewheel();
89
+
90
+ $("div.item").hover(
91
+ function() { $(this).addClass( "selected" ) },
92
+ function() { $(this).removeClass( "selected" ) }
93
+ );
94
+
95
+ $('img.drop' ).overlay( {
96
+ expose: {
97
+ color: '#212021',
98
+ loadSpeed: 200,
99
+ opacity: 0.9
100
+ },
101
+ onBeforeLoad: function() {
102
+ $("button.yes").attr( 'href', this.getTrigger().attr('href') );
103
+ $("button.yes").attr( 'id', this.getTrigger().attr('id') );
104
+ },
105
+ closeOnClick: false
106
+ });
107
+
108
+ $( 'button.yes' ).click( function() {
109
+ var self = $(this);
110
+ $.ajax( {
111
+ dataType: 'script',
112
+ type: 'get',
113
+ url: self.attr('href'),
114
+ complete: function() {
115
+ $( 'div#' + self.attr('id') ).fadeOut( 'slow', function() {
116
+ $( 'span#count').html( $('div.items div.item:visible').length );
117
+ });
118
+ }
119
+ });
120
+ });
121
+
122
+ $('div.item p[rel]').overlay( {
123
+ top: '15%',
124
+ expose: '#1c1c1c',
125
+ onBeforeLoad: function() {
126
+ var wrap = this.getContent().find( 'div#wrap' );
127
+ wrap.load( this.getTrigger().attr( 'href' ) );
128
+ }
129
+ });
130
+ });
131
+ </script>