From 8f81f2bb01ab8ce893b291f7b2897522ce4b56e7 Mon Sep 17 00:00:00 2001 From: dilanua Date: Fri, 22 Jul 2016 18:23:02 +0530 Subject: [PATCH] Refactoring data-tables-invoker-api --- .../devicemgt/api/data-tables-invoker-api.jag | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag index 88babb54f0f..f118862bf16 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/api/data-tables-invoker-api.jag @@ -25,24 +25,21 @@ var uriMatcher = new URIMatcher(String(uri)); var devicemgtProps = require("/app/conf/devicemgt-props.js").config(); var serviceInvokers = require("/app/modules/backend-service-invoker.js")["backendServiceInvoker"]; -if (uriMatcher.match("/{context}/api/data-tables/invoker")) { - var url = request.getParameter("url"); - var targetURL; - var payload = request.getContent(); - - function appendQueryParam (url, queryParam , value) { - if (url.indexOf("?") > 0) { - return url + "&" + queryParam + "=" + value; - } - return url + "?" + queryParam + "=" + value; +function appendQueryParam (url, queryParam , value) { + if (url.indexOf("?") > 0) { + return url + "&" + queryParam + "=" + value; } - targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); + return url + "?" + queryParam + "=" + value; +} +if (uriMatcher.match("/{context}/api/data-tables/invoker")) { + var url = request.getParameter("url"); + var targetURL = devicemgtProps["httpsURL"] + request.getParameter("url"); var allParams = request.getAllParameters(); for (var key in allParams) { if (allParams.hasOwnProperty(key)) { - if(key == "limit" || key == "offset" || key == "filter"){ + if (key == "limit" || key == "offset" || key == "filter") { targetURL = appendQueryParam(targetURL, key, allParams[key]); } }