Rev 27754 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(document).on('click', ".create-api", function() {loadCreateApi("main-content");});$(document).on('click', ".create-api-button", function() {var name = $('#apiName').val();var uri = $('#uri').val();var method = $('#api-methods option:selected').val();createApi("main-content", name, uri, method);});$(document).on('click', ".edit-api", function() {loadEditApi("main-content");});$(document).on('click', ".addBrand", function() {doPostAjaxRequestHandler(context+ "/addBrands", function(response) {console.log(response);if (response == 'true') {alert(success);}});});$(document).on('change', '#apis-for-edit', function() {var apiText = $('#apis-for-edit option:selected').text();var apiTexts = apiText.split('[');var name = apiTexts[0].trim();var uri = apiTexts[1].substring(0, apiTexts[1].length - 1);var method = apiTexts[2].substring(0, apiTexts[2].length - 1);$('#apiName').val(name);$('#uri').val(uri);$('#api-methods').val(method);//$('#apiName').val(roleName);});$(document).on('click', ".edit-api-button", function() {var apiId = $('#apis-for-edit').val();var apiName = $('#apiName').val();var uri = $('#uri').val();var method = $('#api-methods option:selected').text();editApi("main-content", apiId, apiName, uri, method);});$(document).on('click', ".delete-api", function() {loadDeleteApi("main-content");});$(document).on('click', ".delete-api-button", function() {var apiId = $('#apis-for-delete').val();deleteApi("main-content", apiId);});$(document).on('click', ".create-role", function() {loadCreateRole("main-content");});$(document).on('click', ".create-role-button", function() {var roleName = $('#roleName').val();createRole("main-content", roleName);});$(document).on('click', ".create-duplicate-role", function() {loadCreateDuplicateRole("main-content");});$(document).on('change', '#roles-for-duplicate', function() {var roleName = $('#roles-for-duplicate option:selected').text();$('#roleName').val(roleName + "2");});$(document).on('click', ".create-duplicate-role-button", function() {console.log("create duplicate role button clicked");var roleId = $('#roles-for-duplicate').val();var roleName = $('#roleName').val();createDuplicateRole("main-content", roleId, roleName);});$(document).on('click', ".delete-role", function() {loadDeleteRole("main-content");});$(document).on('click', ".delete-role-button", function() {var roleId = $('#roles-for-delete').val();deleteRole("main-content", roleId);});$(document).on('click', ".rename-role", function() {loadRenameRole("main-content");});$(document).on('change', '#roles-for-rename', function() {var roleName = $('#roles-for-rename option:selected').text();$('#roleName').val(roleName);});$(document).on('click', ".rename-role-button", function() {var roleId = $('#roles-for-rename').val();var roleName = $('#roleName').val();renameRole("main-content", roleId, roleName);});$(document).on('click', ".add-remove-api", function() {loadAddRemoveApi("main-content");});$(document).on('click', ".add-remove-role", function() {loadAddRemoveRole("main-content");});$(document).on('change', '#api-roles', function() {//$('#tag-listing-brand-value').text($(this).text());loadApisByRoleId("apis-container", $(this).val());});$(document).on('click', ".add-remove-api-button", function() {var roleId = $('#api-roles').val();var roleName = $('#api-roles option:selected').text();var apiIds = $('#apis').val();addRemoveApis("main-content", roleId, apiIds);//$('#api-roles option:selected').text(roleName);});$(document).on('click', ".add-remove-role-button", function() {var emailIdOrMobileNumber = $('#emailIdOrMobileNumber').val();var roleIds = $('#roles').val();addRemoveRoles("main-content", emailIdOrMobileNumber, roleIds);});});function getRolesByEmailIdOrMobileNumber() {var emailIdOrMobileNumber = $('#emailIdOrMobileNumber').val();console.log("emailIdOrMobileNumber = " + emailIdOrMobileNumber);if (emailIdOrMobileNumber != "") {loadRolesByEmailIdOrMobileNumber("roles-container", emailIdOrMobileNumber);}}function loadCreateApi(domId) {doGetAjaxRequestHandler(context + "/createApi", function(response) {$('#' + domId).html(response);});}function loadEditApi(domId) {doGetAjaxRequestHandler(context + "/editApi", function(response) {$('#' + domId).html(response);});}function loadDeleteApi(domId) {doGetAjaxRequestHandler(context + "/deleteApi", function(response) {$('#' + domId).html(response);});}function loadCreateRole(domId) {doGetAjaxRequestHandler(context + "/createRole", function(response) {$('#' + domId).html(response);});}function loadCreateDuplicateRole(domId) {doGetAjaxRequestHandler(context + "/createDuplicateRole", function(response) {$('#' + domId).html(response);});}function loadDeleteRole(domId) {doGetAjaxRequestHandler(context + "/deleteRole", function(response) {$('#' + domId).html(response);});}function loadRenameRole(domId) {doGetAjaxRequestHandler(context + "/renameRole", function(response) {$('#' + domId).html(response);});}function loadAddRemoveApi(domId) {doGetAjaxRequestHandler(context + "/addRemoveApi", function(response) {$('#' + domId).html(response);});}function loadAddRemoveRole(domId) {doGetAjaxRequestHandler(context + "/addRemoveRole", function(response) {$('#' + domId).html(response);});}function loadApisByRoleId(domId, roleId) {doGetAjaxRequestHandler(context + "/roleApis?roleId=" + roleId, function(response) {$('#' + domId).html(response);configureRoleApisDropDown();});}function loadRolesByEmailIdOrMobileNumber(domId, emailIdOrMobileNumber) {doGetAjaxRequestHandler(context + "/userRoles?emailIdOrMobileNumber=" + emailIdOrMobileNumber, function(response) {$('#' + domId).html(response);configureUserRolesDropDown();});}function configureApisForEditDropDown() {$(document).ready(function() {$('#apis-for-edit').multiselect({multiple: false,includeSelectAllOption: true,maxHeight: 200,buttonWidth: '380px',numberDisplayed: 1,nonSelectedText: 'Apis',nSelectedText: ' - Apis Selected',allSelectedText: 'All Apis Selected',enableFiltering: true});});}function configureApisForDeleteDropDown() {$(document).ready(function() {$('#apis-for-delete').multiselect({multiple: false,includeSelectAllOption: true,maxHeight: 200,buttonWidth: '800px',numberDisplayed: 1,nonSelectedText: 'Apis',nSelectedText: ' - Apis Selected',allSelectedText: 'All Apis Selected',enableFiltering: true});});}function configureUserRolesDropDown() {$(document).ready(function() {$('#roles').multiselect({includeSelectAllOption: true,maxHeight: 200,buttonWidth: '280px',numberDisplayed: 1,nonSelectedText: 'Roles',nSelectedText: ' - Roles Selected',allSelectedText: 'All Roles Selected',enableFiltering: true});});}function configureRoleApisDropDown() {$(document).ready(function() {$('#apis').multiselect({includeSelectAllOption: true,maxHeight: 200,buttonWidth: '800px',numberDisplayed: 1,nonSelectedText: 'Apis',nSelectedText: ' - Apis Selected',allSelectedText: 'All Apis Selected',enableFiltering: true});});}function createApi(domId, name, uri, method) {if (name == "") {alert("Api name is required");return;}if (uri == "") {alert("Api uri is required");return;}if (method == "") {alert("Please choose api method");return;}var params = {"name": name,"uri": uri,"method": method}if (confirm("Are you sure you want to create Api!") == true) {doPostAjaxRequestWithParamsHandler(context + "/createApi", params, function(response) {$('#' + domId).html(response);});}}function editApi(domId, apiId, name, uri, method) {if (confirm("Are you sure you want to update api!") == true) {doPutAjaxRequestHandler(context + "/editApi?apiId=" + apiId + "&name=" + name + "&uri=" + uri + "&method=" + method, function(response) {$('#' + domId).html(response);});}}function deleteApi(domId, apiId) {if (confirm("Are you sure you want to delete api!") == true) {doDeleteAjaxRequestHandler(context + "/deleteApi?apiId=" + apiId, function(response) {$('#' + domId).html(response);});}}function createRole(domId, name) {var params = {"name": name}if (confirm("Are you sure you want to create Role!") == true) {doPostAjaxRequestWithParamsHandler(context + "/createRole", params, function(response) {$('#' + domId).html(response);});}}function createDuplicateRole(domId, roleId, name) {var params = {"roleId": roleId,"name": name}if (confirm("Are you sure you want to create duplicate role!") == true) {doPostAjaxRequestWithParamsHandler(context + "/createDuplicateRole", params, function(response) {$('#' + domId).html(response);});}}function deleteRole(domId, roleId) {if (confirm("Are you sure you want to delete role!") == true) {doDeleteAjaxRequestHandler(context + "/deleteRole?roleId=" + roleId, function(response) {$('#' + domId).html(response);});}}function renameRole(domId, roleId, name) {if (confirm("Are you sure you want to rename role!") == true) {doPutAjaxRequestHandler(context + "/renameRole?roleId=" + roleId + "&name=" + name, function(response) {$('#' + domId).html(response);});}}function addRemoveApis(domId, roleId, apiIds) {if (confirm("Are you sure you want to add or remove apis!") == true) {doPostAjaxRequestWithJsonHandler(context + "/addRemoveApis?roleId=" + roleId, JSON.stringify(apiIds), function(response) {$('#' + domId).html(response);$('#api-roles').val(roleId);$('#api-roles').change();});}}function addRemoveRoles(domId, emailIdOrMobileNumber, roleIds) {if (confirm("Are you sure you want to add or remove roles!") == true) {doPostAjaxRequestWithJsonHandler(context + "/addRemoveRoles?emailIdOrMobileNumber=" + emailIdOrMobileNumber, JSON.stringify(roleIds), function(response) {$('#' + domId).html(response);$('#emailIdOrMobileNumber').val(emailIdOrMobileNumber);getRolesByEmailIdOrMobileNumber();});}}