Skip to content

Commit

Permalink
bsserverdemo: clean some bsconfigutil code
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed May 12, 2022
1 parent 430ade3 commit 31cd90b
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions leshan-bsserver-demo/webapp/src/js/bsconfigutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@

// convert config from rest API format to UI format :
// we regroup security and server data
var configFromRestToUI = function(config) {
var configFromRestToUI = function (config) {
var newConfig = { dm: [], bs: [] };
for (var i in config.security) {
var security = config.security[i];
if (security.bootstrapServer) {
newConfig.bs.push({ security: security });
} else {
newConfig.dm = [];
// search for DM information;
for (var j in config.servers) {
var server = config.servers[j];
Expand All @@ -29,16 +28,13 @@ var configFromRestToUI = function(config) {
server.security = security;
}
}
if (!newConfig.dm) {
newConfig.dm.push({ security: security });
}
}
}
newConfig.toDelete = config.toDelete;
newConfig.autoIdForSecurityObject = config.autoIdForSecurityObject;
return newConfig;
};
var configsFromRestToUI = function(configs) {
var configsFromRestToUI = function (configs) {
var newConfigs = [];
for (var endpoint in configs) {
var config = configFromRestToUI(configs[endpoint]);
Expand All @@ -49,7 +45,7 @@ var configsFromRestToUI = function(configs) {
};

//convert config from UI to rest API format:
var configFromUIToRest = function(c) {
var configFromUIToRest = function (c) {
// do a deep copy
// we should maybe rather use cloneDeep from lodashz
let config = JSON.parse(JSON.stringify(c));
Expand Down

0 comments on commit 31cd90b

Please sign in to comment.