Advertisement
MindKooper

Untitled

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