├── .gitignore ├── CHANGELOG.txt ├── LICENSE.txt ├── README ├── Resources ├── liberary │ ├── css │ │ └── master.css │ ├── img │ │ ├── arrow_left.png │ │ ├── arrow_right.png │ │ ├── box_upload_48.png │ │ ├── caut.png │ │ ├── db.png │ │ ├── dbplus.png │ │ ├── help.png │ │ ├── preference.png │ │ ├── refresh_48.png │ │ ├── search_48.png │ │ ├── spanner_48.png │ │ ├── sqldb.png │ │ ├── sqldb_16.png │ │ └── table_48.png │ └── js │ │ ├── base_window.js │ │ ├── connection.js │ │ ├── main.js │ │ ├── prototype-1.6.0.js │ │ └── scriptaculous-1.8.2.js ├── logo.png ├── mongodb.py ├── pymongo │ ├── __init__.py │ ├── _cbsonmodule.c │ ├── binary.py │ ├── bson.py │ ├── code.py │ ├── collection.py │ ├── connection.py │ ├── cursor.py │ ├── cursor_manager.py │ ├── database.py │ ├── dbref.py │ ├── encoding_helpers.c │ ├── encoding_helpers.h │ ├── errors.py │ ├── helpers.py │ ├── json_util.py │ ├── master_slave_connection.py │ ├── message.py │ ├── objectid.py │ ├── son.py │ ├── son_manipulator.py │ ├── thread_util.py │ ├── time_helpers.c │ └── time_helpers.h └── windows │ ├── add_connection.html │ ├── browse_collection.html │ ├── edit_connection.html │ ├── index.html │ └── query.html ├── manifest ├── tiapp.xml └── timanifest /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | tmp 3 | *.pyc 4 | -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Place your change log text here. This file will be incorporated with your app at package time. -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Place your license text here. This file will be incorporated with your app at package time. -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | MongoHub is a mongodb (http://mongodb.org/) gui tool. 2 | 3 | FEATURES: 4 | 1) Add/remove connections; 5 | 2) Show/drop databases; 6 | 3) Show/drop collections; 7 | 4) Run query. 8 | 9 | TODO: 10 | 1) Create database; 11 | 2) Manage indexes; 12 | 3) Export documents. -------------------------------------------------------------------------------- /Resources/liberary/css/master.css: -------------------------------------------------------------------------------- 1 | /* @group reset css */ 2 | 3 | html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { 4 | background: transparent none repeat scroll 0 0; 5 | border: 0 none; 6 | font-size: 100%; 7 | margin: 0; 8 | outline-color: -moz-use-text-color; 9 | outline-style: none; 10 | outline-width: 0; 11 | padding: 0; 12 | vertical-align: baseline; 13 | } 14 | 15 | a { 16 | cursor: pointer; 17 | } 18 | ol, ul { 19 | list-style-image: none; 20 | list-style-position: outside; 21 | list-style-type: none; 22 | } 23 | 24 | blockquote, q { 25 | quotes: none; 26 | } 27 | 28 | blockquote:before, blockquote:after, q:before, q:after { 29 | content: none; 30 | } 31 | 32 | :focus { 33 | outline-color: -moz-use-text-color; 34 | outline-style: none; 35 | outline-width: 0; 36 | } 37 | 38 | ins { 39 | text-decoration: none; 40 | } 41 | 42 | del { 43 | text-decoration: line-through; 44 | } 45 | 46 | table { 47 | border-collapse: collapse; 48 | border-spacing: 0; 49 | } 50 | 51 | .err { 52 | color:red; 53 | line-height:1.5em; 54 | } 55 | 56 | .caution { 57 | font-size: 14px; 58 | color: #333; 59 | padding-left:40px; 60 | line-height:1.5em; 61 | min-height:32px; 62 | background: transparent url(app://liberary/img/caut.png) no-repeat scroll left center; 63 | } 64 | /* @end */ 65 | 66 | /* 67 | 68 | @group layout css */ 69 | 70 | /* start of float and clearfix css */ 71 | 72 | .fl-left { 73 | float: left; 74 | } 75 | 76 | .fl-right { 77 | float: right; 78 | } 79 | 80 | .clearfix:after { 81 | content: "."; 82 | display: block; 83 | height: 0; 84 | clear: both; 85 | visibility: hidden; 86 | } 87 | 88 | .clearfix { 89 | display: inline-table; 90 | } 91 | .clear{ 92 | clear:both; 93 | } 94 | 95 | /* START */ 96 | body { 97 | background-color:1c1c1c; 98 | margin:0; 99 | font-family: Arial, Verdana, sans-serif; 100 | font-size: 12px; 101 | } 102 | 103 | .NavigationBar { 104 | width: 100%; 105 | height: 50px; 106 | overflow: hidden; 107 | border-bottom:#3F3F3F 1px solid; 108 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#BDBDBD), to(#969696)); 109 | } 110 | .NavigationBar ul { 111 | margin:3px 10px; 112 | } 113 | .NavigationBar li { 114 | margin: 0 5px; 115 | float:left; 116 | font-size:10px; 117 | color:#333; 118 | font-weight:bold; 119 | } 120 | .NavigationBar a.Item, .NavigationBar a.Item:link { 121 | text-align: center; 122 | width:60px; 123 | display:block; 124 | overflow:hidden; 125 | text-shadow: 1px 1px 1px #CCC; 126 | } 127 | .NavigationBar a.Item:hover { 128 | color: #000; 129 | text-shadow: 1px 1px 1px #999; 130 | } 131 | .NavigationBar a.Item img { 132 | width:32px; 133 | height:32px; 134 | border:none; 135 | display:block; 136 | margin:0 9px; 137 | } 138 | #app-status { 139 | -webkit-border-radius:5px; 140 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FDFCE3), to(#D2D3B7)); 141 | border-top:1px #333 solid; 142 | border-left:1px #333 solid; 143 | border-right:1px #999 solid; 144 | border-bottom:1px #999 solid; 145 | padding:5px; 146 | float:right; 147 | margin:3px 10px; 148 | min-width: 60px; 149 | height:25px; 150 | overflow: hidden; 151 | } 152 | 153 | 154 | #main-wrapper { 155 | width: 100%; 156 | height:100%; 157 | } 158 | 159 | #sidebar { 160 | background-color:#CDD5DD; 161 | border-right:1px #999 solid; 162 | height:100%; 163 | width:200px; 164 | overflow:auto; 165 | float:left; 166 | } 167 | 168 | #sidebar ul.connections { 169 | margin:10px 0; 170 | } 171 | #sidebar li.connection { 172 | font-size:13px; 173 | color:#333; 174 | text-shadow: 1px 1px 1px #FFF; 175 | cursor: pointer; 176 | padding:10px; 177 | text-indent:20px; 178 | margin:4px 0; 179 | line-height:1.5em; 180 | background: url(app://liberary/img/db.png) 10px center no-repeat; 181 | } 182 | #sidebar li.connection.selected { 183 | background:none; 184 | background-color: #004394; 185 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, 0.5)), to(rgba(98,202,227, 0.5))); 186 | font-weight:bold; 187 | color:#FFF; 188 | text-shadow: 1px 1px 1px #333; 189 | } 190 | #sidebar li.db { 191 | font-size:12px; 192 | color:#333; 193 | text-shadow: 1px 1px 1px #FFF; 194 | cursor: pointer; 195 | padding:2px 5px; 196 | text-indent:35px; 197 | margin:2px 10px; 198 | line-height:1.5em; 199 | background: url(app://liberary/img/sqldb_16.png) 10px center no-repeat; 200 | } 201 | #sidebar li.db.selected { 202 | background: none; 203 | -webkit-border-radius:10px; 204 | background-color: #004394; 205 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, 0.5)), to(rgba(98,202,227, 0.5))); 206 | text-indent:20px; 207 | font-weight:bold; 208 | color:#FFF; 209 | text-shadow: 1px 1px 1px #333; 210 | -webkit-box-shadow: 0 -1px 1px rgba(0,0,0,0.5); 211 | } 212 | 213 | #main-content { 214 | //background-color:white; 215 | height:100%; 216 | width: 599px; 217 | float:left; 218 | } 219 | #main-innerlist { 220 | overflow:auto; 221 | height:100%; 222 | } 223 | #menubar, .collection-meta { 224 | width:100%; 225 | height:25px; 226 | background-image: -webkit-gradient(linear, 0% 40%, 0% 60%, from(#FFF), to(#DEDEDE)); 227 | border-bottom:1px #000 solid; 228 | } 229 | #menubar li{ 230 | padding:0; 231 | margin:0; 232 | height:100%; 233 | float:left; 234 | } 235 | #menubar a, #menubar a:link { 236 | height:100%; 237 | cursor:pointer; 238 | line-height:25px; 239 | padding:0 10px; 240 | border-right:1px #666 solid; 241 | background-image: -webkit-gradient(linear, 0% 40%, 0% 60%, from(#E6E6E6), to(#BEBEBE)); 242 | display:block; 243 | } 244 | #menubar a:hover { 245 | background:none; 246 | color:white; 247 | background-image: -webkit-gradient(linear, 0% 40%, 0% 60%, from(#A4D0FF), to(#0080FF)); 248 | } 249 | #menubar .meta { 250 | float:right; 251 | height:100%; 252 | padding-right:10px; 253 | line-height:25px; 254 | } 255 | #connection_name { 256 | color:#333; 257 | text-shadow: 1px 1px 1px #FFF; 258 | } 259 | #database_name { 260 | color:#333; 261 | text-shadow: 1px 1px 1px #FFF; 262 | background-color:#FC6; 263 | } 264 | 265 | .collection-meta { 266 | line-height:25px; 267 | } 268 | 269 | ul.collections{ 270 | margin:10px; 271 | } 272 | #entries-list { 273 | overflow:auto; 274 | height:100%; 275 | } 276 | li.collection, li.entry { 277 | -webkit-border-radius:10px; 278 | background-color: #666; 279 | padding:10px; 280 | margin:10px 0; 281 | -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.8); 282 | clear:both; 283 | } 284 | li.entry { 285 | margin:10px; 286 | color:#ccc; 287 | } 288 | li.collection .name { 289 | font-size:14px; 290 | font-weight:bold; 291 | color:#EFEFEF; 292 | text-shadow: 1px 1px 1px #000; 293 | margin-bottom:5px; 294 | } 295 | li.entry table { 296 | width:100%; 297 | } 298 | li.entry tr { 299 | border-bottom: 1px #CCC solid; 300 | } 301 | li.entry td { 302 | padding:5px 0; 303 | } 304 | li.entry .key{ 305 | font-size:12px; 306 | font-weight:bold; 307 | color:#EFEFEF; 308 | text-shadow: 1px 1px 1px #000; 309 | overflow:hidden; 310 | width:100px; 311 | } 312 | li.entry .value{ 313 | font-size:12px; 314 | color:#CCC; 315 | } 316 | body.AddConnectionDialog { 317 | background-color:white; 318 | overflow:hidden; 319 | } 320 | 321 | body.AddConnectionDialog form { 322 | margin:10px; 323 | } 324 | 325 | body.AddConnectionDialog fieldset { 326 | border-top:1px solid #ccc; 327 | border-left:0; 328 | border-bottom:0; 329 | border-right:0; 330 | padding:6px; 331 | margin:0; 332 | } 333 | body.AddConnectionDialog legend { 334 | text-align:left; 335 | color:#ccc; 336 | padding:0px 4px 0px 4px; 337 | margin-left:20px; 338 | } 339 | body.AddConnectionDialog label { 340 | color: #999; 341 | font-weight: bold; 342 | width: 50px; 343 | text-align: right; 344 | display:block; 345 | float:left; 346 | margin:4px 4px 0px 0px; 347 | } 348 | body.AddConnectionDialog input { 349 | float: left; 350 | width: 150px; 351 | margin:2px 0px 2px 2px; 352 | border:1px solid #cccccc; 353 | color:#00abdf; 354 | -webkit-box-shadow: 0 -1px 1px rgba(0,0,0,0.5); 355 | -webkit-border-radius: 5px; 356 | padding:3px; 357 | height:24px; 358 | } 359 | body.AddConnectionDialog input.Port { 360 | width:50px; 361 | } 362 | body.AddConnectionDialog input.Short { 363 | width:100px; 364 | } 365 | 366 | body.AddConnectionDialog p { 367 | margin:20px 10px; 368 | } 369 | 370 | button{ 371 | display: inline-block; 372 | padding: 5px 10px 6px; 373 | color: #fff; 374 | text-decoration: none; 375 | font-weight: bold; 376 | line-height: 1; 377 | -webkit-border-radius: 5px; 378 | -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.5); 379 | text-shadow: 0 -1px 1px rgba(0,0,0,0.25); 380 | border:0; 381 | border-bottom: 1px solid rgba(0,0,0,0.25); 382 | position: relative; 383 | cursor: pointer; 384 | background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(255, 255, 255, 0.5)), to(rgba(255, 255, 255, 0.2))); 385 | } 386 | button.blue { 387 | background-color: #0080FF; 388 | } 389 | 390 | button.red { 391 | background-color: #e33100; 392 | } 393 | 394 | button.magenta { 395 | background-color: #a9014b; 396 | } 397 | 398 | button.orange { 399 | background-color: #ff5c00; 400 | } 401 | 402 | button.yellow { 403 | background-color: #ffb515; 404 | } 405 | 406 | button.green { 407 | background-color: green; 408 | } -------------------------------------------------------------------------------- /Resources/liberary/img/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/arrow_left.png -------------------------------------------------------------------------------- /Resources/liberary/img/arrow_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/arrow_right.png -------------------------------------------------------------------------------- /Resources/liberary/img/box_upload_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/box_upload_48.png -------------------------------------------------------------------------------- /Resources/liberary/img/caut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/caut.png -------------------------------------------------------------------------------- /Resources/liberary/img/db.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/db.png -------------------------------------------------------------------------------- /Resources/liberary/img/dbplus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/dbplus.png -------------------------------------------------------------------------------- /Resources/liberary/img/help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/help.png -------------------------------------------------------------------------------- /Resources/liberary/img/preference.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/preference.png -------------------------------------------------------------------------------- /Resources/liberary/img/refresh_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/refresh_48.png -------------------------------------------------------------------------------- /Resources/liberary/img/search_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/search_48.png -------------------------------------------------------------------------------- /Resources/liberary/img/spanner_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/spanner_48.png -------------------------------------------------------------------------------- /Resources/liberary/img/sqldb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/sqldb.png -------------------------------------------------------------------------------- /Resources/liberary/img/sqldb_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/sqldb_16.png -------------------------------------------------------------------------------- /Resources/liberary/img/table_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bububa/MongoHub/7f761c424741d88bb234426b74b4092c40fb4987/Resources/liberary/img/table_48.png -------------------------------------------------------------------------------- /Resources/liberary/js/base_window.js: -------------------------------------------------------------------------------- 1 | function connection_info(name, connections) 2 | { 3 | for(var i=0; i'; 47 | }); 48 | html += ''; 49 | $('main-innerlist').update(html); 50 | $$('.collection').each(function(e){ 51 | var cname = e.getElementsByClassName('name')[0].innerHTML; 52 | e.getElementsByClassName('browse')[0].observe('click', function(){ 53 | showBrowseCollection(connection, dbname, cname); 54 | }); 55 | e.getElementsByClassName('drop')[0].observe('click', function(){ 56 | showDropCollection(connection, dbname, cname); 57 | }); 58 | }); 59 | $('menubar').show(); 60 | } 61 | } 62 | function updateConnections() 63 | { 64 | var connections = loadConnection(); 65 | if (connections && connections.size()>0) 66 | { 67 | var html = ''; 72 | }else{ 73 | $('sidebar').update(''); 74 | return; 75 | } 76 | $('sidebar').update(html); 77 | $$('#sidebar ul.connections')[0].observe('click', function(e){ 78 | var dom = e.findElement('li.db'); 79 | if (dom) 80 | { 81 | cons = $$('#sidebar li.connection.selected'); 82 | if (!cons || cons.size() == 0) return; 83 | var connection = connection_info(cons[0].innerHTML, connections); 84 | if (!connection) 85 | { 86 | alert('Unexpected error!'); 87 | return false; 88 | } 89 | dom.addClassName('selected'); 90 | $('database_name').update(dom.innerHTML); 91 | updateCollections(connection, dom.innerHTML); 92 | return; 93 | } 94 | $$('#sidebar li.connection').each(function(l){l.removeClassName('selected');}); 95 | $$('#sidebar li.dbs').each(function(l){l.remove();}); 96 | var clickedRow; 97 | clickedRow = e.findElement('li.connection'); 98 | if (clickedRow) { 99 | clickedRow.addClassName('selected'); 100 | var connection = connection_info(clickedRow.innerHTML, connections); 101 | if (!connection) 102 | { 103 | alert('Unexpected error!'); 104 | return false; 105 | } 106 | $('connection_name').update(clickedRow.innerHTML); 107 | var dbs = mongo.show_dbs(connection.host, connection.port); 108 | if (dbs == -1) 109 | { 110 | alert('Failed to connect ' + connection.name); 111 | return false; 112 | }else{ 113 | var html = '
  • '; 118 | clickedRow.insert({after:html}); 119 | } 120 | $$('#sidebar li.dbs')[0].observe('click', function(e){ 121 | $$('#sidebar li.db').each(function(l){l.removeClassName('selected');}); 122 | var clickedRow2; 123 | clickedRow2 = e.findElement('li.db'); 124 | if (clickedRow2) { 125 | clickedRow2.addClassName('selected'); 126 | updateCollections(connection, clickedRow2.innerHTML); 127 | } 128 | }); 129 | } 130 | }); 131 | } 132 | 133 | function showAddConnection() 134 | { 135 | var win = Titanium.UI.getCurrentWindow(); 136 | var win2 = win.createWindow('app://windows/add_connection.html'); 137 | win2.addEventListener(Titanium.CLOSED, updateConnections); 138 | win2.setHeight(160); 139 | win2.setWidth(390); 140 | win2.setTransparency(0.8); 141 | win2.setTitle('New Connection'); 142 | win2.setMaximizable(false); 143 | //win2.setResizable(false); 144 | win2.open(); 145 | } 146 | 147 | function showEditConnection() 148 | { 149 | dom = $$('#sidebar li.connection.selected'); 150 | if (!dom || dom.size()==0) 151 | { 152 | alert('Please select a connection you want to edit!'); 153 | return false; 154 | } 155 | var win = Titanium.UI.getCurrentWindow(); 156 | var win2 = win.createWindow('app://windows/edit_connection.html'); 157 | win2.addEventListener(Titanium.CLOSED, updateConnections); 158 | win2.setHeight(160); 159 | win2.setWidth(390); 160 | win2.setTransparency(0.8); 161 | win2.setTitle('Edit Connection | ' + dom[0].innerHTML); 162 | win2.setMaximizable(false); 163 | //win2.setResizable(false); 164 | win2.open(); 165 | } 166 | 167 | function showRemoveConnection() 168 | { 169 | dom = $$('#sidebar li.connection.selected'); 170 | if (!dom || dom.size()==0) 171 | { 172 | alert('Please select a connection you want to remove!'); 173 | return false; 174 | } 175 | if (confirm('Do you want to delete this connection?')) 176 | { 177 | removeConnection(dom[0].innerHTML.strip()); 178 | updateConnections(); 179 | return; 180 | } 181 | } 182 | 183 | function showDropDB() 184 | { 185 | if ($('connection_name').innerHTML==''|| $('database_name').innerHTML=='') 186 | { 187 | alert('Please select a database you want to remove!'); 188 | return false; 189 | } 190 | if (confirm('Do you want to drop this database?')) 191 | { 192 | dropDB($('connection_name').innerHTML.strip(), $('database_name').innerHTML.strip()); 193 | updateConnections(); 194 | return; 195 | } 196 | } 197 | 198 | function showQuery(query) 199 | { 200 | if ($('connection_name').innerHTML==''|| $('database_name').innerHTML=='') 201 | { 202 | alert('Please select a database you want to query!'); 203 | return false; 204 | } 205 | var win = Titanium.UI.getCurrentWindow(); 206 | var win2 = win.createWindow('app://windows/query.html'); 207 | //win2.addEventListener(Titanium.CLOSED, function(){updateConnections();updateCollections();}); 208 | win2.setHeight(500); 209 | win2.setWidth(600); 210 | win2.setTitle('Query | ' + $('connection_name').innerHTML + ' | ' + $('database_name').innerHTML + ' | ' + query); 211 | //win2.setMaximizable(false); 212 | //win2.setResizable(false); 213 | win2.open(); 214 | } 215 | 216 | function createMenu() 217 | { 218 | var menu = Titanium.UI.createMenu(); 219 | var connection = Titanium.UI.createMenuItem("Connection"); 220 | connection.addItem("New Connection", function() { 221 | showAddConnection(); 222 | }); 223 | connection.addItem("Remove Connection", function() { 224 | showRemoveConnection(); 225 | }); 226 | connection.addItem("Edit Connection", function(){ 227 | showEditConnection(); 228 | }); 229 | menu.appendItem(connection); 230 | var database = Titanium.UI.createMenuItem("Database"); 231 | database.addItem("New Database", function() { 232 | showAddConnection(); 233 | }); 234 | database.addItem("Drop Database", function() { 235 | showDropDB(); 236 | }); 237 | menu.appendItem(database); 238 | Titanium.UI.setMenu(menu); 239 | } 240 | 241 | function createDb() 242 | { 243 | updateConnections(); 244 | } 245 | 246 | function navigatorClickHandler(elm) 247 | { 248 | if (elm.title == 'Connection') 249 | { 250 | showAddConnection(); 251 | }else if (elm.title == 'Query') { 252 | showInputQuery(); 253 | } 254 | } 255 | 256 | function menubarClickHandler(elm) 257 | { 258 | if (elm.title=="Create Database") 259 | { 260 | createDb(); 261 | } 262 | } 263 | function navigatorInit() 264 | { 265 | /*$$('.NavigationBar a.Item').each ( 266 | function(e) 267 | { 268 | e.observe('click', function(){navigatorClickHandler(e);}); 269 | } 270 | ); 271 | $$('#menubar a').each ( 272 | function(e) 273 | { 274 | e.observe('click', function(){menubarClickHandler(e);}); 275 | } 276 | );*/ 277 | $('runquerybtn').observe('click', function(){ 278 | showQuery($F('query')); 279 | }); 280 | updateConnections(); 281 | } 282 | 283 | function updater() 284 | { 285 | Titanium.UpdateManager.onupdate = function(details) { 286 | if (confirm('A new version: ' + details.version + ' is available. Would you like to install it?')) { 287 | // this function installs the new updated version of my app 288 | Titanium.UpdateManager.installAppUpdate(details, function() { 289 | alert('The new version has been installed'); 290 | }); 291 | } 292 | }; 293 | } -------------------------------------------------------------------------------- /Resources/liberary/js/connection.js: -------------------------------------------------------------------------------- 1 | function addConnection(name, host, port) 2 | { 3 | name = name.strip(); 4 | host = host.strip(); 5 | port = port.strip(); 6 | if (name.empty()) 7 | { 8 | $('err').update("* Please input a name for this connection."); 9 | return false; 10 | }else if (host.empty()) { 11 | $('err').update("* Please input the host address."); 12 | return false; 13 | }else if (port.empty()) { 14 | $('err').update("* Please input the port."); 15 | return false; 16 | } 17 | var db = Titanium.Database.open('mongohub'); 18 | db.execute("CREATE TABLE IF NOT EXISTS connections (name TEXT, host TEXT, port INT)"); 19 | var rows = db.execute("SELECT * FROM connections"); 20 | if (rows) 21 | { 22 | for(var i=0; i < rows.rowCount(); i++) 23 | { 24 | if (rows.fieldByName('name') == name) 25 | { 26 | $('err').update("* Connection name already existed, please choose another one."); 27 | db.close(); 28 | return false; 29 | } 30 | rows.next(); 31 | } 32 | } 33 | db.execute("insert into connections (name, host, port) values ('" + name + "','" + host + "'," + port + ")"); 34 | db.close(); 35 | Titanium.UI.getCurrentWindow().close(); 36 | } 37 | 38 | function editConnection(name, host, port, old_name) 39 | { 40 | name = name.strip(); 41 | host = host.strip(); 42 | port = port.strip(); 43 | old_name = old_name.strip(); 44 | if (name.empty()) 45 | { 46 | $('err').update("* Please input a name for this connection."); 47 | return false; 48 | }else if (host.empty()) { 49 | $('err').update("* Please input the host address."); 50 | return false; 51 | }else if (port.empty()) { 52 | $('err').update("* Please input the port."); 53 | return false; 54 | } 55 | var db = Titanium.Database.open('mongohub'); 56 | db.execute("CREATE TABLE IF NOT EXISTS connections (name TEXT, host TEXT, port INT)"); 57 | var rows = db.execute("SELECT * FROM connections"); 58 | if (rows) 59 | { 60 | var counter = 0; 61 | for(var i=0; i < rows.rowCount(); i++) 62 | { 63 | if (rows.fieldByName('name') == name) 64 | { 65 | counter ++; 66 | if (counter > 0) 67 | { 68 | $('err').update("* Connection name already existed, please choose another one."); 69 | db.close(); 70 | return false; 71 | } 72 | } 73 | rows.next(); 74 | } 75 | } 76 | db.execute("UPDATE connections SET name='" + name + "', host='" + host + "', port=" + port + " WHERE name='" + old_name + "'"); 77 | db.close(); 78 | Titanium.UI.getCurrentWindow().close(); 79 | } 80 | 81 | function removeConnection(name) 82 | { 83 | name = name.strip(); 84 | var db = Titanium.Database.open('mongohub'); 85 | db.execute("CREATE TABLE IF NOT EXISTS connections (name TEXT, host TEXT, port INT)"); 86 | db.execute("DELETE FROM connections WHERE name='" + name + "'"); 87 | db.close(); 88 | } 89 | 90 | function loadConnection() 91 | { 92 | var db = Titanium.Database.open('mongohub'); 93 | try 94 | { 95 | var rows = db.execute("SELECT * FROM connections"); 96 | }catch(e){ 97 | var rows = null; 98 | }finally{ 99 | db.close(); 100 | } 101 | var connections = new Array(); 102 | if (!rows) return connections; 103 | for(var i=0; i < rows.rowCount(); i++) 104 | { 105 | connections.push({name: rows.fieldByName('name'), host: rows.fieldByName('host'), port: rows.fieldByName('port')}); 106 | rows.next(); 107 | } 108 | return connections; 109 | } 110 | 111 | function dropDB(cname, dbname) 112 | { 113 | cname = cname.strip(); 114 | dbname = dbname.strip(); 115 | var connections = loadConnection(); 116 | var connection = connection_info(cname, connections); 117 | if (!connection) 118 | { 119 | alert('Unexpected error!'); 120 | return false; 121 | } 122 | mongo.drop_database(connection.host, connection.port, dbname); 123 | } 124 | 125 | function browseCollection(connection_name, db_name, collection_name, page, step) 126 | { 127 | connection_name = connection_name.strip(); 128 | db_name = db_name.strip(); 129 | collection_name = collection_name.strip(); 130 | var connections = loadConnection(); 131 | var connection = connection_info(connection_name, connections); 132 | if (!connection) 133 | { 134 | alert('Unexpected error!'); 135 | return false; 136 | } 137 | var entries = mongo.browse_collection(connection.host, connection.port, db_name, collection_name, page, step); 138 | if (entries == -1) 139 | { 140 | alert('Unexpected error!'); 141 | return false; 142 | } 143 | $('total').update(entries['count']); 144 | var html = ''; 153 | $('entries-list').update(html); 154 | } 155 | 156 | function dropCollection(connection_name, db_name, collection_name) 157 | { 158 | connection_name = connection_name.strip(); 159 | db_name = db_name.strip(); 160 | collection_name = collection_name.strip(); 161 | var connections = loadConnection(); 162 | var connection = connection_info(connection_name, connections); 163 | if (!connection) 164 | { 165 | alert('Unexpected error!'); 166 | return false; 167 | } 168 | mongo.drop_collection(connection.host, connection.port, db_name, collection_name); 169 | } 170 | 171 | function runQuery(connection_name, dbname, query) 172 | { 173 | connection_name = connection_name.strip(); 174 | dbname = dbname.strip(); 175 | query = query.strip(); 176 | var connections = loadConnection(); 177 | var connection = connection_info(connection_name, connections); 178 | if (!connection) 179 | { 180 | alert('Unexpected error!'); 181 | Titanium.UI.getCurrentWindow().close(); 182 | } 183 | var entries = mongo.query(connection.host, connection.port, dbname, query); 184 | if (entries == -1) 185 | { 186 | alert('Unexpected error!'); 187 | Titanium.UI.getCurrentWindow().close(); 188 | }else if (entries == -2) 189 | { 190 | alert('Invalid Query!'); 191 | Titanium.UI.getCurrentWindow().close(); 192 | } 193 | if (Object.isString(entries)) 194 | { 195 | var html = ''; 196 | }else{ 197 | $('total').update(entries['count']); 198 | var html = ''; 207 | $('collection-meta').show(); 208 | } 209 | $('entries-list').update(html); 210 | } -------------------------------------------------------------------------------- /Resources/liberary/js/main.js: -------------------------------------------------------------------------------- 1 | var Chrome = Class.create(); 2 | Chrome.prototype = { 3 | initialize: function () 4 | { 5 | this.pid = 0; 6 | this.current_window = Titanium.UI.getCurrentWindow(); 7 | var self = this; 8 | self.update(); 9 | window.onresize = function (e) { 10 | self.update(e.target); 11 | } 12 | }, 13 | 14 | update: function(win) 15 | { 16 | var self = this; 17 | //document.body.setStyle({height:(this.current_window.getHeight() -50)+ 'px'}); 18 | $('main-content').setStyle({width: (document.viewport.getWidth() - $('sidebar').getWidth() - 1) + 'px'}); 19 | $('main-innerlist').setStyle({height: ($('main-content').getHeight() - 25) + 'px'}); 20 | } 21 | }; -------------------------------------------------------------------------------- /Resources/liberary/js/scriptaculous-1.8.2.js: -------------------------------------------------------------------------------- 1 | // script.aculo.us scriptaculous.js v1.8.2, Tue Nov 18 18:30:58 +0100 2008 2 | 3 | // Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining 6 | // a copy of this software and associated documentation files (the 7 | // "Software"), to deal in the Software without restriction, including 8 | // without limitation the rights to use, copy, modify, merge, publish, 9 | // distribute, sublicense, and/or sell copies of the Software, and to 10 | // permit persons to whom the Software is furnished to do so, subject to 11 | // the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be 14 | // included in all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | // 24 | // For details, see the script.aculo.us web site: http://script.aculo.us/ 25 | 26 | var Scriptaculous = { 27 | Version: '1.8.2', 28 | require: function(libraryName) { 29 | // inserting via DOM fails in Safari 2.0, so brute force approach 30 | document.write(' 5 | 6 | 7 | 18 | 19 | 20 |
    21 | Connection Name 22 | 23 |
    24 |
    25 | Connection Setting 26 | 27 | 28 |
    29 |
    30 |
    31 | 32 | 33 |
    34 | 35 | -------------------------------------------------------------------------------- /Resources/windows/browse_collection.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 45 | 46 | 47 |
    48 | 49 | 50 | 51 | Results/Page: 52 | Total: 0 53 | | Connected to: 54 | 55 | 56 | 57 |
    58 |
    59 | 60 | -------------------------------------------------------------------------------- /Resources/windows/edit_connection.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 21 | 22 | 23 |
    24 | Connection Name 25 | 26 |
    27 |
    28 | Connection Setting 29 | 30 | 31 |
    32 |
    33 |
    34 | 35 | 36 |
    37 | 38 | -------------------------------------------------------------------------------- /Resources/windows/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 21 | 22 | 23 | 38 |
    39 | 40 |
    41 | 50 |
    51 |
    52 |
    53 |
    54 | 55 | -------------------------------------------------------------------------------- /Resources/windows/query.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 13 | 30 | 31 | 32 | 39 |
    40 | 41 | -------------------------------------------------------------------------------- /manifest: -------------------------------------------------------------------------------- 1 | #appname:MongoHub 2 | #appid:com.thepeppersstudio.mongohub 3 | #publisher:prof.syd.xu@gmail.com 4 | #image:logo.png 5 | #url:http://syd.todayclose.com 6 | #guid:2108f4c2-e436-4fe1-a928-3ebd6d52ac62 7 | #desc:Mongodb GUI Tool 8 | #type:desktop 9 | runtime:0.7.0 10 | api:0.7.0 11 | tiapp:0.7.0 12 | tifilesystem:0.7.0 13 | tiplatform:0.7.0 14 | tiui:0.7.0 15 | javascript:0.7.0 16 | tianalytics:0.7.0 17 | python:0.7.0 18 | ticodec:0.7.0 19 | tidatabase:0.7.0 20 | tidesktop:0.7.0 21 | tigrowl:0.7.0 22 | timedia:0.7.0 23 | timonkey:0.7.0 24 | tinetwork:0.7.0 25 | tinotification:0.7.0 26 | tiprocess:0.7.0 27 | tiworker:0.7.0 28 | -------------------------------------------------------------------------------- /tiapp.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | com.thepeppersstudio.mongohub 5 | MongoHub 6 | 0.1.0 7 | prof.syd.xu@gmail.com 8 | http://syd.todayclose.com 9 | logo.png 10 | 2009 by syd 11 | 12 | 13 | initial 14 | MongoHub 15 | app://windows/index.html 16 | 800 17 | 3000 18 | 0 19 | 500 20 | 3000 21 | 0 22 | false 23 | true 24 | true 25 | true 26 | true 27 | true 28 | 29 | 30 | -------------------------------------------------------------------------------- /timanifest: -------------------------------------------------------------------------------- 1 | {"appname": "MongoHub", "appid": "com.thepeppersstudio.mongohub", "appversion": "0.1.0", "mid": "v2:b5e5b1d7-d1fd-4978-81f5-85b7ca7e8904|5c955ed066545a4713e76ba53e8c88d8", "publisher": "prof.syd.xu@gmail.com", "url": "http://syd.todayclose.com", "desc": "Mongodb GUI Tool", "release": true, "image": "logo.png", "platforms": ["osx", "win32", "linux"], "visibility": "private", "runtime": {"version": "0.7.0", "package": "network"}, "guid": "2108f4c2-e436-4fe1-a928-3ebd6d52ac62", "modules": [{"name": "api", "version": "0.7.0", "package": "network"}, {"name": "tiapp", "version": "0.7.0", "package": "network"}, {"name": "tifilesystem", "version": "0.7.0", "package": "network"}, {"name": "tiplatform", "version": "0.7.0", "package": "network"}, {"name": "tiui", "version": "0.7.0", "package": "network"}, {"name": "javascript", "version": "0.7.0", "package": "network"}, {"name": "tianalytics", "version": "0.7.0", "package": "network"}, {"name": "python", "version": "0.7.0", "package": "network"}, {"name": "ticodec", "version": "0.7.0", "package": "network"}, {"name": "tidatabase", "version": "0.7.0", "package": "network"}, {"name": "tidesktop", "version": "0.7.0", "package": "network"}, {"name": "tigrowl", "version": "0.7.0", "package": "network"}, {"name": "timedia", "version": "0.7.0", "package": "network"}, {"name": "timonkey", "version": "0.7.0", "package": "network"}, {"name": "tinetwork", "version": "0.7.0", "package": "network"}, {"name": "tinotification", "version": "0.7.0", "package": "network"}, {"name": "tiprocess", "version": "0.7.0", "package": "network"}, {"name": "tiworker", "version": "0.7.0", "package": "network"}]} --------------------------------------------------------------------------------