summaryrefslogtreecommitdiff
path: root/src/fauxton/app/addons
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2013-04-24 15:57:15 +0200
committerGarren Smith <garren.smith@gmail.com>2013-05-15 10:26:27 +0200
commit4a849dc02a7ab5cf1380e53212542f3ff42eb440 (patch)
tree8316c356542c03168498d31238ad75c467330b31 /src/fauxton/app/addons
parent61419957cfb00dbf83f49458ed611bc75d2611fb (diff)
downloadcouchdb-4a849dc02a7ab5cf1380e53212542f3ff42eb440.tar.gz
Get Route Event api working with modules and addons
Diffstat (limited to 'src/fauxton/app/addons')
-rw-r--r--src/fauxton/app/addons/config/routes.js57
-rw-r--r--src/fauxton/app/addons/logs/resources.js5
-rw-r--r--src/fauxton/app/addons/logs/routes.js57
-rw-r--r--src/fauxton/app/addons/stats/base.js4
-rw-r--r--src/fauxton/app/addons/stats/resources.js2
-rw-r--r--src/fauxton/app/addons/stats/routes.js59
-rw-r--r--src/fauxton/app/addons/stats/views.js4
7 files changed, 104 insertions, 84 deletions
diff --git a/src/fauxton/app/addons/config/routes.js b/src/fauxton/app/addons/config/routes.js
index 7ed64980b..495e3a97e 100644
--- a/src/fauxton/app/addons/config/routes.js
+++ b/src/fauxton/app/addons/config/routes.js
@@ -11,34 +11,45 @@
// the License.
define([
- "app",
+ "app",
- "api",
+ "api",
- // Modules
- "addons/config/resources"
+ // Modules
+ "addons/config/resources"
],
function(app, FauxtonAPI, Config) {
- var configRoute = function () {
- var configs = new Config.Collection();
-
- return {
- layout: "one_pane",
- crumbs: [
- {"name": "Config","link": "_config"}
- ],
- views: {
- "#dashboard-content": new Config.View({collection: configs})
- },
- apiUrl: configs.url()
- };
- };
-
- Config.Routes = {
- "_config": configRoute
- };
- return Config;
+ var ConfigRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "one_pane",
+
+ initialize: function () {
+ this.configs = new Config.Collection();
+ },
+
+ crumbs: [
+ {"name": "Config","link": "_config"}
+ ],
+
+ apiUrl: function () {
+ this.configs.url();
+ },
+
+ routes: ["_config"],
+ defaultRoute: "config",
+
+ config: function () {
+ this.setView("#dashboard-content", new Config.View({collection: this.configs}));
+ },
+
+ establish: function () {
+ return [this.configs.fetch()];
+ }
+ });
+
+
+ Config.RouteObjects = [ConfigRouteObject];
+ return Config;
});
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
index d1e6d2079..91a9bcbb2 100644
--- a/src/fauxton/app/addons/logs/resources.js
+++ b/src/fauxton/app/addons/logs/resources.js
@@ -98,11 +98,16 @@ function (app, FauxtonAPI, Backbone) {
this.filters = [];
this.filteredCollection = new Log.Collection(this.collection.toJSON());
+
this.collection.on("add", function () {
this.createFilteredCollection();
}, this);
},
+ establish: function () {
+ return [this.collection.fetch()];
+ },
+
serialize: function () {
return { logs: this.filteredCollection};
},
diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js
index 4e04d0843..9bd8f6589 100644
--- a/src/fauxton/app/addons/logs/routes.js
+++ b/src/fauxton/app/addons/logs/routes.js
@@ -11,37 +11,48 @@
// the License.
define([
- "app",
+ "app",
- "api",
+ "api",
- // Modules
- "addons/logs/resources"
+ // Modules
+ "addons/logs/resources"
],
function(app, FauxtonAPI, Log) {
- Log.Routes = {
- "_log": function() {
- var logs = new Log.Collection();
-
- return {
- layout: "with_sidebar",
- crumbs: [
- {"name": "Logs", "link": "_log"}
- ],
- views: {
- "#dashboard-content": new Log.Views.View({collection: logs}),
- "#sidebar-content": new Log.Views.FilterView({})
- },
- apiUrl: logs.url(),
- establish: function() {
- return [logs.fetch()];
- }
- };
+ var LogRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "with_sidebar",
+
+ crumbs: [
+ {"name": "Logs", "link": "_log"}
+ ],
+
+ routes: ["_log"],
+
+ defaultRoute: "showLog",
+
+ apiUrl: function() {
+ return this.logs.url();
+ },
+
+ initialize: function () {
+ this.logs = new Log.Collection();
+ this.setView("#sidebar-content", new Log.Views.FilterView({}));
+ },
+
+ showLog: function (event) {
+ this.setView("#dashboard-content", new Log.Views.View({collection: this.logs}));
+ },
+
+ e1stablish: function() {
+ return [this.logs.fetch()];
}
- };
+ });
+
+ Log.RouteObjects = [LogRouteObject];
return Log;
});
+
diff --git a/src/fauxton/app/addons/stats/base.js b/src/fauxton/app/addons/stats/base.js
index 33316c404..4721399dd 100644
--- a/src/fauxton/app/addons/stats/base.js
+++ b/src/fauxton/app/addons/stats/base.js
@@ -16,13 +16,11 @@ define([
"addons/stats/routes"
],
-function(app, FauxtonAPI, AddonRoutes) {
- var Stats = new FauxtonAPI.addon();
+function(app, FauxtonAPI, Stats) {
Stats.initialize = function() {
FauxtonAPI.addHeaderLink({title: "Statistics", href: "#stats"});
};
- Stats.Routes = AddonRoutes;
return Stats;
});
diff --git a/src/fauxton/app/addons/stats/resources.js b/src/fauxton/app/addons/stats/resources.js
index 238a03281..94be6bbf0 100644
--- a/src/fauxton/app/addons/stats/resources.js
+++ b/src/fauxton/app/addons/stats/resources.js
@@ -19,7 +19,7 @@ define([
],
function (app, FauxtonAPI, backbone, _, Fauxton) {
- var Stats = {};
+ var Stats = new FauxtonAPI.addon();
Stats.Collection = Backbone.Collection.extend({
model: Backbone.Model,
diff --git a/src/fauxton/app/addons/stats/routes.js b/src/fauxton/app/addons/stats/routes.js
index 84947fad7..7ad2a1f3b 100644
--- a/src/fauxton/app/addons/stats/routes.js
+++ b/src/fauxton/app/addons/stats/routes.js
@@ -11,49 +11,42 @@
// the License.
define([
- "app",
- "api",
- "addons/stats/resources",
- "addons/stats/views"
+ "app",
+ "api",
+ "addons/stats/views"
],
-function(app, FauxtonAPI, Stats, Views) {
- var data = {
- stats: new Stats.Collection()
- };
+function(app, FauxtonAPI, Stats) {
- var deferred = FauxtonAPI.Deferred();
+ var StatsRouteObject = FauxtonAPI.RouteObject.extend({
+ layout: "with_sidebar",
- var routeCallback = function() {
- return {
- layout: "with_sidebar",
+ routes: ["stats", "_stats"],
+ defaultRoute: "showStats",
- data: data,
+ initialize: function () {
+ this.stats = new Stats.Collection();
- crumbs: [],
+ this.setView("#sidebar-content", new Views.StatSelect({
+ collection: this.stats
+ }));
- views: {
- "#sidebar-content": new Views.StatSelect({
- collection: data.stats
- }),
+ },
- "#dashboard-content": new Views.Statistics({
- collection: data.stats
- })
- },
+ showStats: function (event) {
+ this.setView("#dashboard-content", new Views.Statistics({
+ collection: this.stats
+ }));
+ },
- establish: function() {
- return [data.stats.fetch()];
- },
+ establish: function() {
+ return [this.stats.fetch()];
+ },
- apiUrl: "_stats"
- };
- };
+ apiUrl: "_stats"
+ });
- Routes = {
- "stats": routeCallback,
- "_stats": routeCallback
- };
+ Stats.RouteObjects = [StatsRouteObject];
- return Routes;
+ return Stats;
});
diff --git a/src/fauxton/app/addons/stats/views.js b/src/fauxton/app/addons/stats/views.js
index 21454f93d..9fda708b4 100644
--- a/src/fauxton/app/addons/stats/views.js
+++ b/src/fauxton/app/addons/stats/views.js
@@ -168,5 +168,7 @@ function(app, FauxtonAPI,Stats) {
}
});
- return Views;
+ Stats.Views = Views;
+
+ return Stats;
});