"use strict";
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var _ = require('lodash');
var Action = require('./actionNames');
var buildInfo = require('./buildInfo.json');
/**
* Override config values at runtime in dashboard.json, see: https://gitlab.com/lobaro/iot-dashboard/wikis/home#configuration
*/
var defaultConfig = {
version: "",
revision: "",
revisionShort: "",
branch: "",
persistenceTarget: "local-storage",
devMode: true,
auth: {
username: null,
logoutUrl: null
},
title: {
text: "IoT-Dashboard",
url: "http://iot-dashboard.org"
},
pluginRegistryApiKey: "",
pluginRegistryUrl: "https://dashboard.lobaro.com"
};
function setConfigValue(key, value) {
return {
type: Action.SET_CONFIG_VALUE,
key: key,
value: value
};
}
exports.setConfigValue = setConfigValue;
function config(state, action) {
if (state === void 0) { state = buildInfo; }
switch (action.type) {
case Action.SET_CONFIG_VALUE: {
var value = action.value;
if (action.key === 'pluginRegistryUrl' && _.endsWith(value, '/')) {
value = value.replace(/\/+$/, "");
}
return _.assign({}, defaultConfig, state, (_a = {}, _a[action.key] = value, _a), buildInfo);
}
default:
// Content of configJson overrides everything else!
return _.assign({}, defaultConfig, state, buildInfo);
}
var _a;
}
exports.config = config;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = config;
|