Sha256: 0196f216114ec68ed78b0ba85cd75906cabdb368c955bd29415eb0788066a043

Contents?: true

Size: 1.45 KB

Versions: 23

Compression:

Stored size: 1.45 KB

Contents

define(
[
    'jquery',
    'underscore',
    'backbone',
    'model/monitor'
],
function(
    $,
    _,
    Backbone,
    MonitorModel
) {
    /**
     * MonitorCollection
     *
     * Route that pulls back all available monitors.
     * NOTE : jobs & monitors are synonymous in this web application
     *        context. Dash & dashboard are synonymous as well.
     **/
    var MonitorCollection = Backbone.Collection.extend({
        model : MonitorModel,
        url : function() {
            return ( this.dashboardId ) ? '/dashboards/' + this.dashboardId + '/jobs.json' : '/jobs.json';
        },
        initialize : function(models, options) {
            _.bindAll(this, 'url');

            this.dashboardId = options.dashboardId;
            this.cb          = options.cb;

            this.fetch({
                success : function(result) {
                    if ( this.cb ) this.cb(result);
                }.bind(this),
                async : false
            });
        },
        filterById: function(orderArray) {
            var filteredOrder = [];
            _.each(orderArray, function(monitorId) {
                if(!_.isUndefined(this.get(monitorId))) { 
                    filteredOrder.push(monitorId);
                }
            }, this);
            return this.reset(_.map(filteredOrder, function(monitorId) { 
                    return this.get(monitorId); 
            }, this));  
        }
    });

    return MonitorCollection;
});

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rearview-1.2.3-jruby public/rearview-src/js/collection/monitor.js
rearview-1.2.2.rc.2-jruby public/rearview-src/js/collection/monitor.js
rearview-1.2.2.rc.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.2.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.2.0-jruby public/rearview-src/js/collection/monitor.js
rearview-1.1.2-jruby public/rearview-src/js/collection/monitor.js
rearview-1.1.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.1.0-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.3.rc.4-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.3.rc.3-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.3.rc.2-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.3.rc.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.2-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.2.rc.4-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.2.rc.3-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.2.rc.2-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.2.rc.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.1-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.0-jruby public/rearview-src/js/collection/monitor.js
rearview-1.0.0.rc5-jruby public/rearview-src/js/collection/monitor.js