Skip to content

Commit

Permalink
* (bluefox) Added new option for view: "Limit only for instances"
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Nov 22, 2024
1 parent 2fa0609 commit 8cc6ec5
Show file tree
Hide file tree
Showing 15 changed files with 8,336 additions and 8,288 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ npm run start
### **WORK IN PROGRESS**
-->
## Changelog
### **WORK IN PROGRESS**
* (bluefox) Added new option for view: "Limit only for instances"

### 2.10.7 (2024-07-23)
* (bluefox) Optimization of the module federation

Expand Down
8 changes: 8 additions & 0 deletions packages/iobroker.vis-2/src/src/Attributes/View/Items.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ export function getFields(
hidden: 'data.sizex === undefined && data.sizey === undefined',
notStyle: true,
},
{
type: 'text',
label: 'Limit only for instances',
attr: 'limitForInstances',
hidden: '!data.limitScreen',
title: 'Enter the browser instances divided by comma',
notStyle: true,
},
{
type: 'checkbox',
label: 'Only for desktop',
Expand Down
66 changes: 40 additions & 26 deletions packages/iobroker.vis-2/src/src/Vis/visView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1887,32 +1887,46 @@ class VisView extends React.Component<VisViewProps, VisViewState> {

let limitScreenStyle: React.CSSProperties | null = null;
// limit screen size of desired
if (settings && settings.limitScreen && ((window.screen.width >= 800 && window.screen.height >= 800) || !settings.limitScreenDesktop)) {
const ww = isVarFinite(settings.sizex) ? parseFloat(settings.sizex as unknown as string) : 0;
const hh = isVarFinite(settings.sizey) ? parseFloat(settings.sizey as unknown as string) : 0;
if (ww && hh) {
const borderWidth = parseFloat(settings.limitScreenBorderWidth as unknown as string) || 0;
const borderColor = settings.limitScreenBorderColor || '#333';
const borderStyle = settings.limitScreenBorderStyle || 'dotted';
const bgColor = settings.limitScreenBackgroundColor || null;

limitScreenStyle = {
...backgroundStyle,
width: ww + borderWidth * 2,
height: hh + borderWidth * 2,
minWidth: ww + borderWidth * 2,
minHeight: hh + borderWidth * 2,
overflow: 'auto',
position: 'relative',
boxSizing: 'border-box',
borderWidth,
borderColor,
borderStyle,
};
style.display = 'flex';
style.justifyContent = 'center';
style.alignItems = 'center';
style.backgroundColor = bgColor as Property.BackgroundColor;
if (settings?.limitScreen && ((window.screen.width >= 800 && window.screen.height >= 800) || !settings.limitScreenDesktop)) {
let ignore = false;
if (settings.limitForInstances) {
const visInstance = window.localStorage.getItem('visInstance');
if (visInstance) {
const instances = settings.limitForInstances.split(',').map(i => i.trim()).filter(i => i);
if (instances.length && !instances.includes(visInstance)) {
ignore = true;
}
} else {
ignore = true;
}
}
if (!ignore) {
const ww = isVarFinite(settings.sizex) ? parseFloat(settings.sizex as unknown as string) : 0;
const hh = isVarFinite(settings.sizey) ? parseFloat(settings.sizey as unknown as string) : 0;
if (ww && hh) {
const borderWidth = parseFloat(settings.limitScreenBorderWidth as unknown as string) || 0;
const borderColor = settings.limitScreenBorderColor || '#333';
const borderStyle = settings.limitScreenBorderStyle || 'dotted';
const bgColor = settings.limitScreenBackgroundColor || null;

limitScreenStyle = {
...backgroundStyle,
width: ww + borderWidth * 2,
height: hh + borderWidth * 2,
minWidth: ww + borderWidth * 2,
minHeight: hh + borderWidth * 2,
overflow: 'auto',
position: 'relative',
boxSizing: 'border-box',
borderWidth,
borderColor,
borderStyle,
};
style.display = 'flex';
style.justifyContent = 'center';
style.alignItems = 'center';
style.backgroundColor = bgColor as Property.BackgroundColor;
}
}
}

Expand Down
Loading

0 comments on commit 8cc6ec5

Please sign in to comment.