Sha256: adc6071f73660f3c6d9aacbaa0da39781123198cf686f4a510386fecd6f36bff

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

if (typeof $ === "undefined") { throw new Error("jQuery is required") }

Record.Layer = function(args) {
  var superArguments = Array.prototype.slice.call(arguments);
  superArguments.unshift("layer");
  Record.Generic.apply(this, superArguments);
}

Record.Layer.prototype = Object.create(Record.Generic.prototype);
Record.Layer.prototype.constructor = Record.Layer;

Record.Layer.prototype.fetch = function(callback) {
  var self = this;
  var id = this.id;

  function members(role) {
    return function(cb) {
      $.ajax({
        url: "/api/authz/" + conjurConfiguration.account + "/roles/" + role + "?members",
        success: function(result) { cb(null, result) },
        error: cb
      });
    }
  }

  async.parallel([
    this.attributes.bind(this),
    this.ownedResources.bind(this),
    members('@/layer/' + id + '/use_host'),
    members('@/layer/' + id + '/use_host')
  ],
  function(err, results) {
    if ( err )
      return errback(err);

    callback({ layer: results[0], owned: results[1], users: _.pluck(results[2], 'member'), admins: _.pluck(results[3], 'member') });
  });
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
conjur-asset-ui-api-1.2.0 public/js/models/layerRecord.js