/dashboard/app/scripts/collections/user-request-collection.js

https://github.com/hnuzhoulin/calamari-clients · JavaScript · 32 lines · 26 code · 3 blank · 3 comment · 2 complexity · 2cc893769410661ac36de8d5e97c7ead MD5 · raw file

  1. /*jshint -W106*/
  2. /*global define*/
  3. define(['underscore', 'backbone', 'models/user-request-model'], function(_, Backbone, UserRequestModel) {
  4. 'use strict';
  5. var UserRequestCollection = Backbone.Collection.extend({
  6. url: function() {
  7. return '/api/v2/cluster/' + this.cluster + '/request' + this.params;
  8. },
  9. parse: function(resp) {
  10. return resp.results;
  11. },
  12. model: UserRequestModel,
  13. params: '?page_size=32',
  14. initialize: function(models, options) {
  15. if (options && options.cluster) {
  16. this.cluster = options.cluster;
  17. }
  18. },
  19. // Only grab requests with state submitted
  20. getSubmitted: function(options) {
  21. this.params = '?state=submitted&page_size=32';
  22. var self = this;
  23. return this.fetch(options).always(function() {
  24. self.params = '?page_size=32';
  25. });
  26. }
  27. });
  28. return UserRequestCollection;
  29. });