From b39caade98dbd917138ec2adcb1d2735636487bc Mon Sep 17 00:00:00 2001 From: Rasika Perera Date: Thu, 19 Jan 2017 19:42:41 +0530 Subject: [PATCH] Adding system params picking up for app-conf.json --- .../jaggeryapps/uuf-template-app/lib/utils.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/utils.js b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/utils.js index c108e1e5bf..a7e006682d 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/utils.js +++ b/components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/uuf-template-app/lib/utils.js @@ -365,6 +365,23 @@ var utils = {}; content = content.replace(/\$\{server\.http_port}/g, getProperty("carbon.http.port")); content = content.replace(/\$\{server\.https_port}/g, getProperty("carbon.https.port")); + //parsing system params + var paramPattern = new RegExp("%(.*?)%", "g"); + var out = content; + while ((matches = paramPattern.exec(content)) !== null) { + // This is necessary to avoid infinite loops with zero-width matches + if (matches.index === paramPattern.lastIndex) { + paramPattern.lastIndex++; + } + if (matches.length == 2) { + var property = process.getProperty(matches[1]); + if (property) { + out = out.replace(new RegExp("%" + matches[1] + "%", "g"), property); + } + } + } + content = out; + var appConf = parse(content); application.put(constants.CACHE_KEY_APP_CONF, appConf); application.put(constants.CACHE_KEY_APP_CONF_FILE_LMD,