Now UI configs supports system parameters with eg. %iot.core.host%

revert-dabc3590
Rasika Perera 8 years ago
parent a1d653fc39
commit 1d10dbee88

@ -33,8 +33,23 @@ var conf = function () {
} else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) {
var year = new Date().getFullYear(); var year = new Date().getFullYear();
return value.replace("%date-year%", year); return value.replace("%date-year%", year);
} else {
var paramPattern = new RegExp("%(.*?)%", "g");
var out = value;
while ((matches = paramPattern.exec(value)) !== 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);
}
}
}
return out;
} }
return value;
} }
); );
application.put("CONF", conf); application.put("CONF", conf);

@ -33,8 +33,23 @@ var conf = function () {
} else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) { } else if ((typeof value === "string") && value.indexOf("%date-year%") > -1) {
var year = new Date().getFullYear(); var year = new Date().getFullYear();
return value.replace("%date-year%", year); return value.replace("%date-year%", year);
} else {
var paramPattern = new RegExp("%(.*?)%", "g");
var out = value;
while ((matches = paramPattern.exec(value)) !== 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);
}
}
}
return out;
} }
return value;
} }
); );
application.put("CONF", conf); application.put("CONF", conf);

Loading…
Cancel
Save