PageRenderTime 43ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Nancy/Diagnostics/Resources/Modules/tracing/traces.js

http://github.com/NancyFx/Nancy
JavaScript | 81 lines | 60 code | 21 blank | 0 comment | 0 complexity | dcc9a2bbb0f67dbfbd9c5dc56f319c00 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, LGPL-3.0, Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.0, BSD-3-Clause
  1. (function (Trace) {
  2. var app = diagnostics.app;
  3. Trace.Model = Backbone.Model.extend({});
  4. Trace.Collection = Backbone.Collection.extend({
  5. model: Trace.Model,
  6. initialize: function (opts) {
  7. this.id = opts.id;
  8. },
  9. url: function () {
  10. return Nancy.config.basePath + "trace/sessions/" + this.id;
  11. }
  12. });
  13. Trace.Views.List = Backbone.View.extend({
  14. el: '#main',
  15. events: {
  16. 'click #back': 'back'
  17. },
  18. initialize: function () {
  19. this.router = app.router;
  20. this.template = $("#traceList").html();
  21. },
  22. render: function () {
  23. var traces = this.model.toJSON();
  24. var html = Handlebars.compile(this.template)({ collection: traces });
  25. $(this.el).html(html);
  26. _.each(traces, this.renderItem, this);
  27. },
  28. renderItem: function (model) {
  29. var itemView = new Trace.Views.Item({ model: model });
  30. this.$('#root').append(itemView.el);
  31. },
  32. back: function () {
  33. this.router.navigate("", true);
  34. }
  35. });
  36. Trace.Views.Item = Backbone.View.extend({
  37. className: 'item-list',
  38. events: {
  39. 'click': 'viewDetails'
  40. },
  41. initialize: function (args) {
  42. this.template = $("#trace").html();
  43. this.render();
  44. },
  45. render: function () {
  46. var html = Handlebars.compile(this.template)({ model: this.model });
  47. $(this.el).append(html);
  48. },
  49. viewDetails: function () {
  50. var details = new Trace.Views.Details({ model: this.model });
  51. details.render();
  52. }
  53. });
  54. Trace.Views.Details = Backbone.View.extend({
  55. el: '#details',
  56. render: function () {
  57. $(this.el).html("<div class=\"modelreport\">" + _.modelreport(this.model) + "</div>");
  58. }
  59. });
  60. })(diagnostics.module("trace"));