mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-10-28 23:05:01 -04:00
Update to customFiles - Object instead of array (#7384)
* Updated to use Object instead of array, still supports old array
This commit is contained in:
parent
b50d07c183
commit
3bcfd031ca
@ -1988,15 +1988,41 @@
|
||||
"type": "object"
|
||||
},
|
||||
"customFiles": {
|
||||
"type": "array",
|
||||
"description": "Advanced customization system allowing multiple CSS and JavaScript file configurations per domain. Each configuration can target specific templates using the 'scope' property, enabling granular control over where custom files are loaded. All custom files are loaded after the default custom.css and custom.js files.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "Advanced customization system allowing multiple CSS and JavaScript file configurations per domain. Each configuration is identified by a unique name and can target specific templates using the 'scope' property, enabling granular control over where custom files are loaded. All custom files are loaded after the default custom.css and custom.js files.",
|
||||
"properties": {
|
||||
"example-config": {
|
||||
"type": "object",
|
||||
"description": "Example configuration - replace 'example-config' with your desired name",
|
||||
"properties": {
|
||||
"css": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Ordered list of custom CSS files to load. Files are loaded in the specified order after the default custom.css. Place files in the meshcentral-data/public/styles/ directory. Example: [\"theme.css\", \"overrides.css\", \"mobile.css\"]"
|
||||
},
|
||||
"js": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Ordered list of custom JavaScript files to load. Files are loaded in the specified order after the default custom.js. Place files in the meshcentral-data/public/scripts/ directory. Example: [\"analytics.js\", \"custom-functions.js\", \"ui-enhancements.js\"]"
|
||||
},
|
||||
"scope": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "List of template names where these custom files should be loaded. If not specified or empty, files will NOT be loaded anywhere. Use 'all' to load on all templates. Available template names: all, default, default3, default-mobile, login, login2, login-mobile, messenger, message, message2, invite, agentinvite, player, xterm, mstsc, ssh, sharing, sharing-mobile, download, download2, terms, terms-mobile, error404, error4042, error404-mobile. Example: [\"default3\", \"login2\", \"player\"] or [\"all\"]"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"description": "Custom file configuration identified by a unique name",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "Unique name for this custom files configuration. Used for identification and debugging purposes."
|
||||
},
|
||||
"css": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@ -2018,8 +2044,7 @@
|
||||
},
|
||||
"description": "List of template names where these custom files should be loaded. If not specified or empty, files will NOT be loaded anywhere. Use 'all' to load on all templates. Available template names: all, default, default3, default-mobile, login, login2, login-mobile, messenger, message, message2, invite, agentinvite, player, xterm, mstsc, ssh, sharing, sharing-mobile, download, download2, terms, terms-mobile, error404, error4042, error404-mobile. Example: [\"default3\", \"login2\", \"player\"] or [\"all\"]"
|
||||
}
|
||||
},
|
||||
"required": ["name"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"consentMessages": {
|
||||
|
||||
@ -347,6 +347,18 @@
|
||||
"autoAcceptIfNoUser": false,
|
||||
"oldStyle": true
|
||||
},
|
||||
"_customFiles": {
|
||||
"desktop-theme": {
|
||||
"css": ["theme.css"],
|
||||
"js": ["theme.js"],
|
||||
"scope": ["all"]
|
||||
},
|
||||
"mobile-theme": {
|
||||
"css": ["theme.css", "test.css"],
|
||||
"js": ["analytics.js", "test.js"],
|
||||
"scope": ["login2", "login"]
|
||||
}
|
||||
},
|
||||
"_notificationMessages": {
|
||||
"title": "MeshCentral",
|
||||
"desktop": "{0} started a remote desktop session.",
|
||||
|
||||
62
webserver.js
62
webserver.js
@ -9462,16 +9462,17 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||
return null;
|
||||
}
|
||||
|
||||
function generateCustomCSSTags(customFilesArray, currentTemplate) {
|
||||
function generateCustomCSSTags(customFilesObject, currentTemplate) {
|
||||
var cssTags = '';
|
||||
|
||||
cssTags += '<link keeplink=1 type="text/css" href="styles/custom.css" media="screen" rel="stylesheet" title="CSS" />\n ';
|
||||
|
||||
|
||||
if (customFilesArray) {
|
||||
if (Array.isArray(customFilesArray)) {
|
||||
for (var i = 0; i < customFilesArray.length; i++) {
|
||||
var customFileConfig = customFilesArray[i];
|
||||
if (customFilesObject) {
|
||||
if (Array.isArray(customFilesObject)) {
|
||||
// Legacy array support - convert to object format
|
||||
for (var i = 0; i < customFilesObject.length; i++) {
|
||||
var customFileConfig = customFilesObject[i];
|
||||
if (customFileConfig && customFileConfig.css && Array.isArray(customFileConfig.css)) {
|
||||
if ((customFileConfig.scope && customFileConfig.scope.indexOf('all') !== -1) ||
|
||||
(currentTemplate && customFileConfig.scope && customFileConfig.scope.indexOf(currentTemplate) !== -1)) {
|
||||
@ -9481,9 +9482,23 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (customFilesArray.css && Array.isArray(customFilesArray.css)) {
|
||||
for (var i = 0; i < customFilesArray.css.length; i++) {
|
||||
cssTags += '<link keeplink=1 type="text/css" href="styles/' + customFilesArray.css[i] + '" media="screen" rel="stylesheet" title="CSS" />\n ';
|
||||
} else if (customFilesObject.css && Array.isArray(customFilesObject.css)) {
|
||||
// Legacy single object support
|
||||
for (var i = 0; i < customFilesObject.css.length; i++) {
|
||||
cssTags += '<link keeplink=1 type="text/css" href="styles/' + customFilesObject.css[i] + '" media="screen" rel="stylesheet" title="CSS" />\n ';
|
||||
}
|
||||
} else if (typeof customFilesObject === 'object') {
|
||||
// New object format - iterate through each custom file configuration
|
||||
for (var configName in customFilesObject) {
|
||||
var customFileConfig = customFilesObject[configName];
|
||||
if (customFileConfig && customFileConfig.css && Array.isArray(customFileConfig.css)) {
|
||||
if ((customFileConfig.scope && customFileConfig.scope.indexOf('all') !== -1) ||
|
||||
(currentTemplate && customFileConfig.scope && customFileConfig.scope.indexOf(currentTemplate) !== -1)) {
|
||||
for (var j = 0; j < customFileConfig.css.length; j++) {
|
||||
cssTags += '<link keeplink=1 type="text/css" href="styles/' + customFileConfig.css[j] + '" media="screen" rel="stylesheet" title="CSS" />\n ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9491,15 +9506,16 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||
return cssTags.trim();
|
||||
}
|
||||
|
||||
function generateCustomJSTags(customFilesArray, currentTemplate) {
|
||||
function generateCustomJSTags(customFilesObject, currentTemplate) {
|
||||
var jsTags = '';
|
||||
|
||||
jsTags += '<script keeplink=1 type="text/javascript" src="scripts/custom.js"></script>\n ';
|
||||
|
||||
if (customFilesArray) {
|
||||
if (Array.isArray(customFilesArray)) {
|
||||
for (var i = 0; i < customFilesArray.length; i++) {
|
||||
var customFileConfig = customFilesArray[i];
|
||||
if (customFilesObject) {
|
||||
if (Array.isArray(customFilesObject)) {
|
||||
// Legacy array support - convert to object format
|
||||
for (var i = 0; i < customFilesObject.length; i++) {
|
||||
var customFileConfig = customFilesObject[i];
|
||||
if (customFileConfig && customFileConfig.js && Array.isArray(customFileConfig.js)) {
|
||||
if ((customFileConfig.scope && customFileConfig.scope.indexOf('all') !== -1) ||
|
||||
(currentTemplate && customFileConfig.scope && customFileConfig.scope.indexOf(currentTemplate) !== -1)) {
|
||||
@ -9509,9 +9525,23 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (customFilesArray.js && Array.isArray(customFilesArray.js)) {
|
||||
for (var i = 0; i < customFilesArray.js.length; i++) {
|
||||
jsTags += '<script keeplink=1 type="text/javascript" src="scripts/' + customFilesArray.js[i] + '"></script>\n ';
|
||||
} else if (customFilesObject.js && Array.isArray(customFilesObject.js)) {
|
||||
// Legacy single object support
|
||||
for (var i = 0; i < customFilesObject.js.length; i++) {
|
||||
jsTags += '<script keeplink=1 type="text/javascript" src="scripts/' + customFilesObject.js[i] + '"></script>\n ';
|
||||
}
|
||||
} else if (typeof customFilesObject === 'object') {
|
||||
// New object format - iterate through each custom file configuration
|
||||
for (var configName in customFilesObject) {
|
||||
var customFileConfig = customFilesObject[configName];
|
||||
if (customFileConfig && customFileConfig.js && Array.isArray(customFileConfig.js)) {
|
||||
if ((customFileConfig.scope && customFileConfig.scope.indexOf('all') !== -1) ||
|
||||
(currentTemplate && customFileConfig.scope && customFileConfig.scope.indexOf(currentTemplate) !== -1)) {
|
||||
for (var j = 0; j < customFileConfig.js.length; j++) {
|
||||
jsTags += '<script keeplink=1 type="text/javascript" src="scripts/' + customFileConfig.js[j] + '"></script>\n ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user