Skip to content

Commit

Permalink
Fixed ws server 1 (#2753)
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Oct 8, 2024
1 parent 7bdf3ad commit 63ca2d8
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ The icons may not be reused in other projects without the proper flaticon licens
<!--
### **WORK IN PROGRESS**
-->
### 7.2.3 (2024-10-08)
### **WORK IN PROGRESS**

- (@GermanBluefox) Corrected some GUI errors
- (@GermanBluefox) Ignore error by opening `0_userdata.0`
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions packages/admin/io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
"connectionType": "local",
"dataSource": "push",
"news": {
"7.2.3": {
"en": "Corrected some GUI errors\nIgnore error by opening `0_userdata.0`",
"de": "Einige GUI-Fehler korrigiert\nFehler ignorieren durch Öffnen von `0_userdata.0`",
"ru": "Исправлены некоторые ошибки GUI\nИгнорировать ошибку, открывая `0_userdata.0`",
"pt": "Corrigido alguns erros GUI\nIgnorar erro ao abrir `0_userdata.0`",
"nl": "Enkele GUI-fouten gecorrigeerd\nFout negeren door het openen van ",
"fr": "Correction de certaines erreurs d'interface graphique\nIgnorer l'erreur en ouvrant `0_userdata.0`",
"it": "Corretto alcuni errori GUI\nIgnora errore aprendo `0_userdata.0`",
"es": "Corregido algunos errores de GUI\nIgnora el error al abrir `0_userdata.0`",
"pl": "Poprawiono niektóre błędy GUI\nIgnoruj błąd otwierając '0 _ userdata.0'",
"uk": "Виправлено деякі помилки інтерфейсу\nІм’я користувача `0_userdata.0`",
"zh-cn": "更正了一些图形用户界面错误\n打开 '0_userdata.0' 忽略错误"
},
"7.2.0": {
"en": "Added the check of well-known passwords for the linux systems\nAdded the history for the installation from URL\nfixed wrongly displayed repository warning",
"de": "Hinzugefügt die Überprüfung der bekannten Passwörter für die Linux-Systeme\nDie Geschichte der Installation von URL hinzugefügt\nfalsch angezeigte repository-warnung",
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@iobroker/socket-classes": "^1.6.1",
"@iobroker/webserver": "^1.0.6",
"@iobroker/ws": "^2.0.0",
"@iobroker/ws-server": "3.0.2",
"@iobroker/ws-server": "3.0.3",
"ajv": "^8.17.1",
"archiver": "^7.0.1",
"axios": "^1.7.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ export interface InstanceGenericProps {
item: InstanceItem;
context: InstanceContext;
idx: number;
saveScrollPosition: () => void;
}

export interface InstanceGenericState {
Expand Down Expand Up @@ -1255,6 +1256,7 @@ export default abstract class InstanceGeneric<
onClick={event => {
event.stopPropagation();
event.preventDefault();
this.props.saveScrollPosition();
Router.doNavigate('tab-instances', 'config', this.props.id);
}}
>
Expand Down
23 changes: 22 additions & 1 deletion packages/admin/src-admin/src/tabs/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
PlayArrow as PlayArrowIcon,
Refresh as RefreshIcon,
Edit as EditIcon,
ArrowBack,
} from '@mui/icons-material';

import {
Expand Down Expand Up @@ -608,11 +609,31 @@ class Config extends Component<ConfigProps, ConfigState> {
color="default"
position="static"
>
<Toolbar variant="dense">
<Toolbar
variant="dense"
style={{ marginLeft: 8 }}
>
<Typography
variant="h6"
color="inherit"
>
<IconButton
size="small"
onClick={() => {
if (this.props.easyMode) {
Router.doNavigate('easy');
} else {
Router.doNavigate('tab-instances');
}
}}
onFocus={event => event.stopPropagation()}
style={{
marginRight: 10,
display: 'none',
}}
>
<ArrowBack />
</IconButton>
{this.props.jsonConfig ? (
<Icon
src={this.props.icon}
Expand Down
30 changes: 28 additions & 2 deletions packages/admin/src-admin/src/tabs/Instances.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ interface InstancesState {

// every tab should get their data itself from server
class Instances extends Component<InstancesProps, InstancesState> {
static lastScrollPosition = 0;

private readonly localStorage: Storage;

private statePromise: Promise<Record<string, ioBroker.State>> | null = null;
Expand All @@ -161,6 +163,8 @@ class Instances extends Component<InstancesProps, InstancesState> {

private readonly inputRef: React.RefObject<HTMLInputElement>;

private readonly refTabContent: React.RefObject<HTMLDivElement>;

private subscribed: boolean = false;

private _cacheList: InstanceItem[] | null = null;
Expand Down Expand Up @@ -243,6 +247,7 @@ class Instances extends Component<InstancesProps, InstancesState> {

this.t = this.translate;
this.inputRef = createRef();
this.refTabContent = createRef();
}

translate = (word: string, arg1?: any, arg2?: any): string => {
Expand Down Expand Up @@ -861,6 +866,10 @@ class Instances extends Component<InstancesProps, InstancesState> {
this.closeCommands[panel] = closeCommand;
};

saveScrollPosition = (): void => {
Instances.lastScrollPosition = (this.refTabContent.current?.parentNode as HTMLDivElement)?.scrollTop;
};

getPanels(): JSX.Element[] | JSX.Element {
if (!this._cacheList) {
this.cacheInstances();
Expand Down Expand Up @@ -894,6 +903,7 @@ class Instances extends Component<InstancesProps, InstancesState> {
category: item.category,
render: (
<InstanceCard
saveScrollPosition={this.saveScrollPosition}
deleting={this.state.deleting === instance.id}
id={id}
idx={idx}
Expand All @@ -909,6 +919,7 @@ class Instances extends Component<InstancesProps, InstancesState> {
category: item.category,
render: (
<InstanceRow
saveScrollPosition={this.saveScrollPosition}
deleting={this.state.deleting === instance.id}
id={id}
idx={idx}
Expand Down Expand Up @@ -1088,7 +1099,6 @@ class Instances extends Component<InstancesProps, InstancesState> {
if (!this.state.instances) {
return <LinearProgress />;
}
console.log(`Width: ${this.props.width}`);

if (this.props.currentHost !== this.state.currentHost) {
this.hostsTimer =
Expand Down Expand Up @@ -1135,6 +1145,17 @@ class Instances extends Component<InstancesProps, InstancesState> {
</Paper>
);
}
} else if (Instances.lastScrollPosition) {
setTimeout(
(scrollPos: number): void => {
if (this.refTabContent.current?.parentNode) {
(this.refTabContent.current?.parentNode as HTMLDivElement).scrollTop = scrollPos;
}
},
200,
Instances.lastScrollPosition,
);
Instances.lastScrollPosition = 0;
}

if (this.shouldUpdateAfterDialogClosed) {
Expand Down Expand Up @@ -1377,7 +1398,12 @@ class Instances extends Component<InstancesProps, InstancesState> {
</Box>
</TabHeader>
<TabContent overflow="auto">
<div style={this.state.viewMode ? styles.cards : undefined}>{this.getPanels()}</div>
<div
ref={this.refTabContent}
style={this.state.viewMode ? styles.cards : undefined}
>
{this.getPanels()}
</div>
</TabContent>
</TabContainer>
);
Expand Down

0 comments on commit 63ca2d8

Please sign in to comment.