PageRenderTime 62ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/pollapli/ui/static/pollapli/models/environments_models.js

https://bitbucket.org/kaosat_dev/pollapli
JavaScript | 35 lines | 33 code | 2 blank | 0 comment | 1 complexity | 9015a0b8daa2cd7e4ef206074d638836 MD5 | raw file
  1. var Environment = Backbone.Model.extend(
  2. {
  3. urlRoot : pollapli.mainUrl+'rest/environments',
  4. initialize: function()
  5. {
  6. this.nodes=new NodeCollection();
  7. this.tasks=new TaskCollection();
  8. this.nodes.url=pollapli.mainUrl+"rest/environments/"+this.id+"/tasks";
  9. this.tasks.url=pollapli.mainUrl+"rest/environments/"+this.id+"/nodes";
  10. },
  11. defaults:
  12. {
  13. name: 'Default environment',
  14. description: 'just an environment',
  15. status:'frozen',
  16. }
  17. });
  18. var EnvironmentCollection = Backbone.Collection.extend(
  19. {
  20. model : Environment,
  21. url: pollapli.mainUrl+'rest/environments',
  22. parse: function(response)
  23. {
  24. return response.environments.items;
  25. },
  26. frozen : function()
  27. {
  28. return this.filter(function(environment)
  29. {
  30. return environment.get('status') == 'frozen';
  31. });
  32. }
  33. });