mongo_browser 0.2.0.rc2 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.rspec +1 -1
- data/.travis.yml +6 -1
- data/CHANGELOG.md +15 -0
- data/{grunt.js → Gruntfile.js} +10 -8
- data/Procfile +1 -0
- data/README.md +44 -2
- data/Rakefile +1 -12
- data/app/assets/images/ajax-loader.gif +0 -0
- data/app/assets/javascripts/app/controllers/{breadcrumbs.js.coffee → breadcrumbs_controller.js.coffee} +4 -7
- data/app/assets/javascripts/app/controllers/collections/index_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/collections/stats_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/controllers/{databases.js.coffee → databases/index_controller.js.coffee} +11 -15
- data/app/assets/javascripts/app/controllers/databases/stats_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/documents/index_controller.js.coffee +54 -0
- data/app/assets/javascripts/app/controllers/documents/show_controller.js.coffee +38 -0
- data/app/assets/javascripts/app/controllers/main_controller.js.coffee +15 -0
- data/app/assets/javascripts/app/controllers/servers/show_controller.js.coffee +17 -0
- data/app/assets/javascripts/app/directives.js.coffee +23 -0
- data/app/assets/javascripts/app/filters.js.coffee +14 -1
- data/app/assets/javascripts/app/modules/alerts.js.coffee +58 -0
- data/app/assets/javascripts/app/modules/pager.js.coffee +2 -2
- data/app/assets/javascripts/app/modules/spinner.js.coffee +29 -0
- data/app/assets/javascripts/app/modules/table_filter.js.coffee +4 -4
- data/app/assets/javascripts/app/resources.js.coffee +14 -8
- data/app/assets/javascripts/app/services.js.coffee +11 -33
- data/app/assets/javascripts/application.js.coffee +62 -34
- data/app/assets/javascripts/application.test.js.coffee +5 -0
- data/app/assets/javascripts/compiled_templates.js.coffee +1 -0
- data/app/assets/javascripts/vendor.js.coffee +0 -1
- data/app/assets/stylesheets/application.css.scss +36 -18
- data/{public/index.html → app/views/index.erb} +8 -8
- data/bin/mongo_browser +2 -13
- data/config.ru +3 -1
- data/lib/mongo_browser.rb +1 -0
- data/lib/mongo_browser/api.rb +11 -0
- data/lib/mongo_browser/api/collections.rb +34 -0
- data/lib/mongo_browser/api/databases.rb +32 -0
- data/lib/mongo_browser/api/documents.rb +37 -0
- data/lib/mongo_browser/api/mongo.rb +41 -0
- data/lib/mongo_browser/application.rb +8 -174
- data/lib/mongo_browser/application/development.rb +32 -0
- data/lib/mongo_browser/cli.rb +48 -0
- data/lib/mongo_browser/entities.rb +43 -0
- data/lib/mongo_browser/models/collection.rb +7 -12
- data/lib/mongo_browser/models/document.rb +5 -1
- data/lib/mongo_browser/models/pager.rb +22 -9
- data/lib/mongo_browser/version.rb +1 -1
- data/mongo_browser.gemspec +22 -15
- data/package.json +30 -0
- data/public/ng/templates/alerts.html +6 -0
- data/public/ng/templates/collections/index.html +39 -0
- data/public/ng/templates/collections/stats.html +18 -0
- data/public/ng/templates/databases/index.html +35 -0
- data/public/ng/templates/databases/stats.html +18 -0
- data/public/ng/templates/documents/index.html +40 -0
- data/public/ng/templates/documents/show.html +17 -0
- data/{app/assets → public/ng}/templates/pager.html +0 -0
- data/{app/assets/templates/server_info.html → public/ng/templates/server/show.html} +1 -1
- data/{app/assets → public/ng}/templates/table_filter.html +0 -0
- data/script/ci_all +5 -1
- data/script/ci_e2e +5 -2
- data/script/ci_javascripts +1 -1
- data/script/ci_rspec +1 -1
- data/spec/javascripts/app/controllers/{breadcrumbs_spec.js.coffee → breadcrumbs_controller_spec.js.coffee} +1 -1
- data/spec/javascripts/app/controllers/collections/index_controller_spec.js.coffee +95 -0
- data/spec/javascripts/app/controllers/collections/stats_controller_spec.js.coffee +34 -0
- data/spec/javascripts/app/controllers/databases/index_controller_spec.js.coffee +93 -0
- data/spec/javascripts/app/controllers/databases/stats_controller_spec.js.coffee +30 -0
- data/spec/javascripts/app/controllers/documents/index_controller_spec.js.coffee +108 -0
- data/spec/javascripts/app/controllers/documents/show_controller_spec.js.coffee +94 -0
- data/spec/javascripts/app/controllers/{main_spec.js.coffee → main_controller_spec.js.coffee} +2 -2
- data/spec/javascripts/app/controllers/{server_info_spec.js.coffee → server/show_controller_spec.js.coffee} +5 -6
- data/spec/javascripts/app/directives_spec.js.coffee +108 -24
- data/spec/javascripts/app/filters_spec.js.coffee +31 -5
- data/spec/javascripts/app/modules/alerts_spec.js.coffee +138 -0
- data/spec/javascripts/app/modules/dialogs_spec.js.coffee +1 -2
- data/spec/javascripts/app/modules/pager_spec.js.coffee +0 -1
- data/spec/javascripts/app/modules/spinner_spec.js.coffee +65 -0
- data/spec/javascripts/app/modules/table_filter_spec.js.coffee +9 -9
- data/spec/javascripts/app/resources_spec.js.coffee +99 -0
- data/spec/javascripts/app/services_spec.js.coffee +31 -71
- data/spec/javascripts/config/{testacular-e2e.conf.js → karma-e2e.conf.js} +1 -1
- data/spec/javascripts/config/{testacular.conf.js → karma.conf.js} +2 -3
- data/spec/javascripts/e2e/collection_stats_scenario.js.coffee +12 -0
- data/spec/javascripts/e2e/collections_scenario.js.coffee +59 -20
- data/spec/javascripts/e2e/database_stats_scenario.js.coffee +11 -0
- data/spec/javascripts/e2e/databases_scenario.js.coffee +37 -36
- data/spec/javascripts/e2e/document_show_scenario.js.coffee +31 -0
- data/spec/javascripts/e2e/documents_pagination_scenario.js.coffee +33 -0
- data/spec/javascripts/e2e/documents_scenario.js.coffee +43 -4
- data/spec/javascripts/e2e/server_info_scenario.js.coffee +8 -2
- data/spec/javascripts/helpers/mocks.js.coffee +2 -0
- data/spec/javascripts/helpers_e2e/dsl.js.coffee +20 -0
- data/spec/javascripts/lib/angular-mocks.js +64 -16
- data/spec/javascripts/lib/angular-scenario.js +724 -561
- data/spec/javascripts/runner.html +5 -5
- data/spec/lib/api/collections_spec.rb +62 -0
- data/spec/lib/api/databases_spec.rb +58 -0
- data/spec/lib/api/documents_spec.rb +135 -0
- data/spec/lib/api/mongo_spec.rb +27 -0
- data/spec/lib/cli_spec.rb +19 -0
- data/spec/lib/entities_spec.rb +39 -0
- data/spec/lib/models/collection_spec.rb +16 -10
- data/spec/lib/models/database_spec.rb +4 -4
- data/spec/lib/models/document_spec.rb +5 -5
- data/spec/lib/models/pager_spec.rb +20 -11
- data/spec/spec_helper.rb +7 -15
- data/spec/support/api_example_group.rb +45 -0
- data/spec/support/fixtures.rb +10 -6
- data/spec/support/matchers/expose.rb +18 -0
- data/vendor/assets/javascripts/angular/angular-bootstrap.js +1 -1
- data/vendor/assets/javascripts/angular/angular-resource.js +78 -56
- data/vendor/assets/javascripts/angular/angular-sanitize.js +3 -1
- data/vendor/assets/javascripts/angular/angular.js +720 -404
- metadata +323 -183
- data/app/assets/javascripts/app.js.coffee +0 -8
- data/app/assets/javascripts/app/controllers.js.coffee +0 -2
- data/app/assets/javascripts/app/controllers/alerts.js.coffee +0 -12
- data/app/assets/javascripts/app/controllers/collections.js.coffee +0 -40
- data/app/assets/javascripts/app/controllers/documents.js.coffee +0 -49
- data/app/assets/javascripts/app/controllers/main.js.coffee +0 -10
- data/app/assets/javascripts/app/controllers/server_info.js.coffee +0 -14
- data/app/assets/javascripts/templates.js.coffee +0 -1
- data/app/assets/javascripts/templates/.gitkeep +0 -0
- data/app/assets/templates/collections.html +0 -53
- data/app/assets/templates/databases.html +0 -32
- data/app/assets/templates/documents.html +0 -45
- data/config-e2e.ru +0 -20
- data/spec/features/collections_list_spec.rb +0 -64
- data/spec/features/documents_list_spec.rb +0 -139
- data/spec/features/server_info_spec.rb +0 -23
- data/spec/javascripts/app/controllers/alerts_spec.js.coffee +0 -36
- data/spec/javascripts/app/controllers/collections_spec.js.coffee +0 -78
- data/spec/javascripts/app/controllers/databases_spec.js.coffee +0 -55
- data/spec/javascripts/app/controllers/documents_spec.js.coffee +0 -62
- data/spec/javascripts/helpers_e2e/app_element.js.coffee +0 -6
- data/spec/support/feature_example_group.rb +0 -53
- data/spec/support/matchers/have_flash_message.rb +0 -16
- data/spec/support/mongod.rb +0 -91
- data/spec/support/mongodb.conf +0 -47
data/.gitignore
CHANGED
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
--colour
|
2
|
-
--format
|
2
|
+
--format progress
|
data/.travis.yml
CHANGED
@@ -2,9 +2,14 @@ language: ruby
|
|
2
2
|
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
|
+
- 2.0.0
|
6
|
+
|
7
|
+
services:
|
8
|
+
- mongodb
|
5
9
|
|
6
10
|
before_script:
|
7
|
-
- "npm install -g grunt
|
11
|
+
- "npm install -g grunt-cli karma"
|
12
|
+
- "npm install grunt"
|
8
13
|
- "export DISPLAY=:99.0"
|
9
14
|
- "sh -e /etc/init.d/xvfb start"
|
10
15
|
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# mongo_browser changelog
|
2
|
+
|
3
|
+
## 0.2.5 (07/15/2013)
|
4
|
+
|
5
|
+
* feature: refreshing the document page #99
|
6
|
+
* feature: better CLI runner #103
|
7
|
+
* add `execjs` and `therubyracer` into `Gemfile`
|
8
|
+
* add missing license information #105
|
9
|
+
|
10
|
+
## 0.2.1 (01/15/2013)
|
11
|
+
|
12
|
+
* feature: redirect and set alert message whe a document has not been found
|
13
|
+
* feature: display global spinner for http requests
|
14
|
+
* cleanup coffeescript code for controllers
|
15
|
+
* many other minor bugfixea and improvements
|
data/{grunt.js → Gruntfile.js}
RENAMED
@@ -3,13 +3,13 @@ module.exports = function(grunt) {
|
|
3
3
|
grunt.initConfig({
|
4
4
|
watch: {
|
5
5
|
templates: {
|
6
|
-
files:
|
7
|
-
tasks:
|
6
|
+
files: "public/ng/templates/**/*.html",
|
7
|
+
tasks: "html2js:directives"
|
8
8
|
}
|
9
9
|
},
|
10
10
|
|
11
11
|
html2js: {
|
12
|
-
directives: [
|
12
|
+
directives: ["public/ng/templates/**/*.html"]
|
13
13
|
}
|
14
14
|
});
|
15
15
|
|
@@ -19,18 +19,20 @@ module.exports = function(grunt) {
|
|
19
19
|
return content.replace(/"/g, '\\"').replace(/\n/g, '" +\n "');
|
20
20
|
};
|
21
21
|
|
22
|
-
grunt.registerMultiTask(
|
22
|
+
grunt.registerMultiTask("html2js", "Generate js version of html template.", function() {
|
23
23
|
var files = grunt._watch_changed_files || grunt.file.expand(this.data);
|
24
24
|
|
25
25
|
files.forEach(function(file) {
|
26
|
-
var parts = file.split("/");
|
27
|
-
var name = parts
|
26
|
+
var parts = file.split("/").slice(3);
|
27
|
+
var name = parts.join("/");
|
28
28
|
|
29
|
-
|
29
|
+
var data = {
|
30
30
|
file: file,
|
31
31
|
path: "/ng/templates/" + file.split("/").pop(),
|
32
32
|
content: escapeContent(grunt.file.read(file))
|
33
|
-
}
|
33
|
+
};
|
34
|
+
var content = grunt.template.process(TPL, { data: data });
|
35
|
+
grunt.file.write("app/assets/javascripts/compiled_templates/" + name + ".js", content);
|
34
36
|
});
|
35
37
|
});
|
36
38
|
};
|
data/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
thin: bundle exec thin start -R config.ru -e development -p 4000
|
data/README.md
CHANGED
@@ -1,24 +1,64 @@
|
|
1
1
|
# MongoBrowser
|
2
2
|
|
3
3
|
[![Build status](https://secure.travis-ci.org/lucassus/mongo_browser.png)](http://travis-ci.org/lucassus/mongo_browser)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/lucassus/mongo_browser/badge.png?branch=master)](https://coveralls.io/r/lucassus/mongo_browser)
|
4
5
|
[![Dependency Status](https://gemnasium.com/lucassus/mongo_browser.png)](http://gemnasium.com/lucassus/mongo_browser)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/mongo_browser.png)](http://badge.fury.io/rb/mongo_browser)
|
5
7
|
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/lucassus/mongo_browser)
|
6
8
|
|
7
9
|
Simple but powerful tool for managing mongodb databases
|
8
10
|
|
9
11
|
Install the gem:
|
10
12
|
|
11
|
-
|
13
|
+
gem install mongo_browser
|
12
14
|
|
13
15
|
## Usage
|
14
16
|
|
15
17
|
Run the application
|
16
18
|
|
17
|
-
|
19
|
+
mongo_browser start
|
18
20
|
|
19
21
|
Application will be available by default at http://localhost:5678
|
20
22
|
In order to run it on custom port number pass the `--port` option with selected port.
|
21
23
|
|
24
|
+
## Getting started with the development
|
25
|
+
|
26
|
+
```
|
27
|
+
bundle install
|
28
|
+
sudo npm install -g grunt grunt-cli karma
|
29
|
+
```
|
30
|
+
|
31
|
+
The main goal of this project is to achieve the highest testability with 100% code coverage.
|
32
|
+
|
33
|
+
In order to execute rspec scenarios for backend just execute:
|
34
|
+
|
35
|
+
rspec spec
|
36
|
+
|
37
|
+
### Running frontend specs
|
38
|
+
|
39
|
+
#### Inside the console
|
40
|
+
|
41
|
+
* `./script/ci_javascript` will execute jasmine specs
|
42
|
+
* `./script/ci_e2e` will execute angularjs e2e scenarios
|
43
|
+
|
44
|
+
#### Inside the browser
|
45
|
+
|
46
|
+
Run thin in the test environment:
|
47
|
+
|
48
|
+
thin start -R config.ru -e test -p 3001
|
49
|
+
|
50
|
+
or
|
51
|
+
foreman start
|
52
|
+
|
53
|
+
Navigate to the one of the following url:
|
54
|
+
|
55
|
+
* [http://localhost:3001/jasmine](http://localhost:3001/jasmine) will execute jasmine specs
|
56
|
+
* [http://localhost:3001/e2e](http://localhost:3001/e2e) will execute angularjs e2e scenarios
|
57
|
+
|
58
|
+
### Continuous integration
|
59
|
+
|
60
|
+
All specs (backend + frontend) could be executed with the following command `./script/ci_all`
|
61
|
+
|
22
62
|
## Contributing
|
23
63
|
|
24
64
|
1. Fork it
|
@@ -26,3 +66,5 @@ In order to run it on custom port number pass the `--port` option with selected
|
|
26
66
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
67
|
4. Push to the branch (`git push origin my-new-feature`)
|
28
68
|
5. Create new Pull Request
|
69
|
+
|
70
|
+
This software is licensed under the MIT License.
|
data/Rakefile
CHANGED
@@ -28,8 +28,6 @@ require 'rake/clean'
|
|
28
28
|
|
29
29
|
require 'rake/testtask'
|
30
30
|
|
31
|
-
require 'cucumber'
|
32
|
-
require 'cucumber/rake/task'
|
33
31
|
gem 'rdoc' # we need the installed RDoc gem, not the system one
|
34
32
|
require 'rdoc/task'
|
35
33
|
|
@@ -37,19 +35,10 @@ include Rake::DSL
|
|
37
35
|
|
38
36
|
Bundler::GemHelper.install_tasks
|
39
37
|
|
40
|
-
|
41
38
|
Rake::TestTask.new do |t|
|
42
39
|
t.pattern = 'test/tc_*.rb'
|
43
40
|
end
|
44
41
|
|
45
|
-
|
46
|
-
CUKE_RESULTS = 'results.html'
|
47
|
-
CLEAN << CUKE_RESULTS
|
48
|
-
Cucumber::Rake::Task.new(:features) do |t|
|
49
|
-
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty --no-source -x"
|
50
|
-
t.fork = false
|
51
|
-
end
|
52
|
-
|
53
42
|
Rake::RDocTask.new do |rd|
|
54
43
|
|
55
44
|
rd.main = "README.rdoc"
|
@@ -57,4 +46,4 @@ Rake::RDocTask.new do |rd|
|
|
57
46
|
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
58
47
|
end
|
59
48
|
|
60
|
-
task :default => [:test
|
49
|
+
task :default => [:test]
|
Binary file
|
@@ -1,9 +1,7 @@
|
|
1
|
-
module = angular.module("mb.controllers")
|
2
|
-
|
3
1
|
# TODO find better solution for breadcrumbs
|
4
|
-
class
|
2
|
+
class BreadcrumbsCtrl
|
3
|
+
@$inject = ["$rootScope", "$scope"]
|
5
4
|
constructor: (@$rootScope, @$scope) ->
|
6
|
-
|
7
5
|
@$scope.showDatabase = => @$scope.dbName
|
8
6
|
@$scope.showCollection = => @$scope.collectionName
|
9
7
|
|
@@ -20,6 +18,5 @@ class BreadcrumbsController
|
|
20
18
|
dbName: @$scope.dbName
|
21
19
|
name: @$scope.collectionName
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
module.controller "breadcrumbs", BreadcrumbsController
|
21
|
+
angular.module("mb")
|
22
|
+
.controller("breadcrumbs", BreadcrumbsCtrl)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class CollectionsIndexCtrl
|
2
|
+
@$inject = ["$scope", "$routeParams", "Collection", "confirmationDialog", "alerts"]
|
3
|
+
constructor: (@$scope, $routeParams, @Collection, @confirmationDialog, @alerts) ->
|
4
|
+
@loading = false
|
5
|
+
{ @dbName } = $routeParams
|
6
|
+
|
7
|
+
# Scope variables
|
8
|
+
@$scope.dbName = @dbName
|
9
|
+
@$scope.filterValue = ""
|
10
|
+
|
11
|
+
# Scope methods
|
12
|
+
@$scope.isLoading = => @loading
|
13
|
+
@$scope.delete = (collection) => @deleteWithConfirmation(collection)
|
14
|
+
|
15
|
+
@fetchCollections()
|
16
|
+
|
17
|
+
fetchCollections: ->
|
18
|
+
@loading = true
|
19
|
+
params = dbName: @dbName
|
20
|
+
@$scope.collections = @Collection.query(params, @onLoadComplete)
|
21
|
+
|
22
|
+
onLoadComplete: (data) =>
|
23
|
+
@$scope.collections = data
|
24
|
+
@loading = false
|
25
|
+
|
26
|
+
deleteWithConfirmation: (collection) ->
|
27
|
+
@confirmationDialog
|
28
|
+
message: "Deleting #{collection.name}. Are you sure?"
|
29
|
+
onOk: => @delete(collection)
|
30
|
+
|
31
|
+
delete: (data) ->
|
32
|
+
collection = new @Collection(data)
|
33
|
+
collection.$delete =>
|
34
|
+
@alerts.info("Collection #{data.name} has been deleted.")
|
35
|
+
@fetchCollections()
|
36
|
+
|
37
|
+
angular.module("mb")
|
38
|
+
.controller("collections.index", CollectionsIndexCtrl)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CollectionsStatsCtrl
|
2
|
+
@$inject = ["$scope", "$routeParams", "Collection"]
|
3
|
+
constructor: (@$scope, $routeParams, Collection) ->
|
4
|
+
{ @dbName, @collectionName } = $routeParams
|
5
|
+
|
6
|
+
@$scope.dbName = @dbName
|
7
|
+
@$scope.collectionName = @collectionName
|
8
|
+
|
9
|
+
@collection = new Collection(dbName: @dbName, name: @collectionName)
|
10
|
+
@fetchStats()
|
11
|
+
|
12
|
+
fetchStats: ->
|
13
|
+
@collection.$stats (data) =>
|
14
|
+
@$scope.stats = data
|
15
|
+
|
16
|
+
angular.module("mb")
|
17
|
+
.controller("collections.stats", CollectionsStatsCtrl)
|
@@ -1,17 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class DatabasesController
|
1
|
+
class DatabasesIndexCtrl
|
2
|
+
@$inject = ["$scope", "Database", "confirmationDialog", "alerts"]
|
4
3
|
constructor: (@$scope, @Database, @confirmationDialog, @alerts) ->
|
5
4
|
@loading = false
|
6
|
-
@fetchDatabases()
|
7
5
|
|
8
6
|
# Scope variables
|
9
7
|
@$scope.filterValue = ""
|
10
8
|
|
11
9
|
# Scope methods
|
12
|
-
@$scope.isLoading =
|
10
|
+
@$scope.isLoading = => @loading
|
13
11
|
@$scope.delete = (database) => @dropWithConfirmation(database)
|
14
12
|
|
13
|
+
@fetchDatabases()
|
14
|
+
|
15
15
|
fetchDatabases: ->
|
16
16
|
@loading = true
|
17
17
|
@Database.query(@onLoadComplete)
|
@@ -25,15 +25,11 @@ class DatabasesController
|
|
25
25
|
message: "Deleting #{database.name}. Are you sure?"
|
26
26
|
onOk: => @drop(database)
|
27
27
|
|
28
|
-
drop: (
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
resource.$delete params, =>
|
33
|
-
@alerts.info("Database #{database.name} has been deleted.")
|
28
|
+
drop: (data) ->
|
29
|
+
database = new @Database(data)
|
30
|
+
database.$delete =>
|
31
|
+
@alerts.info("Database #{data.name} has been deleted.")
|
34
32
|
@fetchDatabases()
|
35
33
|
|
36
|
-
|
37
|
-
"
|
38
|
-
|
39
|
-
module.controller "databases", DatabasesController
|
34
|
+
angular.module("mb")
|
35
|
+
.controller("databases.index", DatabasesIndexCtrl)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class DatabasesStatsCtrl
|
2
|
+
@$inject = ["$scope", "$routeParams", "Database"]
|
3
|
+
constructor: (@$scope, $routeParams, Database) ->
|
4
|
+
{ @dbName } = $routeParams
|
5
|
+
@$scope.dbName = @dbName
|
6
|
+
|
7
|
+
@database = new Database(name: @dbName)
|
8
|
+
@fetchStats()
|
9
|
+
|
10
|
+
fetchStats: ->
|
11
|
+
@database.$stats (data) =>
|
12
|
+
@$scope.stats = data
|
13
|
+
|
14
|
+
angular.module("mb")
|
15
|
+
.controller("databases.stats", DatabasesStatsCtrl)
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class DocumentsIndexCtrl
|
2
|
+
@$inject = ["$scope", "$routeParams", "$location",
|
3
|
+
"Document", "confirmationDialog", "alerts"]
|
4
|
+
constructor: (@$scope, $routeParams, $location, @Document, @confirmationDialog, @alerts) ->
|
5
|
+
@loading = false
|
6
|
+
{ @dbName, @collectionName } = $routeParams
|
7
|
+
|
8
|
+
# Scope variables
|
9
|
+
@$scope.dbName = @dbName
|
10
|
+
@$scope.collectionName = @collectionName
|
11
|
+
|
12
|
+
@$scope.page = parseInt($location.search().page || 1)
|
13
|
+
|
14
|
+
# Scope methods
|
15
|
+
@$scope.delete = (document) => @deleteWithConfirmation(document)
|
16
|
+
@$scope.isLoading = => @loading
|
17
|
+
@$scope.showDocuments = => @$scope.size > 0
|
18
|
+
|
19
|
+
@$scope.$watch "page", (page) =>
|
20
|
+
if page > 1
|
21
|
+
$location.search("page", page)
|
22
|
+
else
|
23
|
+
$location.search("page", null)
|
24
|
+
|
25
|
+
@fetchDocuments(page)
|
26
|
+
|
27
|
+
fetchDocuments: (page = 1) ->
|
28
|
+
@loading = true
|
29
|
+
|
30
|
+
params = dbName: @dbName, collectionName: @collectionName, page: page
|
31
|
+
@Document.query(params, @onLoadComplete)
|
32
|
+
|
33
|
+
onLoadComplete: (data) =>
|
34
|
+
@$scope.documents = data.documents
|
35
|
+
@$scope.page = data.page
|
36
|
+
@$scope.totalPages = data.totalPages
|
37
|
+
@$scope.size = data.size
|
38
|
+
|
39
|
+
@loading = false
|
40
|
+
|
41
|
+
deleteWithConfirmation: (document) ->
|
42
|
+
@confirmationDialog
|
43
|
+
message: "Are you sure?"
|
44
|
+
onOk: => @delete(document)
|
45
|
+
|
46
|
+
delete: (data) ->
|
47
|
+
params = dbName: @dbName, collectionName: @collectionName, id: data.id
|
48
|
+
document = new @Document(params)
|
49
|
+
document.$delete =>
|
50
|
+
@alerts.info("Document #{data.id} has been deleted.")
|
51
|
+
@fetchDocuments()
|
52
|
+
|
53
|
+
angular.module("mb")
|
54
|
+
.controller("documents.index", DocumentsIndexCtrl)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
class DocumentsShowCtrl
|
2
|
+
@$inject = ["$scope", "$routeParams", "$location", "Document", "alerts"]
|
3
|
+
constructor: ($scope, $routeParams, @$location, Document, @alerts) ->
|
4
|
+
@loading = false
|
5
|
+
|
6
|
+
{ @dbName, @collectionName, @id } = $routeParams
|
7
|
+
@document = new Document(dbName: @dbName, collectionName: @collectionName, id: @id)
|
8
|
+
|
9
|
+
# Scope variables
|
10
|
+
$scope.dbName = @dbName
|
11
|
+
$scope.collectionName = @collectionName
|
12
|
+
$scope.document = @document
|
13
|
+
|
14
|
+
# Scope methods
|
15
|
+
$scope.isLoading = => @loading
|
16
|
+
$scope.refresh = => @refreshDocument()
|
17
|
+
|
18
|
+
@fetchDocument =>
|
19
|
+
@loading = false
|
20
|
+
|
21
|
+
fetchDocument: (onSuccess = ->) ->
|
22
|
+
@loading = true
|
23
|
+
@document.$get(onSuccess, @handleNotFoundDocument)
|
24
|
+
|
25
|
+
refreshDocument: ->
|
26
|
+
@fetchDocument =>
|
27
|
+
@loading = false
|
28
|
+
@alerts.info("Document was refreshed")
|
29
|
+
|
30
|
+
# Redirects to the collection page
|
31
|
+
# alert.error will be set by the `httpErrorsInterceptor`
|
32
|
+
handleNotFoundDocument: (response) =>
|
33
|
+
return unless response.status is 404
|
34
|
+
# TODO use filter here
|
35
|
+
@$location.path("/databases/#{@dbName}/collections/#{@collectionName}/documents")
|
36
|
+
|
37
|
+
angular.module("mb")
|
38
|
+
.controller("documents.show", DocumentsShowCtrl)
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class MainCtrl
|
2
|
+
@$inject = ["$scope", "$http"]
|
3
|
+
constructor: (@$scope, @$http) ->
|
4
|
+
@fetchVersion()
|
5
|
+
|
6
|
+
@$scope.showEnvironment = =>
|
7
|
+
@$scope.environment != "production"
|
8
|
+
|
9
|
+
fetchVersion: ->
|
10
|
+
@$http.get("/api/version").success (data) =>
|
11
|
+
@$scope.appVersion = data.version
|
12
|
+
@$scope.environment = data.environment
|
13
|
+
|
14
|
+
angular.module("mb")
|
15
|
+
.controller("main", MainCtrl)
|