From d04cb54ae8412e4bf20ab4cde7277617f82256e3 Mon Sep 17 00:00:00 2001 From: dilanua Date: Sun, 24 Jul 2016 21:34:22 +0530 Subject: [PATCH] Refactoring base ui app config reader --- .../devicemgt/app/conf/reader/main.js | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/reader/main.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/reader/main.js index 219c6de62db..3e8797e2d3a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/reader/main.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/conf/reader/main.js @@ -17,24 +17,25 @@ */ var config = function () { - var conf = application.get("UI_CONFIG"); + var conf = application.get("UI_CONF"); if (!conf) { + conf = require("/app/conf/config.json"); var pinch = require("/app/conf/reader/pinch.min.js")["pinch"]; - var config = require("/app/conf/config.json"); var server = require("carbon")["server"]; - pinch(config, /^/, function (path, key, value) { - if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) { - return value.replace("%https.ip%", server.address("https")); - } else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) { - return value.replace("%http.ip%", server.address("http")); - } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { - var year = new Date().getFullYear(); - return value.replace("%date-year%", year); + pinch(conf, /^/, + function (path, key, value) { + if ((typeof value === "string") && value.indexOf("%https.ip%") > -1) { + return value.replace("%https.ip%", server.address("https")); + } else if ((typeof value === "string") && value.indexOf("%http.ip%") > -1) { + return value.replace("%http.ip%", server.address("http")); + } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { + var year = new Date().getFullYear(); + return value.replace("%date-year%", year); + } + return value; } - return value; - }); - application.put("UI_CONFIG", config); - conf = config; + ); + application.put("UI_CONF", conf); } return conf; }; \ No newline at end of file