Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends layout
- block bodyScripts
- script(type='text/javascript').
- $(document).ready(function(){
- $('#approvalsGrid').jsGrid({
- width: "100%", pageSize: 10, sorting: true, paging: true, filtering: true, autoload: true,
- controller: {
- loadData: function (filter) {
- var d = $.Deferred();
- $.ajax({
- url: "/admin/approvals",
- data: filter,
- dataType: "json"
- }).done(function(result) {
- if (isEmptyGridFilter(filter)) {
- data = result.approvals
- }
- else {
- data = $.grep(result.approvals, function (item) {
- if (applyGridFilter(filter, item))
- return item;
- });
- }
- d.resolve(data);
- });
- return d.promise();
- }
- },
- fields: [
- { name: "user.email", type: "text", title: "User",
- itemTemplate: function (value, item) {
- return $("<a>").attr("href", "/users/" + item.user.id).text(value);
- }
- },
- { name: "application.name", type: "text", title: "Application",
- itemTemplate: function(value, item) {
- return $("<a>").attr("href", "/applications/"+item.application.id).text(value);
- }
- },
- { name: "application.trusted", type: "text", title: "Trusted", width: "4%",
- itemTemplate: function (value, item) {
- return item.application.trusted ? 'Yes' : '-';
- }
- },
- { name: "api.id", type: "text", title: "API",
- itemTemplate: function(value, item) {
- return $("<a>").attr("href", "/apis/"+item.api.id).text(value);
- }
- },
- { name: "plan.name", type: "text", title: "Plan" },
- { type: "actions", type: "control", width: "100",
- _createFilterSwitchButton: function() {
- return this._createOnOffSwitchButton("filtering", this.searchModeButtonClass, false);
- },
- itemTemplate: function(value,item) {
- var $form = $("<form>").attr("role", "form").attr("method","post")
- .append("<input type='hidden' name='id' value='" + item.id + "'>")
- .append("<input type='hidden' name='api' value='" + item.api.id + "'>")
- .append("<input type='hidden' name='app' value='" + item.application.id + "'>");
- var $approveBtn = $("<button>").attr("type", "submit")
- .attr("class", "btn btn-sm btn-success")
- .attr("style", "float: left; margin: 2px; width: 6em")
- .text("Approve")
- .on("click", function () {
- $.ajax({
- url: "/admin/approvals/approve",
- type: "POST",
- dataType: "json",
- data: {
- id: item.id,
- app: item.application.id,
- api: item.api.id
- }
- }).done(function(result) {
- $("#approvalsGrid").jsGrid("loadData");
- });
- });
- var $declineBtn = $("<button>").attr("type", "submit")
- .attr("class", "btn btn-sm btn-danger")
- .attr("style", "float: left; margin: 2px; width: 6em")
- .text("Decline")
- .on("click", function () {
- $.ajax({
- url: "/admin/approvals/decline",
- type: "POST",
- dataType: "json",
- data: {
- id: item.id,
- app: item.application.id,
- api: item.api.id
- }
- }).done(function(result) {
- $("#approvalsGrid").jsGrid("loadData");
- });
- });
- return $("<td nowrap>").append($approveBtn)
- .append("<span> </span>")
- .append($declineBtn)
- .append($form);
- }
- }
- ]
- });
- $("#approvalsGrid").jsGrid("option", "filtering", false);
- });
- block content
- .jumbotron.wicked-admin-title
- .container.wicked-title-container
- h1 Pending Subscription Approvals
- p Please review the pending subscription approvals. You may either approve of or decline the subscription.
- .container.wicked-container
- if approvals.length == 0
- h3 No pending approvals
- else
- p Before approving of "trusted" subscriptions, <a href="/help/trusted" target="_blank">please be aware of the impliciations</a>.
- div#approvalsGrid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement