Skip to content

Commit

Permalink
Merge branch 'master' into cron-text-change
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox authored Nov 16, 2024
2 parents c27ce0c + 3decc54 commit 470bcd6
Show file tree
Hide file tree
Showing 26 changed files with 162 additions and 1,846 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG_OLD.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Older changes
## 7.1.5 (2024-09-26)

- (bluefox) Added the read-only flag to the `state` JSON Config component

## 7.1.3 (2024-09-20)

- (@foxriver76) improve appearance and standardization of some warning messages
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ The icons may not be reused in other projects without the proper flaticon licens
<!--
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
### 7.3.2 (2024-11-15)

- (@GermanBluefox) Some GUI packages were updated.
- (@GermanBluefox) Improved file viewer. Added icons viewer

### 7.3.1 (2024-11-14)

- (@GermanBluefox) Corrected cloud icon for admin
- (@GermanBluefox) Added old dialog names to adapter-react-v5 again
Expand All @@ -109,10 +114,6 @@ The icons may not be reused in other projects without the proper flaticon licens
- (@GermanBluefox) Added the history for the installation from URL
- (@foxriver76) fixed wrongly displayed repository warning

### 7.1.5 (2024-09-26)

- (bluefox) Added the read-only flag to the `state` JSON Config component

## License

The MIT License (MIT)
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.3.0",
"version": "7.3.2",
"packages": [
"packages/*"
],
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions packages/adapter-react-v5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If you want to create the configuration page with ReactJS:
- Change `name` from `src` to `ADAPTERNAME-admin` (Of course replace `ADAPTERNAME` with yours)
- Add to devDependencies:
```json
"@iobroker/adapter-react-v5": "^7.3.0",
"@iobroker/adapter-react-v5": "^7.3.1",
```
Versions can be higher.
So your `src/package.json` should look like:
Expand All @@ -24,7 +24,7 @@ If you want to create the configuration page with ReactJS:
"version": "0.1.0",
"private": true,
"dependencies": {
"@iobroker/adapter-react-v5": "^7.3.0",
"@iobroker/adapter-react-v5": "^7.3.1",
"@iobroker/build-tools": "^1.0.0",
"babel-eslint": "^10.1.0",
"react-scripts": "^5.0.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-react-v5/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iobroker/adapter-react-v5",
"version": "7.3.0",
"version": "7.3.2",
"description": "React components to develop ioBroker interfaces with react.",
"author": {
"name": "bluefox",
Expand Down Expand Up @@ -54,7 +54,7 @@
"@emotion/styled": "^11.13.0",
"@iobroker/js-controller-common": "^6.0.11",
"@iobroker/js-controller-common-db": "^6.0.11",
"@iobroker/socket-client": "^3.1.1",
"@iobroker/socket-client": "^3.1.2",
"@iobroker/types": "^6.0.11",
"@mui/icons-material": "^6.1.5",
"@mui/material": "^6.1.5",
Expand Down
18 changes: 8 additions & 10 deletions packages/adapter-react-v5/src/Components/FileViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const styles: Record<string, React.CSSProperties> = {
};

export const EXTENSIONS = {
images: ['png', 'jpg', 'svg', 'jpeg', 'bmp', 'gif', 'apng', 'avif', 'webp'],
images: ['png', 'jpg', 'svg', 'jpeg', 'bmp', 'gif', 'apng', 'avif', 'webp', 'ico'],
code: ['js', 'json', 'json5', 'md'],
txt: ['log', 'txt', 'html', 'css', 'xml', 'ics'],
audio: ['mp3', 'wav', 'ogg', 'acc'],
Expand All @@ -55,7 +55,7 @@ export const EXTENSIONS = {

function bufferToBase64(buffer: Buffer, isFull?: boolean): string {
let binary = '';
const bytes = new Uint8Array(buffer);
const bytes = new Uint8Array((buffer as unknown as { data: number[]; type: 'Buffer' })?.data || buffer);
const len = bytes.byteLength;
for (let i = 0; i < len && (isFull || i < 50); i++) {
binary += String.fromCharCode(bytes[i]);
Expand Down Expand Up @@ -121,9 +121,9 @@ export class FileViewerClass extends Component<FileViewerProps, FileViewerState>

this.props.socket
.readFile(adapter, name)
.then((data: { data: Buffer; type: string } | { file: string; mimeType: string }) => {
let fileData = '';
if ((data as { file: string; mimeType: string }).file !== undefined) {
.then((data: { file: string | Buffer; mimeType: string }) => {
let fileData: string | Buffer = '';
if (data.file !== undefined) {
fileData = (data as { file: string; mimeType: string }).file;
}

Expand All @@ -132,20 +132,18 @@ export class FileViewerClass extends Component<FileViewerProps, FileViewerState>
ext: this.state.ext,
};
// try to detect valid extension
if ((data as { data: Buffer; type: string }).type === 'Buffer') {
if ((fileData as unknown as { data: Buffer; type: string }).type === 'Buffer') {
if (name.toLowerCase().endsWith('.json5')) {
newState.ext = 'json5';
newState.copyPossible = true;
try {
fileData = atob(bufferToBase64((data as { data: Buffer; type: string }).data, true));
fileData = atob(bufferToBase64(fileData as unknown as Buffer, true));
} catch {
console.error('Cannot convert base64 to string');
fileData = '';
}
} else {
const ext = Utils.detectMimeType(
bufferToBase64((data as { data: Buffer; type: string }).data),
);
const ext = Utils.detectMimeType(bufferToBase64(fileData as unknown as Buffer));
if (ext) {
newState.ext = ext;
newState.copyPossible = EXTENSIONS.code.includes(ext) || EXTENSIONS.txt.includes(ext);
Expand Down
13 changes: 3 additions & 10 deletions packages/adapter-react-v5/src/Components/UploadImage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component, createRef, type JSX } from 'react';
import Dropzone from 'react-dropzone';
import Dropzone, { type FileRejection } from 'react-dropzone';
import { Cropper, type ReactCropperElement } from 'react-cropper';

import { Menu, MenuItem, Tooltip, IconButton } from '@mui/material';
Expand Down Expand Up @@ -500,17 +500,10 @@ export class UploadImage extends Component<UploadImageProps, UploadImageState> {
maxSize={maxSize}
onDragEnter={() => this.setState({ uploadFile: 'dragging' })}
onDragLeave={() => this.setState({ uploadFile: true })}
onDrop={(acceptedFiles: File[], errors) => {
onDrop={(acceptedFiles: File[], errors: FileRejection[]) => {
this.setState({ uploadFile: false });
if (!acceptedFiles.length) {
window.alert(
(errors &&
errors[0] &&
errors[0].errors &&
errors[0].errors[0] &&
errors[0].errors[0].message) ||
I18n.t('ra_Cannot upload'),
);
window.alert(errors?.[0]?.errors?.[0]?.message || I18n.t('ra_Cannot upload'));
} else {
this.onDrop(acceptedFiles);
}
Expand Down
28 changes: 27 additions & 1 deletion packages/admin/io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "admin",
"version": "7.3.0",
"version": "7.3.2",
"titleLang": {
"en": "Admin",
"de": "Admin",
Expand All @@ -19,6 +19,32 @@
"connectionType": "local",
"dataSource": "push",
"news": {
"7.3.2": {
"en": "Some GUI packages were updated.\nImproved file viewer. Added icons viewer",
"de": "Einige GUI-Pakete wurden aktualisiert.\nVerbesserte Dateiansicht. Icons Viewer hinzugefügt",
"ru": "Некоторые пакеты GUI были обновлены.\nУлучшен просмотрщик файлов. Добавлен значок",
"pt": "Alguns pacotes GUI foram atualizados.\nVisualizador de arquivo melhorado. Visualizador de ícones adicionado",
"nl": "Sommige GUI-pakketten werden bijgewerkt.\nVerbeterde bestandsviewer. Pictogrammenviewer toegevoegd",
"fr": "Certains paquets GUI ont été mis à jour.\nVisualiseur de fichiers amélioré. Affichage des icônes ajoutées",
"it": "Alcuni pacchetti GUI sono stati aggiornati.\nVisualizzatore di file migliorato. Aggiunto icone viewer",
"es": "Algunos paquetes GUI fueron actualizados.\nMejorado visor de archivos. Añadido iconos visor",
"pl": "Niektóre pakiety GUI zostały zaktualizowane.\nUlepszona przeglądarka plików. Dodano przeglądarkę ikon",
"uk": "Деякі пакети GUI були оновлено.\nПоліпшення перегляду файлів. Перегляд іконок",
"zh-cn": "一些图形用户界面软件包已经更新.\n改进的文件查看器 。 添加图标查看器"
},
"7.3.1": {
"en": "Corrected cloud icon for admin\nAdded old dialog names to adapter-react-v5 again\nCorrected the password field in JSON-Config",
"de": "Korrigiertes Cloud-Symbol für Admin\nWieder alte Dialognamen zum Adapter-React-v5 hinzugefügt\nDas Passwortfeld in JSON-Config korrigiert",
"ru": "Исправлена значок облака для администратора\nДобавлены старые диалоговые имена для адаптер-реакт-v5\nИсправлено поле паролей в JSON-Config",
"pt": "Ícone de nuvem corrigido para admin\nAdicionados nomes de diálogo antigos para adaptador-react-v5 novamente\nCorrigido o campo de senha em JSON-Config",
"nl": "Gecorrigeerde cloudpictogram voor admin\nOude dialoognamen weer toegevoegd aan adapter-react-v5\nHet wachtwoordveld in JSON-Config corrigeren",
"fr": "Icône cloud corrigée pour admin\nAjout d'anciens noms de dialogue à adaptateur-réaction-v5 à nouveau\nCorrection du champ mot de passe dans JSON-Config",
"it": "Icona cloud corretta per admin\nAggiunto vecchi nomi di dialogo per adattatore-react-v5 di nuovo\nCorretto il campo password in JSON-Config",
"es": "Icono de nube corregido para admin\nAñadido viejos nombres de diálogo para adaptar-react-v5 de nuevo\nCorregido el campo de contraseña en JSON-Config",
"pl": "Skorygowana ikona chmur dla admin\nDodano stare nazwy dialogowe do adapter- react- v5 ponownie\nPoprawiono hasło w JSON- Config",
"uk": "Виправлена хмарна ікона для адміністратора\nДодано старі діалогові імена для адаптера-react-v5 знову\nВиправлено поле пароля в JSON-Config",
"zh-cn": "管理员的校正云图标\n再次添加旧对话框名称到适配器- react-v5\n更正了 JSON- Config 中的密码字段"
},
"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
@@ -1,7 +1,7 @@
{
"name": "iobroker.admin",
"description": "The adapter opens a webserver for the ioBroker admin UI.",
"version": "7.3.0",
"version": "7.3.2",
"contributors": [
"bluefox <[email protected]>",
"apollon77",
Expand Down
4 changes: 2 additions & 2 deletions packages/admin/src-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@honkhonk/vite-plugin-svgr": "^1.1.0",
"@iobroker/admin-component-easy-access": "^1.0.8",
"@iobroker/dm-utils": "^0.5.0",
"@iobroker/socket-client": "^3.1.1",
"@iobroker/socket-client": "^3.1.2",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@react-leaflet/core": "^2.1.0",
"@tsconfig/node16": "^16.1.3",
Expand Down Expand Up @@ -99,5 +99,5 @@
}
]
],
"version": "7.3.0"
"version": "7.3.1"
}
6 changes: 6 additions & 0 deletions packages/admin/src-admin/src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import React, { Component, type JSX } from 'react';

import AceEditor from 'react-ace';
import 'ace-builds/src-min-noconflict/mode-json';
import 'ace-builds/src-min-noconflict/mode-json5';
import 'ace-builds/src-min-noconflict/mode-xml';
import 'ace-builds/src-min-noconflict/mode-html';
import 'ace-builds/src-min-noconflict/worker-json';
import 'ace-builds/src-min-noconflict/worker-javascript';
import 'ace-builds/src-min-noconflict/worker-xml';
import 'ace-builds/src-min-noconflict/worker-html';
import 'ace-builds/src-min-noconflict/theme-clouds_midnight';
import 'ace-builds/src-min-noconflict/theme-chrome';
import 'ace-builds/src-min-noconflict/ext-language_tools';
Expand Down
44 changes: 34 additions & 10 deletions packages/admin/src/lib/checkLinuxPass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,33 @@ function checkLinuxPassword(login: string, password: string): Promise<boolean> {
try {
const su = spawn('su', [login]);
let result = false;
let responseTimeout = setTimeout(() => {
let responseTimeout: NodeJS.Timeout | null = setTimeout(() => {
responseTimeout = null;
su.kill();
}, 3000);

function _checkPassword(data: string): void {
if (!responseTimeout) {
return;
}
data = data.replace(/\r/g, ' ').replace(/\n/g, ' ').trim();
console.log(`[STDX] "${data}"`);
if (data.endsWith(':')) {
su.stdin.write(`${password}\n`);
try {
su.stdin?.write(`${password}\n`);
} catch {
return;
}
setTimeout(() => {
if (!responseTimeout) {
return;
}
console.log(`[LOG] write whoami`);
su.stdin.write(`whoami\n`);
try {
su.stdin?.write(`whoami\n`);
} catch {
// ignore
}
}, 50);
} else if (data === login) {
result = true;
Expand All @@ -55,21 +69,31 @@ function checkLinuxPassword(login: string, password: string): Promise<boolean> {
}

// Listen for data on stdout
su.stdout.on('data', data => _checkPassword(data.toString()));
su.stdout.on('data', data => {
if (data && responseTimeout) {
_checkPassword(data.toString());
}
});

// Listen for data on stderr
su.stderr.on('data', data => _checkPassword(data.toString()));
su.stderr.on('data', data => {
if (data && responseTimeout) {
_checkPassword(data.toString());
}
});

// Listen for the close event
su.on('close', () => {
console.log(`[LOG] -------- closed with result: ${result}\n`);
responseTimeout && clearTimeout(responseTimeout);
responseTimeout = null;
if (responseTimeout) {
clearTimeout(responseTimeout);
responseTimeout = null;
}
resolve(result);
});
} catch (e: any) {
console.error(`[LOG] -------- Error by execution: ${e.message}\n`);
reject(new Error(e));
} catch (e: unknown) {
console.error(`[LOG] -------- Error by execution: ${(e as Error).message}\n`);
reject(new Error(e as string));
}
});
}
Expand Down
Loading

0 comments on commit 470bcd6

Please sign in to comment.