You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/01/09 01:22:25 UTC
[49/51] [partial] move src/apps/fauxton -> src/share/fauxton
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/permissions/views.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/permissions/views.js b/src/apps/fauxton/app/addons/permissions/views.js
deleted file mode 100644
index eb5a378..0000000
--- a/src/apps/fauxton/app/addons/permissions/views.js
+++ /dev/null
@@ -1,200 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/permissions/resources"
-],
-function (app, FauxtonAPI, Permissions ) {
- var events = {};
- Permissions.events = _.extend(events, Backbone.Events);
-
- Permissions.Permissions = FauxtonAPI.View.extend({
- template: "addons/permissions/templates/permissions",
-
- initialize: function (options) {
- this.database = options.database;
- this.listenTo(Permissions.events, 'itemRemoved', this.itemRemoved);
- },
-
- itemRemoved: function (event) {
- this.model.set({
- admins: this.adminsView.items(),
- members: this.membersView.items()
- });
-
- this.model.save().then(function () {
- FauxtonAPI.addNotification({
- msg: 'Database permissions has been updated.'
- });
- }, function (xhr) {
- FauxtonAPI.addNotification({
- msg: 'Could not update permissions - reason: ' + xhr.responseText,
- type: 'error'
- });
- });
- },
-
- beforeRender: function () {
- this.adminsView = this.insertView('#sections', new Permissions.PermissionSection({
- model: this.model,
- section: 'admins',
- help: 'Database admins can update design documents and edit the admin and member lists.'
- }));
-
- this.membersView = this.insertView('#sections', new Permissions.PermissionSection({
- model: this.model,
- section: 'members',
- help: 'Database members can access the database. If no members are defined, the database is public.'
- }));
- },
-
- serialize: function () {
- return {
- databaseName: this.database.id,
- };
- }
- });
-
- Permissions.PermissionSection = FauxtonAPI.View.extend({
- template: "addons/permissions/templates/section",
- initialize: function (options) {
- this.section = options.section;
- this.help = options.help;
- },
-
- events: {
- "submit .permission-item-form": "addItem",
- 'click button.close': "removeItem"
- },
-
- beforeRender: function () {
- var section = this.model.get(this.section);
-
- this.nameViews = [];
- this.roleViews = [];
-
- _.each(section.names, function (name) {
- var nameView = this.insertView('#'+this.section+'-items-names', new Permissions.PermissionItem({
- item: name,
- }));
- this.nameViews.push(nameView);
- }, this);
-
- _.each(section.roles, function (role) {
- var roleView = this.insertView('#'+this.section+'-items-roles', new Permissions.PermissionItem({
- item: role,
- }));
- this.roleViews.push(roleView);
- }, this);
- },
-
- getItemFromView: function (viewList) {
- return _.map(viewList, function (view) {
- return view.item;
- });
- },
-
- discardRemovedViews: function () {
- this.nameViews = _.filter(this.nameViews, function (view) {
- return !view.removed;
- });
-
- this.roleViews = _.filter(this.roleViews, function (view) {
- return !view.removed;
- });
- },
-
- items: function () {
- this.discardRemovedViews();
-
- return {
- names: this.getItemFromView(this.nameViews),
- roles: this.getItemFromView(this.roleViews)
- };
- },
-
- addItem: function (event) {
- event.preventDefault();
- var $item = this.$(event.currentTarget).find('.item'),
- value = $item.val(),
- section = $item.data('section'),
- type = $item.data('type'),
- that = this;
-
- var resp = this.model.addItem(value, type, section);
-
- if (resp && resp.error) {
- return FauxtonAPI.addNotification({
- msg: resp.msg,
- type: 'error'
- });
- }
-
- this.model.save().then(function () {
- that.render();
- FauxtonAPI.addNotification({
- msg: 'Database permissions has been updated.'
- });
- }, function (xhr) {
- FauxtonAPI.addNotification({
- msg: 'Could not update permissions - reason: ' + xhr.responseText,
- type: 'error'
- });
- });
- },
-
- serialize: function () {
- return {
- section: this.section,
- help: this.help
- };
- }
-
- });
-
- Permissions.PermissionItem = FauxtonAPI.View.extend({
- tagName: "li",
- template: "addons/permissions/templates/item",
- initialize: function (options) {
- this.item = options.item;
- this.viewsList = options.viewsList;
- },
-
- events: {
- 'click .close': "removeItem"
- },
-
- removeItem: function (event) {
- var that = this;
- event.preventDefault();
-
- this.removed = true;
- Permissions.events.trigger('itemRemoved');
-
- this.$el.hide('fast', function () {
- that.remove();
- });
- },
-
-
- serialize: function () {
- return {
- item: this.item
- };
- }
-
- });
-
- return Permissions;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/plugins/base.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/plugins/base.js b/src/apps/fauxton/app/addons/plugins/base.js
deleted file mode 100644
index 0798fbd..0000000
--- a/src/apps/fauxton/app/addons/plugins/base.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/plugins/routes"
-],
-
-function(app, FauxtonAPI, plugins) {
- plugins.initialize = function() {
- //FauxtonAPI.addHeaderLink({title: "Plugins", href: "#_plugins", icon: "fonticon-plugins", className: 'plugins'});
- };
- return plugins;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/plugins/resources.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/plugins/resources.js b/src/apps/fauxton/app/addons/plugins/resources.js
deleted file mode 100644
index d00fada..0000000
--- a/src/apps/fauxton/app/addons/plugins/resources.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api"
-],
-
-function (app, FauxtonAPI) {
- var plugins = FauxtonAPI.addon();
-
- plugins.Hello = FauxtonAPI.View.extend({
- template: "addons/plugins/templates/plugins"
- });
-
- return plugins;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/plugins/routes.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/plugins/routes.js b/src/apps/fauxton/app/addons/plugins/routes.js
deleted file mode 100644
index 24d47f0..0000000
--- a/src/apps/fauxton/app/addons/plugins/routes.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/plugins/resources"
-],
-function(app, FauxtonAPI, plugins) {
- var PluginsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
-
- crumbs: [
- {"name": "Plugins","link": "_plugins"}
- ],
-
- routes: {
- "_plugins": "pluginsRoute"
- },
-
- selectedHeader: "Plugins",
-
- roles: ["_admin"],
-
- apiUrl:'plugins',
-
- initialize: function () {
- //put common views used on all your routes here (eg: sidebars )
- },
-
- pluginsRoute: function () {
- this.setView("#dashboard-content", new plugins.Hello({}));
- }
- });
-
- plugins.RouteObjects = [PluginsRouteObject];
- return plugins;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/plugins/templates/plugins.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/plugins/templates/plugins.html b/src/apps/fauxton/app/addons/plugins/templates/plugins.html
deleted file mode 100644
index 3002247..0000000
--- a/src/apps/fauxton/app/addons/plugins/templates/plugins.html
+++ /dev/null
@@ -1,102 +0,0 @@
-<!--
-
-Licensed under the Apache License, Version 2.0 (the "License"); you may not use
-this file except in compliance with the License. You may obtain a copy of the
-License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software distributed
-under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
-CONDITIONS OF ANY KIND, either express or implied. See the License for the
-specific language governing permissions and limitations under the License.
-
--->
- <div id="content">
- <div class="row">
- <h2>GeoCouch</h2>
- <p>Version: <strong>couchdb1.2.x_v0.3.0-11-g66e6219</strong></p>
- <p>Author: Volker Mische</p>
- <p>
- Available Erlang Versions:
- <ul>
- <li>CouchDB 1.4.0-XXX R15B01</li>
- </ul>
- </p>
- <p>
- <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"D5QPhrJTAifM42DXqAj4RxzfEtI="}}' data-name="geocouch" data-version="couchdb1.2.x_v0.3.0-16-g66e6219">Install GeoCouch Now</button>
- </p>
- </div>
- <div class="row">
- <h2>CouchPerUser</h2>
- <p>Version: <strong>1.0.0</strong></p>
- <p>Author: Bob Ippolito</p>
- <p>
- Available Erlang Versions:
- <ul>
- <li>CouchDB 1.4.0-XXX R15B01</li>
- </ul>
- </p>
- <p>
- <button href="#" class="install-plugin" data-url="http://people.apache.org/~jan" data-checksums='{"1.4.0": {"R15B03":"Aj3mjC6M75NA62q5/xkP0tl8Hws="}}' data-name="couchperuser" data-version="1.0.0">Install CouchPerUser Now</button>
- </p>
- </div>
- </div>
- </div></body>
- <script>
- $('.install-plugin').each(function() {
- var button = $(this);
- var name = button.data('name');
- var version = button.data('version');
- $.get("/_config/plugins/" + name + "/", function(body, textStatus) {
- body = JSON.parse(body);
- if(body == version) {
- button.html('Already Installed. Click to Uninstall');
- button.data('delete', true);
- } else {
- button.html('Other Version Installed: ' + body);
- button.attr('disabled', true);
- }
- });
- });
-
- $('.install-plugin').click(function(event) {
- var button = $(this);
- var delete_plugin = button.data('delete') || false;
- var plugin_spec = JSON.stringify({
- name: button.data('name'),
- url: button.data('url'),
- version: button.data('version'),
- checksums: button.data('checksums'),
- "delete": delete_plugin
- });
- var url = '/_plugins'
- $.ajax({
- url: url,
- type: 'POST',
- data: plugin_spec,
- contentType: 'application/json', // what we send to the server
- dataType: 'json', // expected from the server
- processData: false, // keep our precious JSON
- success: function(data, textStatus, jqXhr) {
- if(textStatus == "success") {
- var action = delete_plugin ? 'Uninstalled' : 'Installed';
- button.html('Sucessfully ' + action);
- button.attr('disabled', true);
- } else {
- button.html(textStatus);
- }
- },
- beforeSend: function(xhr) {
- xhr.setRequestHeader('Accept', 'application/json');
- },
- });
- });
- </script>
- <style type="text/css">
- .row {
- background-color: #FFF;
- padding:1em;
- margin-bottom:1em;
- }
- </style>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/assets/less/replication.less
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/assets/less/replication.less b/src/apps/fauxton/app/addons/replication/assets/less/replication.less
deleted file mode 100644
index a301966..0000000
--- a/src/apps/fauxton/app/addons/replication/assets/less/replication.less
+++ /dev/null
@@ -1,196 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-
-@brown: #3A2C2B;
-@red: #E33F3B;
-@darkRed: #AF2D24;
-@linkRed: #DA4F49;
-@greyBrown: #A59D9D;
-@fontGrey: #808080;
-@secondarySidebar: #E4DFDC;
-
-
-form#replication {
- position: relative;
- max-width: none;
- width: auto;
-
- .form_set{
- width: 350px;
- display: inline-block;
- border: 1px solid @greyBrown;
- padding: 15px 10px 0;
- margin-bottom: 20px;
- &.middle{
- width: 100px;
- border: none;
- position: relative;
- height: 100px;
- margin: 0;
- }
- input, select {
- margin: 0 0 16px 5px;
- height: 40px;
- width: 318px;
- }
- .btn-group{
- margin: 0 0 16px 5px;
- .btn {
- padding: 10px 57px;
- }
- }
- &.local{
- .local_option{
- display: block;
- }
- .remote_option{
- display: none;
- }
- .local-btn{
- background-color: @red;
- color: #fff;
- }
- .remote-btn{
- background-color: #f5f5f5;
- color: @fontGrey;
- }
- }
- .local_option{
- display: none;
- }
- .remote-btn{
- background-color: @red;
- color: #fff;
- }
- }
-
-
- .options {
- position: relative;
- &:after{
- content: '';
- display: block;
- position: absolute;
- right: -16px;
- top: 9px;
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-bottom: 5px solid black;
- border-top: none;
- }
- &.off {
- &:after{
- content: '';
- display: block;
- position: absolute;
- right: -16px;
- top: 9px;
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-bottom: none;
- border-top: 5px solid black;
- }
- }
- }
- .control-group{
- label{
- float: left;
- min-height: 30px;
- vertical-align: top;
- padding-right: 5px;
- min-width: 130px;
- padding-left: 0px;
- }
- input[type=radio],
- input[type=checkbox]{
- margin: 0 0 2px 0;
- }
- }
-
- .circle{
- z-index: 0;
- position: absolute;
- top: 20px;
- left: 15px;
-
- &:after {
- width: 70px;
- height: 70px;
- content: '';
- display: block;
- position: relative;
- margin: 0 auto;
- border: 1px solid @greyBrown;
- -webkit-border-radius: 40px;
- -moz-border-radius: 40px;
- border-radius:40px;
- }
- }
- .swap {
- text-decoration: none;
- z-index: 30;
- cursor: pointer;
- position: absolute;
- font-size: 40px;
- width: 27px;
- height: 12px;
- top: 31px;
- left: 30px;
- &:hover {
- color: @greyBrown;
- }
- }
-
-}
-#replicationStatus{
- &.showHeader{
- li.header{
- display: block;
- border: none;
- }
- ul {
- border:1px solid @greyBrown;
- }
- }
- li.header{
- display: none;
- }
- ul{
- margin: 0;
- li{
- .progress,
- p{
- margin: 0px;
- vertical-align: bottom;
- &.break {
- -ms-word-break: break-all;
- word-break: break-all;
-
- /* Non standard for webkit */
- word-break: break-word;
- -webkit-hyphens: auto;
- -moz-hyphens: auto;
- hyphens: auto;
- }
- }
- padding: 10px 10px;
- margin: 0;
- list-style: none;
- border-top: 1px solid @greyBrown;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/base.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/base.js b/src/apps/fauxton/app/addons/replication/base.js
deleted file mode 100644
index 93965c1..0000000
--- a/src/apps/fauxton/app/addons/replication/base.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/replication/route"
-],
-
-function(app, FauxtonAPI, replication) {
- replication.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Replication", href: "#/replication", icon: "fonticon-replicate",});
- };
- return replication;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/resources.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/resources.js b/src/apps/fauxton/app/addons/replication/resources.js
deleted file mode 100644
index 14f255a..0000000
--- a/src/apps/fauxton/app/addons/replication/resources.js
+++ /dev/null
@@ -1,69 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- 'addons/activetasks/resources'
-],
-
-function (app, FauxtonAPI, ActiveTasks) {
- var Replication = {};
-
- //these are probably dupes from the database modules. I'm going to keep them seperate for now.
- Replication.DBModel = Backbone.Model.extend({
- label: function () {
- //for autocomplete
- return this.get("name");
- }
- });
-
- Replication.DBList = Backbone.Collection.extend({
- model: Replication.DBModel,
- url: function() {
- return app.host + "/_all_dbs";
- },
- parse: function(resp) {
- // TODO: pagination!
- return _.map(resp, function(database) {
- return {
- id: database,
- name: database
- };
- });
- }
- });
-
- Replication.Task = Backbone.Model.extend({});
-
- Replication.Tasks = Backbone.Collection.extend({
- model: Replication.Task,
- url: function () {
- return app.host + '/_active_tasks';
- },
- parse: function(resp){
- //only want replication tasks to return
- return _.filter(resp, function(task){
- return task.type === "replication";
- });
- }
- });
-
- Replication.Replicate = Backbone.Model.extend({
- documentation: "replication_doc",
- url: function(){
- return app.host + "/_replicate";
- }
- });
-
- return Replication;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/route.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/route.js b/src/apps/fauxton/app/addons/replication/route.js
deleted file mode 100644
index 17368f8..0000000
--- a/src/apps/fauxton/app/addons/replication/route.js
+++ /dev/null
@@ -1,50 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/replication/resources",
- "addons/replication/views"
-],
-function(app, FauxtonAPI, Replication, Views) {
- var RepRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "one_pane",
- roles: ["_admin"],
- routes: {
- "replication": "defaultView",
- "replication/:dbname": "defaultView"
- },
- selectedHeader: "Replication",
- apiUrl: function() {
- return [this.replication.url(), this.replication.documentation];
- },
- crumbs: [
- {"name": "Replicate changes from: ", "link": "replication"}
- ],
- defaultView: function(dbname){
- this.databases = new Replication.DBList({});
- this.tasks = new Replication.Tasks({id: "ReplicationTasks"});
- this.replication = new Replication.Replicate({});
- this.setView("#dashboard-content", new Views.ReplicationForm({
- selectedDB: dbname ||"",
- collection: this.databases,
- status: this.tasks
- }));
- }
- });
-
-
- Replication.RouteObjects = [RepRouteObject];
-
- return Replication;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/templates/form.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/templates/form.html b/src/apps/fauxton/app/addons/replication/templates/form.html
deleted file mode 100644
index 32a87dc..0000000
--- a/src/apps/fauxton/app/addons/replication/templates/form.html
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<form id="replication" class="form-horizontal">
- <div class="from form_set local">
- <div class="btn-group">
- <button class="btn local-btn" type="button" value="local">Local</button>
- <button class="btn remote-btn" type="button" value="remote">Remote</button>
- </div>
-
- <div class="from_local local_option">
- <select id="from_name" name="source">
- <% _.each( databases, function( db, i ){ %>
- <option value="<%=db.name%>" <% if(selectedDB == db.name){%>selected<%}%> ><%=db.name%></option>
- <% }); %>
- </select>
- </div>
- <div class="from_to_remote remote_option">
- <input type="text" id="from_url" name="source" size="30" value="http://">
- </div>
- </div>
-
- <div class="form_set middle">
- <span class="circle "></span>
- <a href="#" title="Switch Target and Source" class="swap">
- <span class="fonticon-swap-arrows"></span>
- </a>
- </span>
- </div>
-
- <div class="to form_set local">
- <div class="btn-group">
- <button class="btn local-btn" type="button" value="local">Local</button>
- <button class="btn remote-btn" type="button" value="remote">Remote</button>
- </div>
- <div class="to_local local_option">
- <input type="text" id="to_name" name="target" size="30" placeholder="database name">
- </div>
-
- <div class="to_remote remote_option">
- <input type="text" id="to_url" name="target" size="30" value="http://">
- </div>
- </div>
-
-
- <div class="actions">
- <div class="control-group">
- <label for="continuous">
- <input type="checkbox" name="continuous" value="true" id="continuous">
- Continuous
- </label>
-
- <label for="createTarget">
- <input type="checkbox" name="create_target" value="true" id="createTarget">
- Create Target <a href="<%=getDocUrl('replication_doc')%>" target="_blank"><i class="icon-question-sign" rel="tooltip" title="Create the target database"></i></a>
- </label>
- </div>
-
- <button class="btn btn-success btn-large save" type="submit">Replicate</button>
- </div>
-</form>
-
-<div id="replicationStatus"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/templates/progress.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/templates/progress.html b/src/apps/fauxton/app/addons/replication/templates/progress.html
deleted file mode 100644
index 1e6ef90..0000000
--- a/src/apps/fauxton/app/addons/replication/templates/progress.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-<p class="span6 break">Replicating <strong><%=source%></strong> to <strong><%=target%></strong></p>
-
-<div class="span4 progress progress-striped active">
- <div class="bar" style="width: <%=progress || 0%>%;"><%=progress || "0"%>%</div>
-</div>
-
-<span class="span1">
- <button class="cancel btn btn-danger btn-large delete" data-source="<%=source%>" data-rep-id="<%=repid%>" data-continuous="<%=continuous%>" data-target="<%=target%>">Cancel</a>
-</span>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/tests/replicationSpec.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/tests/replicationSpec.js b/src/apps/fauxton/app/addons/replication/tests/replicationSpec.js
deleted file mode 100644
index 788b082..0000000
--- a/src/apps/fauxton/app/addons/replication/tests/replicationSpec.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-define([
- 'addons/replication/base',
- 'chai'
-], function (Replication, chai) {
- var expect = chai.expect;
-
- describe('Replication Addon', function(){
-
- describe('Replication DBList Collection', function () {
- var rep;
-
- beforeEach(function () {
- rep = new rep.DBList(["foo","bar","baz","bo"]);
- });
- });
- });
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/replication/views.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/replication/views.js b/src/apps/fauxton/app/addons/replication/views.js
deleted file mode 100644
index f4b96fd..0000000
--- a/src/apps/fauxton/app/addons/replication/views.js
+++ /dev/null
@@ -1,295 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "modules/fauxton/components",
- "addons/replication/resources"
-],
-function(app, FauxtonAPI, Components, replication) {
- var View = {},
- Events ={},
- pollingInfo ={
- rate: 5,
- intervalId: null
- };
-
- _.extend(Events, Backbone.Events);
-
- // NOTES: http://wiki.apache.org/couchdb/Replication
-
- // Replication form view is huge
- // -----------------------------------
- // afterRender: autocomplete on the target input field
- // beforeRender: add the status table
- // disableFields: disable non active fields on submit
- // enableFields: enable field when radio btns are clicked
- // establish: get the DB list for autocomplete
- // formValidation: make sure fields aren't empty
- // showProgress: make a call to active_tasks model and show only replication types. Poll every 5 seconds. (make this it's own view)
- // startReplication: saves to the model, starts replication
- // submit: form submit handler
- // swapFields: change to and from target
- // toggleAdvancedOptions: toggle advanced
-
- View.ReplicationForm = FauxtonAPI.View.extend({
- template: "addons/replication/templates/form",
- events: {
- "submit #replication": "validate",
- "click .btn-group .btn": "showFields",
- "click .swap": "swapFields",
- "click .options": "toggleAdvancedOptions"
- },
- initialize: function(options){
- this.status = options.status;
- this.selectedDB = options.selectedDB;
- this.newRepModel = new replication.Replicate({});
- },
- afterRender: function(){
- this.dbSearchTypeahead = new Components.DbSearchTypeahead({
- dbLimit: 30,
- el: "input#to_name"
- });
-
- this.dbSearchTypeahead.render();
-
- },
-
- beforeRender: function(){
- this.insertView("#replicationStatus", new View.ReplicationList({
- collection: this.status
- }));
- },
- cleanup: function(){
- clearInterval(pollingInfo.intervalId);
- },
- enableFields: function(){
- this.$el.find('input','select').attr('disabled',false);
- },
- disableFields: function(){
- this.$el.find('input:hidden','select:hidden').attr('disabled',true);
- },
- showFields: function(e){
- var $currentTarget = this.$(e.currentTarget),
- targetVal = $currentTarget.val();
-
- if (targetVal === "local"){
- $currentTarget.parents('.form_set').addClass('local');
- }else{
- $currentTarget.parents('.form_set').removeClass('local');
- }
- },
- establish: function(){
- return [ this.collection.fetch(), this.status.fetch()];
- },
- validate: function(e){
- e.preventDefault();
- var notification;
- if (this.formValidation()){
- notification = FauxtonAPI.addNotification({
- msg: "Please enter every field.",
- type: "error",
- clear: true
- });
- }else if (this.$('input#to_name').is(':visible') && !this.$('input[name=create_target]').is(':checked')){
- var alreadyExists = this.collection.where({"name":this.$('input#to_name').val()});
- if (alreadyExists.length === 0){
- notification = FauxtonAPI.addNotification({
- msg: "This database doesn't exist. Check create target if you want to create it.",
- type: "error",
- clear: true
- });
- }
- }else{
- this.submit(e);
- }
- },
- formValidation: function(e){
- var $remote = this.$el.find('input:visible'),
- error = false;
- for(var i=0; i<$remote.length; i++){
- if ($remote[i].value =="http://" || $remote[i].value ===""){
- error = true;
- }
- }
- return error;
- },
- serialize: function(){
- return {
- databases: this.collection.toJSON(),
- selectedDB: this.selectedDB
- };
- },
- startReplication: function(json){
- var that = this;
- this.newRepModel.save(json,{
- success: function(resp){
- var notification = FauxtonAPI.addNotification({
- msg: "Replication from "+resp.get('source')+" to "+ resp.get('target')+" has begun.",
- type: "success",
- clear: true
- });
- that.updateButtonText(false);
- Events.trigger('update:tasks');
- },
- error: function(model, xhr, options){
- var errorMessage = JSON.parse(xhr.responseText);
- var notification = FauxtonAPI.addNotification({
- msg: errorMessage.reason,
- type: "error",
- clear: true
- });
- that.updateButtonText(false);
- }
- });
- this.enableFields();
- },
- updateButtonText: function(wait){
- var $button = this.$('#replication button[type=submit]');
- if(wait){
- $button.text('Starting replication...').attr('disabled', true);
- } else {
- $button.text('Replication').attr('disabled', false);
- }
- },
- submit: function(e){
- this.disableFields();
- var formJSON = {};
- _.map(this.$(e.currentTarget).serializeArray(), function(formData){
- if(formData.value !== ''){
- formJSON[formData.name] = (formData.value ==="true"? true: formData.value.replace(/\s/g, '').toLowerCase());
- }
- });
-
- this.updateButtonText(true);
- this.startReplication(formJSON);
- },
- swapFields: function(e){
- e.preventDefault();
- //WALL O' VARIABLES
- var $fromSelect = this.$('#from_name'),
- $toSelect = this.$('#to_name'),
- $toInput = this.$('#to_url'),
- $fromInput = this.$('#from_url'),
- fromSelectVal = $fromSelect.val(),
- fromInputVal = $fromInput.val(),
- toSelectVal = $toSelect.val(),
- toInputVal = $toInput.val();
-
- $fromSelect.val(toSelectVal);
- $toSelect.val(fromSelectVal);
-
- $fromInput.val(toInputVal);
- $toInput.val(fromInputVal);
- }
- });
-
-
- View.ReplicationList = FauxtonAPI.View.extend({
- tagName: "ul",
- initialize: function(){
- Events.bind('update:tasks', this.establish, this);
- this.listenTo(this.collection, "reset", this.render);
- this.$el.prepend("<li class='header'><h4>Active Replication Tasks</h4></li>");
- },
- establish: function(){
- return [this.collection.fetch({reset: true})];
- },
- setPolling: function(){
- var that = this;
- this.cleanup();
- pollingInfo.intervalId = setInterval(function() {
- that.establish();
- }, pollingInfo.rate*1000);
- },
- cleanup: function(){
- clearInterval(pollingInfo.intervalId);
- },
- beforeRender: function(){
- this.collection.forEach(function(item) {
- this.insertView(new View.replicationItem({
- model: item
- }));
- }, this);
- },
- showHeader: function(){
- if (this.collection.length > 0){
- this.$el.parent().addClass('showHeader');
- } else {
- this.$el.parent().removeClass('showHeader');
- }
- },
- afterRender: function(){
- this.showHeader();
- this.setPolling();
- }
- });
-
- //make this a table row item.
- View.replicationItem = FauxtonAPI.View.extend({
- tagName: "li",
- className: "row",
- template: "addons/replication/templates/progress",
- events: {
- "click .cancel": "cancelReplication"
- },
- initialize: function(){
- this.newRepModel = new replication.Replicate({});
- },
- establish: function(){
- return [this.model.fetch()];
- },
- cancelReplication: function(e){
- //need to pass "cancel": true with source & target
- var $currentTarget = this.$(e.currentTarget),
- repID = $currentTarget.attr('data-rep-id');
- this.newRepModel.save({
- "replication_id": repID,
- "cancel": true
- },
- {
- success: function(model, xhr, options){
- var notification = FauxtonAPI.addNotification({
- msg: "Replication stopped.",
- type: "success",
- clear: true
- });
- },
- error: function(model, xhr, options){
- var errorMessage = JSON.parse(xhr.responseText);
- var notification = FauxtonAPI.addNotification({
- msg: errorMessage.reason,
- type: "error",
- clear: true
- });
- }
- });
- },
- afterRender: function(){
- if (this.model.get('continuous')){
- this.$el.addClass('continuous');
- }
- },
- serialize: function(){
- return {
- progress: this.model.get('progress'),
- target: this.model.get('target'),
- source: this.model.get('source'),
- continuous: this.model.get('continuous'),
- repid: this.model.get('replication_id')
- };
- }
- });
-
- return View;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/assets/less/stats.less
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/assets/less/stats.less b/src/apps/fauxton/app/addons/stats/assets/less/stats.less
deleted file mode 100644
index cfa7679..0000000
--- a/src/apps/fauxton/app/addons/stats/assets/less/stats.less
+++ /dev/null
@@ -1,19 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-.datatypes {
- border: #d3d3d3 1px solid;
- -webkit-border-radius: 5px;
- -moz-border-radius: 5px;
- border-radius: 5px;
- padding: 15px;
-}
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/base.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/base.js b/src/apps/fauxton/app/addons/stats/base.js
deleted file mode 100644
index 1b44b8b..0000000
--- a/src/apps/fauxton/app/addons/stats/base.js
+++ /dev/null
@@ -1,26 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/stats/routes"
-],
-
-function(app, FauxtonAPI, Stats) {
-
- Stats.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Statistics", href: "#stats", icon: "fonticon-stats", className: 'stats'});
- };
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/resources.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/resources.js b/src/apps/fauxton/app/addons/stats/resources.js
deleted file mode 100644
index a761e6b..0000000
--- a/src/apps/fauxton/app/addons/stats/resources.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "backbone",
- "lodash",
- "modules/fauxton/base"
-],
-
-function (app, FauxtonAPI, backbone, _, Fauxton) {
- var Stats = new FauxtonAPI.addon();
-
- Stats.Collection = Backbone.Collection.extend({
- model: Backbone.Model,
- documentation: "stats",
- url: app.host+"/_stats",
- parse: function(resp) {
- return _.flatten(_.map(resp, function(doc, key) {
- return _.map(doc, function(v, k){
- return _.extend({id: k, type: key}, v);
- });
- }), true);
- }
- });
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/routes.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/routes.js b/src/apps/fauxton/app/addons/stats/routes.js
deleted file mode 100644
index 971c111..0000000
--- a/src/apps/fauxton/app/addons/stats/routes.js
+++ /dev/null
@@ -1,63 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/stats/views"
-],
-
-function(app, FauxtonAPI, Stats) {
-
- var StatsRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
-
- routes: {
- "stats":"showStats",
- "_stats": "showStats"
- },
-
-
- crumbs: [
- {"name": "Statistics", "link": "_stats"}
- ],
-
- selectedHeader: "Statistics",
-
- initialize: function () {
- this.stats = new Stats.Collection();
-
- this.setView("#sidebar-content", new Views.StatSelect({
- collection: this.stats
- }));
-
- },
-
- showStats: function () {
- this.setView("#dashboard-content", new Views.Statistics({
- collection: this.stats
- }));
- },
-
- establish: function() {
- return [this.stats.fetch()];
- },
-
- apiUrl: function(){
- return [ this.stats.url, this.stats.documentation];
- }
- });
-
- Stats.RouteObjects = [StatsRouteObject];
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/templates/by_method.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/templates/by_method.html b/src/apps/fauxton/app/addons/stats/templates/by_method.html
deleted file mode 100644
index 099d737..0000000
--- a/src/apps/fauxton/app/addons/stats/templates/by_method.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<h2>By Method <small>GET, POST, PUT, DELETE</small></h2>
-<div id="httpd_request_methods"></div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/templates/pie_table.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/templates/pie_table.html b/src/apps/fauxton/app/addons/stats/templates/pie_table.html
deleted file mode 100644
index c8e89cd..0000000
--- a/src/apps/fauxton/app/addons/stats/templates/pie_table.html
+++ /dev/null
@@ -1,54 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="row-fluid">
- <h2> <%= datatype %> </h2>
-</div>
-
-<div class="row-fluid">
- <div>
- <table class="table table-condensed table-striped">
- <thead>
- <tr>
- <th> Description </th>
- <th> current </th>
- <th> sum </th>
- <th> mean </th>
- <th> stddev </th>
- <th> min </th>
- <th> max </th>
- </tr>
- </thead>
- <% _.each (statistics, function (stat_line) {
- if (stat_line.get("sum")){
- %>
- <tr>
- <td><%= stat_line.get("description") %></td>
- <td><%= stat_line.get("current") %></td>
- <td><%= stat_line.get("sum") %></td>
- <td><%= stat_line.get("mean") %></td>
- <td><%= stat_line.get("stddev") %></td>
- <td><%= stat_line.get("min") %></td>
- <td><%= stat_line.get("max") %></td>
- </tr>
- <% }}) %>
- </table>
- </div>
-
- <div class="span5" style="height:430px;min-width: 430px">
- <center>
- <svg id="<%= datatype %>_graph"></svg>
- </center>
- </div>
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/templates/stats.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/templates/stats.html b/src/apps/fauxton/app/addons/stats/templates/stats.html
deleted file mode 100644
index ae7ce14..0000000
--- a/src/apps/fauxton/app/addons/stats/templates/stats.html
+++ /dev/null
@@ -1,16 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<div class="datatypes">
-</div>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/templates/statselect.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/templates/statselect.html b/src/apps/fauxton/app/addons/stats/templates/statselect.html
deleted file mode 100644
index ef1133c..0000000
--- a/src/apps/fauxton/app/addons/stats/templates/statselect.html
+++ /dev/null
@@ -1,22 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-
-<% _.each(datatypes, function (datatype) { %>
-<li>
-<a href="#stats" class="datatype-select" data-type-select="<%= datatype %>">
- <%= datatype %>
- <i class="icon-chevron-right" style="float:right"></i>
-</a>
-</li>
-<% }); %>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/stats/views.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/stats/views.js b/src/apps/fauxton/app/addons/stats/views.js
deleted file mode 100644
index 9dd9cbc..0000000
--- a/src/apps/fauxton/app/addons/stats/views.js
+++ /dev/null
@@ -1,171 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- "api",
- 'addons/stats/resources',
- "d3",
- "nv.d3"
-
-],
-
-function(app, FauxtonAPI,Stats) {
- Views = {};
-
- datatypeEventer = {};
- _.extend(datatypeEventer, Backbone.Events);
-
- Views.Legend = FauxtonAPI.View.extend({
- tagName: 'ul',
- template: "addons/stats/templates/legend",
-
- serialize: function () {
- return {
- legend_items: this.collection.toJSON()
- };
- }
- });
-
- Views.Pie = FauxtonAPI.View.extend({
- className: "datatype-section",
- template: 'addons/stats/templates/pie_table',
-
- initialize: function(args){
- this.datatype = args.datatype;
- },
-
- serialize: function() {
- return {
- statistics: this.collection.where({type: this.datatype}),
- datatype: this.datatype
- };
- },
-
- afterRender: function(){
- var collection = this.collection,
- chartelem = "#" + this.datatype + '_graph',
- series = _.map(this.collection.where({type: this.datatype}),
- function(d, counter){
- // TODO: x should be a counter
- var point = {
- y: d.get("sum") || 0,
- key: d.id
- };
- return point;
- }
- );
-
- series = _.filter(series, function(d){return d.y > 0;});
- series = _.sortBy(series, function(d){return -d.y;});
-
- nv.addGraph(function() {
- var width = 550,
- height = 400;
-
- var chart = nv.models.pieChart()
- .x(function(d) { return d.key; })
- .y(function(d) { return d.y; })
- .showLabels(true)
- .showLegend(false)
- .values(function(d) { return d; })
- .color(d3.scale.category10().range())
- .width(width)
- .height(height);
-
- d3.select(chartelem)
- .datum([series])
- .transition().duration(300)
- .attr('width', width)
- .attr('height', height)
- .call(chart);
-
- return chart;
- });
-
- this.$el.addClass(this.datatype + '_section');
- }
- });
-
- Views.StatSelect = FauxtonAPI.View.extend({
- className: 'nav nav-tabs nav-stacked',
- tagName: 'ul',
-
- template: "addons/stats/templates/statselect",
-
- initialize: function (options) {
- this.rows = [];
- },
-
- events: {
- 'click .datatype-select': "datatype_selected"
- },
-
- serialize: function () {
- return {
- datatypes: _.uniq(this.collection.pluck("type"))
- };
- },
-
- afterRender: function () {
- this.$('.datatype-select').first().addClass('active');
- },
-
- datatype_selected: function (event) {
- var $target = $(event.currentTarget);
-
- event.preventDefault();
- event.stopPropagation();
- this.$('.datatype-select').removeClass('active');
- $target.addClass('active');
- datatypeEventer.trigger('datatype-select', $target.attr('data-type-select'));
- }
- });
-
- Views.Statistics = FauxtonAPI.View.extend({
- template: "addons/stats/templates/stats",
-
- initialize: function (options) {
- this.rows = [];
- datatypeEventer.on('datatype-select', this.display_datatype, this);
- },
-
- serialize: function () {
- return {
- datatypes: _.uniq(this.collection.pluck("type"))
- };
- },
-
- beforeRender: function () {
- _.each(_.uniq(this.collection.pluck("type")), function(datatype) {
- this.rows[datatype] = this.insertView(".datatypes", new Views.Pie({
- collection: this.collection,
- datatype: datatype
- }));
- }, this);
- },
-
- afterRender: function () {
- this.$('.datatype-section').hide().first().toggle();
- },
-
- display_datatype: function (datatype) {
- this.$('.datatype-section').hide();
- this.$('.' + datatype + '_section').show();
- }
- });
-
- Stats.Views = Views;
-
- return Stats;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less b/src/apps/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
deleted file mode 100644
index e084cb3..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/assets/less/verifyinstall.less
+++ /dev/null
@@ -1,16 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#start {
- margin-bottom: 20px;
-}
-
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/base.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/base.js b/src/apps/fauxton/app/addons/verifyinstall/base.js
deleted file mode 100644
index d17c353..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/base.js
+++ /dev/null
@@ -1,31 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/verifyinstall/routes"
-],
-
-function(app, FauxtonAPI, VerifyInstall) {
- VerifyInstall.initialize = function () {
- FauxtonAPI.addHeaderLink({
- title: "Verify",
- href: "#verifyinstall",
- icon: "fonticon-circle-check",
- bottomNav: true,
- });
- };
-
-
- return VerifyInstall;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/resources.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/resources.js b/src/apps/fauxton/app/addons/verifyinstall/resources.js
deleted file mode 100644
index 5d83f9a..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/resources.js
+++ /dev/null
@@ -1,181 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "modules/databases/resources",
- "modules/documents/resources"
-],
-
-function (app, FauxtonAPI, Databases, Documents) {
- var Verifyinstall = FauxtonAPI.addon();
-
- var db = new Databases.Model({
- id: 'verifytestdb',
- name: 'verifytestdb'
- });
-
- var dbReplicate = new Databases.Model({
- id: 'verifytestdb_replicate',
- name: 'verifytestdb_replicate'
- });
-
- var doc, viewDoc;
-
- Verifyinstall.testProcess = {
-
- saveDoc: function () {
- doc = new Documents.Doc({_id: 'test_doc_1', a: 1}, {
- database: db
- });
-
- return doc.save();
- },
-
- destroyDoc: function () {
- return doc.destroy();
- },
-
- updateDoc: function () {
- doc.set({b: "hello"});
- return doc.save();
- },
-
- saveDB: function () {
- return db.save();
- },
-
- setupDB: function (db) {
- var deferred = FauxtonAPI.Deferred();
- db.fetch()
- .then(function () {
- return db.destroy();
- }, function (xhr) {
- deferred.resolve();
- })
- .then(function () {
- deferred.resolve();
- }, function (xhr, error, reason) {
- if (reason === "Unauthorized") {
- deferred.reject(xhr, error, reason);
- }
- });
-
- return deferred;
- },
-
- setup: function () {
- return FauxtonAPI.when([
- this.setupDB(db),
- this.setupDB(dbReplicate)
- ]);
- },
-
- testView: function () {
- var deferred = FauxtonAPI.Deferred();
- var promise = $.get(viewDoc.url() + '/_view/testview');
-
- promise.then(function (resp) {
- var row = JSON.parse(resp).rows[0];
- if (row.value === 6) {
- return deferred.resolve();
- }
- var reason = {
- reason: 'Values expect 6, got ' + row.value
- };
-
- deferred.reject({responseText: JSON.stringify(reason)});
- }, deferred.reject);
-
- return deferred;
- },
-
- setupView: function () {
- var doc1 = new Documents.Doc({_id: 'test_doc10', a: 1}, {
- database: db
- });
-
- var doc2 = new Documents.Doc({_id: 'test_doc_20', a: 2}, {
- database: db
- });
-
- var doc3 = new Documents.Doc({_id: 'test_doc_30', a: 3}, {
- database: db
- });
-
- viewDoc = new Documents.Doc({
- _id: '_design/view_check',
- views: {
- 'testview': {
- map:'function (doc) { emit(doc._id, doc.a); }',
- reduce: '_sum'
- }
- }
- },{
- database: db,
- });
-
- return FauxtonAPI.when([doc1.save(),doc2.save(), doc3.save(), viewDoc.save()]);
- },
-
- setupReplicate: function () {
- return $.ajax({
- url: '/_replicate',
- contentType: 'application/json',
- type: 'POST',
- dataType: 'json',
- processData: false,
- data: JSON.stringify({
- create_target: true,
- source: 'verifytestdb',
- target: 'verifytestdb_replicate'
- }),
- });
- },
-
- testReplicate: function () {
- var deferred = FauxtonAPI.Deferred();
- /*var dbReplicate = new Databases.Model({
- id: 'verifytestdb_replicate',
- name: 'verifytestdb_replicate'
- });*/
-
- var promise = dbReplicate.fetch();
-
- promise.then(function () {
- var docCount = dbReplicate.get('doc_count');
- if ( docCount === 4) {
- deferred.resolve();
- return;
- }
-
- var reason = {
- reason: 'Replication Failed, expected 4 docs got ' + docCount
- };
-
- deferred.reject({responseText: JSON.stringify(reason)});
- }, deferred.reject);
-
- return deferred;
- },
-
- removeDBs: function () {
- dbReplicate.destroy();
- db.destroy();
-
- }
- };
-
-
- return Verifyinstall;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/routes.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/routes.js b/src/apps/fauxton/app/addons/verifyinstall/routes.js
deleted file mode 100644
index e5024ba..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/routes.js
+++ /dev/null
@@ -1,37 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/verifyinstall/views"
-],
-function(app, FauxtonAPI, VerifyInstall) {
-
- var VerifyRouteObject = FauxtonAPI.RouteObject.extend({
- layout: 'one_pane',
-
- routes: {
- 'verifyinstall': "verifyInstall"
- },
- selectedHeader: "Verify",
-
- verifyInstall: function () {
- this.setView('#dashboard-content', new VerifyInstall.Main({}));
- },
-
- crumbs: [{name: 'Verify Couchdb Installation', link: '#'}]
- });
-
- VerifyInstall.RouteObjects = [VerifyRouteObject];
- return VerifyInstall;
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/templates/main.html
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/templates/main.html b/src/apps/fauxton/app/addons/verifyinstall/templates/main.html
deleted file mode 100644
index fa41907..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/templates/main.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
-Licensed under the Apache License, Version 2.0 (the "License"); you may not
-use this file except in compliance with the License. You may obtain a copy of
-the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-License for the specific language governing permissions and limitations under
-the License.
--->
-<button id="start" class="btn btn-large btn-success"> Verify Installation </button>
-<div id="error"> </div>
-
-<table id="test-score" class="table table-striped table-bordered" >
- <thead>
- <tr>
- <th> Test </th>
- <th> Status </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td> Create Database </td>
- <td id="create-database" class="status"> </td>
- </tr>
- <tr>
- <td> Create Document </td>
- <td id="create-document" class="status"> </td>
- </tr>
- <tr>
- <td> Update Document </td>
- <td id="update-document" class="status"> </td>
- </tr>
- <tr>
- <td> Delete Document </td>
- <td id="delete-document" class="status"> </td>
- </tr>
- <tr>
- <td> Create View </td>
- <td id="create-view" class="status"> </td>
- </tr>
- <tr>
- <td> Replication </td>
- <td id="replicate" class="status"> </td>
- </tr>
- </tbody>
-</table>
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/addons/verifyinstall/views.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/addons/verifyinstall/views.js b/src/apps/fauxton/app/addons/verifyinstall/views.js
deleted file mode 100644
index eb6dac4..0000000
--- a/src/apps/fauxton/app/addons/verifyinstall/views.js
+++ /dev/null
@@ -1,127 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
- "api",
- "addons/verifyinstall/resources",
-],
-function(app, FauxtonAPI, VerifyInstall) {
-
- VerifyInstall.Main = FauxtonAPI.View.extend({
- template: 'addons/verifyinstall/templates/main',
-
- events: {
- "click #start": "startTest"
- },
-
- initialize: function (options) {
- _.bindAll(this);
- },
-
- setPass: function (id) {
- this.$('#' + id).html('✓');
- },
-
- setError: function (id, msg) {
- this.$('#' + id).html('✗');
- FauxtonAPI.addNotification({
- msg: 'Error: ' + msg,
- type: 'error',
- selector: '#error'
- });
- },
-
- complete: function () {
- FauxtonAPI.addNotification({
- msg: 'Success! You Couchdb install is working. Time to Relax',
- type: 'success',
- selector: '#error'
- });
- },
-
- enableButton: function () {
- this.$('#start').removeAttr('disabled').text('Verify Installation');
- },
-
- disableButton: function () {
- this.$('#start').attr('disabled','disabled').text('Verifying');
- },
-
- formatError: function (id) {
- var enableButton = this.enableButton,
- setError = this.setError;
-
- return function (xhr, error, reason) {
- enableButton();
-
- if (!xhr) { return; }
-
- setError(id, JSON.parse(xhr.responseText).reason);
- };
- },
-
-
- startTest: function () {
- this.disableButton();
- this.$('.status').text('');
-
- var testProcess = VerifyInstall.testProcess,
- setPass = this.setPass,
- complete = this.complete,
- setError = this.setError,
- formatError = this.formatError;
-
- testProcess.setup()
- .then(function () {
- return testProcess.saveDB();
- }, formatError('create-database'))
- .then(function () {
- setPass('create-database');
- return testProcess.saveDoc();
- }, formatError('create-document'))
- .then(function () {
- setPass('create-document');
- return testProcess.updateDoc();
- }, formatError('update-document'))
- .then(function () {
- setPass('update-document');
- return testProcess.destroyDoc();
- }, formatError('delete-document'))
- .then(function () {
- setPass('delete-document');
- return testProcess.setupView();
- }, formatError('create-view'))
- .then(function () {
- return testProcess.testView();
- }, formatError('create-view'))
- .then(function () {
- setPass('create-view');
- return testProcess.setupReplicate();
- }, formatError('create-view'))
- .then(function () {
- return testProcess.testReplicate();
- }, formatError('replicate'))
- .then(function () {
- setPass('replicate');
- complete();
- testProcess.removeDBs();
- }, formatError('replicate'));
-
- this.enableButton();
- }
- });
-
-
- return VerifyInstall;
-
-});
http://git-wip-us.apache.org/repos/asf/couchdb/blob/b90c3b0a/src/apps/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/apps/fauxton/app/api.js b/src/apps/fauxton/app/api.js
deleted file mode 100644
index 5ad032a..0000000
--- a/src/apps/fauxton/app/api.js
+++ /dev/null
@@ -1,558 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-define([
- "app",
-
- // Modules
- "modules/fauxton/base",
- "spin"
-],
-
-function(app, Fauxton) {
- var FauxtonAPI = app.module();
-
- FauxtonAPI.moduleExtensions = {
- Routes: {
- }
- };
-
- FauxtonAPI.addonExtensions = {
- initialize: function() {}
- };
-
- // List of JSHINT errors to ignore
- // Gets around problem of anonymous functions not being a valid statement
- FauxtonAPI.excludedViewErrors = [
- "Missing name in function declaration.",
- "['{a}'] is better written in dot notation."
- ];
-
- FauxtonAPI.isIgnorableError = function(msg) {
- return _.contains(FauxtonAPI.excludedViewErrors, msg);
- };
-
- FauxtonAPI.View = Backbone.View.extend({
- // This should return an array of promises, an empty array, or null
- establish: function() {
- return null;
- },
-
- loaderClassname: 'loader',
-
- disableLoader: false,
-
- forceRender: function () {
- this.hasRendered = false;
- }
- });
-
- FauxtonAPI.navigate = function(url, _opts) {
- var options = _.extend({trigger: true}, _opts );
- app.router.navigate(url,options);
- };
-
- FauxtonAPI.beforeUnload = function () {
- app.router.beforeUnload.apply(app.router, arguments);
- };
-
- FauxtonAPI.removeBeforeUnload = function () {
- app.router.removeBeforeUnload.apply(app.router, arguments);
- };
-
- FauxtonAPI.addHeaderLink = function(link) {
- app.masterLayout.navBar.addLink(link);
- };
-
- FauxtonAPI.removeHeaderLink = function(link) {
- app.masterLayout.navBar.removeLink(link);
- };
-
- FauxtonAPI.Deferred = function() {
- return $.Deferred();
- };
-
- FauxtonAPI.when = function (deferreds) {
- if (deferreds instanceof Array) {
- return $.when.apply(null, deferreds);
- }
-
- return $.when(deferreds);
- };
-
- FauxtonAPI.addRoute = function(route) {
- app.router.route(route.route, route.name, route.callback);
- };
-
- FauxtonAPI.triggerRouteEvent = function (routeEvent, args) {
- app.router.triggerRouteEvent("route:"+routeEvent, args);
- };
-
- FauxtonAPI.module = function(extra) {
- return app.module(_.extend(FauxtonAPI.moduleExtensions, extra));
- };
-
- FauxtonAPI.addon = function(extra) {
- return FauxtonAPI.module(FauxtonAPI.addonExtensions, extra);
- };
-
- FauxtonAPI.addNotification = function(options) {
- options = _.extend({
- msg: "Notification Event Triggered!",
- type: "info",
- selector: "#global-notifications"
- }, options);
- var view = new Fauxton.Notification(options);
-
- return view.renderNotification();
- };
-
- FauxtonAPI.UUID = Backbone.Model.extend({
- initialize: function(options) {
- options = _.extend({count: 1}, options);
- this.count = options.count;
- },
-
- url: function() {
- return app.host + "/_uuids?count=" + this.count;
- },
-
- next: function() {
- return this.get("uuids").pop();
- }
- });
-
- FauxtonAPI.Session = Backbone.Model.extend({
- url: '/_session',
-
- user: function () {
- var userCtx = this.get('userCtx');
-
- if (!userCtx || !userCtx.name) { return null; }
-
- return {
- name: userCtx.name,
- roles: userCtx.roles
- };
- },
-
- fetchOnce: function (opt) {
- var options = _.extend({}, opt);
-
- if (!this._deferred || this._deferred.state() === "rejected" || options.forceFetch ) {
- this._deferred = this.fetch();
- }
-
- return this._deferred;
- },
-
- fetchUser: function (opt) {
- var that = this,
- currentUser = this.user();
-
- return this.fetchOnce(opt).then(function () {
- var user = that.user();
-
- // Notify anyone listening on these events that either a user has changed
- // or current user is the same
- if (currentUser !== user) {
- that.trigger('session:userChanged');
- } else {
- that.trigger('session:userFetched');
- }
-
- // this will return the user as a value to all function that calls done on this
- // eg. session.fetchUser().done(user) { .. do something with user ..}
- return user;
- });
- }
- });
-
- FauxtonAPI.setSession = function (newSession) {
- app.session = FauxtonAPI.session = newSession;
- return FauxtonAPI.session.fetchUser();
- };
-
- FauxtonAPI.setSession(new FauxtonAPI.Session());
-
- // This is not exposed externally as it should not need to be accessed or overridden
- var Auth = function (options) {
- this._options = options;
- this.initialize.apply(this, arguments);
- };
-
- // Piggy-back on Backbone's self-propagating extend function,
- Auth.extend = Backbone.Model.extend;
-
- _.extend(Auth.prototype, Backbone.Events, {
- authDeniedCb: function() {},
-
- initialize: function() {
- var that = this;
- },
-
- authHandlerCb : function (roles) {
- var deferred = $.Deferred();
- deferred.resolve();
- return deferred;
- },
-
- registerAuth: function (authHandlerCb) {
- this.authHandlerCb = authHandlerCb;
- },
-
- registerAuthDenied: function (authDeniedCb) {
- this.authDeniedCb = authDeniedCb;
- },
-
- checkAccess: function (roles) {
- var requiredRoles = roles || [],
- that = this;
-
- return FauxtonAPI.session.fetchUser().then(function (user) {
- return FauxtonAPI.when(that.authHandlerCb(FauxtonAPI.session, requiredRoles));
- });
- }
- });
-
- FauxtonAPI.auth = new Auth();
-
- FauxtonAPI.RouteObject = function(options) {
- this._options = options;
-
- this._configure(options || {});
- this.initialize.apply(this, arguments);
- this.addEvents();
- };
-
- var broadcaster = {};
- _.extend(broadcaster, Backbone.Events);
-
- FauxtonAPI.RouteObject.on = function (eventName, fn) {
- broadcaster.on(eventName, fn);
- };
-
- /* How Route Object events work
- To listen to a specific route objects events:
-
- myRouteObject = FauxtonAPI.RouteObject.extend({
- events: {
- "beforeRender": "beforeRenderEvent"
- },
-
- beforeRenderEvent: function (view, selector) {
- console.log('Hey, beforeRenderEvent triggered',arguments);
- },
- });
-
- It is also possible to listen to events triggered from all Routeobjects.
- This is great for more general things like adding loaders, hooks.
-
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- console.log('hey, this will trigger when any routeobject renders a view');
- });
-
- Current Events to subscribe to:
- * beforeFullRender -- before a full render is being done
- * beforeEstablish -- before the routeobject calls establish
- * AfterEstablish -- after the routeobject has run establish
- * beforeRender -- before a view is rendered
- * afterRender -- a view is finished being rendered
- * renderComplete -- all rendering is complete
-
- */
-
- // Piggy-back on Backbone's self-propagating extend function
- FauxtonAPI.RouteObject.extend = Backbone.Model.extend;
-
- var routeObjectOptions = ["views", "routes", "events", "roles", "crumbs", "layout", "apiUrl", "establish"];
-
- _.extend(FauxtonAPI.RouteObject.prototype, Backbone.Events, {
- // Should these be default vals or empty funcs?
- views: {},
- routes: {},
- events: {},
- crumbs: [],
- layout: "with_sidebar",
- apiUrl: null,
- disableLoader: false,
- loaderClassname: 'loader',
- renderedState: false,
- establish: function() {},
- route: function() {},
- roles: [],
- initialize: function() {}
- }, {
-
- renderWith: function(route, masterLayout, args) {
- var routeObject = this,
- triggerBroadcast = _.bind(this.triggerBroadcast, this);
-
- // Only want to redo the template if its a full render
- if (!this.renderedState) {
- masterLayout.setTemplate(this.layout);
- triggerBroadcast('beforeFullRender');
- $('#primary-navbar li').removeClass('active');
-
- if (this.selectedHeader) {
- app.selectedHeader = this.selectedHeader;
- $('#primary-navbar li[data-nav-name="' + this.selectedHeader + '"]').addClass('active');
- }
- }
-
- masterLayout.clearBreadcrumbs();
- var crumbs = this.get('crumbs');
-
- if (crumbs.length) {
- masterLayout.setBreadcrumbs(new Fauxton.Breadcrumbs({
- crumbs: crumbs
- }));
- }
-
- triggerBroadcast('beforeEstablish');
- FauxtonAPI.when(this.establish()).then(function(resp) {
- triggerBroadcast('afterEstablish');
- _.each(routeObject.getViews(), function(view, selector) {
- if(view.hasRendered) {
- triggerBroadcast('viewHasRendered', view, selector);
- return;
- }
-
- triggerBroadcast('beforeRender', view, selector);
- FauxtonAPI.when(view.establish()).then(function(resp) {
- masterLayout.setView(selector, view);
-
- masterLayout.renderView(selector);
- triggerBroadcast('afterRender', view, selector);
- }, function(resp) {
- view.establishError = {
- error: true,
- reason: resp
- };
-
- if (resp) {
- var errorText = JSON.parse(resp.responseText).reason;
- FauxtonAPI.addNotification({
- msg: 'An Error occurred: ' + errorText,
- type: 'error',
- clear: true
- });
- }
-
- masterLayout.renderView(selector);
- });
-
- });
- }.bind(this), function (resp) {
- if (!resp) { return; }
- FauxtonAPI.addNotification({
- msg: 'An Error occurred' + JSON.parse(resp.responseText).reason,
- type: 'error',
- clear: true
- });
- });
-
- if (this.get('apiUrl')){
- masterLayout.apiBar.update(this.get('apiUrl'));
- } else {
- masterLayout.apiBar.hide();
- }
-
- // Track that we've done a full initial render
- this.renderedState = true;
- triggerBroadcast('renderComplete');
- },
-
- triggerBroadcast: function (eventName) {
- var args = Array.prototype.slice.call(arguments);
- this.trigger.apply(this, args);
-
- args.splice(0,1, eventName, this);
- broadcaster.trigger.apply(broadcaster, args);
- },
-
- get: function(key) {
- return _.isFunction(this[key]) ? this[key]() : this[key];
- },
-
- addEvents: function(events) {
- events = events || this.get('events');
- _.each(events, function(method, event) {
- if (!_.isFunction(method) && !_.isFunction(this[method])) {
- throw new Error("Invalid method: "+method);
- }
- method = _.isFunction(method) ? method : this[method];
-
- this.on(event, method);
- }, this);
- },
-
- _configure: function(options) {
- _.each(_.intersection(_.keys(options), routeObjectOptions), function(key) {
- this[key] = options[key];
- }, this);
- },
-
- getView: function(selector) {
- return this.views[selector];
- },
-
- setView: function(selector, view) {
- this.views[selector] = view;
- return view;
- },
-
- getViews: function() {
- return this.views;
- },
-
- removeViews: function () {
- _.each(this.views, function (view, selector) {
- view.remove();
- delete this.views[selector];
- }, this);
- },
-
- getRouteUrls: function () {
- return _.keys(this.get('routes'));
- },
-
- hasRoute: function (route) {
- if (this.get('routes')[route]) {
- return true;
- }
- return false;
- },
-
- routeCallback: function (route, args) {
- var routes = this.get('routes'),
- routeObj = routes[route],
- routeCallback;
-
- if (typeof routeObj === 'object') {
- routeCallback = this[routeObj.route];
- } else {
- routeCallback = this[routeObj];
- }
-
- routeCallback.apply(this, args);
- },
-
- getRouteRoles: function (routeUrl) {
- var route = this.get('routes')[routeUrl];
-
- if ((typeof route === 'object') && route.roles) {
- return route.roles;
- }
-
- return this.roles;
- }
-
- });
-
- // We could look at moving the spinner code out to its own module
- var routeObjectSpinner;
- FauxtonAPI.RouteObject.on('beforeEstablish', function (routeObject) {
- if (!routeObject.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- if (!$('.spinner').length) {
- $('<div class="spinner"></div>')
- .appendTo('#app-container');
- }
-
- routeObjectSpinner = new Spinner(opts).spin();
- $('.spinner').append(routeObjectSpinner.el);
- }
- });
-
- var removeRouteObjectSpinner = function () {
- if (routeObjectSpinner) {
- routeObjectSpinner.stop();
- $('.spinner').remove();
- }
- };
-
- var removeViewSpinner = function () {
- if (viewSpinner){
- viewSpinner.stop();
- $('.spinner').remove();
- }
- };
-
- var viewSpinner;
- FauxtonAPI.RouteObject.on('beforeRender', function (routeObject, view, selector) {
- removeRouteObjectSpinner();
-
- if (!view.disableLoader){
- var opts = {
- lines: 16, // The number of lines to draw
- length: 8, // The length of each line
- width: 4, // The line thickness
- radius: 12, // The radius of the inner circle
- color: '#333', // #rbg or #rrggbb
- speed: 1, // Rounds per second
- trail: 10, // Afterglow percentage
- shadow: false // Whether to render a shadow
- };
-
- viewSpinner = new Spinner(opts).spin();
- $('<div class="spinner"></div>')
- .appendTo(selector)
- .append(viewSpinner.el);
- }
- });
-
- FauxtonAPI.RouteObject.on('afterRender', function (routeObject, view, selector) {
- removeViewSpinner();
- });
-
- FauxtonAPI.RouteObject.on('viewHasRendered', function () {
- removeViewSpinner();
- removeRouteObjectSpinner();
- });
-
- var extensions = _.extend({}, Backbone.Events);
- // Can look at a remove function later.
- FauxtonAPI.registerExtension = function (name, view) {
- if (!extensions[name]) {
- extensions[name] = [];
- }
-
- extensions.trigger('add:' + name, view);
- extensions[name].push(view);
- };
-
- FauxtonAPI.getExtensions = function (name) {
- var views = extensions[name];
-
- if (!views) {
- views = [];
- }
-
- return views;
- };
-
- FauxtonAPI.extensions = extensions;
-
- app.fauxtonAPI = FauxtonAPI;
- return app.fauxtonAPI;
-});