From 19a910a91c3eab2ee5b6ccb6dd7fcbca49764bbf Mon Sep 17 00:00:00 2001 From: soulteary Date: Tue, 4 Jan 2022 13:26:50 +0800 Subject: [PATCH 1/4] bugfix: local-search support cjk --- client/src/components/SearchBar/SearchBar.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/components/SearchBar/SearchBar.tsx b/client/src/components/SearchBar/SearchBar.tsx index 99200730..dd0efe40 100644 --- a/client/src/components/SearchBar/SearchBar.tsx +++ b/client/src/components/SearchBar/SearchBar.tsx @@ -69,7 +69,8 @@ export const SearchBar = (props: Props): JSX.Element => { ); if (isLocal) { - setLocalSearch(search); + // no additional encoding required for local search + setLocalSearch(inputRef.current.value); } if (e.code === 'Enter' || e.code === 'NumpadEnter') { From 0044d265d1f7789afd2b432a9cdd47585669f6d7 Mon Sep 17 00:00:00 2001 From: soulteary Date: Tue, 4 Jan 2022 14:18:54 +0800 Subject: [PATCH 2/4] chore: bg-task optimization --- server.js | 1 + utils/jobs.js | 49 +++++++++++++++++++++++++++---------------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/server.js b/server.js index c6f25f94..41705634 100644 --- a/server.js +++ b/server.js @@ -23,6 +23,7 @@ const logger = new Logger(); await initApp(); await connectDB(); await associateModels(); + await jobs(); // Create server for Express API and WebSockets const server = http.createServer(); diff --git a/utils/jobs.js b/utils/jobs.js index 0ce32842..615c5ef4 100644 --- a/utils/jobs.js +++ b/utils/jobs.js @@ -6,30 +6,35 @@ const Logger = require('./Logger'); const loadConfig = require('./loadConfig'); const logger = new Logger(); -// Update weather data every 15 minutes -const weatherJob = schedule.scheduleJob( - 'updateWeather', - '0 */15 * * * *', - async () => { - const { WEATHER_API_KEY: secret } = await loadConfig(); +module.exports = async function () { + const { WEATHER_API_KEY } = await loadConfig(); + const FEAT_WHEATHER_ENABLED = WEATHER_API_KEY != ''; - try { - const weatherData = await getExternalWeather(); + if (FEAT_WHEATHER_ENABLED) { + // Update weather data every 15 minutes + const weatherJob = schedule.scheduleJob( + 'updateWeather', + '0 */15 * * * *', + async () => { + try { + const weatherData = await getExternalWeather(); - Sockets.getSocket('weather').socket.send(JSON.stringify(weatherData)); - } catch (err) { - if (secret) { - logger.log(err.message, 'ERROR'); + Sockets.getSocket('weather').socket.send(JSON.stringify(weatherData)); + } catch (err) { + if (WEATHER_API_KEY) { + logger.log(err.message, 'ERROR'); + } + } } - } - } -); + ); -// Clear old weather data every 4 hours -const weatherCleanerJob = schedule.scheduleJob( - 'clearWeather', - '0 5 */4 * * *', - async () => { - clearWeatherData(); + // Clear old weather data every 4 hours + const weatherCleanerJob = schedule.scheduleJob( + 'clearWeather', + '0 5 */4 * * *', + async () => { + clearWeatherData(); + } + ); } -); +}; From 396c442062ab9d7a1e06c76b379637170bda3536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Malak?= Date: Sat, 8 Jan 2022 12:48:33 +0100 Subject: [PATCH 3/4] Added app descriptions to local search parser --- CHANGELOG.md | 3 +++ client/src/components/Home/Home.tsx | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 008f899b..ce9aec09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### v2.X.Y (TBA) +- Local search will now include app descriptions ([#266](https://github.com/pawelmalak/flame/issues/266)) + ### v2.2.0 (2021-12-17) - Added option to set custom description for apps ([#201](https://github.com/pawelmalak/flame/issues/201)) - Fixed fatal error while deploying Flame to cluster ([#242](https://github.com/pawelmalak/flame/issues/242)) diff --git a/client/src/components/Home/Home.tsx b/client/src/components/Home/Home.tsx index e24e5c0e..629ed893 100644 --- a/client/src/components/Home/Home.tsx +++ b/client/src/components/Home/Home.tsx @@ -64,8 +64,10 @@ export const Home = (): JSX.Element => { if (localSearch) { // Search through apps setAppSearchResult([ - ...apps.filter(({ name }) => - new RegExp(escapeRegex(localSearch), 'i').test(name) + ...apps.filter(({ name, description }) => + new RegExp(escapeRegex(localSearch), 'i').test( + `${name} ${description}` + ) ), ]); From fac8ef40278e984a120c18179ee31d5afc7e1120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Malak?= Date: Sat, 8 Jan 2022 14:03:10 +0100 Subject: [PATCH 4/4] Pushed version 2.2.1 --- .env | 2 +- CHANGELOG.md | 4 +- client/.env | 2 +- .../Settings/AppDetails/AppDetails.tsx | 72 +++++++++++-------- utils/jobs.js | 3 +- 5 files changed, 49 insertions(+), 34 deletions(-) diff --git a/.env b/.env index 71d9fdb6..d5f54d5b 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ PORT=5005 NODE_ENV=development -VERSION=2.2.0 +VERSION=2.2.1 PASSWORD=flame_password SECRET=e02eb43d69953658c6d07311d6313f2d4467672cb881f96b29368ba1f3f4da4b \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ce9aec09..9502adfb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ -### v2.X.Y (TBA) +### v2.2.1 (2022-01-08) - Local search will now include app descriptions ([#266](https://github.com/pawelmalak/flame/issues/266)) +- Fixed bug with unsupported characters in local search [#279](https://github.com/pawelmalak/flame/issues/279)) +- Background tasks optimization ([#283](https://github.com/pawelmalak/flame/issues/283)) ### v2.2.0 (2021-12-17) - Added option to set custom description for apps ([#201](https://github.com/pawelmalak/flame/issues/201)) diff --git a/client/.env b/client/.env index b41b338a..edd69d98 100644 --- a/client/.env +++ b/client/.env @@ -1 +1 @@ -REACT_APP_VERSION=2.2.0 \ No newline at end of file +REACT_APP_VERSION=2.2.1 \ No newline at end of file diff --git a/client/src/components/Settings/AppDetails/AppDetails.tsx b/client/src/components/Settings/AppDetails/AppDetails.tsx index 1829a4df..efa15860 100644 --- a/client/src/components/Settings/AppDetails/AppDetails.tsx +++ b/client/src/components/Settings/AppDetails/AppDetails.tsx @@ -1,43 +1,57 @@ import { Fragment } from 'react'; + +// UI import { Button, SettingsHeadline } from '../../UI'; +import { AuthForm } from './AuthForm/AuthForm'; import classes from './AppDetails.module.css'; + +// Store +import { useSelector } from 'react-redux'; +import { State } from '../../../store/reducers'; + +// Other import { checkVersion } from '../../../utility'; -import { AuthForm } from './AuthForm/AuthForm'; export const AppDetails = (): JSX.Element => { + const { isAuthenticated } = useSelector((state: State) => state.auth); + return ( -
- -
- -

- - Flame - {' '} - version {process.env.REACT_APP_VERSION} -

- -

- See changelog{' '} - - here - -

- - -
+ {isAuthenticated && ( + +
+ +
+ +

+ + Flame + {' '} + version {process.env.REACT_APP_VERSION} +

+ +

+ See changelog{' '} + + here + +

+ + +
+
+ )}
); }; diff --git a/utils/jobs.js b/utils/jobs.js index 615c5ef4..e509ef50 100644 --- a/utils/jobs.js +++ b/utils/jobs.js @@ -8,9 +8,8 @@ const logger = new Logger(); module.exports = async function () { const { WEATHER_API_KEY } = await loadConfig(); - const FEAT_WHEATHER_ENABLED = WEATHER_API_KEY != ''; - if (FEAT_WHEATHER_ENABLED) { + if (WEATHER_API_KEY != '') { // Update weather data every 15 minutes const weatherJob = schedule.scheduleJob( 'updateWeather',