PageRenderTime 49ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/aeolus-conductor-0.10.5/src/public/javascripts/backbone/models.js

#
JavaScript | 87 lines | 77 code | 10 blank | 0 comment | 4 complexity | 722c7a591d2322ab708aec35652896c3 MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, MPL-2.0-no-copyleft-exception
  1. Conductor.Models = Conductor.Models || {}
  2. Conductor.Models.UserInfo = Backbone.Model.extend({});
  3. Conductor.Models.Pool = Backbone.Model.extend({
  4. initialize: function() {
  5. this.deployments = new Conductor.Models.Deployments().filter(function(attributes) {
  6. return attributes.pool.id == this.id;
  7. });
  8. },
  9. queryParams: {},
  10. url: function() {
  11. var path = Conductor.prefixedPath('/pools/' + this.id);
  12. return Conductor.parameterizedPath(path, this.queryParams);
  13. }
  14. });
  15. Conductor.Models.Pools = Backbone.Collection.extend({
  16. model: Backbone.Model.Pool,
  17. queryParams: {},
  18. parse: function(response) {
  19. this.userInfo = new Conductor.Models.UserInfo(response.user_info);
  20. return response.collection;
  21. },
  22. url: function() {
  23. var path = Conductor.prefixedPath('/pools');
  24. return Conductor.parameterizedPath(path, this.queryParams);
  25. }
  26. });
  27. Conductor.Models.Instance = Backbone.Model.extend({
  28. urlRoot: Conductor.prefixedPath('/instances')
  29. });
  30. Conductor.Models.Instances = Backbone.Collection.extend({
  31. model: Backbone.Model.Instance,
  32. queryParams: {},
  33. url: function() {
  34. var path = Conductor.prefixedPath('/instances');
  35. return Conductor.parameterizedPath(path, this.queryParams);
  36. }
  37. });
  38. Conductor.Models.Deployable = Backbone.Model.extend({
  39. initialize: function(options) {
  40. this.catalog_id = options['catalog_id']
  41. },
  42. url: function() {
  43. if( this.catalog_id == null ){
  44. return Conductor.prefixedPath('/deployables/' + this.id);
  45. }
  46. else{
  47. return Conductor.prefixedPath('/catalogs/' + this.catalog_id + '/deployables/' + this.id);
  48. }
  49. }
  50. });
  51. Conductor.Models.Deployment = Backbone.Model.extend({
  52. urlRoot: Conductor.prefixedPath('/deployments'),
  53. queryParams: {},
  54. initialize: function() {
  55. this.instances = new Conductor.Models.Instances();
  56. var self = this;
  57. this.instances.url = function() {
  58. var path = self.urlRoot + '/' + self.id + '/instances';
  59. return Conductor.parameterizedPath(path, self.queryParams);
  60. };
  61. }
  62. });
  63. Conductor.Models.Deployments = Backbone.Collection.extend({
  64. model: Backbone.Model.Deployment,
  65. queryParams: {},
  66. url: function() {
  67. var path = Conductor.prefixedPath('/deployments');
  68. return Conductor.parameterizedPath(path, this.queryParams);
  69. }
  70. });
  71. Conductor.Models.Image = Backbone.Model.extend({
  72. queryParams: {},
  73. url: function() {
  74. var path = Conductor.prefixedPath('/images/' + this.id);
  75. return Conductor.parameterizedPath(path, this.queryParams);
  76. }
  77. });