Skip to content

Commit

Permalink
Merge pull request emsesp#2006 from proddy/dev
Browse files Browse the repository at this point in the history
fix typos, optimize web log
  • Loading branch information
proddy authored Sep 12, 2024
2 parents a417cf7 + fde4255 commit f0ff51a
Show file tree
Hide file tree
Showing 54 changed files with 1,886 additions and 1,437 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ interface/tsconfig.tsbuildinfo

# python virtual environment
venv/

# cspell
words-found-verbose.txt
1 change: 1 addition & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- command 'show log' that lists out the current weblog buffer, showing last messages.
- default web log buffer to 25 lines for ESP32s with no PSRAM
- Try and determine correct board profile if none is set
- Auto Scroll in WebLog UI - reduced delay so incoming logs are faster

## Fixed

Expand Down
13 changes: 13 additions & 0 deletions cspell.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"version": "0.2",
"dictionaryDefinitions": [
{
"name": "project-words",
"path": "./project-words.txt",
"addWords": true
}
],
"dictionaries": ["project-words"],
"ignorePaths": ["node_modules", "**/venv/**", "lib/eModbus", "lib/ESPAsyncWebServer", "lib/espMqttClient", "analyse.html", "dist", "**/*.csv", "locale_translations.h", "TZ.tsx", "**/*.txt","build/**", "**/i18n/**", "/project-words.txt"]
}
17 changes: 8 additions & 9 deletions interface/package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "EMS-ESP",
"version": "3.7",
"description": "Build the EMS-ESP WebUI",
"version": "3.7.0",
"description": "EMS-ESP WebUI",
"homepage": "https://emsesp.org",
"author": "proddy",
"author": "proddy, emsesp.org",
"license": "MIT",
"private": true,
"type": "module",
Expand All @@ -24,8 +24,8 @@
"@alova/adapter-xhr": "2.0.7",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.0.2",
"@mui/material": "^6.0.2",
"@mui/icons-material": "^6.1.0",
"@mui/material": "^6.1.0",
"@table-library/react-table-library": "4.1.7",
"alova": "3.0.16",
"async-validator": "^4.2.5",
Expand All @@ -43,16 +43,15 @@
"devDependencies": {
"@babel/core": "^7.25.2",
"@eslint/js": "^9.10.0",
"@preact/compat": "^17.1.2",
"@preact/compat": "^18.3.1",
"@preact/preset-vite": "^2.9.0",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/babel__core": "^7",
"@types/formidable": "^3",
"@types/node": "^22.5.4",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"concurrently": "^9.0.0",
"concurrently": "^9.0.1",
"eslint": "^9.10.0",
"eslint-config-prettier": "^9.1.0",
"formidable": "^3.5.1",
Expand All @@ -64,5 +63,5 @@
"vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^5.0.1"
},
"packageManager": "[email protected].0"
"packageManager": "[email protected].1"
}
2 changes: 1 addition & 1 deletion interface/src/api/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const alovaInstance = createAlova({
method.config.headers.Authorization =
'Bearer ' + localStorage.getItem(ACCESS_TOKEN);
}
// for simualting vrey slow networks
// for simulating vrey slow networks
// return new Promise((resolve) => {
// const random = 3000 + Math.random() * 2000;
// setTimeout(resolve, Math.floor(random));
Expand Down
1 change: 0 additions & 1 deletion interface/src/api/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const readLogSettings = () =>
alovaInstance.Get<LogSettings>(`/rest/logSettings`);
export const updateLogSettings = (data: LogSettings) =>
alovaInstance.Post('/rest/logSettings', data);
export const fetchLog = () => alovaInstance.Post('/rest/fetchLog');
export const fetchLogES = () => alovaInstance.Get('/es/log');

// Get versions from github
Expand Down
1 change: 0 additions & 1 deletion interface/src/app/settings/DownloadUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ const DownloadUpload = () => {
if (!latestVersion || !latestDevVersion) {
return '';
}
console.log('getBinURL', useDevVersion, latestDevVersion, latestVersion);
const filename =
'EMS-ESP-' +
(useDevVersion ? latestDevVersion : latestVersion).replaceAll('.', '_') +
Expand Down
57 changes: 26 additions & 31 deletions interface/src/app/status/SystemLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import WarningIcon from '@mui/icons-material/Warning';
import { Box, Button, Checkbox, MenuItem, TextField, styled } from '@mui/material';
import Grid from '@mui/material/Grid2';

import {
fetchLog,
fetchLogES,
readLogSettings,
updateLogSettings
} from 'api/system';
import { fetchLogES, readLogSettings, updateLogSettings } from 'api/system';

import { useRequest, useSSE } from 'alova/client';
import {
Expand Down Expand Up @@ -86,7 +81,7 @@ const SystemLog = () => {
});

const [logEntries, setLogEntries] = useState<LogEntry[]>([]);
const [lastIndex, setLastIndex] = useState<number>(0);
const [autoscroll, setAutoscroll] = useState(true);

const updateFormValue = updateValueDirty(
origData,
Expand All @@ -95,28 +90,18 @@ const SystemLog = () => {
updateDataValue
);

// eslint-disable-next-line @typescript-eslint/unbound-method
const { onMessage, onError } = useSSE(fetchLogES, {
// withCredentials: true,
useSSE(fetchLogES, {
immediate: true,
interceptByGlobalResponded: false
});

onMessage((message: { id: number; data: string }) => {
const rawData = message.data;
const logentry = JSON.parse(rawData) as LogEntry;
if (logentry.i > lastIndex) {
setLastIndex(logentry.i);
})
.onMessage((message: { id: number; data: string }) => {
const rawData = message.data;
const logentry = JSON.parse(rawData) as LogEntry;
setLogEntries((log) => [...log, logentry]);
}
});

onError(() => {
toast.error('No connection to Log server');
});

// called on page load to reset pointer and fetch all log entries
useRequest(fetchLog());
})
.onError(() => {
toast.error('No connection to Log service');
});

const paddedLevelLabel = (level: LogLevel) => {
const label = levelLabel(level);
Expand Down Expand Up @@ -157,7 +142,7 @@ const SystemLog = () => {
// handle scrolling
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (logEntries.length) {
if (logEntries.length && autoscroll) {
ref.current?.scrollIntoView({
behavior: 'smooth',
block: 'end'
Expand All @@ -173,12 +158,12 @@ const SystemLog = () => {
return (
<>
<Grid container spacing={2} alignItems="center">
<Grid size={2}>
<Grid>
<TextField
name="level"
label={LL.LOG_LEVEL()}
value={data.level}
fullWidth
sx={{ width: '15ch' }}
variant="outlined"
onChange={updateFormValue}
margin="normal"
Expand All @@ -193,12 +178,12 @@ const SystemLog = () => {
</TextField>
</Grid>
{data.psram && (
<Grid size={2}>
<Grid>
<TextField
name="max_messages"
label={LL.BUFFER_SIZE()}
value={data.max_messages}
fullWidth
sx={{ width: '15ch' }}
variant="outlined"
onChange={updateFormValue}
margin="normal"
Expand All @@ -222,6 +207,16 @@ const SystemLog = () => {
}
label={LL.COMPACT()}
/>
<BlockFormControlLabel
control={
<Checkbox
checked={autoscroll}
onChange={() => setAutoscroll(!autoscroll)}
name="autoscroll"
/>
}
label={LL.AUTO_SCROLL()}
/>
</Grid>
<Button
startIcon={<DownloadIcon />}
Expand Down
3 changes: 2 additions & 1 deletion interface/src/i18n/de/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const de: Translation = {
LATEST_VERSION: 'Sie verwenden die neueste Firmware-Version.',
PLEASE_WAIT: 'Bitte warten',
RESTARTING_PRE: 'Initialisierung',
RESTARTING_POST: 'Vorbereitung'
RESTARTING_POST: 'Vorbereitung',
AUTO_SCROLL: 'Automatisches Scrollen'
};

export default de;
7 changes: 4 additions & 3 deletions interface/src/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const en: Translation = {
STABLE: 'Stable',
DEVELOPMENT: 'Development',
RELEASE_NOTES: 'release notes',
EMS_ESP_VER: 'Firmware Version', // TODO translate
EMS_ESP_VER: 'Firmware Version',
UPTIME: 'System Uptime',
FREE_MEMORY: 'Free Memory',
PSRAM: 'PSRAM (Size / Free)',
Expand All @@ -186,7 +186,7 @@ const en: Translation = {
FILESYSTEM: 'File System (Used / Free)',
BUFFER_SIZE: 'Max Buffer Size',
COMPACT: 'Compact',
DOWNLOAD_SETTINGS_TEXT: 'Create a backup of your configuration and settings', // TODO translate
DOWNLOAD_SETTINGS_TEXT: 'Create a backup of your configuration and settings',
UPLOAD_TEXT: 'Upload a new firmware (.bin) file or a backup file (.json)',
UPLOAD_DROP_TEXT: 'Drop file or click here',
ERROR: 'Unexpected Error, please try again',
Expand Down Expand Up @@ -338,7 +338,8 @@ const en: Translation = {
LATEST_VERSION: 'You are using the latest firmware version.',
PLEASE_WAIT: 'Please wait',
RESTARTING_PRE: 'Initializing',
RESTARTING_POST: 'Preparing'
RESTARTING_POST: 'Preparing',
AUTO_SCROLL: 'Auto Scroll'
};

export default en;
3 changes: 2 additions & 1 deletion interface/src/i18n/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const fr: Translation = {
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate // TODO translate
PLEASE_WAIT: 'Please wait', // TODO translate
RESTARTING_PRE: 'Initializing', // TODO translate
RESTARTING_POST: 'Preparing' // TODO translate
RESTARTING_POST: 'Preparing', // TODO translate
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default fr;
3 changes: 2 additions & 1 deletion interface/src/i18n/it/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const it: Translation = {
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate
PLEASE_WAIT: 'Please wait', // TODO translate
RESTARTING_PRE: 'Initializing', // TODO translate
RESTARTING_POST: 'Preparing' // TODO translate
RESTARTING_POST: 'Preparing', // TODO translate
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default it;
3 changes: 2 additions & 1 deletion interface/src/i18n/nl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const nl: Translation = {
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate
PLEASE_WAIT: 'Please wait', // TODO translate
RESTARTING_PRE: 'Initializing', // TODO translate
RESTARTING_POST: 'Preparing' // TODO translate
RESTARTING_POST: 'Preparing', // TODO translate
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default nl;
3 changes: 2 additions & 1 deletion interface/src/i18n/no/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const no: Translation = {
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate
PLEASE_WAIT: 'Please wait', // TODO translate
RESTARTING_PRE: 'Initializing', // TODO translate
RESTARTING_POST: 'Preparing' // TODO translate
RESTARTING_POST: 'Preparing', // TODO translate
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default no;
3 changes: 2 additions & 1 deletion interface/src/i18n/pl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ const pl: BaseTranslation = {
LATEST_VERSION: 'You are using the latest firmware version.', // TODO translate
PLEASE_WAIT: 'Please wait', // TODO translate
RESTARTING_PRE: 'Initializing', // TODO translate
RESTARTING_POST: 'Preparing' // TODO translate
RESTARTING_POST: 'Preparing', // TODO translate
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default pl;
57 changes: 29 additions & 28 deletions interface/src/i18n/sk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const sk: Translation = {
TX_ISSUES: 'Problémy s Tx – skontrolujte Tx režim',
DISCONNECTED: 'Odpojené',
EMS_SCAN: 'Naozaj chcete spustiť úplnú kontrolu zariadenia zbernice EMS?',
DATA_TRAFFIC: 'Dátová prevádzka', // TODO Translate
DATA_TRAFFIC: 'Dátová prevádzka',
EMS_DEVICE: 'EMS zariadenie',
SUCCESS: 'ÚSPEŠNÉ',
FAIL: 'ZLÝHANIE',
Expand Down Expand Up @@ -174,7 +174,7 @@ const sk: Translation = {
FACTORY_RESET: 'Továrenské nastavenia',
SYSTEM_FACTORY_TEXT: 'Zariadenie bolo obnovené z výroby a teraz sa reštartuje',
SYSTEM_FACTORY_TEXT_DIALOG: 'Naozaj chcete resetovať EMS-ESP na predvolené výrobné nastavenia?',
STABLE: 'Stabilná', // TODO translate
STABLE: 'Stabilná',
DEVELOPMENT: 'Vývojárska',
RELEASE_NOTES: 'poznámky k verzii',
EMS_ESP_VER: 'Firmware verzia',
Expand Down Expand Up @@ -291,9 +291,9 @@ const sk: Translation = {
SCHEDULE: 'Plánovač',
TIME: 'Čas',
TIMER: 'Časovač',
ONCHANGE: 'Pri zmene', // TODO translate
CONDITION: 'Podmienka', // TODO translate
IMMEDIATE: 'Okamžite', // TODO translate
ONCHANGE: 'Pri zmene',
CONDITION: 'Podmienka',
IMMEDIATE: 'Okamžite',
SCHEDULE_UPDATED: 'Plánovanie aktualizované',
SCHEDULE_TIMER_1: 'pri spustení',
SCHEDULE_TIMER_2: 'každú minútu',
Expand All @@ -315,30 +315,31 @@ const sk: Translation = {
ALWAYS: 'Vždy',
ACTIVITY: 'Aktivita',
CONFIGURE: 'Konfiguracia {0}',
SYSTEM_MEMORY: 'Systémová pamäť', // TODO translate
APPLICATION_SETTINGS_1: 'Zmeniť nastavenia aplikácie EMS-ESP', // TODO translate
SECURITY_1: 'Pridať, alebo odstrániť použivateľov', // TODO translate
DOWNLOAD_UPLOAD_1: 'Stiahnúť a nahrať nastavenia a firmware', // TODO translate
MODULES: 'Moduly', // TODO translate
MODULES_1: 'Aktivujte alebo deaktivujte externé moduly', // TODO translate
MODULES_UPDATED: 'Aktualizované moduly', // TODO translate
MODULES_DESCRIPTION: 'Kliknutím na modul aktivujete alebo deaktivujete moduly knižnice EMS-ESP', // TODO translate
MODULES_NONE: 'Neboli zistené žiadne externé moduly', // TODO translate
RENAME: 'Premenovať', // TODO translate
SYSTEM_MEMORY: 'Systémová pamäť',
APPLICATION_SETTINGS_1: 'Zmeniť nastavenia aplikácie EMS-ESP',
SECURITY_1: 'Pridať, alebo odstrániť použivateľov',
DOWNLOAD_UPLOAD_1: 'Stiahnúť a nahrať nastavenia a firmware',
MODULES: 'Moduly',
MODULES_1: 'Aktivujte alebo deaktivujte externé moduly',
MODULES_UPDATED: 'Aktualizované moduly',
MODULES_DESCRIPTION: 'Kliknutím na modul aktivujete alebo deaktivujete moduly knižnice EMS-ESP',
MODULES_NONE: 'Neboli zistené žiadne externé moduly',
RENAME: 'Premenovať',
ENABLE_MODBUS: 'Povoliť Modbus',
VIEW_LOG: 'Zobrazte log na diagnostiku problémov', // TODO translate
UPLOAD_DRAG: 'presuňte sem súbor alebo ho kliknutím vyberte', // TODO translate
SERVICES: 'Služby', // TODO translate
ALLVALUES: 'Všetky hodnoty', // TODO translate
SPECIAL_FUNCTIONS: 'Špeciálne funkcie', // TODO translate
WAIT_FIRMWARE: 'Firmvér sa nahráva a inštaluje', // TODO translate
INSTALL_VERSION: 'Týmto sa nainštaluje verzia {0}. Si si istý?', // TODO translate
SWITCH_DEV: 'prejsť na vývojovú verziu', // TODO translate
UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!', // TODO translate
LATEST_VERSION: 'Používate poslednú verziu firmvéru.', // TODO translate
PLEASE_WAIT: 'Čakajte prosím', // TODO translate
RESTARTING_PRE: 'Prebieha inicializácia', // TODO translate
RESTARTING_POST: 'Opätovné načítanie' // TODO translate
VIEW_LOG: 'Zobrazte log na diagnostiku problémov',
UPLOAD_DRAG: 'presuňte sem súbor alebo ho kliknutím vyberte',
SERVICES: 'Služby',
ALLVALUES: 'Všetky hodnoty',
SPECIAL_FUNCTIONS: 'Špeciálne funkcie',
WAIT_FIRMWARE: 'Firmvér sa nahráva a inštaluje',
INSTALL_VERSION: 'Týmto sa nainštaluje verzia {0}. Si si istý?',
SWITCH_DEV: 'prejsť na vývojovú verziu',
UPGRADE_AVAILABLE: 'K dispozícii je aktualizácia firmvéru!',
LATEST_VERSION: 'Používate poslednú verziu firmvéru.',
PLEASE_WAIT: 'Čakajte prosím',
RESTARTING_PRE: 'Prebieha inicializácia',
RESTARTING_POST: 'Príprava',
AUTO_SCROLL: 'Auto Scroll' // TODO translate
};

export default sk;
Loading

0 comments on commit f0ff51a

Please sign in to comment.