Skip to content

Commit

Permalink
* (bluefox) Preparations for a custom loading background
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Mar 16, 2024
1 parent f650bdd commit 179d0c0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ the path could be provided here (e.g. `/vis/`) so this path will be opened autom
-->

## Changelog
### **WORK IN PROGRESS**
* (bluefox) Preparations for a custom loading background

### 6.2.5 (2024-02-22)
* (bluefox) Just some packages were updates

Expand Down
9 changes: 8 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@
"dsn": "https://[email protected]/16"
}
},
"licenseInformation": {
"type": "free",
"link": "https://github.com/ioBroker/ioBroker.web/blob/master/LICENSE"
},
"tier": 3
},
"native": {
Expand Down Expand Up @@ -199,7 +203,10 @@
"staticAssetCacheMaxAge": 60,
"language": "",
"startDisabledExtensions": false,
"showFolderIndex": false
"showFolderIndex": false,
"loadingBackgroundColor": "",
"loadingHideLogo": false,
"loadingBackgroundImage": false
},
"instanceObjects": [
{
Expand Down
30 changes: 29 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ let passport; // = require('passport');
let LocalStrategy; // = require('passport-local').Strategy;
let flash; // = require('connect-flash'); // TODO report error to user
let checkTimeout;
let vendorPrefix;

let webServer = null;
let store = null;
Expand Down Expand Up @@ -335,6 +336,14 @@ function startAdapter(options) {
adapter.log.error('Cannot find object system.config');
}

let uuid = null;
try {
uuid = await adapter.getForeignObjectAsync('system.meta.uuid');
} catch (e) {
adapter.log.warn(`Cannot read UUID: ${e}`);
}
vendorPrefix = systemConfig?.native?.vendor?.uuidPrefix || (uuid?.native?.uuid?.length > 36 ? uuid.native.uuid.substring(0, 2) : '');

// information about connected socket.io adapter
if (adapter.config.socketio && adapter.config.socketio.match(/^system\.adapter\./)) {
socketUrl = await getSocketUrl();
Expand Down Expand Up @@ -1744,6 +1753,7 @@ async function initWebServer(settings) {
return;
}

// If root directory requested
if (url === '/' || url === '/index.html') {
if (adapter.config.defaultRedirect) {
res.redirect(301, adapter.config.defaultRedirect);
Expand Down Expand Up @@ -1898,9 +1908,27 @@ async function initWebServer(settings) {
} else {
mimeType = mimeType || mime.lookup(url) || 'text/javascript';

// replace some important variables in HTML
if (url === 'index.html' || url === 'edit.html') {
buffer = buffer
.toString()
.replaceAll(`'@@vendorPrefix@@'`, vendorPrefix)
.replaceAll(`"@@vendorPrefix@@"`, vendorPrefix)

.replaceAll(`'@@disableDataReporting@@'`, adapter.common.disableDataReporting ? 'true' : 'false')
.replaceAll(`"@@disableDataReporting@@"`, adapter.common.disableDataReporting ? 'true' : 'false')

.replaceAll(`@@loadingBackgroundColor@@`, adapter.config.loadingBackgroundColor || '')

.replaceAll(`@@loadingBackgroundImage@@`, adapter.config.loadingBackgroundImage ? `files/${adapter.namespace}/loading-bg.png` : '')

.replaceAll(`'@@loadingHideLogo@@'`, adapter.config.loadingHideLogo ? 'true' : 'false')
.replaceAll(`"@@loadingHideLogo@@"`, adapter.config.loadingHideLogo ? 'true' : 'false');
}

// Store file in cache
if (settings.cache) {
cache[`${id}/${url}`] = {buffer, mimeType};
cache[`${id}/${url}`] = { buffer, mimeType };
}

res.contentType(mimeType);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@alcalzone/release-script-plugin-iobroker": "^3.7.0",
"@alcalzone/release-script-plugin-license": "^3.7.0",
"@iobroker/legacy-testing": "^1.0.9",
"axios": "^1.6.7",
"axios": "^1.6.8",
"chai": "^4.4.1",
"eslint": "^8.57.0",
"gulp": "^4.0.2",
Expand Down
12 changes: 6 additions & 6 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"private": true,
"dependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@iobroker/adapter-react-v5": "^4.9.10",
"@mui/icons-material": "^5.15.11",
"@iobroker/adapter-react-v5": "^4.10.2",
"@mui/icons-material": "^5.15.13",
"@mui/material": "5.14.14",
"@mui/styles": "5.14.14",
"@sentry/browser": "^7.102.1",
"@sentry/integrations": "^7.102.1",
"@sentry/browser": "^7.107.0",
"@sentry/integrations": "^7.107.0",
"babel-eslint": "^10.1.0",
"eslint": "^8.57.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-eqeqeq-fix": "^1.0.3",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
Expand All @@ -43,4 +43,4 @@
"not ie <= 11",
"not op_mini all"
]
}
}

0 comments on commit 179d0c0

Please sign in to comment.