From 1fbe0746a45ffde112e423c1088e4c14b4ce6165 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Jul 2021 11:36:48 +0200 Subject: [PATCH] Fixed custom icons not updating --- CHANGELOG.md | 46 +++++++++++++++++++ .../src/components/Apps/AppCard/AppCard.tsx | 2 +- .../src/components/Apps/AppForm/AppForm.tsx | 30 ++++++++---- controllers/apps.js | 9 +++- package.json | 2 +- routes/apps.js | 2 +- 6 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..44a7ec8 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,46 @@ +### v1.6 (2021-07-17) +- Added support for Steam URLs ([#62](https://github.com/pawelmalak/flame/issues/62)) +- Fixed bug with custom CSS not persisting ([#64](https://github.com/pawelmalak/flame/issues/64)) +- Added option to set default prefix for search bar ([#65](https://github.com/pawelmalak/flame/issues/65)) + +### v1.5 (2021-06-24) +- Added ability to set custom CSS from settings ([#8](https://github.com/pawelmalak/flame/issues/8) and [#17](https://github.com/pawelmalak/flame/issues/17)) (experimental) +- Added option to upload custom icons ([#12](https://github.com/pawelmalak/flame/issues/12)) +- Added option to open links in a new or the same tab ([#27](https://github.com/pawelmalak/flame/issues/27)) +- Added Search bar with support for 3 search engines and 4 services ([#44](https://github.com/pawelmalak/flame/issues/44)) +- Added option to hide applications and categories ([#48](https://github.com/pawelmalak/flame/issues/48)) +- Improved Logger + +### v1.4 (2021-06-18) +- Added more sorting options. User can now choose to sort apps and categories by name, creation time or to use custom order ([#13](https://github.com/pawelmalak/flame/issues/13)) +- Added reordering functionality. User can now set custom order for apps and categories from their 'edit tables' ([#13](https://github.com/pawelmalak/flame/issues/13)) +- Changed get all controllers for applications and categories to use case-insensitive ordering ([#36](https://github.com/pawelmalak/flame/issues/36)) +- New apps will be placed correctly in the array depending on used sorting settings ([#37](https://github.com/pawelmalak/flame/issues/37)) +- Added app version to settings with option to check for updates manually ([#38](https://github.com/pawelmalak/flame/issues/38)) +- Added update check on app start ([#38](https://github.com/pawelmalak/flame/issues/38)) +- Fixed bug with decimal input values in Safari browser ([#40](https://github.com/pawelmalak/flame/issues/40)) + +### v1.3 (2021-06-14) +- Added reverse proxy support ([#23](https://github.com/pawelmalak/flame/issues/23) and [#24](https://github.com/pawelmalak/flame/issues/24)) +- Added support for more url formats ([#26](https://github.com/pawelmalak/flame/issues/26)) +- Added ability to hide main header ([#28](https://github.com/pawelmalak/flame/issues/28)) +- Fixed settings not being synchronized ([#29](https://github.com/pawelmalak/flame/issues/29)) +- Added auto-refresh for greeting and date ([#34](https://github.com/pawelmalak/flame/issues/34)) + +### v1.2 (2021-06-10) +- Added simple check to the weather module settings to inform user if the api key is missing ([#2](https://github.com/pawelmalak/flame/issues/2)) +- Added ability to set optional icons to the bookmarks ([#7](https://github.com/pawelmalak/flame/issues/7)) +- Added option to pin new applications and categories to the homescreen by default ([#11](https://github.com/pawelmalak/flame/issues/11)) +- Added background highlight while hovering over application card ([#15](https://github.com/pawelmalak/flame/issues/15)) +- Created CRON job to clear old weather data from the database ([#16](https://github.com/pawelmalak/flame/issues/16)) +- Added proxy for websocket instead of using hard coded host ([#18](https://github.com/pawelmalak/flame/issues/18)) +- Fixed bug with overwriting opened tabs ([#20](https://github.com/pawelmalak/flame/issues/20)) + +### v1.1 (2021-06-09) +- Added custom favicon and changed page title ([#3](https://github.com/pawelmalak/flame/issues/3)) +- Added functionality to set custom page title ([#3](https://github.com/pawelmalak/flame/issues/3)) +- Changed messages on the homescreen when there are apps/bookmarks created but not pinned to the homescreen ([#4](https://github.com/pawelmalak/flame/issues/4)) +- Added 'warnings' to apps and bookmarks forms about supported url formats ([#5](https://github.com/pawelmalak/flame/issues/5)) + +### v1.0 (2021-06-08) +Initial release of Flame - self-hosted startpage using Node.js on backend and React on frontend. \ No newline at end of file diff --git a/client/src/components/Apps/AppCard/AppCard.tsx b/client/src/components/Apps/AppCard/AppCard.tsx index 43d7b72..79ad3d8 100644 --- a/client/src/components/Apps/AppCard/AppCard.tsx +++ b/client/src/components/Apps/AppCard/AppCard.tsx @@ -21,7 +21,7 @@ const AppCard = (props: ComponentProps): JSX.Element => { className={classes.AppCard} >
- {(/.(jpeg|jpg|png)$/).test(props.app.icon) + {(/.(jpeg|jpg|png)$/i).test(props.app.icon) ? {`${props.app.name} void; addApp: (formData: NewApp | FormData) => any; - updateApp: (id: number, formData: NewApp) => any; + updateApp: (id: number, formData: NewApp | FormData) => any; app?: App; } @@ -66,21 +65,32 @@ const AppForm = (props: ComponentProps): JSX.Element => { const formSubmitHandler = (e: SyntheticEvent): void => { e.preventDefault(); + const createFormData = (): FormData => { + const data = new FormData(); + if (customIcon) { + data.append('icon', customIcon); + } + data.append('name', formData.name); + data.append('url', formData.url); + + return data; + } + if (!props.app) { if (customIcon) { - const data = new FormData(); - data.append('icon', customIcon); - - data.append('name', formData.name); - data.append('url', formData.url); - + const data = createFormData(); props.addApp(data); } else { props.addApp(formData); } } else { - props.updateApp(props.app.id, formData); - props.modalHandler(); + if (customIcon) { + const data = createFormData(); + props.updateApp(props.app.id, data); + } else { + props.updateApp(props.app.id, formData); + props.modalHandler(); + } } setFormData({ diff --git a/controllers/apps.js b/controllers/apps.js index 238c66b..92c1736 100644 --- a/controllers/apps.js +++ b/controllers/apps.js @@ -20,7 +20,6 @@ exports.createApp = asyncWrapper(async (req, res, next) => { _body.icon = req.file.filename; } - if (pinApps) { if (parseInt(pinApps.value)) { app = await App.create({ @@ -96,7 +95,13 @@ exports.updateApp = asyncWrapper(async (req, res, next) => { return next(new ErrorResponse(`App with id of ${req.params.id} was not found`, 404)); } - app = await app.update({ ...req.body }); + let _body = { ...req.body }; + + if (req.file) { + _body.icon = req.file.filename; + } + + app = await app.update(_body); res.status(200).json({ success: true, diff --git a/package.json b/package.json index 3150454..2716484 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "start": "node server.js", - "init-server": "echo Instaling server dependencies && npm install", + "init-server": "echo Instaling server dependencies && npm install && mkdir public && touch public/flame.css", "init-client": "cd client && echo Instaling client dependencies && npm install", "dev-init": "npm run init-server && npm run init-client", "dev-server": "nodemon server.js", diff --git a/routes/apps.js b/routes/apps.js index 091550c..37c0286 100644 --- a/routes/apps.js +++ b/routes/apps.js @@ -19,7 +19,7 @@ router router .route('/:id') .get(getApp) - .put(updateApp) + .put(upload, updateApp) .delete(deleteApp); router