ReplicationAuditTableLayoutView.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. define([ "require", "backbone", "hbs!tmpl/audit/ReplicationAuditTableLayoutView_tmpl", "utils/CommonViewFunction", "utils/Utils", "collection/VSearchList", "collection/VEntityList", "utils/Messages", "utils/UrlLinks" ], function(require, Backbone, ReplicationAuditTableLayoutView_tmpl, CommonViewFunction, Utils, VSearchList, VEntityList, Messages, UrlLinks) {
  2. "use strict";
  3. var ReplicationAuditTableLayoutView = Backbone.Marionette.LayoutView.extend({
  4. _viewName: "ReplicationAuditTableLayoutView",
  5. template: ReplicationAuditTableLayoutView_tmpl,
  6. regions: {
  7. RReplicationAuditTableLayoutView: "#r_replicationAuditTableLayoutView"
  8. },
  9. ui: {},
  10. events: function() {
  11. var events = {};
  12. return events;
  13. },
  14. initialize: function(options) {
  15. _.extend(this, _.pick(options, "entity", "entityName", "attributeDefs")), this.searchCollection = new VSearchList(),
  16. this.entityModel = new (new VEntityList().model)(), this.limit = 25, this.offset = 0,
  17. this.name = Utils.getName(this.entity), this.commonTableOptions = {
  18. collection: this.searchCollection,
  19. includePagination: !1,
  20. includeAtlasPagination: !0,
  21. includeFooterRecords: !1,
  22. includeColumnManager: !1,
  23. includeOrderAbleColumns: !1,
  24. includeSizeAbleColumns: !1,
  25. includeTableLoader: !0,
  26. includeAtlasPageSize: !0,
  27. includeAtlasTableSorting: !0,
  28. atlasPaginationOpts: {
  29. limit: this.limit,
  30. offset: this.offset,
  31. fetchCollection: this.fetchCollection.bind(this)
  32. },
  33. gridOpts: {
  34. emptyText: "No Record found!",
  35. className: "table table-hover backgrid table-quickMenu colSort"
  36. },
  37. filterOpts: {},
  38. paginatorOpts: {}
  39. };
  40. },
  41. bindEvents: function() {},
  42. onRender: function() {
  43. this.renderTableLayoutView();
  44. },
  45. fetchCollection: function(options) {
  46. var that = this;
  47. this.searchCollection.getExpimpAudit(this.searchCollection.queryParams, {
  48. success: function(response) {
  49. that.searchCollection.reset(response, options);
  50. }
  51. });
  52. },
  53. renderTableLayoutView: function() {
  54. var that = this;
  55. require([ "utils/TableLayout" ], function(TableLayout) {
  56. var columnCollection = Backgrid.Columns.extend({
  57. sortKey: "displayOrder",
  58. comparator: function(item) {
  59. return item.get(this.sortKey) || 999;
  60. },
  61. setPositions: function() {
  62. return _.each(this.models, function(model, index) {
  63. model.set("displayOrder", index + 1, {
  64. silent: !0
  65. });
  66. }), this;
  67. }
  68. }), columns = new columnCollection(that.getColumn());
  69. columns.setPositions().sort(), that.RReplicationAuditTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
  70. columns: columns
  71. }))), _.extend(that.searchCollection.queryParams, {
  72. limit: that.limit,
  73. offset: that.offset,
  74. serverName: that.name
  75. }), that.fetchCollection(_.extend({
  76. fromUrl: !0
  77. }));
  78. });
  79. },
  80. getColumn: function(argument) {
  81. var that = this, col = {};
  82. return col.tools = {
  83. label: "",
  84. cell: "html",
  85. editable: !1,
  86. sortable: !1,
  87. fixWidth: "20",
  88. cell: Backgrid.ExpandableCell,
  89. accordion: !1,
  90. expand: function(el, model) {
  91. el.attr("colspan", "6");
  92. var result = JSON.parse(model.get("resultSummary")), view = "<table class='table table-bordered table-striped'>" + CommonViewFunction.propertyTable({
  93. scope: that,
  94. valueObject: result,
  95. attributeDefs: that.attributeDefs
  96. }) + "</table>";
  97. $(el).append($("<div>").html(view));
  98. }
  99. }, col.operation = {
  100. label: "Operation",
  101. cell: "string",
  102. editable: !1,
  103. sortable: !1,
  104. className: "searchTableName"
  105. }, col.sourceServerName = {
  106. label: "Source Server",
  107. cell: "string",
  108. editable: !1,
  109. sortable: !1,
  110. className: "searchTableName"
  111. }, col.targetServerName = {
  112. label: "Target Server",
  113. cell: "string",
  114. editable: !1,
  115. sortable: !1,
  116. className: "searchTableName"
  117. }, col.startTime = {
  118. label: "Operation StartTime",
  119. cell: "html",
  120. editable: !1,
  121. sortable: !1,
  122. formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
  123. fromRaw: function(rawValue, model) {
  124. return rawValue ? Utils.formatDate({
  125. date: rawValue
  126. }) : "-";
  127. }
  128. })
  129. }, col.endTime = {
  130. label: "Operation EndTime",
  131. cell: "html",
  132. editable: !1,
  133. sortable: !1,
  134. formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
  135. fromRaw: function(rawValue, model) {
  136. return rawValue ? Utils.formatDate({
  137. date: rawValue
  138. }) : "-";
  139. }
  140. })
  141. }, this.searchCollection.constructor.getTableCols(col, this.searchCollection);
  142. }
  143. });
  144. return ReplicationAuditTableLayoutView;
  145. });