couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From garrensmith <...@git.apache.org>
Subject [GitHub] couchdb pull request: 2125 sort tasks refactor
Date Wed, 09 Apr 2014 07:39:53 GMT
Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb/pull/203#discussion_r11425423
  
    --- Diff: src/fauxton/app/addons/activetasks/resources.js ---
    @@ -12,104 +12,44 @@
     
     define([
       "app",
    -  "backbone",
       "addons/fauxton/base",
    -  "d3"
     ],
     
    -function (app, backbone, Fauxton) {
    +function (app, Fauxton) {
       var Active = {},
           apiv = app.versionAPI;
           app.taskSortBy = 'type';
     
    -  Active.Task = Backbone.Model.extend({
    -    initialize: function() { 
    -      this.set({"id": this.get('pid')});
    -    }
    -  });
    -
    -// ALL THE TASKS
    -  Active.Tasks = Backbone.Model.extend({
    -    alltypes: {
    -      "all": "All tasks",
    -      "replication": "Replication",
    -      "database_compaction":" Database Compaction",
    -      "indexer": "Indexer",
    -      "view_compaction": "View Compaction"
    -    },
    -    documentation: "_active_tasks",
    -    url: function (context) {
    -      if (context === "apiurl"){
    -        return window.location.origin + '/_active_tasks';
    -      } else {
    -        return app.host + '/_active_tasks';
    -      }
    -    },
    -    fetch: function (options) {
    -     var fetchoptions = options || {};
    -     fetchoptions.cache = false;
    -     return Backbone.Model.prototype.fetch.call(this, fetchoptions);
    -    },
    -    parse: function(resp){
    -      var types = this.getUniqueTypes(resp),
    -          that = this;
     
    -      var typeCollections = _.reduce(types, function (collection, val, key) {
    -          collection[key] = new Active.AllTasks(that.sortThis(resp, key));
    -          return collection;
    -        }, {});
    +  Active.events = {};
    +  _.extend(Active.events, Backbone.Events);
     
    -      typeCollections.all = new Active.AllTasks(resp);
    -
    -      this.set(typeCollections);  //now set them all to the model
    -    },
    -    getUniqueTypes: function(resp){
    -      var types = this.alltypes;
    -
    -      _.each(resp, function(type){
    -        if( typeof(types[type.type]) === "undefined"){
    -          types[type.type] = type.type.replace(/_/g,' ');
    -        }
    -      },this);
    -
    -      this.alltypes = types;
    -      return types;
    -    },
    -    sortThis: function(resp, type){
    -      return _.filter(resp, function(item) { return item.type === type; });
    -    },
    -    changeView: function (view){
    -      this.set({
    -        "currentView": view
    -      });
    -    },
    -    getCurrentViewData: function(){
    -      var currentView = this.get('currentView');
    -      return this.get(currentView);
    -    },
    -    getDatabaseCompactions: function(){
    -      return this.get('databaseCompactions');
    -    },
    -    getIndexes: function(){
    -      return this.get('indexes');
    -    },
    -    getViewCompactions: function(){
    -      return this.get('viewCompactions');
    +  Active.Task = Backbone.Model.extend({
    +    initialize: function () {
    +      this.set({"id": this.get('pid')});
    --- End diff --
    
    @robertkowalski you can set the idAttribute of a model so that you don't need to do this.
http://backbonejs.org/#Model-idAttribute


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message