diff --git a/libs/basic/utils.js b/libs/basic/utils.js index be6e92fd..ef66d23a 100644 --- a/libs/basic/utils.js +++ b/libs/basic/utils.js @@ -228,6 +228,18 @@ module.exports = (processCwd,config) => { return s; } + function setDefaultIfUndefined(config, key, defaultValue) { + const mustDoDefault = !config.userHasSubscribed; + if (Array.isArray(defaultValue)) { + if (config[key] === undefined || mustDoDefault) { + config[key] = [...defaultValue]; // Spread operator to clone the array + } + } else { + if (config[key] === undefined || mustDoDefault) { + config[key] = defaultValue; + } + } + } return { parseJSON: parseJSON, stringJSON: stringJSON, @@ -248,5 +260,6 @@ module.exports = (processCwd,config) => { asyncSetTimeout: asyncSetTimeout, copyFile: copyFile, hmsToSeconds, + setDefaultIfUndefined, } } diff --git a/libs/branding.js b/libs/branding.js index db7da985..d85efa29 100644 --- a/libs/branding.js +++ b/libs/branding.js @@ -1,46 +1,31 @@ module.exports = function(s,config,lang,app,io){ - if(config.showPoweredByShinobi === undefined){config.showPoweredByShinobi=true} - if(config.poweredByShinobi === undefined){config.poweredByShinobi='Powered by Shinobi.Systems'} - if(config.showLoginCardHeader === undefined){config.showLoginCardHeader=true} - if(config.webFavicon === undefined){config.webFavicon = 'libs/img/icon/favicon.ico'} - if(!config.logoLocationAppleTouchIcon)config.logoLocationAppleTouchIcon = 'libs/img/icon/apple-touch-icon.png'; - if(!config.logoLocation57x57)config.logoLocation57x57 = 'libs/img/icon/apple-touch-icon-57x57.png'; - if(!config.logoLocation72x72)config.logoLocation72x72 = 'libs/img/icon/apple-touch-icon-72x72.png'; - if(!config.logoLocation76x76)config.logoLocation76x76 = 'libs/img/icon/apple-touch-icon-76x76.png'; - if(!config.logoLocation114x114)config.logoLocation114x114 = 'libs/img/icon/apple-touch-icon-114x114.png'; - if(!config.logoLocation120x120)config.logoLocation120x120 = 'libs/img/icon/apple-touch-icon-120x120.png'; - if(!config.logoLocation144x144)config.logoLocation144x144 = 'libs/img/icon/apple-touch-icon-144x144.png'; - if(!config.logoLocation152x152)config.logoLocation152x152 = 'libs/img/icon/apple-touch-icon-152x152.png'; - if(!config.logoLocation196x196)config.logoLocation196x196 = 'libs/img/icon/favicon-196x196.png'; - if(config.logoLocation76x76Link === undefined){config.logoLocation76x76Link='https://shinobi.video'} - if(config.logoLocation76x76Style === undefined){config.logoLocation76x76Style='border-radius:50%'} - if(config.loginScreenBackground === undefined){config.loginScreenBackground='assets/img/splash.avif'} - if(config.showLoginSelector === undefined){config.showLoginSelector=true} - if(config.defaultTheme === undefined)config.defaultTheme = 'Ice-v3'; - if(config.socialLinks === undefined){ - config.socialLinks = [ - { - icon: 'home', - href: 'https://shinobi.video', - title: 'Homepage' - }, - { - icon: 'facebook', - href: 'https://www.facebook.com/ShinobiCCTV', - title: 'Facebook' - }, - { - icon: 'twitter', - href: 'https://twitter.com/ShinobiCCTV', - title: 'Twitter' - }, - { - icon: 'youtube', - href: 'https://www.youtube.com/channel/UCbgbBLTK-koTyjOmOxA9msQ', - title: 'YouTube' - } - ] - } + const processCwd = process.cwd(); + const { setDefaultIfUndefined } = require('./basic/utils.js')(processCwd,config); + setDefaultIfUndefined(config, 'showPoweredByShinobi', true); + setDefaultIfUndefined(config, 'poweredByShinobi', 'Powered by Shinobi.Systems'); + setDefaultIfUndefined(config, 'showLoginCardHeader', true); + setDefaultIfUndefined(config, 'webFavicon', 'libs/img/icon/favicon.ico'); + setDefaultIfUndefined(config, 'logoLocationAppleTouchIcon', 'libs/img/icon/apple-touch-icon.png'); + setDefaultIfUndefined(config, 'logoLocation57x57', 'libs/img/icon/apple-touch-icon-57x57.png'); + setDefaultIfUndefined(config, 'logoLocation72x72', 'libs/img/icon/apple-touch-icon-72x72.png'); + setDefaultIfUndefined(config, 'logoLocation76x76', 'libs/img/icon/apple-touch-icon-76x76.png'); + setDefaultIfUndefined(config, 'logoLocation114x114', 'libs/img/icon/apple-touch-icon-114x114.png'); + setDefaultIfUndefined(config, 'logoLocation120x120', 'libs/img/icon/apple-touch-icon-120x120.png'); + setDefaultIfUndefined(config, 'logoLocation144x144', 'libs/img/icon/apple-touch-icon-144x144.png'); + setDefaultIfUndefined(config, 'logoLocation152x152', 'libs/img/icon/apple-touch-icon-152x152.png'); + setDefaultIfUndefined(config, 'logoLocation196x196', 'libs/img/icon/favicon-196x196.png'); + setDefaultIfUndefined(config, 'logoLocation76x76Link', 'https://shinobi.video'); + setDefaultIfUndefined(config, 'logoLocation76x76Style', 'border-radius:50%'); + setDefaultIfUndefined(config, 'loginScreenBackground', 'assets/img/splash.avif'); + setDefaultIfUndefined(config, 'showLoginSelector', true); + setDefaultIfUndefined(config, 'defaultTheme', 'Ice-v3'); + setDefaultIfUndefined(config, 'socialLinks', [ + { icon: 'home', href: 'https://shinobi.video', title: 'Homepage' }, + { icon: 'facebook', href: 'https://www.facebook.com/ShinobiCCTV', title: 'Facebook' }, + { icon: 'twitter', href: 'https://twitter.com/ShinobiCCTV', title: 'Twitter' }, + { icon: 'youtube', href: 'https://www.youtube.com/channel/UCbgbBLTK-koTyjOmOxA9msQ', title: 'YouTube' } + ]); + s.getConfigWithBranding = function(domain){ var configCopy = Object.assign({},config) if(config.brandingConfig && config.brandingConfig[domain]){ diff --git a/package-lock.json b/package-lock.json index 9d3e67d7..0b076837 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "pixel-change": "^1.1.0", "pushover-notifications": "^1.2.2", "sat": "^0.7.1", - "shinobi-node-moving-things-tracker": "^0.9.1", + "shinobi-node-moving-things-tracker": "^0.9.3", "shinobi-onvif": "0.1.9", "shinobi-sound-detection": "^0.1.13", "shinobi-zwave": "^1.0.11", @@ -6687,9 +6687,9 @@ "integrity": "sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=" }, "node_modules/shinobi-node-moving-things-tracker": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/shinobi-node-moving-things-tracker/-/shinobi-node-moving-things-tracker-0.9.1.tgz", - "integrity": "sha512-pcI/IJ9D87RJiTGEsBYvtb2FTQXkHCkuyv6dYaXB5KVpnhQJGyf37BvAbvCNuCJmlffBGTMClY2dg84ZwHl/Ow==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/shinobi-node-moving-things-tracker/-/shinobi-node-moving-things-tracker-0.9.3.tgz", + "integrity": "sha512-SdOOu8vww6zulWL1R3Fx6kXkAbY0YEsRtJ/XrvioIKFykA1OV88/kzjJ4qmUM/d29DqurauqBH+18UtPe98ZVg==", "dependencies": { "lodash.isequal": "^4.5.0", "minimist": "^1.2.0", @@ -13292,9 +13292,9 @@ "integrity": "sha1-aP0CXrBJC09WegJ/C/IkgLX4QTM=" }, "shinobi-node-moving-things-tracker": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/shinobi-node-moving-things-tracker/-/shinobi-node-moving-things-tracker-0.9.1.tgz", - "integrity": "sha512-pcI/IJ9D87RJiTGEsBYvtb2FTQXkHCkuyv6dYaXB5KVpnhQJGyf37BvAbvCNuCJmlffBGTMClY2dg84ZwHl/Ow==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/shinobi-node-moving-things-tracker/-/shinobi-node-moving-things-tracker-0.9.3.tgz", + "integrity": "sha512-SdOOu8vww6zulWL1R3Fx6kXkAbY0YEsRtJ/XrvioIKFykA1OV88/kzjJ4qmUM/d29DqurauqBH+18UtPe98ZVg==", "requires": { "lodash.isequal": "^4.5.0", "minimist": "^1.2.0", diff --git a/package.json b/package.json index 54cf0909..05d773e0 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "pixel-change": "^1.1.0", "pushover-notifications": "^1.2.2", "sat": "^0.7.1", - "shinobi-node-moving-things-tracker": "^0.9.1", + "shinobi-node-moving-things-tracker": "^0.9.3", "shinobi-onvif": "0.1.9", "shinobi-sound-detection": "^0.1.13", "shinobi-zwave": "^1.0.11",