Advertisement
MindKooper

Untitled

Jun 24th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  1. extends layout
  2.  
  3. block bodyScripts
  4. script(type='text/javascript').
  5. $(document).ready(function(){
  6. $('#approvalsGrid').jsGrid({
  7. width: "100%", pageSize: 10, sorting: true, paging: true, filtering: true, autoload: true,
  8. controller: {
  9. loadData: function (filter) {
  10. var d = $.Deferred();
  11. $.ajax({
  12. url: "/admin/approvals",
  13. data: filter,
  14. dataType: "json"
  15. }).done(function(result) {
  16. if (isEmptyGridFilter(filter)) {
  17. data = result.approvals
  18. }
  19. else {
  20. data = $.grep(result.approvals, function (item) {
  21. if (applyGridFilter(filter, item))
  22. return item;
  23. });
  24. }
  25. d.resolve(data);
  26. });
  27. return d.promise();
  28. }
  29. },
  30. fields: [
  31. { name: "user.email", type: "text", title: "User",
  32. itemTemplate: function (value, item) {
  33. return $("<a>").attr("href", "/users/" + item.user.id).text(value);
  34. }
  35. },
  36. { name: "application.name", type: "text", title: "Application",
  37. itemTemplate: function(value, item) {
  38. return $("<a>").attr("href", "/applications/"+item.application.id).text(value);
  39. }
  40. },
  41. { name: "application.trusted", type: "text", title: "Trusted", width: "4%",
  42. itemTemplate: function (value, item) {
  43. return item.application.trusted ? 'Yes' : '-';
  44. }
  45. },
  46. { name: "api.id", type: "text", title: "API",
  47. itemTemplate: function(value, item) {
  48. return $("<a>").attr("href", "/apis/"+item.api.id).text(value);
  49. }
  50. },
  51. { name: "plan.name", type: "text", title: "Plan" },
  52. { type: "actions", type: "control", width: "100",
  53. _createFilterSwitchButton: function() {
  54. return this._createOnOffSwitchButton("filtering", this.searchModeButtonClass, false);
  55. },
  56. itemTemplate: function(value,item) {
  57. var $form = $("<form>").attr("role", "form").attr("method","post")
  58. .append("<input type='hidden' name='id' value='" + item.id + "'>")
  59. .append("<input type='hidden' name='api' value='" + item.api.id + "'>")
  60. .append("<input type='hidden' name='app' value='" + item.application.id + "'>");
  61. var $approveBtn = $("<button>").attr("type", "submit")
  62. .attr("class", "btn btn-sm btn-success")
  63. .attr("style", "float: left; margin: 2px; width: 6em")
  64. .text("Approve")
  65. .on("click", function () {
  66. $.ajax({
  67. url: "/admin/approvals/approve",
  68. type: "POST",
  69. dataType: "json",
  70. data: {
  71. id: item.id,
  72. app: item.application.id,
  73. api: item.api.id
  74. }
  75. }).done(function(result) {
  76. $("#approvalsGrid").jsGrid("loadData");
  77. });
  78. });
  79. var $declineBtn = $("<button>").attr("type", "submit")
  80. .attr("class", "btn btn-sm btn-danger")
  81. .attr("style", "float: left; margin: 2px; width: 6em")
  82. .text("Decline")
  83. .on("click", function () {
  84. $.ajax({
  85. url: "/admin/approvals/decline",
  86. type: "POST",
  87. dataType: "json",
  88. data: {
  89. id: item.id,
  90. app: item.application.id,
  91. api: item.api.id
  92. }
  93. }).done(function(result) {
  94. $("#approvalsGrid").jsGrid("loadData");
  95. });
  96. });
  97. return $("<td nowrap>").append($approveBtn)
  98. .append("<span>&nbsp;</span>")
  99. .append($declineBtn)
  100. .append($form);
  101. }
  102. }
  103. ]
  104. });
  105. $("#approvalsGrid").jsGrid("option", "filtering", false);
  106. });
  107. block content
  108. .jumbotron.wicked-admin-title
  109. .container.wicked-title-container
  110. h1 Pending Subscription Approvals
  111.  
  112. p Please review the pending subscription approvals. You may either approve of or decline the subscription.
  113.  
  114. .container.wicked-container
  115. if approvals.length == 0
  116. h3 No pending approvals
  117. else
  118.  
  119. p Before approving of "trusted" subscriptions, <a href="/help/trusted" target="_blank">please be aware of the impliciations</a>.
  120.  
  121. div#approvalsGrid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement