2019-09-12 21:58:57 +02:00
|
|
|
let config = {};
|
2019-07-14 07:50:53 +02:00
|
|
|
|
2019-09-12 21:58:57 +02:00
|
|
|
const setConf = function(cnf) {
|
2019-07-21 11:09:22 +02:00
|
|
|
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
2019-09-12 21:58:57 +02:00
|
|
|
const lvl1Keys = Object.keys(cnf);
|
2019-07-21 11:09:22 +02:00
|
|
|
for (let i = 0; i < lvl1Keys.length; i++) {
|
|
|
|
if (typeof cnf[lvl1Keys[i]] === 'object' && cnf[lvl1Keys[i]] != null) {
|
2019-09-12 21:58:57 +02:00
|
|
|
const lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
2019-07-21 11:09:22 +02:00
|
|
|
|
|
|
|
for (let j = 0; j < lvl2Keys.length; j++) {
|
|
|
|
// logger.debug('Setting conf ', lvl1Keys[i], '-', lvl2Keys[j])
|
|
|
|
if (typeof config[lvl1Keys[i]] === 'undefined') {
|
2019-09-12 21:58:57 +02:00
|
|
|
config[lvl1Keys[i]] = {};
|
2019-07-21 11:09:22 +02:00
|
|
|
}
|
|
|
|
// logger.debug('Setting config: ' + lvl1Keys[i] + ' ' + lvl2Keys[j] + ' to ' + cnf[lvl1Keys[i]][lvl2Keys[j]])
|
2019-09-12 21:58:57 +02:00
|
|
|
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
2019-07-21 11:09:22 +02:00
|
|
|
}
|
|
|
|
} else {
|
2019-09-12 21:58:57 +02:00
|
|
|
config[lvl1Keys[i]] = cnf[lvl1Keys[i]];
|
2019-07-21 11:09:22 +02:00
|
|
|
}
|
|
|
|
}
|
2019-09-12 21:58:57 +02:00
|
|
|
};
|
2019-07-21 11:09:22 +02:00
|
|
|
|
2019-07-14 07:50:53 +02:00
|
|
|
export const setConfig = conf => {
|
2019-09-12 21:58:57 +02:00
|
|
|
setConf(conf);
|
|
|
|
};
|
|
|
|
export const getConfig = () => config;
|
2019-10-11 15:39:50 +02:00
|
|
|
|
|
|
|
const configApi = {
|
|
|
|
setConfig,
|
|
|
|
getConfig
|
|
|
|
// get conf() {
|
|
|
|
// return config;
|
|
|
|
// }
|
|
|
|
};
|
|
|
|
export default configApi;
|