Repository: couchdb-fauxton Updated Branches: refs/heads/master aff2283d8 -> e43fa4790
Whitespace and style fixes Updated styles for the Active Tasks add-on. - â not â - underscore comments - whitespace fixes - removed a couple of unused vars Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/e43fa479 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/e43fa479 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/e43fa479 Branch: refs/heads/master Commit: e43fa4790b6896ce3a012768acdffb5a0d2aac3d Parents: aff2283 Author: Benjamin Keen <[email protected]> Authored: Wed Nov 5 16:10:04 2014 -0800 Committer: Benjamin Keen <[email protected]> Committed: Wed Nov 5 16:10:04 2014 -0800 ---------------------------------------------------------------------- app/addons/activetasks/base.js | 10 +- app/addons/activetasks/resources.js | 21 ++-- app/addons/activetasks/routes.js | 30 ++--- .../activetasks/templates/tab_header.html | 6 +- app/addons/activetasks/templates/table.html | 12 +- .../activetasks/templates/tabledetail.html | 4 +- app/addons/activetasks/templates/tabs.html | 4 +- app/addons/activetasks/views.js | 120 +++++++++---------- 8 files changed, 99 insertions(+), 108 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/base.js ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/base.js b/app/addons/activetasks/base.js index c01fd55..4aabcbc 100644 --- a/app/addons/activetasks/base.js +++ b/app/addons/activetasks/base.js @@ -11,15 +11,15 @@ // the License. define([ - "app", - "api", - "addons/activetasks/routes" + 'app', + 'api', + 'addons/activetasks/routes' ], function (app, FauxtonAPI, Activetasks) { - Activetasks.initialize = function() { - FauxtonAPI.addHeaderLink({title: "Active Tasks", icon: "fonticon-activetasks", href: "#/activetasks"}); + Activetasks.initialize = function () { + FauxtonAPI.addHeaderLink({title: 'Active Tasks', icon: 'fonticon-activetasks', href: '#/activetasks'}); }; return Activetasks; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/resources.js ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/resources.js b/app/addons/activetasks/resources.js index 0872d41..b8c59c6 100644 --- a/app/addons/activetasks/resources.js +++ b/app/addons/activetasks/resources.js @@ -11,15 +11,13 @@ // the License. define([ - "app", - "addons/fauxton/base", + 'app' ], -function (app, Fauxton) { - var Active = {}, - apiv = app.versionAPI; - app.taskSortBy = 'type'; +function (app) { + app.taskSortBy = 'type'; + var Active = {}; Active.events = {}; _.extend(Active.events, Backbone.Events); @@ -48,24 +46,23 @@ function (app, Fauxton) { } }); } - return item.get(value); }, - documentation: "_active_tasks", + documentation: '_active_tasks', url: function (context) { - if (context === "apiurl") { - return window.location.origin + "/_active_tasks"; + if (context === 'apiurl') { + return window.location.origin + '/_active_tasks'; } else { - return app.host + "/_active_tasks"; + return app.host + '/_active_tasks'; } } }); Active.Search = Backbone.Model.extend({ filterDatabase: null, - filterType: "all" + filterType: 'all' }); return Active; http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/routes.js ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/routes.js b/app/addons/activetasks/routes.js index 1805d3f..5044091 100644 --- a/app/addons/activetasks/routes.js +++ b/app/addons/activetasks/routes.js @@ -11,37 +11,37 @@ // the License. define([ - "app", - "api", - "addons/activetasks/resources", - "addons/activetasks/views" + 'app', + 'api', + 'addons/activetasks/resources', + 'addons/activetasks/views' ], function (app, FauxtonAPI, Activetasks, Views) { var ActiveTasksRouteObject = FauxtonAPI.RouteObject.extend({ - layout: "with_tabs_sidebar", + layout: 'with_tabs_sidebar', routes: { - "activetasks/:id": "defaultView", - "activetasks": "defaultView" + 'activetasks/:id': 'defaultView', + 'activetasks': 'defaultView' }, events: { - "route:changeFilter": "changeFilter", + 'route:changeFilter': 'changeFilter' }, selectedHeader: 'Active Tasks', crumbs: [ - {"name": "Active tasks", "link": "activetasks"} + {'name': 'Active tasks', 'link': 'activetasks'} ], apiUrl: function () { - return [this.allTasks.url("apiurl"), this.allTasks.documentation]; + return [this.allTasks.url('apiurl'), this.allTasks.documentation]; }, - roles: ["_admin"], + roles: ['_admin'], initialize: function () { this.allTasks = new Activetasks.AllTasks(); @@ -49,15 +49,15 @@ function (app, FauxtonAPI, Activetasks, Views) { }, defaultView: function () { - this.setView("#dashboard-lower-content", new Views.View({ + this.setView('#dashboard-lower-content', new Views.View({ collection: this.allTasks, - currentView: "all", + currentView: 'all', searchModel: this.search })); - this.setView("#sidebar-content", new Views.TabMenu({})); + this.setView('#sidebar-content', new Views.TabMenu({})); - this.headerView = this.setView("#dashboard-upper-content", new Views.TabHeader({ + this.headerView = this.setView('#dashboard-upper-content', new Views.TabHeader({ searchModel: this.search })); }, http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/templates/tab_header.html ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/templates/tab_header.html b/app/addons/activetasks/templates/tab_header.html index d613c7d..9ebc28a 100644 --- a/app/addons/activetasks/templates/tab_header.html +++ b/app/addons/activetasks/templates/tab_header.html @@ -1,4 +1,4 @@ -<!-- +<%/* 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 @@ -10,7 +10,7 @@ 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="dashboard-upper-menu"> <ul class="nav nav-tabs window-resizeable" id="db-views-tabs-nav"> @@ -26,7 +26,7 @@ the License. <div class="tab-pane" id="query"> <div class="activetasks-header"> <div class="pull-right"> - <input class="task-search-database" type="text" name="search" placeholder="Search for databases..."> + <input class="task-search-database" type="text" name="search" placeholder="Search for databases..."> </div> </div> </div> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/templates/table.html ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/templates/table.html b/app/addons/activetasks/templates/table.html index 2268927..92264dd 100644 --- a/app/addons/activetasks/templates/table.html +++ b/app/addons/activetasks/templates/table.html @@ -1,4 +1,4 @@ -<!-- +<%/* 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 @@ -10,17 +10,15 @@ 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. ---> +*/%> - - -<% if (collection.length === 0){%> +<% if (collection.length === 0) { %> <tr> <td> <p>No tasks.</p> </td> </tr> -<%}else{%> +<% } else { %> <thead> <tr> @@ -34,7 +32,5 @@ the License. </thead> <tbody class="js-tasks-go-here"> - </tbody> - <% } %> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/templates/tabledetail.html ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/templates/tabledetail.html b/app/addons/activetasks/templates/tabledetail.html index 3f5e6c4..ca4c766 100644 --- a/app/addons/activetasks/templates/tabledetail.html +++ b/app/addons/activetasks/templates/tabledetail.html @@ -1,4 +1,4 @@ -<!-- +<%/* 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 @@ -10,7 +10,7 @@ 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. ---> +*/%> <td> <%= model.get("type")%> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/templates/tabs.html ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/templates/tabs.html b/app/addons/activetasks/templates/tabs.html index 56f6ab2..8bffa4d 100644 --- a/app/addons/activetasks/templates/tabs.html +++ b/app/addons/activetasks/templates/tabs.html @@ -1,4 +1,4 @@ -<!-- +<%/* 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 @@ -10,7 +10,7 @@ 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. ---> +*/%> <ul class="task-tabs nav nav-list"> <% for (var filter in filters) { %> http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/e43fa479/app/addons/activetasks/views.js ---------------------------------------------------------------------- diff --git a/app/addons/activetasks/views.js b/app/addons/activetasks/views.js index 2f13a21..d8f7117 100644 --- a/app/addons/activetasks/views.js +++ b/app/addons/activetasks/views.js @@ -11,9 +11,9 @@ // the License. define([ - "app", - "api", - "addons/activetasks/resources" + 'app', + 'api', + 'addons/activetasks/resources' ], function (app, FauxtonAPI, ActiveTasks) { @@ -21,25 +21,24 @@ function (app, FauxtonAPI, ActiveTasks) { var Views = {}, Events = {}, pollingInfo = { - rate: "5", + rate: '5', intervalId: null }; - Views.Events = _.extend(Events, Backbone.Events); Views.View = FauxtonAPI.View.extend({ - tagName: "table", - className: "table table-bordered table-striped active-tasks", - template: "addons/activetasks/templates/table", + tagName: 'table', + className: 'table table-bordered table-striped active-tasks', + template: 'addons/activetasks/templates/table', events: { - "click th": "sortByType" + 'click th': 'sortByType' }, - initialize: function (options) { - this.listenTo(this.searchModel, "change", this.render); - this.listenTo(this.collection, "reset", this.render); + initialize: function () { + this.listenTo(this.searchModel, 'change', this.render); + this.listenTo(this.collection, 'reset', this.render); }, beforeRender: function () { @@ -47,35 +46,34 @@ function (app, FauxtonAPI, ActiveTasks) { }, filterAndInsertView: function () { - var that = this, - database = this.searchModel.get("filterDatabase"), - filter = this.searchModel.get("filterType"), - databaseRegex = new RegExp(database, "g"); + var database = this.searchModel.get('filterDatabase'), + filter = this.searchModel.get('filterType'), + databaseRegex = new RegExp(database, 'g'); - this.removeView(".js-tasks-go-here"); + this.removeView('.js-tasks-go-here'); this.collection.forEach(function (item) { - if (filter && filter !== "all" && item.get("type") !== filter) { + if (filter && filter !== 'all' && item.get('type') !== filter) { return; } if (database && - !databaseRegex.test(item.get("source")) && - !databaseRegex.test(item.get("target")) && - !databaseRegex.test(item.get("database"))) { + !databaseRegex.test(item.get('source')) && + !databaseRegex.test(item.get('target')) && + !databaseRegex.test(item.get('database'))) { return; } var view = new Views.TableDetail({ model: item }); - this.insertView(".js-tasks-go-here", view); + this.insertView('.js-tasks-go-here', view); }, this); }, afterRender: function () { - Events.bind("update:poll", this.setPolling, this); + Events.bind('update:poll', this.setPolling, this); this.setPolling(); }, @@ -92,7 +90,7 @@ function (app, FauxtonAPI, ActiveTasks) { sortByType: function (e) { var currentTarget = e.currentTarget, - datatype = this.$(currentTarget).attr("data-type"); + datatype = this.$(currentTarget).attr('data-type'); this.collection.sortByColumn(datatype); this.render(); @@ -113,28 +111,28 @@ function (app, FauxtonAPI, ActiveTasks) { }); Views.TabMenu = FauxtonAPI.View.extend({ - tagName: "nav", - className: "sidenav", - template: "addons/activetasks/templates/tabs", + tagName: 'nav', + className: 'sidenav', + template: 'addons/activetasks/templates/tabs', events: { - "click .task-tabs li": "requestByType", - "input #pollingRange": "changePollInterval" + 'click .task-tabs li': 'requestByType', + 'input #pollingRange': 'changePollInterval' }, serialize: function () { return { filters: { - "all": "All tasks", - "replication": "Replication", - "database_compaction":" Database Compaction", - "indexer": "Indexer", - "view_compaction": "View Compaction" + 'all': 'All tasks', + 'replication': 'Replication', + 'database_compaction': 'Database Compaction', + 'indexer': 'Indexer', + 'view_compaction': 'View Compaction' } }; }, - afterRender: function(){ + afterRender: function () { this.$('.task-tabs').find('li').eq(0).addClass('active'); }, @@ -152,7 +150,7 @@ function (app, FauxtonAPI, ActiveTasks) { requestByType: function(e){ var currentTarget = e.currentTarget, - filter = this.$(currentTarget).attr("data-type"); + filter = this.$(currentTarget).attr('data-type'); this.$('.task-tabs').find('li').removeClass('active'); this.$(currentTarget).addClass('active'); @@ -163,46 +161,46 @@ function (app, FauxtonAPI, ActiveTasks) { Views.TableDetail = FauxtonAPI.View.extend({ tagName: 'tr', - template: "addons/activetasks/templates/tabledetail", + template: 'addons/activetasks/templates/tabledetail', - initialize: function(){ + initialize: function () { this.type = this.model.get('type'); }, - getObject: function(){ + getObject: function () { var objectField = this.model.get('database'); - if (this.type === "replication"){ - objectField = this.model.get('source') + " to " + this.model.get('target'); - } else if (this.type === "indexer") { - objectField = this.model.get("database") + " (View: " + this.model.get("design_document") + ")"; + if (this.type === 'replication') { + objectField = this.model.get('source') + ' to ' + this.model.get('target'); + } else if (this.type === 'indexer') { + objectField = this.model.get('database') + ' (View: ' + this.model.get('design_document') + ')'; } return objectField; }, - getProgress: function(){ - var progress = ""; - if (this.type === "indexer"){ - progress = "Processed " +this.model.get('changes_done')+ " of "+this.model.get('total_changes')+ ' changes. '; - } else if (this.type === "replication"){ - progress = this.model.get('docs_written')+ " docs written. "; - if (this.model.get('changes_pending') !== undefined) { + getProgress: function () { + var progress = ''; + if (this.type === 'indexer') { + progress = 'Processed ' + this.model.get('changes_done') + ' of ' + this.model.get('total_changes') + ' changes. '; + } else if (this.type === 'replication') { + progress = this.model.get('docs_written')+ ' docs written. '; + if (!_.isUndefined(this.model.get('changes_pending'))) { progress += this.model.get('changes_pending') + ' pending changes. '; } } - if (this.model.get('source_seq') !== undefined) { - progress += "Current source sequence: " + this.model.get('source_seq') + ". "; + if (!_.isUndefined(this.model.get('source_seq'))) { + progress += 'Current source sequence: ' + this.model.get('source_seq') + '. '; } - if (this.model.get('changes_done') !== undefined) { - progress += this.model.get('changes_done') + " Changes done. "; + if (!_.isUndefined(this.model.get('changes_done'))) { + progress += this.model.get('changes_done') + ' Changes done. '; } - if (this.model.get('progress') !== undefined) { - progress += "Progress: " + this.model.get('progress') + "% "; + if (!_.isUndefined(this.model.get('progress'))) { + progress += 'Progress: ' + this.model.get('progress') + '% '; } return progress; }, - serialize: function(){ + serialize: function () { return { model: this.model, objectField: this.getObject(), @@ -212,14 +210,14 @@ function (app, FauxtonAPI, ActiveTasks) { }); Views.TabHeader = FauxtonAPI.View.extend({ - template: "addons/activetasks/templates/tab_header", + template: 'addons/activetasks/templates/tab_header', events: { - "keyup input": "searchDb", - "click .js-toggle-filter": "toggleQuery" + 'keyup input': 'searchDb', + 'click .js-toggle-filter': 'toggleQuery' }, - toggleQuery: function (event) { + toggleQuery: function () { $('#dashboard-content').scrollTop(0); this.$('#query').toggle('slow'); },
