Compare commits

...

326 Commits

Author SHA1 Message Date
Thomas Camlong
ce0f27bb6e v0.8.0 Docker 🐋 and Dash. ⚙ integrations !
<!-- Small release message -->

-  Add support for lists in module option by @ajnart in https://github.com/ajnart/homarr/pull/280
- 🔨 Fix Readarr default port number by @Moohan in https://github.com/ajnart/homarr/pull/287
-  Add dash. Integration by @MauriceNino in https://github.com/ajnart/homarr/pull/277
-  Add Docker integration by @ajnart in https://github.com/ajnart/homarr/pull/289

- Dash. (Pronounced Dashdot) is another self-hosted service, made by @MauriceNino that provides a simple way to see stats about your PC in a sleek way
- Docker integration provides a simple way to start, stop, restart and delete containers. To get started, simply mount your docker socket by adding `-v /var/run/docker.sock:/var/run/docker.sock` to your Homarr container !

* @Moohan made their first contribution in https://github.com/ajnart/homarr/pull/287
* @MauriceNino made their first contribution in https://github.com/ajnart/homarr/pull/277

**Full Changelog**: https://github.com/ajnart/homarr/compare/v0.7.2...v0.8.0
2022-07-20 16:49:48 +02:00
Thomas Camlong
5c1a171832 🔀 Merge pull request #289 from ajnart/docker-integration
Add Docker integration 🚀
2022-07-20 15:22:40 +02:00
Thomas "ajnart" Camlong
fd8ab2f643 🔀 Backmerge dev with dash. integration 2022-07-20 15:15:07 +02:00
Thomas Camlong
c750eed5ef Merge branch 'dev' into docker-integration 2022-07-20 15:05:16 +02:00
Thomas "ajnart" Camlong
c446bf1a1f 📦 Update cookies-next package 2022-07-20 15:02:09 +02:00
Thomas Camlong
0fdfa55067 🔀 Merge pull request #277 from MauriceNino/feature/276
Add dash. Integration thanks to @MauriceNino !
2022-07-20 14:52:12 +02:00
Thomas "ajnart" Camlong
c313eacefd 🐛 Fix small bug with the network module 2022-07-20 14:47:51 +02:00
Thomas "ajnart" Camlong
649f7521bc 🔒 Add guard for Docker socket 2022-07-20 14:21:11 +02:00
Thomas "ajnart" Camlong
7065b06c82 💄 Format code 2022-07-20 14:09:47 +02:00
Thomas "ajnart" Camlong
c4e01e482e Add simple image name matching 2022-07-20 14:08:56 +02:00
Thomas Camlong
e56c4b6b56 🔀 Merge pull request #287 from Moohan/master
Fix Readarr default port number
2022-07-11 13:54:01 +02:00
James McMahon
ce38163c6d Fix Readarr default port number
Per https://wiki.servarr.com/readarr
2022-07-11 12:21:28 +01:00
Thomas Camlong
0406d6d5ee Add skeleton while the meto module is loading 2022-07-07 07:13:11 +00:00
Thomas Camlong
4b92c52ea8 Add "Add to homarr" feature and move code 2022-07-06 18:08:39 +02:00
Thomas Camlong
be770d282a ⬆️ Upgrade NextJS version 2022-07-06 18:08:03 +02:00
MauriceNino
0bf95483f9 fix: styles for dash. widget 2022-06-30 16:08:39 +02:00
MauriceNino
60b88389a6 fix: remove leftover console.log 2022-06-30 16:08:39 +02:00
MauriceNino
72832a5767 fix: move enabled options to multi-select 2022-06-30 16:08:39 +02:00
MauriceNino
eb0313f551 fix: transform dash. -> dashdot for icon find 2022-06-30 16:08:39 +02:00
MauriceNino
c0ecc3d4c6 fix: types 2022-06-30 16:08:38 +02:00
MauriceNino
da7b478d81 feat: add dash. integration 2022-06-30 16:08:38 +02:00
Thomas Camlong
2702c9a7cf 🔀 Merge pull request #280 from ajnart/ajnart/issue279
 Add support for lists in module option
2022-06-28 22:33:28 +02:00
Thomas Camlong
3bda6c2b76 🔥 Remove the popover TIP when using the searchbar 2022-06-28 19:09:02 +02:00
Thomas Camlong
1a66bfb8be add a <Tip/> component and use it 2022-06-28 19:08:18 +02:00
Thomas Camlong
41be0e6362 🐛 Fix default values for modules
The default value was not set correctly for modules. This has been fixed. It was also fixed in the Weather Module and the Date Module.
2022-06-28 12:12:39 +02:00
Thomas Camlong
e93a3a3b5f Add support for lists in module option
This feature allows a module maker to use a list as the different possible values for a module integration.
2022-06-28 11:27:23 +02:00
Thomas Camlong
9945ef892e 📱 Fix settings pannels height 2022-06-28 11:06:45 +02:00
Thomas Camlong
812de35149 🐛 Fix a bug where download module was always there 2022-06-28 10:34:25 +02:00
Thomas Camlong
035224b02b add start/stop/restart feature on containers 2022-06-27 23:38:54 +02:00
Thomas Camlong
72aba9d8cd 🚧 Work in progress on the Docker integration 2022-06-27 19:25:26 +02:00
ajnart
df7e833b84 🚧 Work in progress on docker integration 2022-06-27 08:03:40 +02:00
Thomas Camlong
aab1492934 🔖 v0.7.2 2022-06-25 17:53:20 +02:00
Thomas Camlong
1ae074db8f 🔥 Remove .docusaurus/ 2022-06-25 17:51:44 +02:00
Thomas Camlong
f21004e944 🔖 v0.7.2
Tag version v0.7.2
2022-06-25 17:47:39 +02:00
Thomas Camlong
7c421cc52f 🔀 Merge pull request #260 from walkxcode/dev
💄 Changes AppShelf category styling
2022-06-25 16:11:38 +02:00
Thomas Camlong
d8e407ab22 🔀 Merge pull request #257 from ajnart/fix-multiple-torrent-client
🐛 Fix itteration on the different types of services
2022-06-25 15:36:59 +02:00
Thomas Camlong
37565284e6 🔀 Merge pull request #271 from ajnart/searchBar
 Adds query placeholder and autoFocus (#267 #268)
2022-06-25 15:36:06 +02:00
Bjorn Lammers
b758df9f44 🔥 Fix indentation because I'm a perfectionist 2022-06-25 15:14:39 +02:00
Bjorn Lammers
a735ae47c5 🙈 Updates .dockerignore 2022-06-25 15:13:00 +02:00
WalkxCode
97d585dc17 Adds query placeholder and autoFocus (#267 #268) 2022-06-25 14:02:53 +02:00
Thomas Camlong
7f3db9add1 🐛 Fix adding a service doesn't fetch 2022-06-24 13:44:43 +02:00
Thomas Camlong
6d6964f086 🔀 Merge pull request #258 from ajnart/ajnart/issue256
🐛 Allow anything in the input for the form.
2022-06-24 13:39:18 +02:00
Thomas Camlong
2a4012f73a 🔀 Merge pull request #263 from ajnart/#261-discord
💬 Adds Discord Button (#261)
2022-06-24 12:44:23 +02:00
Bjorn Lammers
9385315f03 🔀 Merge pull request #265 from jelliuk/patch-1 2022-06-24 12:06:27 +02:00
James
ee824f0b27 Update README.md
Correct the link to Wiki/Integrations
2022-06-24 10:36:43 +01:00
Bjorn Lammers
792af504c7 💬 Adds Discord Button
#261
2022-06-22 13:19:44 +02:00
Bjorn Lammers
cd3c062a24 💄 Changes AppShelf category styling 2022-06-21 19:14:18 +00:00
ajnart
a5f477c19b 🚑 Hotfix to spread torrent pushing 2022-06-21 21:04:21 +02:00
ajnart
85164d79fc 🚑 Hotfix password and usernames 2022-06-21 20:35:40 +02:00
ajnart
7aedc4111f 🚑 Hotfix how the result from the services are awaited 2022-06-21 19:59:25 +02:00
ajnart
d1f89847f5 💄 Small UI fix for mobile 2022-06-21 19:38:32 +02:00
ajnart
57170847a1 🐛 Allow anything in the input for the form.
If it works, it works.
Fixes #256
2022-06-21 19:22:14 +02:00
ajnart
45de715390 🐛 Fix itteration on the different types of services 2022-06-21 19:16:29 +02:00
Thomas Camlong
c29d6f58dd 🔀 Merge pull request #252 from LarveyOfficial/fix-multiple-download-clients
🐛Allow multiple of the same torrent client +1
2022-06-21 16:22:18 +02:00
ajnart
f0bae49830 🚨 Lint and prettier fix 2022-06-21 16:21:40 +02:00
Larvey
c3ceae4dc6 Also fixed Torrent form fields 2022-06-20 17:26:13 -04:00
Larvey
d654fb39e5 🐛Allow multiple of the same torrent client
Allows multiple of the same type of torrent client
2022-06-20 17:10:54 -04:00
Thomas Camlong
7dc205fa66 🚀 v0.7.1 ! Bug fixes and QOL improvements
### Features
*  Changing deluge/qbittorent to use href instead of origin by @VinnyVynce in https://github.com/ajnart/homarr/pull/178
*  Transmission Integration by @ajnart in https://github.com/ajnart/homarr/pull/181
*  Add different URL for API calls by @ajnart in https://github.com/ajnart/homarr/pull/180
* Password / Login Page by @ajnart in https://github.com/ajnart/homarr/pull/179
*  Ability to toggle categories by @ajnart in https://github.com/ajnart/homarr/pull/177
*  Add settings to change title and icons by @Aimsucks in https://github.com/ajnart/homarr/pull/184
*  Color, shade, app opacity, and background customizations by @Aimsucks in https://github.com/ajnart/homarr/pull/188
*  Calendar indication about date and w-e with secondary color by @Darkham42 in https://github.com/ajnart/homarr/pull/193
*  More Information in Torrents Module by @LarveyOfficial in https://github.com/ajnart/homarr/pull/195
*  Could position widgets at left by @Darkham42 in https://github.com/ajnart/homarr/pull/197
*  Configure calendar widget to show Sunday first by @ajnart in https://github.com/ajnart/homarr/pull/224
* Service Addition Overhaul by @LarveyOfficial in https://github.com/ajnart/homarr/pull/229
*  Slidable service span in customizations  by @Aimsucks in https://github.com/ajnart/homarr/pull/222
### Tweaks
🔧 Make credentials non-required for torrents by @ajnart in https://github.com/ajnart/homarr/pull/223
### Bug fixes
* 🐛Fix completed torrents progress color by @LarveyOfficial in https://github.com/ajnart/homarr/pull/227
* 🐛Tiles could be moved accidentally on mobiles by @ajnart in https://github.com/ajnart/homarr/pull/226
* 🐛 Cannot open "New Tab URL" on mobile by @ajnart in https://github.com/ajnart/homarr/pull/225
* 🐛 Fix Calendar Item Duplication by @LarveyOfficial in https://github.com/ajnart/homarr/pull/249
* 🐛Fix URL for Radarr and other services by @LarveyOfficial in https://github.com/ajnart/homarr/pull/250
* 🐛 Fix Calendar not loading content when a service fails by @LarveyOfficial in https://github.com/ajnart/homarr/pull/230
* 🐛 Calendar current day for light theme by @Darkham42 in https://github.com/ajnart/homarr/pull/194
* 🐛 Fix for timezone issues by @LarveyOfficial in https://github.com/ajnart/homarr/pull/186
* 🐛 Fix Sonarr Incorrect Dates by @LarveyOfficial in https://github.com/ajnart/homarr/pull/189
* 🐛 Fix for origin URL not containing path in API request URL by @Aimsucks in https://github.com/ajnart/homarr/pull/221
2022-06-20 22:09:25 +02:00
ajnart
91a249d953 🔖 tag v0.7.1 2022-06-20 22:03:43 +02:00
Thomas Camlong
356afda9c7 Merge pull request #250 from LarveyOfficial/patch-2
🐛Fix URL for Radarr and other services
2022-06-20 20:14:17 +02:00
Larvey
35f02a2296 Fix URL for Radarr and other services 2022-06-20 14:02:33 -04:00
Thomas Camlong
16bcec0deb Merge pull request #249 from LarveyOfficial/patch-1
🐛 Fix Calendar Item Duplication
2022-06-20 19:45:47 +02:00
Larvey
16ec57081b Fix Calendar Item Duplication
- 6fd23cf6a0 changed how items for the calendar are acquired, making it so every series gets updated when a new one gets added, or one gets moved. This causes the entries in the calendar to duplicate due to old code being left in.
2022-06-20 13:32:31 -04:00
ajnart
690f09fcf3 🚑 Hotfix ServiceItems 2022-06-20 10:40:30 +02:00
Thomas Camlong
2f960169bb 🔀 Merge pull request #222 from Aimsucks/app-card-with-slider
 Slidable service span in customizations
2022-06-20 10:29:39 +02:00
ajnart
14a40d9f66 🔧 Tweak values and UI changes 2022-06-20 10:24:22 +02:00
Thomas Camlong
e5abd67f83 🔀 Merge pull request #221 from Aimsucks/issue-215-fix
🐛 Fix for origin URL not containing path in API request URL
2022-06-20 10:22:13 +02:00
Thomas Camlong
399ba7e2fc 🔀 Merge pull request #229 from LarveyOfficial/rework-AddAppShelfItem
Service Addition Overhaul
2022-06-20 10:20:01 +02:00
ajnart
7780ae3d7a ♻️ Re-implement changes 2022-06-20 10:17:49 +02:00
ajnart
80d3f16473 🔧 Tweak UI and change the name of the settings 2022-06-20 10:06:30 +02:00
Larvey
a8c0dfcd0c Fix Capitalization 2022-06-20 10:06:15 +02:00
Larvey
6ee7d6ec8d declutter config file 2022-06-20 10:06:15 +02:00
Larvey
544fae3808 Added Scrollbar 2022-06-20 10:05:55 +02:00
Larvey
4516dde1f4 Reworked AddAppShelfItem
Adds:
- Advanced Options tab
- Changed which ping status codes identify as "Online"
- Change if service opens in new tab or not

Fixes:
- Deluge and Transmission Password requirement
2022-06-20 10:01:36 +02:00
Thomas Camlong
a20c5f8d12 🔀 Merge pull request #223 from ajnart/transmission-login
🔧 Make credentials non-required for torrents
2022-06-20 09:08:10 +02:00
Thomas Camlong
60e5c0d165 🔀 Merge pull request #230 from LarveyOfficial/calendar-multi-content-fix
🐛 Fix Calendar not loading content when a service fails
2022-06-20 09:03:14 +02:00
Larvey
b7bf18250d Fix CalendarModule.tsx
Fix no content showing when 1 of the same service is down.
2022-06-16 21:02:30 -04:00
Thomas Camlong
93256b7a6a 🔀 Merge pull request #224 from ajnart/ajnart/issue217
 Configure calendar widget to show Sunday first #217
2022-06-15 06:52:50 +02:00
Thomas Camlong
47a4437a01 🔀 Merge pull request #225 from ajnart/ajnart/issue202
🐛 Fix cannot open "New Tab URL" on mobile
2022-06-15 06:52:16 +02:00
Thomas Camlong
92470c619e 🔀 Merge pull request #226 from ajnart/ajnart/issue214
🐛Tiles could be moved accidentally on mobiles
2022-06-15 06:51:18 +02:00
Thomas Camlong
7cb3dfbd16 🔀 Merge pull request #227 from LarveyOfficial/fix-progress-color
🐛Fix completed torrents progress color
2022-06-15 06:51:06 +02:00
ajnart
d69e4f41a1 🐛 Fix required username 2022-06-15 06:47:53 +02:00
Larvey
4980254e89 Update DownloadsModule.tsx 2022-06-14 21:14:26 -04:00
ajnart
5133286e04 🐛Tiles could be moved accidentally on mobiles
Fixes #214
2022-06-14 22:45:31 +02:00
ajnart
ca2713a12c 🐛 Cannot open "New Tab URL" on mobile
Fixes #202
2022-06-14 22:11:55 +02:00
ajnart
4981823c37 🔧 Tweak values on the slider 2022-06-14 22:09:30 +02:00
ajnart
5d31e414f0 Configure calendar widget to show Sunday first
Fixes #217
2022-06-14 20:50:11 +02:00
ajnart
8ec2b9d0cd 🔧 Make credentials non-required for torrents
Fixes #201
2022-06-14 20:33:26 +02:00
Aimsucks
bd920dfc86 App card width slider
Added a slider to determine the XL app card width
2022-06-14 17:45:22 +00:00
Aimsucks
b5540a9958 🐛 Origin URL in calendar to includes path
Changed the origin variable in the calendar module to use the entire URL instead of just the origin domain
2022-06-14 17:01:30 +00:00
Thomas Camlong
778988de58 🚀 v0.7.0 : Theming, Password protection, Autocompletion, Transmission, Mobile responsiveness! This is a big upgrade 👀 2022-06-13 10:15:39 +02:00
ajnart
5b1437552d 🔖 Bump version to v0.7.0 2022-06-12 16:58:48 +02:00
WalkxCode
e8a8fbe6ac 💄 Makes the ModuleEnabler grid look better 2022-06-12 16:35:56 +02:00
WalkxCode
5c0a074219 💬 Updates names and placeholders in AddAppShelfItem 2022-06-12 16:35:31 +02:00
WalkxCode
58ec74bb68 🚸 Improves case matching for auto-fill 2022-06-12 16:34:24 +02:00
Thomas Camlong
6ac82bda40 🔀 Merge pull request #197 from Darkham42/dev
feat: could position widgets at left
2022-06-12 15:46:13 +02:00
Thomas Camlong
2c6e86840a 🔀 Merge pull request #195 from LarveyOfficial/patch-3
More Information in Torrents Module
2022-06-12 15:39:32 +02:00
ajnart
df85fc6b7d 🐛 Fix multiple bugs and reformat code 2022-06-12 15:38:14 +02:00
Darkham42
89804dafd1 feat: could position widgets at left 2022-06-12 08:04:20 +02:00
Larvey
98eaee1234 Use humanFileSize 2022-06-12 01:15:38 -04:00
Larvey
433edafddd Remove humanFileSize 2022-06-12 01:14:38 -04:00
Larvey
e39d5741b6 Create humanFileSize.ts 2022-06-12 01:13:51 -04:00
Larvey
21c08cbe63 Change Elements hidden on Mobile 2022-06-12 00:59:12 -04:00
Larvey
ec92a1d89c Removed new Features on Mobile (Temporary) 2022-06-12 00:52:12 -04:00
ajnart
0f2c5dbce2 🔥 Remove keyboard usage to sort items 2022-06-12 06:36:37 +02:00
Larvey
8eae5a908c Merge branch 'dev' into patch-3 2022-06-12 00:25:36 -04:00
Thomas Camlong
a37f0fdee6 🔀 Merge pull request #194 from Darkham42/dev
fix: calendar current day for light theme
2022-06-12 06:16:59 +02:00
Larvey
08799aac18 Fix build issue from pull request #193 2022-06-11 19:16:03 -04:00
Larvey
06531e0fb8 Removed Logging used during development 2022-06-11 19:02:34 -04:00
Larvey
0f56ead24f Fixed Customization Spelling 2022-06-11 19:00:50 -04:00
Larvey
922caa76da More Info in Torrents Module
Added
- ETA
- Torrent Size
- Paused state color in progress bar
2022-06-11 18:59:45 -04:00
Darkham42
0acb1f6b6d refactor: use theme 2022-06-11 23:44:14 +02:00
Darkham42
8d645ca404 fix: calendar current day for light theme 2022-06-11 23:22:58 +02:00
Thomas Camlong
a5c4f30f57 Merge pull request #193 from Darkham42/dev
feat: calendar indication about date and w-e with secondary color
2022-06-11 20:20:37 +02:00
Darkham42
562a05adf5 feat: calendar indication about date and we with secondary color 2022-06-11 20:11:20 +02:00
Thomas Camlong
de77e06b18 🔀 Merge pull request #188 from Aimsucks/more-customizations
Color, shade, app opacity, and background customizations thank you @Aimsucks !
2022-06-11 19:49:46 +02:00
ajnart
03c499d822 🚚 Make the weather module release (from beta) 2022-06-11 19:45:09 +02:00
ajnart
169d08f3b6 🚚 Move selectors to customisation tab 2022-06-11 19:44:11 +02:00
ajnart
437807a9e0 💄 Change module enabler layout 2022-06-11 19:43:01 +02:00
ajnart
4866fd74b5 🚚 Rename tabs in settings 2022-06-11 19:42:36 +02:00
ajnart
426ba69afd Add more transparency areas and fix bugs 2022-06-11 18:37:13 +02:00
Aimsucks
74f87b570d Update src/components/layout/Background.tsx
Co-authored-by: Bjorn Lammers <walkxnl@gmail.com>
2022-06-08 18:09:59 -04:00
Aimsucks
fed5f6df52 📝 Added a placeholder for background 2022-06-08 20:20:24 +00:00
Aimsucks
5cc160473c Revert "📝 Background image placeholder and instructions"
This reverts commit 4833157061.
2022-06-08 20:18:42 +00:00
Aimsucks
4833157061 📝 Background image placeholder and instructions
Updated readme with instructions to mount the /public folder instead of the /public/icons folder, as well as added a placeholder for background image settings
2022-06-08 18:13:41 +00:00
Aimsucks
a0c8518d22 🎨 Made opacity change app background
Made the opacity slider change the individual app background and border rgba values instead of the entire app.
2022-06-08 18:01:16 +00:00
Aimsucks
c0c816d3db Update src/components/Settings/ShadeSelector.tsx
Co-authored-by: Bjorn Lammers <walkxnl@gmail.com>
2022-06-08 13:13:04 -04:00
Aimsucks
ac47de72ee Merge branch 'dev' into more-customizations 2022-06-08 12:48:02 -04:00
ajnart
d631865f71 💄 Small UI qol update
Module download now has a different look and can be toggled on and off
2022-06-08 18:41:22 +02:00
Aimsucks
4ee6562e35 🐛 Fix for favicon not changing
Removed favicon and title from _app.tsx
2022-06-08 16:26:09 +00:00
ajnart
19f80b9b4c 🚑 Hotfix calendar and mobile responsiveness 2022-06-08 16:16:00 +00:00
ajnart
949deacd6d 🔀 Rebase with dev 2022-06-08 16:16:00 +00:00
Larvey
b0f4a91878 Fix Sonarr Incorrect Dates
Due to how Sonarr gives dates, they recommend using UTC time when displaying it as it matches their calendar. Took some digging but it fixed it.
2022-06-08 16:16:00 +00:00
ajnart
68f2e79056 🧱 Try to fix cookies issues 2022-06-08 16:16:00 +00:00
ajnart
43e68e1bbf 🐛 Trying to fix dates 2022-06-08 16:16:00 +00:00
Larvey
5033323b7c Fix for timezone issues 2022-06-08 16:16:00 +00:00
Aimsucks
7519b4a6b2 Added an app opacity slider
Added a slider to change individual app opacity on the AppShelf
2022-06-08 16:03:06 +00:00
Aimsucks
e6eedefec4 Added a shade selector
Added a popover shade selector similar to the color selector, but shows primary and secondary colors to pick the desired Mantine primaryShade
2022-06-08 15:36:54 +00:00
Aimsucks
845d6a3d87 🎨 Made color switcher change Mantine styles
Moved the color switcher's functions to a context provider and made Mantine's styles derived off of that context.
2022-06-08 14:58:32 +00:00
ajnart
f75da289c2 🚑 Hotfix calendar and mobile responsiveness 2022-06-08 09:56:04 +02:00
Thomas Camlong
063a6447c0 🔀 Merge pull request #189 from LarveyOfficial/patch-2
Fix Sonarr Incorrect Dates
2022-06-08 08:11:13 +02:00
ajnart
4dac730412 🔀 Rebase with dev 2022-06-08 08:09:59 +02:00
Larvey
de6e0f645f Fix Sonarr Incorrect Dates
Due to how Sonarr gives dates, they recommend using UTC time when displaying it as it matches their calendar. Took some digging but it fixed it.
2022-06-07 22:05:28 -04:00
Aimsucks
b26ab50c8d 🎨 Changed primary/secondary color to camelCase 2022-06-07 17:48:04 +00:00
Aimsucks
423f8110b9 Added a background image input
Added an input in the advanced options for a background image. Also removed an unused import from my previous commit and changed the margin on the header bar to padding instead.
2022-06-07 17:36:05 +00:00
ajnart
84ae49ed2a 🧱 Try to fix cookies issues 2022-06-07 19:34:58 +02:00
ajnart
fb291c5411 🐛 Trying to fix dates 2022-06-07 19:34:24 +02:00
Aimsucks
901798055b Added primary/secondary color selection
Added two new inputs to the options menu: primary and secondary color selectors.
2022-06-07 16:53:51 +00:00
Thomas Camlong
d32d599098 🔀 Merge pull request #186 from LarveyOfficial/patch-1
Fix for timezone issues
2022-06-07 17:22:57 +02:00
Larvey
76e02cf148 Fix for timezone issues 2022-06-07 11:19:53 -04:00
Thomas Camlong
f19b4675ad 🔀 Merge pull request #184 from Aimsucks/change-title-icons
Add settings to change title and icons
2022-06-07 16:17:50 +02:00
ajnart
4f1640b70a 🐛 Fix a small bug inside the torrent module 2022-06-07 12:41:49 +02:00
Thomas Camlong
c1d17ec8b2 Update src/components/Settings/AdvancedSettings.tsx
Co-authored-by: Bjorn Lammers <walkxnl@gmail.com>
2022-06-07 12:12:23 +02:00
Thomas Camlong
d2f1268520 Merge branch 'dev' into change-title-icons 2022-06-07 10:37:36 +02:00
ajnart
b72afc2270 📦 💄 Upgrade packages and style 2022-06-07 10:36:47 +02:00
ajnart
de0c625f88 🐛 Fixing Deluge integration
Thanks to @scttcper for fixing https://github.com/scttcper/deluge/issues/106 so quickly !
2022-06-07 09:50:04 +02:00
Thomas Camlong
29c9f3ecac 🔥 Remove the Code quality tickboxes
They were annoying (to me at least)
2022-06-07 08:32:39 +02:00
ajnart
a321095daf 💄 Styling the settings 2022-06-07 08:21:03 +02:00
ajnart
ced18da65a 🔥 Remove default values for the Advanced settings 2022-06-07 08:20:19 +02:00
ajnart
1a642ad7b4 🔧 Make the changed values optional 2022-06-07 07:20:44 +02:00
Aimsucks
838f196937 Ability to change title and icons V2!
Results of criticism in pull request #182
2022-06-07 01:35:50 +00:00
Aimsucks
6af5166aa5 Ability to change title and icons 2022-06-07 00:07:56 +00:00
ajnart
7935fb6616 🚑 Hotfix icon matching 2022-06-07 01:04:34 +02:00
ajnart
ed567065b4 ⚰️ Remove dead code 2022-06-07 00:30:42 +02:00
ajnart
06035fb6f0 💄 Very minor fix the the AppShelf UI 2022-06-07 00:15:19 +02:00
ajnart
c1af0a087d 💄 Styling the AppShelf 2022-06-07 00:07:36 +02:00
ajnart
6067c5dfcf 💄 Styling changes for medias and AppShelf 2022-06-06 23:56:33 +02:00
ajnart
bf7b9637f7 🔥 Remove CPU module 2022-06-06 23:56:08 +02:00
ajnart
c552104413 🔥 Remove CPU module 2022-06-06 23:55:49 +02:00
ajnart
6fd23cf6a0 Add support for multiple Arr services
In the calendar, you can now have 2 separate Sonarr or Radarr instances
2022-06-06 23:40:45 +02:00
ajnart
e2f59383d6 🚑 Small UI hotfixes 2022-06-06 23:27:55 +02:00
ajnart
8b92135a80 💄 Make responsiveness better for mobile
Posters aren't huge on mobile anymore, yay
2022-06-06 22:32:57 +02:00
ajnart
aef4a30512 🚑 Hotfix position of the downloads module 2022-06-06 21:45:45 +02:00
Thomas Camlong
ace8bd75e7 🔀 Merge pull request #177 from ajnart/ajnart/issue150
 Ability to toggle categories
2022-06-06 21:40:02 +02:00
Thomas Camlong
2e461b4e7a 🔀 Merge pull request #179 from ajnart/ajnart/issue174
Password / Login Page
2022-06-06 21:39:47 +02:00
Thomas Camlong
3f87e939c9 🔀Merge pull request #180 from ajnart/ajnart/issue163
 Add different URL for API calls
2022-06-06 21:39:38 +02:00
Thomas Camlong
1d9dfc5102 🔀 Merge pull request #181 from ajnart/ajnart/issue147
Transmission Integration
2022-06-06 21:39:26 +02:00
ajnart
80a94d3778 FR: Transmission Integration
Fixes #147
2022-06-06 21:38:50 +02:00
ajnart
39d66faf4e Add autocomplete to Search Module
Suggestions when searching with the search bar Fixes #12
2022-06-06 20:02:42 +02:00
ajnart
c50e11c75b 🐛 Fix celcius to farenheit 2022-06-06 19:12:59 +02:00
ajnart
9a3ebb56cb 🎨 Quality of life : Use debouncedValue 2022-06-06 18:44:02 +02:00
ajnart
1d1495453a 🩹 Add default values for the categories to be opened by default 2022-06-06 18:31:42 +02:00
ajnart
26cfc485c2 Ability to toggle categories
Fixes #150
2022-06-06 18:31:40 +02:00
ajnart
83b4da282a Password / Login Page
Fixes #174
2022-06-06 18:30:14 +02:00
ajnart
ea972effb4 Add different URL for API calls
Fixes #163
2022-06-06 18:29:02 +02:00
ajnart
9686761c3d Merge branch 'master' into dev 2022-06-06 18:28:34 +02:00
ajnart
13a5a4a263 Revert CI changes 2022-06-06 18:28:26 +02:00
ajnart
339919cfff Add keyboard navigation (kind of)
Fixes #165
2022-06-06 17:39:18 +02:00
ajnart
2594a7caa5 💄 Disable item selection on mobile
Fixed Disable text selection in iOS (touch devices) #166
2022-06-06 17:37:42 +02:00
ajnart
2966be4fc4 Add support for multiple same service in Calendar
Fixes Calendar Support for Multiple Sonarr / Radarr #176
2022-06-06 15:34:33 +02:00
ajnart
5e21a7df9c 🐛 Fix bug in ping module
Module would not ping on the first activation / deactivation
2022-06-06 15:33:25 +02:00
Thomas Camlong
64eb00f2ee 🔀 Changing deluge/qbittorent to use href instead of origin
Thank you @VinnyVynce
2022-06-06 15:21:16 +02:00
ajnart
00928ae709 📱 Make the design way more responsive for mobile 2022-06-06 15:20:46 +02:00
ajnart
bbb912479b 🪝 AdduseSetSafeInterval hook 2022-06-06 15:02:41 +02:00
VinnyVynce
5b16589360 Change urls for href instead of origin 2022-06-06 07:07:35 -04:00
Thomas Camlong
39674fc769 Update docker_dev.yml 2022-06-06 12:22:32 +02:00
Thomas Camlong
e718fd6b80 v0.6.0 Categories and current download graphs ! 🥳 2022-06-03 14:14:47 +02:00
ajnart
bdaf70f26b 🚑 Hotfix errors 2022-06-03 14:11:24 +02:00
Thomas Camlong
44a7df5ae0 Merge pull request #170 from ajnart/system-info
System info
2022-06-03 13:56:45 +02:00
ajnart
25fa376c2d Update display for current CPU 2022-06-03 13:56:15 +02:00
Thomas "ajnart" Camlong
de3792fb6b 🐛 Fixing a bug related to imports 2022-06-03 13:56:14 +02:00
ajnart
64b1679b03 🐛 Fixing bugs in system info 2022-06-03 13:56:14 +02:00
ajnart
8da0b38662 Working on system info 2022-06-03 13:56:13 +02:00
ajnart
13fd1a9fc0 System-info WIP 2022-06-03 13:55:43 +02:00
Thomas Camlong
04c1b41015 Merge pull request #169 from ajnart/qol
🚸 Improve UX and QoL
2022-06-03 13:55:29 +02:00
Thomas Camlong
6a32b80098 📝 Update demo link 2022-06-02 17:51:21 +02:00
WalkxCode
759e02f74a 🔥 Remove modified files from pull request" 2022-06-01 20:00:21 +02:00
WalkxCode
5758019923 🚸 Improve UX and QoL 2022-06-01 19:53:57 +02:00
Thomas "ajnart" Camlong
cad160010d Make proxied requests for calendar 2022-06-01 16:19:32 +02:00
Thomas "ajnart" Camlong
56b6347824 🚧 Trying to improve calendar module 2022-06-01 15:32:29 +02:00
ajnart
c258003ec5 🐛 Fixed a bug in the Lidarr image display 2022-05-30 21:43:33 +02:00
ajnart
5ac5098a2a 💄 Small UI changes
Changed the color to use one of mantine's
2022-05-30 09:20:16 +02:00
ajnart
3c96053b7f Add a ScrollArea to the Downloads module 2022-05-30 09:19:49 +02:00
Thomas Camlong
67a89ba61a Merge pull request #167 from ajnart/build-optimization
Build optimization
2022-05-29 19:04:19 +02:00
ajnart
4c0a3ce48c 💚 Update CI 2022-05-29 18:57:03 +02:00
ajnart
2d2f9d8d19 🏗️ Update Yarn install 2022-05-29 18:55:22 +02:00
ajnart
0a7f98dd80 🏗️ Change packageManager 2022-05-29 18:47:12 +02:00
ajnart
5b4d302c17 ⬆️ Upgrade dependencies 2022-05-29 18:43:31 +02:00
ajnart
31d23852f7 Migrate from tabler-icons-react to @tabler/icons 2022-05-29 18:42:58 +02:00
ajnart
a9e8db5018 🔖 Bumb version to v0.6.0 2022-05-29 15:34:31 +02:00
ajnart
f3d1767daf 🚨 Linting 2022-05-29 15:33:44 +02:00
ajnart
b229aacba5 Add download module to the AppShelf 2022-05-29 15:32:39 +02:00
ajnart
174ed140ae Add total downloads module 2022-05-29 15:31:25 +02:00
ajnart
62635bffe9 💄 Style DownloadsModule (torrents) 2022-05-29 15:31:04 +02:00
ajnart
63e6efab1f Add TotalDownloadsModule to module exports 2022-05-29 15:30:50 +02:00
ajnart
ad1af0e07d 🧱 Move components in infrastructure 2022-05-29 15:30:23 +02:00
ajnart
cfd9eb94b5 💄 Improve boxShadows of menus
Makes them look better
2022-05-29 15:30:03 +02:00
ajnart
c6762281ef 📦 Add nivo for charts 💹 2022-05-29 15:29:11 +02:00
ajnart
7d09a0064a 🔥 Delete Download module from index 2022-05-29 15:28:45 +02:00
ajnart
2d6b9522c5 Make Calendar module fetch way more data 2022-05-29 11:25:53 +02:00
ajnart
1a2e752281 Add categories! 2022-05-29 10:45:49 +02:00
ajnart
c7c76ee22b 💄 Styling backgrounds of widgets 2022-05-29 09:11:46 +02:00
ajnart
0457c91ede 🚸 Improve add service autofill capabilities 2022-05-27 13:14:09 +02:00
ajnart
1a420c3b8b 🚑 Hotfix deluge torrent progress 2022-05-27 09:45:51 +02:00
Thomas Camlong
c993d32dd3 v0.5.2 : Torrents module : Deluge and qBittorrent integrations ! 🥳
v0.5.2 adds a bunch of QOL changes and the long awaited Deluge and qBittorrent integrations. More feature to come with the torrent module soon.
2022-05-26 21:29:48 +02:00
ajnart
1f66d64f24 Add deluge integration
Fixes #122
2022-05-26 21:08:16 +02:00
ajnart
54ce138475 Add deluge password saving 2022-05-26 21:07:01 +02:00
ajnart
6173c20616 🏷️ Update types for AppShelfMenu 2022-05-26 21:06:44 +02:00
ajnart
e3d22c6d3a 🏷️ Add deluge types 2022-05-26 21:06:17 +02:00
ajnart
fd44fbb208 📦 Add Deluge package for future deluge integration 2022-05-26 21:06:04 +02:00
ajnart
3dc0208a73 💄 Styling changes 2022-05-26 20:07:54 +02:00
ajnart
b6fcabc270 🐛 Fix footer display issues 2022-05-26 20:07:22 +02:00
ajnart
ee2e36bdfa Rename the download module 2022-05-26 19:45:18 +02:00
ajnart
6bc16a51f1 🔖 Bump version to v0.5.2 2022-05-26 19:16:33 +02:00
ajnart
b0c92c9951 💄 Style DownloadModule 2022-05-26 19:14:36 +02:00
ajnart
72fddda411 Make the Footer update a notification 2022-05-26 19:14:19 +02:00
ajnart
949379e6e6 🎨 Change default config 2022-05-26 18:35:28 +02:00
Thomas Camlong
17736fc432 Update README.md 2022-05-26 18:29:24 +02:00
ajnart
da31832a1e 💫 Add download module on the main page 2022-05-26 18:19:32 +02:00
ajnart
3a358a229d Add Download Module!
Shows current downloads from qbittorrent at the moment, transmission coming soon 😉
2022-05-26 18:19:12 +02:00
ajnart
a6875abfe3 💬 Update API to support getting downloads 2022-05-26 18:18:30 +02:00
ajnart
2aad3d3eb0 Add support for qBittorrent in AddAppShelfItem 2022-05-26 18:17:59 +02:00
ajnart
8e2d347ab5 🏗️ Rework moduleWrapper architecture 2022-05-26 18:16:57 +02:00
ajnart
8b055bc3b6 💄 Style the notifications to the bottom right 2022-05-26 18:16:24 +02:00
ajnart
54a68f1d74 🏷️ Update types to support qBittorrent login 2022-05-26 18:16:00 +02:00
ajnart
2fabd1908d 📦 Add @ctrl/qbittorrent as a dependency 2022-05-26 18:15:42 +02:00
ajnart
789e0510ea 🐛 Fix a bug with strings as module settings 2022-05-26 18:15:00 +02:00
ajnart
2c16075413 💄 WeatherModule styling 2022-05-26 18:13:51 +02:00
ajnart
96f58288ac 💄 DateModule styling 2022-05-26 18:13:35 +02:00
ajnart
d4168dcdf4 💄 Styling and UI changes 2022-05-26 18:13:23 +02:00
Thomas Camlong
c044da2b55 Update Crowdin configuration file 2022-05-26 00:44:24 +02:00
ajnart
1ec8f1db19 🚑 Critical hotfix for various bugs 2022-05-26 00:10:48 +02:00
ajnart
c725559e9b 🔥 Remove Crowdin 2022-05-25 18:32:55 +02:00
ajnart
044c3fdf4c Merge branch 'dev' of github.com:/ajnart/homarr into dev 2022-05-25 18:26:17 +02:00
ajnart
4026d0b6be 💄 Update poster styling 2022-05-25 18:26:13 +02:00
Thomas Camlong
151e37c282 Update Crowdin configuration file 2022-05-25 18:13:29 +02:00
Thomas Camlong
0a476f648a v0.5.1 : Readarr and Lidarr integrations !
### New Features
-  Lidarr and Readarr integrations
-  Add a way to delete a config via the API
-  Add a way to save a config and delete it
-  Add a key bind to open settings (CTRL + L)

### Bug Fixes
- 🐛 Fixing date issues with weather module
- 🐛 Fix Readarr date match

### UI Changes
- 💄 Totally rework how the media previews work!
- 💄 Make the settings menu a drawer instead
- 💄 Change the way the footer is displayed

### GitHub Changes
- 📝 (README): Updates documentation & Move to Wiki

### Other Changes
- 🧑‍💻 Added strings as an option type for modules
- 🏗️ Make the max notifications to 4
2022-05-25 13:17:54 +02:00
ajnart
3f2aa50f85 Totally rework how the media previews work! 2022-05-25 13:13:36 +02:00
ajnart
fbaaa389c2 🐛 Fix Readarr date match 2022-05-25 13:13:17 +02:00
ajnart
af83695d81 🏗️ Make the max notifications to 4 2022-05-25 13:12:12 +02:00
ajnart
2cb6781a94 Lidarr and Readarr integrations 2022-05-25 10:50:57 +02:00
ajnart
4f68f7e395 Add a keybind to open settings, CTRL + L 2022-05-24 23:02:27 +02:00
ajnart
6a14937112 Merge branch 'dev' of github.com:/ajnart/homarr into dev 2022-05-24 22:55:50 +02:00
ajnart
9eef4988e7 Add a way to save a config and delete it 2022-05-24 22:55:47 +02:00
ajnart
3855673787 Add a way to delete a config via the API 2022-05-24 22:55:28 +02:00
ajnart
a89b0746ba 💄 Make the settings menu a drawer instead 2022-05-24 22:55:10 +02:00
Bjorn Lammers
09dd5d7907 🔖 Update version to v0.5.1 2022-05-24 21:51:08 +02:00
Bjorn Lammers
f029483f1e 🔖 Update version to v0.5.1 2022-05-24 21:50:57 +02:00
Bjorn Lammers
364055b9b6 📝 Oopsie doopsie hehe 2022-05-24 21:48:06 +02:00
Thomas Camlong
8775ad249c Merge pull request #152 from ajnart/docs
📝 (README): Updates documentation & Move to Wiki
2022-05-24 21:39:50 +02:00
Bjorn Lammers
3249d766b3 📝 Add "Read the Wiki" 2022-05-24 21:39:34 +02:00
Bjorn Lammers
fd65dc8943 📝 Fix some bugs 2022-05-24 21:26:10 +02:00
WalkxCode
fd73c7f70d 📝 (README): Updates documentation & Move to Wiki 2022-05-24 21:21:20 +02:00
ajnart
4984866fb3 🚨 Linting and add icons
Adds future support for self hosted icons
2022-05-24 20:15:07 +02:00
ajnart
4ae4b224c7 🐛 Fixing issues with weahter module 2022-05-24 20:14:26 +02:00
ajnart
802f7fd6c7 🧑‍💻 Added strings as an option type for modules 2022-05-24 20:14:07 +02:00
ajnart
bbb35b236f 💄 Change the way the footer is displayed 2022-05-24 20:13:01 +02:00
Bjorn Lammers
2eb3b18499 Merge pull request #144 from ajnart/dev
v0.5.0 : Quality of life and dev experience
2022-05-23 22:24:24 +02:00
Bjorn Lammers
553be7da33 Merge pull request #144 from ajnart/dev
v0.5.0 : Quality of life and dev experience
2022-05-23 22:22:08 +02:00
Bjorn Lammers
260b850e1a 📝 Add star mention 2022-05-23 21:49:03 +02:00
Bjorn Lammers
726a4fddd3 🔥Remove fixed issues 2022-05-23 21:09:48 +02:00
Bjorn Lammers
318c094f27 📝 Update Docs to match new release 2022-05-23 18:30:11 +02:00
Thomas Camlong
6e0d3807e4 Merge pull request #142 from ajnart/dnd
Drag and drop ! (v0.5.0)
2022-05-23 17:02:18 +02:00
ajnart
10e9dc06dd ⚰️ Remove dead code 2022-05-23 16:52:43 +02:00
ajnart
e84687e5fc 🔖 Version v0.5.0 2022-05-23 14:44:01 +02:00
Thomas Camlong
361d41065c Merge branch 'dev' into dnd 2022-05-23 14:39:17 +02:00
ajnart
4c0fbc0b42 ⚰️ Remove dead code 2022-05-23 14:38:39 +02:00
ajnart
ef8e380956 🔥 Remove some other default configuration files 2022-05-23 14:34:17 +02:00
ajnart
5db28b1607 🚨 Fix storybook compilation 2022-05-23 14:23:05 +02:00
ajnart
dbfd4cf050 🐛 Fix search module default queryUrl 2022-05-23 12:38:10 +02:00
ajnart
ffd298a2b6 🐛 Fix line clamping in media display 2022-05-23 12:37:36 +02:00
ajnart
9b1b5906e7 ⬆️ Upgrade and remove dependencies 2022-05-23 11:48:25 +02:00
Thomas Camlong
19bd14c63d Merge branch 'dev' into dnd 2022-05-23 11:24:31 +02:00
ajnart
b69343af56 Introduce DND in main app shelf! 2022-05-23 11:20:08 +02:00
ajnart
94ee90eebb ⚰️ Remove dead code 2022-05-23 11:19:40 +02:00
ajnart
72b3097ad1 ⚰️ Remove dead code 2022-05-23 11:19:26 +02:00
Thomas Camlong
225f910fe8 Merge pull request #139 from ajnart/New-Config-Format
 Add new config format
2022-05-23 10:48:46 +02:00
ajnart
10d9ffc740 🚨 Fix compilation for types 2022-05-23 10:44:31 +02:00
ajnart
4202d25d62 📦 Add type definitions for UUID 2022-05-23 10:26:17 +02:00
ajnart
6a905e1b49 🚨 Lint code and prettier 2022-05-23 10:24:54 +02:00
ajnart
72e08f484f 🚑 Use different type of UUID 2022-05-23 10:23:10 +02:00
ajnart
64dbb9c025 Add drag and drop, fixes #88 2022-05-23 00:04:14 +02:00
ajnart
af2e0235bf Add new config format
Should be WAAAAY easier to work with modules now
2022-05-22 20:42:10 +02:00
ajnart
bf85818f8b 🐛 Fix #133 2022-05-22 20:40:10 +02:00
ajnart
1840713179 Basic drag and drop 2022-05-21 10:32:54 +02:00
ajnart
b11bffb7cf 🐛 Exclude stories from tsconfig 2022-05-21 10:32:35 +02:00
ajnart
bfb26a9402 🚑 Fix API url for services 2022-05-21 01:26:55 +02:00
ajnart
c3b11be2d0 🚑 Fix UUID by using crypto 2022-05-21 01:26:24 +02:00
ajnart
ecfb89de40 🏷️ Fix types
Fixed the apiKey field for a service
2022-05-21 01:02:45 +02:00
ajnart
e1eab70f93 Match config with URL typed
Homarr will now match a config with the URL used or return a 404 if not found
2022-05-21 01:01:20 +02:00
ajnart
adb341c0fa Add default icon, fix URL parsing
Fixes #121 and Fixes #132
2022-05-21 00:54:36 +02:00
ajnart
25ccdffeb9 Make logo clickable 2022-05-21 00:52:55 +02:00
ajnart
b98d399a9c Change 404 message 2022-05-21 00:52:39 +02:00
ajnart
f36e7b8abb Made service name clickable
Co-authored-by: Bjorn L. <walkxnl@gmail.com>
2022-05-20 23:03:42 +02:00
Thomas "ajnart" Camlong
667322d14e Use ID instead of only names 2022-05-20 22:34:36 +02:00
Thomas "ajnart" Camlong
9b440c0da3 🚧 Add basic BASE_URL and PORT env utilisation #76 2022-05-19 02:05:23 +02:00
105 changed files with 22126 additions and 13726 deletions

View File

@@ -2,5 +2,8 @@ Dockerfile
.dockerignore .dockerignore
node_modules node_modules
npm-debug.log npm-debug.log
README.md *.md
.git .git
.github
LICENSE
docs/

View File

@@ -14,10 +14,3 @@
### Screenshot _(if applicable)_ ### Screenshot _(if applicable)_
> If you've introduced any significant UI changes, please include a screenshot. > If you've introduced any significant UI changes, please include a screenshot.
### Code Quality Checklist _(Please complete)_
- [ ] All changes are backwards compatible
- [ ] There are no (new) build warnings or errors
- [ ] _(If a new config option is added)_ Attribute is outlined in the schema and documented
- [ ] _(If a new dependency is added)_ Package is essential, and has been checked out for security or performance
- [ ] Bumps version, if new feature added

View File

@@ -52,7 +52,7 @@ jobs:
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache. # If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- run: yarn install --frozen-lockfile - run: yarn install --immutable
- run: yarn build - run: yarn build
- name: Cache build output - name: Cache build output
# to copy needed files to docker build job # to copy needed files to docker build job

View File

@@ -16,7 +16,7 @@ on:
workflow_dispatch: workflow_dispatch:
inputs: inputs:
tags: tags:
requierd: true required: true
description: 'Tags to deploy to' description: 'Tags to deploy to'
env: env:
@@ -62,7 +62,7 @@ jobs:
# If source files changed but packages didn't, rebuild from a prior cache. # If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- restore-keys: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- run: yarn install --frozen-lockfile - run: yarn install --immutable
- run: yarn build - run: yarn build
- name: Cache build output - name: Cache build output

12
.gitignore vendored
View File

@@ -36,4 +36,14 @@ yarn-error.log*
# storybook # storybook
storybook-static storybook-static
data/configs data/configs
# https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
# Yarn v2
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

View File

@@ -1,14 +1,9 @@
module.exports = { module.exports = {
stories: ['../src/components/**/*.story.mdx', '../src/components/**/*.story.*'], stories: ['../src/components/**/*.story.mdx', '../src/components/**/*.story.*'],
addons: [ addons: [
'storybook-dark-mode',
'@storybook/addon-links', '@storybook/addon-links',
'storybook-addon-mock/register', 'storybook-addon-mock/register',
'@storybook/addon-essentials', '@storybook/addon-essentials',
{
name: 'storybook-addon-turbo-build',
options: { optimizationLevel: 2 },
},
], ],
typescript: { typescript: {
check: false, check: false,

View File

@@ -1,4 +1,3 @@
import { useDarkMode } from 'storybook-dark-mode';
import { MantineProvider, ColorSchemeProvider } from '@mantine/core'; import { MantineProvider, ColorSchemeProvider } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications'; import { NotificationsProvider } from '@mantine/notifications';
@@ -7,11 +6,7 @@ export const parameters = { layout: 'fullscreen' };
function ThemeWrapper(props: { children: React.ReactNode }) { function ThemeWrapper(props: { children: React.ReactNode }) {
return ( return (
<ColorSchemeProvider colorScheme="light" toggleColorScheme={() => {}}> <ColorSchemeProvider colorScheme="light" toggleColorScheme={() => {}}>
<MantineProvider <MantineProvider withGlobalStyles withNormalizeCSS>
theme={{ colorScheme: useDarkMode() ? 'dark' : 'light' }}
withGlobalStyles
withNormalizeCSS
>
<NotificationsProvider>{props.children}</NotificationsProvider> <NotificationsProvider>{props.children}</NotificationsProvider>
</MantineProvider> </MantineProvider>
</ColorSchemeProvider> </ColorSchemeProvider>

786
.yarn/releases/yarn-3.2.1.cjs vendored Normal file

File diff suppressed because one or more lines are too long

5
.yarnrc Normal file
View File

@@ -0,0 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
yarn-path ".yarn/releases/yarn-1.22.19.cjs"

3
.yarnrc.yml Normal file
View File

@@ -0,0 +1,3 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View File

@@ -2,12 +2,13 @@ FROM node:16-alpine
WORKDIR /app WORKDIR /app
ENV NODE_ENV production ENV NODE_ENV production
COPY /next.config.js ./ COPY /next.config.js ./
COPY /public ./public COPY /public ./public
COPY /package.json ./package.json COPY /package.json ./package.json
# Automatically leverage output traces to reduce image size. https://nextjs.org/docs/advanced-features/output-file-tracing # Automatically leverage output traces to reduce image size. https://nextjs.org/docs/advanced-features/output-file-tracing
COPY /.next/standalone ./ COPY /.next/standalone ./
COPY /.next/static ./.next/static COPY /.next/static ./.next/static
EXPOSE 7575 EXPOSE 7575
ENV PORT 7575 ENV PORT 7575
RUN apk add tzdata
VOLUME /app/data/configs VOLUME /app/data/configs
CMD ["node", "server.js"] CMD ["node", "server.js"]

282
README.md
View File

@@ -1,65 +1,97 @@
<h3 align="center">Homarr</h3>
<br> <!-- Project Title -->
<h1 align="center">Homarr</h1>
<!-- Badges -->
<p align="center"> <p align="center">
<a href="https://github.com/ajnart/homarr/actions/workflows/docker.yml"> <img src="https://img.shields.io/github/stars/ajnart/homarr?label=%E2%AD%90%20Stars&style=flat-square?branch=master&kill_cache=1%22">
<img title="Docker CI Status" src="https://github.com/ajnart/homarr/actions/workflows/docker.yml/badge.svg" alt="CI Status"></a> <a href="https://github.com/ajnart/homarr/releases/latest">
<a href="https://github.com/ajnart/homarr/releases/latest"> <img alt="Latest Release (Semver)" src="https://img.shields.io/github/v/release/ajnart/homarr?label=%F0%9F%9A%80%20Release">
<img alt="GitHub release (latest SemVer)" src="https://img.shields.io/github/v/release/ajnart/homarr"></a> </a>
<a href="https://github.com/ajnart/homarr/pkgs/container/homarr"> <a href="https://github.com/ajnart/homarr/actions/workflows/docker.yml">
<img alt="Docker Pulls" src="https://img.shields.io/docker/pulls/ajnart/homarr?label=Downloads%20"></a> <img title="Docker CI Status" src="https://github.com/ajnart/homarr/actions/workflows/docker.yml/badge.svg" alt="CI Status">
</p> </a>
<p align="center"> <a href="https://discord.gg/aCsmEV5RgA">
<img align="end" width=600 src="https://user-images.githubusercontent.com/49837342/168315259-b778c816-10fe-44db-bd25-3eea6f31b233.png" /> <img title="Discord" src="https://discordapp.com/api/guilds/972958686051962910/widget.png?style=shield">
</p> </a>
<p align = "center">
A homepage for <i>your</i> server.
<br/>
<a href = "https://homarr.netlify.app/" > <strong> Demo ↗️ </strong> </a> • <a href = "#-installation" > <strong> Install ➡️ </strong> </a>
<br />
<br />
<i>Join the discord!</i>
<br />
<a href = "https://discord.gg/aCsmEV5RgA" > <img title="Discord" src="https://discordapp.com/api/guilds/972958686051962910/widget.png?style=shield" > </a>
<br/>
<br/>
</p> </p>
# 📃 Table of Contents <!-- Links -->
- [📃 Table of Contents](#-table-of-contents) <p align="center">
- [🚀 Getting Started](#-getting-started) <i>Join the discord! — Don't forget to star the repo if you are enjoying the project!</i>
- [ About](#-about) </p>
- [💥 Known Issues](#-known-issues) <p align="center">
- [⚡ Installation](#-installation) <a href="https://homarr.ajnart.fr/"><strong> Demo ↗️ </strong></a> • <a href="#-installation"><strong> Install ➡️ </strong></a> • <a href="https://github.com/ajnart/homarr/wiki"><strong> Read the Wiki 📄 </strong></a>
- [🐳 Deploying from Docker Image](#-deploying-from-docker-image) </p>
- [🛠️ Building from Source](#%EF%B8%8F-building-from-source)
- [🔧 Configuration](#-configuration)
- [🧩 Integrations](#--integrations)
- [🧑‍🤝‍🧑 Multiple Configs](#-multiple-configs)
- [🐻 Icons](#-icons)
- [📊 Modules](#-modules)
- [🔍 Search Bar](#-search-bar)
- [💖 Contributing](#-contributing)
- [🍏 Request Icons](#-request-icons)
---
<!-- Getting Started --> <!-- Homarr Description -->
# 🚀 Getting Started <img align="right" width=250 src="public/imgs/logo-color.svg" />
## About
Homarr is a simple and lightweight homepage for your server, that helps you easily access all of your services in one place. Homarr is a simple and lightweight homepage for your server, that helps you easily access all of your services in one place.
**[⤴️ Back to Top](#-table-of-contents)** It integrates with the services you use to display information on the homepage (E.g. Show upcoming Sonarr/Radarr releases).
For a full list of integrations look at: [wiki/integrations](https://github.com/ajnart/homarr/wiki/Integrations)
If you have any questions about Homarr or want to share information with us, please go to one of the following places:
- [Github Discussions](https://github.com/ajnart/homarr/discussions)
- [Discord Server](https://discord.gg/aCsmEV5RgA)
*Before you file an [issue](https://github.com/ajnart/homarr/issues/new/choose), make sure you have the read [known issues](#-known-issues) section.*
**For more information, [read the wiki!](https://github.com/ajnart/homarr/wiki)**
<details>
<summary><b>Table of Contents</b></summary>
<p>
- [✨ Features](#-features)
- [👀 Preview](#-preview)
- [💥 Known Issues](#-known-issues)
- [🚀 Installation](#-installation)
- [🐳 Deploying from Docker Image](#-deploying-from-docker-image)
- [🛠️ Building from Source](#-building-from-source)
- [💖 Contributing](#-contributing)
- [📜 License](#-license)
</p>
</details>
---
## ✨ Features
- Integrates with services you use.
- Search the web direcetly from your homepage.
- Real-time status indicator for every service.
- Automatically finds icons while you type the name of a serivce.
- Widgets that can display all types of information.
- Easy deployment with Docker.
- Very light-weight and fast.
- Free and Open-Source.
- And more...
**[⤴️ Back to Top](#homarr)**
---
## 👀 Preview
<img alt="Homarr Preview" align="center" width="100%" src="https://user-images.githubusercontent.com/71191962/169860380-856634fb-4f41-47cb-ba54-6a9e7b3b9c81.gif" />
**[⤴️ Back to Top](#homarr)**
---
## 💥 Known Issues ## 💥 Known Issues
- Posters on the Calendar get blocked by adblockers. (IMDb posters) - Posters on the Calendar get blocked by adblockers. (IMDb posters)
- Editing a service creates a duplicate (#97)
- Used search engine not properly selected (#35)
**[⤴️ Back to Top](#-table-of-contents)** **[⤴️ Back to Top](#homarr)**
## ⚡ Installation ---
## 🚀 Installation
### 🐳 Deploying from Docker Image ### 🐳 Deploying from Docker Image
> Supported architectures: x86-64, ARM, ARM64 > Supported architectures: x86-64, ARM, ARM64
@@ -67,29 +99,42 @@ _Requirements_:
- [Docker](https://docs.docker.com/get-docker/) - [Docker](https://docs.docker.com/get-docker/)
**Standard Docker Install** **Standard Docker Install**
```sh ```bash
docker run --name homarr -p 7575:7575 -v /data/docker/homarr:/app/data/configs -d ghcr.io/ajnart/homarr:latest docker run \
--name homarr \
--restart unless-stopped \
-p 7575:7575 \
-v ./homarr/configs:/app/data/configs \
-v ./homarr/icons:/app/public/icons \
-d ghcr.io/ajnart/homarr:latest
``` ```
**Docker Compose** **Docker Compose**
```yml ```yml
--- ---
version: '3' version: '3'
#--------------------------------------------------------------------------------------------# #---------------------------------------------------------------------#
# Homarr - A homepage for your server. # # Homarr - A homepage for your server. #
#--------------------------------------------------------------------------------------------# #---------------------------------------------------------------------#
services: services:
homarr: homarr:
container_name: homarr container_name: homarr
image: ghcr.io/ajnart/homarr:latest image: ghcr.io/ajnart/homarr:latest
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- /data/docker/homarr:/app/data/configs - ./homarr/configs:/app/data/configs
- ./homarr/icons:/app/public/icons
ports: ports:
- '7575:7575' - '7575:7575'
``` ```
***Getting EACCESS errors in the logs? Try running `sudo chmod 775 /directory-you-mounted-to`!*** ```sh
docker compose up -d
```
*Getting EACCESS errors in the logs? Try running `sudo chmod 777 /directory-you-mounted-to`!*
**[⤴️ Back to Top](#homarr)**
### 🛠️ Building from Source ### 🛠️ Building from Source
@@ -106,96 +151,51 @@ _Requirements_:
- Start the NextJS web server: ``yarn start`` - Start the NextJS web server: ``yarn start``
- *Note: If you want to update the code in real time, launch with ``yarn dev``* - *Note: If you want to update the code in real time, launch with ``yarn dev``*
## 🔧 Configuration **[⤴️ Back to Top](#homarr)**
### 🧩 Integrations ---
Homarr natively integrates with your services. Here is a list of all supported services. ## 💖 Contributing
**Emby**
*The Emby integration is still in development.*
**Lidarr**
*The Lidarr integration is still in development.*
**Sonarr**
*Sonarr needs an API key.*<br>
Make a new API key in `Advanced > Security > Create new API key`<br>
**Current integration:** Upcoming media is displayed in the **Calendar** module.
**Plex**
*The Plex integration is still in development.*
**Radarr**
*Radarr needs an API key.*<br>
Make a new API key in `Advanced > Security > Create new API key`<br>
**Current integration:** Upcoming media is displayed in the **Calendar** module.
**qBittorent**
*The qBittorent integration is still in development.*
**[⤴️ Back to Top](#-table-of-contents)**
### 🧑‍🤝‍🧑 Multiple Configs
Homarr allows the usage of multiple configs. You can add a new config in two ways.
**Drag-and-Drop**
1. Download your config from the Homarr settings.
2. Change the name of the `.json` file and the name in the `.json` file to any name you want *(just make sure it's different)*.
3. Drag-and-Drop the file into the Homarr tab in your browser.
4. Change the config in settings.
**Using a filebrowser**
1. Locate your mounted `default.json` file.
2. Duplicate your `default.json` file.
3. Change the name of the `.json` file and the name in the `.json` file to any name you want *(just make sure it's different)*.
4. Refresh the Homarr tab in your browser.
5. Change the config in settings.
**[⤴️ Back to Top](#-table-of-contents)**
### 🐻 Icons
The icons used in Homarr are automatically requested from the [dashboard-icons](https://github.com/walkxhub/dashboard-icons) repo.
Icons are requested in the following way: <br>
`Grab name > Replace ' ' with '-' > .toLower() > https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/{name}.png`
**[⤴️ Back to Top](#-table-of-contents)**
### 📊 Modules
Modules are blocks shown on the sides of the Homarr dashboard that display information. They can be enabled in settings.
**Clock Module**
The Clock Module will display your current time and date.
**Calendar Module**
The Calendar Module uses [integrations](#--integrations-1) to display new content.
**Weather Module**
The Weather Module uses your devices location to display the current, highest, and lowest temperature.
**[⤴️ Back to Top](#-table-of-contents)**
### 🔍 Search Bar
The Search Bar will open any Search Query after the Query URL you've specified in settings.
*(Eg. `https://www.google.com/search?q=*Your Query will be inserted here*`)*
**[⤴️ Back to Top](#-table-of-contents)**
# 💖 Contributing
**Please read our [Contribution Guidelines](/CONTRIBUTING.md)** **Please read our [Contribution Guidelines](/CONTRIBUTING.md)**
All contributions are highly appreciated. All contributions are highly appreciated.
**[⤴️ Back to Top](#-table-of-contents)** **[⤴️ Back to Top](#homarr)**
## 🍏 Request Icons ---
The icons used in Homarr are automatically requested from the [dashboard-icons](https://github.com/walkxhub/dashboard-icons) repo. You can make a icon request by creating an [issue](https://github.com/walkxhub/dashboard-icons/issues/new/choose).
## 📜 License
**[⤴️ Back to Top](#-table-of-contents)** Homarr is Licensed under [MIT](https://en.wikipedia.org/wiki/MIT_License)
```txt
Copyright © 2022 Thomas "ajnart" Camlong
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
**[⤴️ Back to Top](#homarr)**
---
<p align="center">
<i>Thank you for visiting! <b>For more information <a href="https://github.com/ajnart/homarr/wiki">read the wiki!</a></b></i>
<br/>
<br/>
</p>

3
crowdin.yml Normal file
View File

@@ -0,0 +1,3 @@
files:
- source: /public/locales/en/*.json
translation: /public/locales/%two_letters_code%/%original_file_name%.json

View File

@@ -1,26 +0,0 @@
{
"name": "config",
"services": [
{
"type": "Other",
"name": "YouTube",
"icon": "https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/youtube.png",
"url": "https://youtube.com/"
},
{
"type": "Other",
"name": "YouTube ",
"icon": "https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/youtube.png",
"url": "https://youtube.com/"
}
],
"settings": {
"searchBar": true,
"searchUrl": "Custom",
"enabledModules": [
"Date",
"Calendar",
"Weather"
]
}
}

View File

@@ -1,16 +0,0 @@
{
"name": "config_new",
"services": [
{
"type": "Other",
"name": "example",
"icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}
],
"settings": {
"searchBar": true,
"searchUrl": "https://duckduckgo.com/?q=",
"enabledModules": []
}
}

View File

@@ -2,15 +2,22 @@
"name": "default", "name": "default",
"services": [ "services": [
{ {
"type": "Other",
"name": "example", "name": "example",
"id": "09c45847-8afc-4c1a-9697-f03192de948a",
"type": "Other",
"icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif", "icon": "https://c.tenor.com/o656qFKDzeUAAAAC/rick-astley-never-gonna-give-you-up.gif",
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ" "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
} }
], ],
"settings": { "settings": {
"searchBar": true, "searchUrl": "https://google.com/search?q="
"searchUrl": "https://bing.com/search?q=", },
"enabledModules": [] "modules": {
"Search Bar": {
"enabled": true
},
"Date": {
"enabled": false
}
} }
} }

View File

@@ -1,2 +1,2 @@
export const REPO_URL = 'ajnart/homarr'; export const REPO_URL = 'ajnart/homarr';
export const CURRENT_VERSION = 'v0.4.0'; export const CURRENT_VERSION = 'v0.8.0';

View File

@@ -1,13 +1,14 @@
const { env } = require('process');
const withBundleAnalyzer = require('@next/bundle-analyzer')({ const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true', enabled: process.env.ANALYZE === 'true',
}); });
module.exports = withBundleAnalyzer({ module.exports = withBundleAnalyzer({
reactStrictMode: true, reactStrictMode: false,
eslint: { eslint: {
ignoreDuringBuilds: true, ignoreDuringBuilds: true,
}, },
experimental: { output: 'standalone',
outputStandalone: true, basePath: env.BASE_URL,
},
}); });

View File

@@ -1,91 +1,90 @@
{ {
"name": "homarr", "name": "homarr",
"version": "0.4.0", "version": "0.8.0",
"private": "false",
"description": "Homarr - A homepage for your server.", "description": "Homarr - A homepage for your server.",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/ajnart/homarr" "url": "https://github.com/ajnart/homarr"
}, },
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"analyze": "ANALYZE=true next build", "analyze": "ANALYZE=true next build",
"start": "next start --port 7575", "start": "next start",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"export": "next build && next export", "export": "next build && next export",
"lint": "next lint", "lint": "next lint",
"jest": "jest", "jest": "jest",
"jest:watch": "jest --watch", "jest:watch": "jest --watch",
"prettier:check": "prettier --check \"**/*.{ts,tsx}\"", "prettier:check": "prettier --check \"**/*.{ts,tsx}\"",
"prettier:write": "prettier --write \"**/*.{ts,tsx}\"", "prettier:write": "prettier --write \"**/*.{ts,tsx}\"",
"test": "npm run prettier:check && npm run lint && npm run typecheck && npm run jest", "test": "npm run prettier:check && npm run lint && npm run typecheck && npm run jest",
"storybook": "start-storybook -p 7001", "storybook": "start-storybook -p 7001",
"storybook:build": "build-storybook", "storybook:build": "build-storybook",
"ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write" "ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write"
}, },
"dependencies": { "dependencies": {
"@mantine/core": "^4.2.4", "@ctrl/deluge": "^4.1.0",
"@mantine/dates": "^4.2.4", "@ctrl/qbittorrent": "^4.0.0",
"@mantine/dropzone": "^4.2.4", "@ctrl/shared-torrent": "^4.1.0",
"@mantine/form": "^4.2.4", "@ctrl/transmission": "^4.1.1",
"@mantine/hooks": "^4.2.4", "@dnd-kit/core": "^6.0.1",
"@mantine/modals": "^4.2.4", "@dnd-kit/sortable": "^7.0.0",
"@mantine/next": "^4.2.4", "@dnd-kit/utilities": "^3.2.0",
"@mantine/notifications": "^4.2.4", "@mantine/core": "^4.2.8",
"@mantine/prism": "^4.2.4", "@mantine/dates": "^4.2.8",
"@mantine/rte": "^4.2.4", "@mantine/dropzone": "^4.2.8",
"@mantine/spotlight": "^4.2.4", "@mantine/form": "^4.2.8",
"@modulz/radix-icons": "^4.0.0", "@mantine/hooks": "^4.2.8",
"axios": "^0.27.2", "@mantine/next": "^4.2.8",
"cookies-next": "^2.0.4", "@mantine/notifications": "^4.2.8",
"dayjs": "^1.11.2", "@mantine/prism": "^4.2.8",
"framer-motion": "^6.3.1", "@nivo/core": "^0.79.0",
"js-file-download": "^0.4.12", "@nivo/line": "^0.79.1",
"next": "12.1.5-canary.4", "@tabler/icons": "^1.68.0",
"prism-react-renderer": "^1.3.1", "axios": "^0.27.2",
"react": "18.0.0", "cookies-next": "^2.1.1",
"react-dom": "18.0.0", "dayjs": "^1.11.3",
"tabler-icons-react": "^1.46.0" "dockerode": "^3.3.2",
}, "framer-motion": "^6.3.1",
"devDependencies": { "js-file-download": "^0.4.12",
"@babel/core": "^7.17.8", "next": "^12.2.0",
"@next/bundle-analyzer": "^12.1.4", "prism-react-renderer": "^1.3.1",
"@next/eslint-plugin-next": "^12.1.4", "react": "^17.0.1",
"@storybook/addon-essentials": "^6.4.22", "react-dom": "^17.0.1",
"@storybook/addon-links": "^6.4.22", "systeminformation": "^5.11.16",
"@storybook/react": "^6.4.22", "uuid": "^8.3.2"
"@testing-library/dom": "^8.12.0", },
"@testing-library/jest-dom": "^5.16.3", "devDependencies": {
"@testing-library/react": "^13.0.0", "@babel/core": "^7.17.8",
"@testing-library/user-event": "^14.0.4", "@next/bundle-analyzer": "^12.2.0",
"@types/jest": "^27.4.1", "@next/eslint-plugin-next": "^12.2.0",
"@types/node": "^17.0.23", "@storybook/react": "^6.5.4",
"@types/react": "17.0.43", "@types/dockerode": "^3.3.9",
"@typescript-eslint/eslint-plugin": "^5.16.0", "@types/node": "^17.0.23",
"@typescript-eslint/parser": "^5.16.0", "@types/react": "17.0.43",
"babel-loader": "^8.2.4", "@types/uuid": "^8.3.4",
"eslint": "^8.11.0", "@typescript-eslint/eslint-plugin": "^5.16.0",
"eslint-config-airbnb": "19.0.4", "@typescript-eslint/parser": "^5.16.0",
"eslint-config-airbnb-typescript": "^16.1.4", "eslint": "^8.11.0",
"eslint-config-mantine": "1.1.0", "eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.25.4", "eslint-config-airbnb-typescript": "^16.1.0",
"eslint-plugin-jest": "^26.1.3", "eslint-config-mantine": "1.1.0",
"eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-import": "^2.25.4",
"eslint-plugin-react": "^7.29.4", "eslint-plugin-jest": "^26.1.3",
"eslint-plugin-react-hooks": "^4.3.0", "eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-storybook": "^0.5.11", "eslint-plugin-react": "^7.29.4",
"eslint-plugin-testing-library": "^5.2.0", "eslint-plugin-react-hooks": "^4.3.0",
"eslint-plugin-unused-imports": "^2.0.0", "eslint-plugin-storybook": "^0.5.11",
"jest": "^27.5.1", "eslint-plugin-testing-library": "^5.2.0",
"prettier": "^2.6.2", "eslint-plugin-unused-imports": "^2.0.0",
"storybook-addon-mock": "^2.3.2", "jest": "^28.1.0",
"storybook-addon-turbo-build": "^1.1.0", "prettier": "^2.6.2",
"storybook-dark-mode": "^1.0.9", "require-from-string": "^2.0.2",
"ts-jest": "^27.1.4", "typescript": "4.6.4"
"typescript": "4.6.3" },
}, "resolutions": {
"resolutions": { "@types/react": "17.0.30"
"@types/react": "17.0.30" },
} "packageManager": "yarn@3.2.1"
} }

0
public/icons/.gitkeep Normal file
View File

View File

@@ -1,26 +1,30 @@
import { import {
Modal, ActionIcon,
Anchor,
Button,
Center, Center,
Group, Group,
TextInput,
Image, Image,
Button,
Select,
AspectRatio,
Text,
Card,
LoadingOverlay, LoadingOverlay,
ActionIcon, Modal,
Tooltip, MultiSelect,
ScrollArea,
Select,
Switch,
Tabs,
Text,
TextInput,
Title, Title,
Tooltip,
} from '@mantine/core'; } from '@mantine/core';
import { useForm } from '@mantine/form'; import { useForm } from '@mantine/form';
import { motion } from 'framer-motion'; import { useDebouncedValue } from '@mantine/hooks';
import { useState } from 'react'; import { IconApps as Apps } from '@tabler/icons';
import { Apps } from 'tabler-icons-react'; import { useEffect, useState } from 'react';
import { v4 as uuidv4 } from 'uuid';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { ServiceTypeList } from '../../tools/types'; import { ServiceTypeList, StatusCodes } from '../../tools/types';
import { AppShelfItemWrapper } from './AppShelfItemWrapper'; import Tip from '../layout/Tip';
export function AddItemShelfButton(props: any) { export function AddItemShelfButton(props: any) {
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
@@ -51,106 +55,117 @@ export function AddItemShelfButton(props: any) {
); );
} }
export default function AddItemShelfItem(props: any) {
const [opened, setOpened] = useState(false);
return (
<>
<Modal
size="xl"
radius="md"
opened={props.opened || opened}
onClose={() => setOpened(false)}
title="Add a service"
>
<AddAppShelfItemForm setOpened={setOpened} />
</Modal>
<AppShelfItemWrapper>
<Card.Section>
<Group position="center" mx="lg">
<Text
// TODO: #1 Remove this hack to get the text to be centered.
ml={15}
style={{
alignSelf: 'center',
alignContent: 'center',
alignItems: 'center',
justifyContent: 'center',
justifyItems: 'center',
}}
mt="sm"
weight={500}
>
Add a service
</Text>
</Group>
</Card.Section>
<Card.Section>
<AspectRatio ratio={5 / 3} m="xl">
<motion.i
whileHover={{
cursor: 'pointer',
scale: 1.1,
}}
>
<Apps style={{ cursor: 'pointer' }} onClick={() => setOpened(true)} size={60} />
</motion.i>
</AspectRatio>
</Card.Section>
</AppShelfItemWrapper>
</>
);
}
function MatchIcon(name: string, form: any) { function MatchIcon(name: string, form: any) {
fetch( fetch(
`https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
.replace(/\s+/g, '-') .replace(/\s+/g, '-')
.toLowerCase()}.png` .toLowerCase()
) .replace(/^dash\.$/, 'dashdot')}.png`
.then((res) => { ).then((res) => {
if (res.status === 200) { if (res.ok) {
form.setFieldValue('icon', res.url); form.setFieldValue('icon', res.url);
} }
}) });
.catch(() => {
// Do nothing
});
return false; return false;
} }
function MatchService(name: string, form: any) {
const service = ServiceTypeList.find((s) => s.toLowerCase() === name.toLowerCase());
if (service) {
form.setFieldValue('type', service);
}
}
function MatchPort(name: string, form: any) {
const portmap = [
{ name: 'qbittorrent', value: '8080' },
{ name: 'sonarr', value: '8989' },
{ name: 'radarr', value: '7878' },
{ name: 'lidarr', value: '8686' },
{ name: 'readarr', value: '8787' },
{ name: 'deluge', value: '8112' },
{ name: 'transmission', value: '9091' },
{ name: 'dash.', value: '3001' },
];
// Match name with portmap key
const port = portmap.find((p) => p.name === name.toLowerCase());
if (port) {
form.setFieldValue('url', `http://localhost:${port.value}`);
}
}
const DEFAULT_ICON = '/favicon.svg';
export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) { export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & any) {
const { setOpened } = props; const { setOpened } = props;
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
// Extract all the categories from the services in config
const categoryList = config.services.reduce((acc, cur) => {
if (cur.category && !acc.includes(cur.category)) {
acc.push(cur.category);
}
return acc;
}, [] as string[]);
const form = useForm({ const form = useForm({
initialValues: { initialValues: {
id: props.id ?? uuidv4(),
type: props.type ?? 'Other', type: props.type ?? 'Other',
category: props.category ?? undefined,
name: props.name ?? '', name: props.name ?? '',
icon: props.icon ?? '', icon: props.icon ?? DEFAULT_ICON,
url: props.url ?? '', url: props.url ?? '',
apiKey: props.apiKey ?? (undefined as unknown as string), apiKey: props.apiKey ?? (undefined as unknown as string),
username: props.username ?? (undefined as unknown as string),
password: props.password ?? (undefined as unknown as string),
openedUrl: props.openedUrl ?? (undefined as unknown as string),
status: props.status ?? ['200'],
newTab: props.newTab ?? true,
}, },
validate: { validate: {
apiKey: () => null, apiKey: () => null,
// Validate icon with a regex // Validate icon with a regex
icon: (value: string) => { icon: (value: string) =>
if (!value.match(/^https?:\/\/.+\.(png|jpg|jpeg|gif)$/)) { // Disable matching to allow any values
return 'Please enter a valid icon URL'; null,
// Validate url with a regex http/https
url: (value: string) => {
try {
const _isValid = new URL(value);
} catch (e) {
return 'Please enter a valid URL';
} }
return null; return null;
}, },
// Validate url with a regex http/https status: (value: string[]) => {
url: (value: string) => { if (!value.length) {
if (!value.match(/^https?:\/\/.+\/$/)) { return 'Please select a status code';
return 'Please enter a valid URL (that ends with a /)';
} }
return null; return null;
}, },
}, },
}); });
const [debounced, cancel] = useDebouncedValue(form.values.name, 250);
useEffect(() => {
if (form.values.name !== debounced || form.values.icon !== DEFAULT_ICON) return;
MatchIcon(form.values.name, form);
MatchService(form.values.name, form);
MatchPort(form.values.name, form);
}, [debounced]);
// Try to set const hostname to new URL(form.values.url).hostname)
// If it fails, set it to the form.values.url
let hostname = form.values.url;
try {
hostname = new URL(form.values.url).origin;
} catch (e) {
// Do nothing
}
return ( return (
<> <>
<Center> <Center>
@@ -165,12 +180,19 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
</Center> </Center>
<form <form
onSubmit={form.onSubmit(() => { onSubmit={form.onSubmit(() => {
if (JSON.stringify(form.values.status) === JSON.stringify(['200'])) {
form.values.status = undefined;
}
if (form.values.newTab === true) {
form.values.newTab = undefined;
}
// If service already exists, update it. // If service already exists, update it.
if (config.services && config.services.find((s) => s.name === form.values.name)) { if (config.services && config.services.find((s) => s.id === form.values.id)) {
setConfig({ setConfig({
...config, ...config,
// replace the found item by matching ID
services: config.services.map((s) => { services: config.services.map((s) => {
if (s.name === form.values.name) { if (s.id === form.values.id) {
return { return {
...form.values, ...form.values,
}; };
@@ -188,58 +210,171 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } &
form.reset(); form.reset();
})} })}
> >
<Group direction="column" grow> <Tabs grow>
<TextInput <Tabs.Tab label="Options">
required <ScrollArea style={{ height: 500 }} scrollbarSize={4}>
label="Service name" <Group direction="column" grow>
placeholder="Plex" <TextInput
value={form.values.name} required
onChange={(event) => { label="Service name"
form.setFieldValue('name', event.currentTarget.value); placeholder="Plex"
const match = MatchIcon(event.currentTarget.value, form); {...form.getInputProps('name')}
if (match) { />
form.setFieldValue('icon', match);
}
}}
error={form.errors.name && 'Invalid icon url'}
/>
<TextInput
required
label="Icon url"
placeholder="https://i.gifer.com/ANPC.gif"
{...form.getInputProps('icon')}
/>
<TextInput
required
label="Service url"
placeholder="http://localhost:8989"
{...form.getInputProps('url')}
/>
<Select
label="Select the type of service (used for API calls)"
defaultValue="Other"
placeholder="Pick one"
required
searchable
data={ServiceTypeList}
{...form.getInputProps('type')}
/>
<LoadingOverlay visible={isLoading} />
{(form.values.type === 'Sonarr' || form.values.type === 'Radarr') && (
<TextInput
required
label="API key"
placeholder="Your API key"
value={form.values.apiKey}
onChange={(event) => {
form.setFieldValue('apiKey', event.currentTarget.value);
}}
error={form.errors.apiKey && 'Invalid API key'}
/>
)}
</Group>
<TextInput
required
label="Icon URL"
placeholder={DEFAULT_ICON}
{...form.getInputProps('icon')}
/>
<TextInput
required
label="Service URL"
placeholder="http://localhost:7575"
{...form.getInputProps('url')}
/>
<TextInput
label="On Click URL"
placeholder="http://sonarr.example.com"
{...form.getInputProps('openedUrl')}
/>
<Select
label="Service type"
defaultValue="Other"
placeholder="Pick one"
required
searchable
data={ServiceTypeList}
{...form.getInputProps('type')}
/>
<Select
label="Category"
data={categoryList}
placeholder="Select a category or create a new one"
nothingFound="Nothing found"
searchable
clearable
creatable
onClick={(e) => {
e.preventDefault();
}}
getCreateLabel={(query) => `+ Create "${query}"`}
onCreate={(query) => {}}
{...form.getInputProps('category')}
/>
<LoadingOverlay visible={isLoading} />
{(form.values.type === 'Sonarr' ||
form.values.type === 'Radarr' ||
form.values.type === 'Lidarr' ||
form.values.type === 'Readarr') && (
<>
<TextInput
required
label="API key"
placeholder="Your API key"
value={form.values.apiKey}
onChange={(event) => {
form.setFieldValue('apiKey', event.currentTarget.value);
}}
error={form.errors.apiKey && 'Invalid API key'}
/>
<Tip>
Get your API key{' '}
<Anchor
target="_blank"
weight="bold"
style={{ fontStyle: 'inherit', fontSize: 'inherit' }}
href={`${hostname}/settings/general`}
>
here.
</Anchor>
</Tip>
</>
)}
{form.values.type === 'qBittorrent' && (
<>
<TextInput
required
label="Username"
placeholder="admin"
value={form.values.username}
onChange={(event) => {
form.setFieldValue('username', event.currentTarget.value);
}}
error={form.errors.username && 'Invalid username'}
/>
<TextInput
required
label="Password"
placeholder="adminadmin"
value={form.values.password}
onChange={(event) => {
form.setFieldValue('password', event.currentTarget.value);
}}
error={form.errors.password && 'Invalid password'}
/>
</>
)}
{form.values.type === 'Deluge' && (
<>
<TextInput
label="Password"
placeholder="password"
value={form.values.password}
onChange={(event) => {
form.setFieldValue('password', event.currentTarget.value);
}}
error={form.errors.password && 'Invalid password'}
/>
</>
)}
{form.values.type === 'Transmission' && (
<>
<TextInput
label="Username"
placeholder="admin"
value={form.values.username}
onChange={(event) => {
form.setFieldValue('username', event.currentTarget.value);
}}
error={form.errors.username && 'Invalid username'}
/>
<TextInput
label="Password"
placeholder="adminadmin"
value={form.values.password}
onChange={(event) => {
form.setFieldValue('password', event.currentTarget.value);
}}
error={form.errors.password && 'Invalid password'}
/>
</>
)}
</Group>
</ScrollArea>
</Tabs.Tab>
<Tabs.Tab label="Advanced Options">
<Group direction="column" grow>
<MultiSelect
required
label="HTTP Status Codes"
data={StatusCodes}
placeholder="Select valid status codes"
clearButtonLabel="Clear selection"
nothingFound="Nothing found"
defaultValue={['200']}
clearable
searchable
{...form.getInputProps('status')}
/>
<Switch
label="Open service in new tab"
defaultChecked={form.values.newTab}
{...form.getInputProps('newTab')}
/>
</Group>
</Tabs.Tab>
</Tabs>
<Group grow position="center" mt="xl"> <Group grow position="center" mt="xl">
<Button type="submit">{props.message ?? 'Add service'}</Button> <Button type="submit">{props.message ?? 'Add service'}</Button>
</Group> </Group>

View File

@@ -1,5 +1,6 @@
import { SimpleGrid } from '@mantine/core'; import { SimpleGrid } from '@mantine/core';
import AppShelf, { AppShelfItem } from './AppShelf'; import AppShelf from './AppShelf';
import { AppShelfItem } from './AppShelfItem';
export default { export default {
title: 'Item Shelf', title: 'Item Shelf',

View File

@@ -1,106 +1,209 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { motion } from 'framer-motion'; import { Accordion, createStyles, Grid, Group, Paper, useMantineColorScheme } from '@mantine/core';
import { Text, AspectRatio, Card, Image, Center, Grid, createStyles } from '@mantine/core'; import {
closestCenter,
DndContext,
DragOverlay,
MouseSensor,
TouchSensor,
useSensor,
useSensors,
} from '@dnd-kit/core';
import { arrayMove, SortableContext } from '@dnd-kit/sortable';
import { useLocalStorage } from '@mantine/hooks';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { serviceItem } from '../../tools/types';
import AppShelfMenu from './AppShelfMenu';
import PingComponent from '../modules/ping/PingModule';
const useStyles = createStyles((theme) => ({ import { SortableAppShelfItem, AppShelfItem } from './AppShelfItem';
import { ModuleMenu, ModuleWrapper } from '../modules/moduleWrapper';
import { DownloadsModule } from '../modules';
import DownloadComponent from '../modules/downloads/DownloadsModule';
const useStyles = createStyles((theme, _params) => ({
item: { item: {
transition: 'box-shadow 150ms ease, transform 100ms ease', overflow: 'hidden',
borderLeft: '3px solid transparent',
borderRight: '3px solid transparent',
borderBottom: '3px solid transparent',
borderRadius: '20px',
borderColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
marginTop: theme.spacing.md,
},
control: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
borderRadius: theme.spacing.md,
'&:hover': { '&:hover': {
boxShadow: `${theme.shadows.md} !important`, backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1],
transform: 'scale(1.05)',
}, },
}, },
content: {
margin: theme.spacing.md,
},
label: {
overflow: 'visible',
},
})); }));
const AppShelf = (props: any) => { const AppShelf = (props: any) => {
const { config } = useConfig(); const { classes, cx } = useStyles(props);
const [toggledCategories, settoggledCategories] = useLocalStorage({
key: 'app-shelf-toggled',
// This is a bit of a hack to get the 5 first categories to be toggled on by default
defaultValue: { 0: true, 1: true, 2: true, 3: true, 4: true } as Record<string, boolean>,
});
const [activeId, setActiveId] = useState(null);
const { config, setConfig } = useConfig();
const { colorScheme } = useMantineColorScheme();
const sensors = useSensors(
useSensor(TouchSensor, {
activationConstraint: {
delay: 500,
tolerance: 5,
},
}),
useSensor(MouseSensor, {
// Require the mouse to move by 10 pixels before activating
activationConstraint: {
delay: 500,
tolerance: 5,
},
})
);
function handleDragStart(event: any) {
const { active } = event;
setActiveId(active.id);
}
function handleDragEnd(event: any) {
const { active, over } = event;
if (active.id !== over.id) {
const newConfig = { ...config };
const activeIndex = newConfig.services.findIndex((e) => e.id === active.id);
const overIndex = newConfig.services.findIndex((e) => e.id === over.id);
newConfig.services = arrayMove(newConfig.services, activeIndex, overIndex);
setConfig(newConfig);
}
setActiveId(null);
}
// Extract all the categories from the services in config
const categoryList = config.services.reduce((acc, cur) => {
if (cur.category && !acc.includes(cur.category)) {
acc.push(cur.category);
}
return acc;
}, [] as string[]);
const item = (filter?: string) => {
// If filter is not set, return all the services without a category or a null category
let filtered = config.services;
if (!filter) {
filtered = config.services.filter((e) => !e.category || e.category === null);
}
if (filter) {
filtered = config.services.filter((e) => e.category === filter);
}
return (
<DndContext
sensors={sensors}
collisionDetection={closestCenter}
onDragStart={handleDragStart}
onDragEnd={handleDragEnd}
>
<SortableContext items={config.services}>
<Grid gutter="xl" align="center">
{filtered.map((service) => (
<Grid.Col
key={service.id}
span={6}
xl={config.settings.appCardWidth || 2}
xs={4}
sm={3}
md={3}
>
<SortableAppShelfItem service={service} key={service.id} id={service.id} />
</Grid.Col>
))}
</Grid>
</SortableContext>
<DragOverlay
style={{
// Add a shadow to the drag overlay
boxShadow: '0 0 10px rgba(0, 0, 0, 0.5)',
}}
>
{activeId ? (
<AppShelfItem service={config.services.find((e) => e.id === activeId)} id={activeId} />
) : null}
</DragOverlay>
</DndContext>
);
};
if (categoryList.length > 0) {
const noCategory = config.services.filter(
(e) => e.category === undefined || e.category === null
);
const downloadEnabled = config.modules?.[DownloadsModule.title]?.enabled ?? false;
// Create an item with 0: true, 1: true, 2: true... For each category
return (
// Return one item for each category
<Group grow direction="column">
<Accordion
disableIconRotation
classNames={classes}
order={2}
iconPosition="right"
multiple
initialState={toggledCategories}
onChange={(idx) => settoggledCategories(idx)}
>
{categoryList.map((category, idx) => (
<Accordion.Item key={category} label={category}>
{item(category)}
</Accordion.Item>
))}
{/* Return the item for all services without category */}
{noCategory && noCategory.length > 0 ? (
<Accordion.Item key="Other" label="Other">
{item()}
</Accordion.Item>
) : null}
{downloadEnabled ? (
<Accordion.Item key="Downloads" label="Your downloads">
<Paper
p="lg"
radius="lg"
style={{
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
${(config.settings.appOpacity || 100) / 100}`,
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
${(config.settings.appOpacity || 100) / 100}`,
}}
>
<ModuleMenu module={DownloadsModule} />
<DownloadComponent />
</Paper>
</Accordion.Item>
) : null}
</Accordion>
</Group>
);
}
return ( return (
<Grid gutter="xl" align="center"> <Group grow direction="column">
{config.services.map((service) => ( {item()}
<Grid.Col key={service.name} span={6} xl={2} xs={4} sm={3} md={3}> <ModuleWrapper mt="xl" module={DownloadsModule} />
<AppShelfItem key={service.name} service={service} /> </Group>
</Grid.Col>
))}
</Grid>
); );
}; };
export function AppShelfItem(props: any) {
const { service }: { service: serviceItem } = props;
const [hovering, setHovering] = useState(false);
const { classes, theme } = useStyles();
return (
<motion.div
animate={{
scale: [0.9, 1.06, 1],
rotate: [0, 5, 0],
}}
transition={{ duration: 0.6, type: 'spring', damping: 10, mass: 0.75, stiffness: 100 }}
key={service.name}
onHoverStart={() => {
setHovering(true);
}}
onHoverEnd={() => {
setHovering(false);
}}
>
<Card withBorder radius="lg" shadow="md" className={classes.item}>
<Card.Section>
<Text mt="sm" align="center" lineClamp={1} weight={550}>
{service.name}
</Text>
<motion.div
style={{
position: 'absolute',
top: 15,
right: 15,
alignSelf: 'flex-end',
}}
animate={{
opacity: hovering ? 1 : 0,
}}
>
<AppShelfMenu service={service} />
</motion.div>
</Card.Section>
<Center>
<Card.Section>
<AspectRatio
ratio={3 / 5}
m="xl"
style={{
width: 150,
height: 90,
}}
>
<motion.i
whileHover={{
cursor: 'pointer',
scale: 1.1,
}}
>
<Image
width={80}
height={80}
src={service.icon}
fit="contain"
onClick={() => {
window.open(service.url);
}}
/>
</motion.i>
</AspectRatio>
<PingComponent url={service.url} />
</Card.Section>
</Center>
</Card>
</motion.div>
);
}
export default AppShelf; export default AppShelf;

View File

@@ -0,0 +1,143 @@
import {
Text,
Card,
Anchor,
AspectRatio,
Image,
Center,
createStyles,
useMantineColorScheme,
} from '@mantine/core';
import { motion } from 'framer-motion';
import { useState } from 'react';
import { useSortable } from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import { serviceItem } from '../../tools/types';
import PingComponent from '../modules/ping/PingModule';
import AppShelfMenu from './AppShelfMenu';
import { useConfig } from '../../tools/state';
const useStyles = createStyles((theme) => ({
item: {
transition: 'box-shadow 150ms ease, transform 100ms ease',
'&:hover': {
boxShadow: `${theme.shadows.md} !important`,
transform: 'scale(1.05)',
},
[theme.fn.smallerThan('sm')]: {
WebkitUserSelect: 'none',
},
},
}));
export function SortableAppShelfItem(props: any) {
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
id: props.id,
});
const style = {
transform: CSS.Transform.toString(transform),
transition,
};
return (
<div ref={setNodeRef} style={style} {...attributes} {...listeners}>
<AppShelfItem service={props.service} />
</div>
);
}
export function AppShelfItem(props: any) {
const { service }: { service: serviceItem } = props;
const [hovering, setHovering] = useState(false);
const { config } = useConfig();
const { colorScheme } = useMantineColorScheme();
const { classes } = useStyles();
return (
<motion.div
animate={{
scale: [0.9, 1.06, 1],
rotate: [0, 5, 0],
}}
transition={{ duration: 0.6, type: 'spring', damping: 10, mass: 0.75, stiffness: 100 }}
key={service.name}
onHoverStart={() => {
setHovering(true);
}}
onHoverEnd={() => {
setHovering(false);
}}
>
<Card
withBorder
radius="lg"
shadow="md"
className={classes.item}
style={{
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
${(config.settings.appOpacity || 100) / 100}`,
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
${(config.settings.appOpacity || 100) / 100}`,
}}
>
<Card.Section>
<Anchor
target={service.newTab === false ? '_top' : '_blank'}
href={service.openedUrl ? service.openedUrl : service.url}
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
>
<Text mt="sm" align="center" lineClamp={1} weight={550}>
{service.name}
</Text>
</Anchor>
<motion.div
style={{
position: 'absolute',
top: 15,
right: 15,
alignSelf: 'flex-end',
}}
animate={{
opacity: hovering ? 1 : 0,
}}
>
<AppShelfMenu service={service} />
</motion.div>
</Card.Section>
<Center>
<Card.Section>
<AspectRatio
ratio={3 / 5}
m="xl"
style={{
width: 150,
height: 90,
}}
>
<motion.i
whileHover={{
scale: 1.1,
}}
>
<Image
styles={{ root: { cursor: 'pointer' } }}
width={80}
height={80}
src={service.icon}
fit="contain"
onClick={() => {
if (service.openedUrl) {
window.open(service.openedUrl, service.newTab === false ? '_top' : '_blank');
} else window.open(service.url, service.newTab === false ? '_top' : '_blank');
}}
/>
</motion.i>
</AspectRatio>
<PingComponent url={service.url} status={service.status} />
</Card.Section>
</Center>
</Card>
</motion.div>
);
}

View File

@@ -1,17 +0,0 @@
import { useMantineTheme, Card } from '@mantine/core';
export function AppShelfItemWrapper(props: any) {
const { children, hovering } = props;
const theme = useMantineTheme();
return (
<Card
style={{
boxShadow: hovering ? '0px 0px 3px rgba(0, 0, 0, 0.5)' : '0px 0px 1px rgba(0, 0, 0, 0.5)',
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : theme.colors.gray[1],
}}
radius="md"
>
{children}
</Card>
);
}

View File

@@ -1,12 +1,13 @@
import { Menu, Modal, Text, useMantineTheme } from '@mantine/core'; import { Menu, Modal, Text, useMantineTheme } from '@mantine/core';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { useState } from 'react'; import { useState } from 'react';
import { Check, Edit, Trash } from 'tabler-icons-react'; import { IconCheck as Check, IconEdit as Edit, IconTrash as Trash } from '@tabler/icons';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { serviceItem } from '../../tools/types';
import { AddAppShelfItemForm } from './AddAppShelfItem'; import { AddAppShelfItemForm } from './AddAppShelfItem';
export default function AppShelfMenu(props: any) { export default function AppShelfMenu(props: any) {
const { service } = props; const { service }: { service: serviceItem } = props;
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const theme = useMantineTheme(); const theme = useMantineTheme();
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
@@ -19,30 +20,23 @@ export default function AppShelfMenu(props: any) {
onClose={() => setOpened(false)} onClose={() => setOpened(false)}
title="Modify a service" title="Modify a service"
> >
<AddAppShelfItemForm <AddAppShelfItemForm setOpened={setOpened} {...service} message="Save service" />
setOpened={setOpened}
name={service.name}
type={service.type}
url={service.url}
icon={service.icon}
apiKey={service.apiKey}
message="Save service"
/>
</Modal> </Modal>
<Menu <Menu
position="right" position="right"
radius="md" radius="md"
shadow="xl"
styles={{ styles={{
body: { body: {
backgroundColor: // Add shadow and elevation to the body
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1], boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.05)',
}, },
}} }}
> >
<Menu.Label>Settings</Menu.Label> <Menu.Label>Settings</Menu.Label>
<Menu.Item <Menu.Item
color="primary" color="primary"
icon={<Edit size={14} />} icon={<Edit />}
// TODO: #2 Add the ability to edit the service. // TODO: #2 Add the ability to edit the service.
onClick={() => setOpened(true)} onClick={() => setOpened(true)}
> >
@@ -54,13 +48,13 @@ export default function AppShelfMenu(props: any) {
onClick={(e: any) => { onClick={(e: any) => {
setConfig({ setConfig({
...config, ...config,
services: config.services.filter((s) => s.name !== service.name), services: config.services.filter((s) => s.id !== service.id),
}); });
showNotification({ showNotification({
autoClose: 5000, autoClose: 5000,
title: ( title: (
<Text> <Text>
Service <b>{service.name}</b> removed successfully Service <b>{service.name}</b> removed successfully!
</Text> </Text>
), ),
color: 'green', color: 'green',
@@ -68,7 +62,7 @@ export default function AppShelfMenu(props: any) {
message: undefined, message: undefined,
}); });
}} }}
icon={<Trash size={14} />} icon={<Trash />}
> >
Delete Delete
</Menu.Item> </Menu.Item>

View File

@@ -0,0 +1,2 @@
export { default as AppShelf } from './AppShelf';
export * from './AppShelfItem';

View File

@@ -1,6 +1,7 @@
import React from 'react'; import React from 'react';
import { createStyles, Switch, Group, useMantineColorScheme, Kbd } from '@mantine/core'; import { createStyles, Switch, Group, useMantineColorScheme, Kbd } from '@mantine/core';
import { Sun, MoonStars } from 'tabler-icons-react'; import { IconSun as Sun, IconMoonStars as MoonStars } from '@tabler/icons';
import { useConfig } from '../../tools/state';
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
root: { root: {
@@ -29,6 +30,7 @@ const useStyles = createStyles((theme) => ({
})); }));
export function ColorSchemeSwitch() { export function ColorSchemeSwitch() {
const { config } = useConfig();
const { colorScheme, toggleColorScheme } = useMantineColorScheme(); const { colorScheme, toggleColorScheme } = useMantineColorScheme();
const { classes, cx } = useStyles(); const { classes, cx } = useStyles();

View File

@@ -1,5 +1,5 @@
import { Box, useMantineColorScheme } from '@mantine/core'; import { Box, useMantineColorScheme } from '@mantine/core';
import { Sun, MoonStars } from 'tabler-icons-react'; import { IconSun as Sun, IconMoonStars as MoonStars } from '@tabler/icons';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
export function ColorSchemeToggle() { export function ColorSchemeToggle() {

View File

@@ -26,7 +26,10 @@ export default function ConfigChanger() {
label="Config loader" label="Config loader"
onChange={(e) => { onChange={(e) => {
loadConfig(e ?? 'default'); loadConfig(e ?? 'default');
setCookies('config-name', e ?? 'default', { maxAge: 60 * 60 * 24 * 30 }); setCookies('config-name', e ?? 'default', {
maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict',
});
}} }}
data={ data={
// If config list is empty, return the current config // If config list is empty, return the current config

View File

@@ -1,5 +1,11 @@
import { Group, Text, useMantineTheme, MantineTheme } from '@mantine/core'; import { Group, Text, useMantineTheme, MantineTheme } from '@mantine/core';
import { Upload, Photo, X, Icon as TablerIcon, Check } from 'tabler-icons-react'; import {
IconUpload as Upload,
IconPhoto as Photo,
IconX as X,
IconCheck as Check,
TablerIcon,
} from '@tabler/icons';
import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone'; import { DropzoneStatus, FullScreenDropzone } from '@mantine/dropzone';
import { showNotification } from '@mantine/notifications'; import { showNotification } from '@mantine/notifications';
import { useRef } from 'react'; import { useRef } from 'react';
@@ -7,6 +13,7 @@ import { useRouter } from 'next/router';
import { setCookies } from 'cookies-next'; import { setCookies } from 'cookies-next';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { Config } from '../../tools/types'; import { Config } from '../../tools/types';
import { migrateToIdConfig } from '../../tools/migrate';
function getIconColor(status: DropzoneStatus, theme: MantineTheme) { function getIconColor(status: DropzoneStatus, theme: MantineTheme) {
return status.accepted return status.accepted
@@ -83,8 +90,12 @@ export default function LoadConfigComponent(props: any) {
icon: <Check />, icon: <Check />,
message: undefined, message: undefined,
}); });
setCookies('config-name', newConfig.name, { maxAge: 60 * 60 * 24 * 30 }); setCookies('config-name', newConfig.name, {
setConfig(newConfig); maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict',
});
const migratedConfig = migrateToIdConfig(newConfig);
setConfig(migratedConfig);
}); });
}} }}
accept={['application/json']} accept={['application/json']}

View File

@@ -1,18 +1,102 @@
import { Button } from '@mantine/core'; import { Button, Group, Modal, TextInput } from '@mantine/core';
import { useForm } from '@mantine/form';
import { showNotification } from '@mantine/notifications';
import axios from 'axios';
import fileDownload from 'js-file-download'; import fileDownload from 'js-file-download';
import { Download } from 'tabler-icons-react'; import { useState } from 'react';
import {
IconCheck as Check,
IconDownload as Download,
IconPlus as Plus,
IconTrash as Trash,
IconX as X,
} from '@tabler/icons';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
export default function SaveConfigComponent(props: any) { export default function SaveConfigComponent(props: any) {
const { config } = useConfig(); const [opened, setOpened] = useState(false);
const { config, setConfig } = useConfig();
const form = useForm({
initialValues: {
configName: config.name,
},
});
function onClick(e: any) { function onClick(e: any) {
if (config) { if (config) {
fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`); fileDownload(JSON.stringify(config, null, '\t'), `${config.name}.json`);
} }
} }
return ( return (
<Button leftIcon={<Download />} variant="outline" onClick={onClick}> <Group spacing="xs">
Download your config <Modal
</Button> radius="md"
opened={opened}
onClose={() => setOpened(false)}
title="Choose the name of your new config"
>
<form
onSubmit={form.onSubmit((values) => {
setConfig({ ...config, name: values.configName });
setOpened(false);
showNotification({
title: 'Config saved',
icon: <Check />,
color: 'green',
autoClose: 1500,
radius: 'md',
message: `Config saved as ${values.configName}`,
});
})}
>
<TextInput
required
label="Config name"
placeholder="Your new config name"
{...form.getInputProps('configName')}
/>
<Group position="right" mt="md">
<Button type="submit">Confirm</Button>
</Group>
</form>
</Modal>
<Button size="xs" leftIcon={<Download />} variant="outline" onClick={onClick}>
Download config
</Button>
<Button
size="xs"
leftIcon={<Trash />}
variant="outline"
onClick={() => {
axios
.delete(`/api/configs/${config.name}`)
.then(() => {
showNotification({
title: 'Config deleted',
icon: <Check />,
color: 'green',
autoClose: 1500,
radius: 'md',
message: 'Config deleted',
});
})
.catch(() => {
showNotification({
title: 'Config delete failed',
icon: <X />,
color: 'red',
autoClose: 1500,
radius: 'md',
message: 'Config delete failed',
});
});
setConfig({ ...config, name: 'default' });
}}
>
Delete config
</Button>
<Button size="xs" leftIcon={<Plus />} variant="outline" onClick={() => setOpened(true)}>
Save a copy
</Button>
</Group>
); );
} }

View File

@@ -1,16 +0,0 @@
import { Select } from '@mantine/core';
import { useState } from 'react';
export default function SelectConfig(props: any) {
const [value, setValue] = useState<string | null>('');
return (
<Select
value={value}
onChange={setValue}
data={[
{ value: 'default', label: 'Default' },
{ value: 'yourmom', label: 'Your mom' },
]}
/>
);
}

View File

@@ -0,0 +1,182 @@
import { Button, Group, Modal, Title } from '@mantine/core';
import { useBooleanToggle } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications';
import {
IconCheck,
IconPlayerPlay,
IconPlayerStop,
IconPlus,
IconRefresh,
IconRotateClockwise,
IconTrash,
IconX,
} from '@tabler/icons';
import axios from 'axios';
import Dockerode from 'dockerode';
import { tryMatchService } from '../../tools/addToHomarr';
import { useConfig } from '../../tools/state';
import { AddAppShelfItemForm } from '../AppShelf/AddAppShelfItem';
function sendDockerCommand(action: string, containerId: string, containerName: string) {
showNotification({
id: containerId,
loading: true,
title: `${action}ing container ${containerName.substring(1)}`,
message: undefined,
autoClose: false,
disallowClose: true,
});
axios.get(`/api/docker/container/${containerId}?action=${action}`).then((res) => {
setTimeout(() => {
if (res.data.success === true) {
updateNotification({
id: containerId,
title: `Container ${containerName} ${action}ed`,
message: `Your container was successfully ${action}ed`,
icon: <IconCheck />,
autoClose: 2000,
});
}
if (res.data.success === false) {
updateNotification({
id: containerId,
color: 'red',
title: 'There was an error with your container.',
message: undefined,
icon: <IconX />,
autoClose: 2000,
});
}
}, 500);
});
}
export interface ContainerActionBarProps {
selected: Dockerode.ContainerInfo[];
reload: () => void;
}
export default function ContainerActionBar({ selected, reload }: ContainerActionBarProps) {
const { config, setConfig } = useConfig();
const [opened, setOpened] = useBooleanToggle(false);
return (
<Group>
<Modal
size="xl"
radius="md"
opened={opened}
onClose={() => setOpened(false)}
title="Add service"
>
<AddAppShelfItemForm
setOpened={setOpened}
{...tryMatchService(selected.at(0))}
message="Add service to homarr"
/>
</Modal>
<Button
leftIcon={<IconRotateClockwise />}
onClick={() =>
Promise.all(
selected.map((container) =>
sendDockerCommand('restart', container.Id, container.Names[0].substring(1))
)
).then(() => reload())
}
variant="light"
color="orange"
radius="md"
>
Restart
</Button>
<Button
leftIcon={<IconPlayerStop />}
onClick={() =>
Promise.all(
selected.map((container) => {
if (
container.State === 'stopped' ||
container.State === 'created' ||
container.State === 'exited'
) {
return showNotification({
id: container.Id,
title: `Failed to stop ${container.Names[0].substring(1)}`,
message: "You can't stop a stopped container",
autoClose: 1000,
});
}
return sendDockerCommand('stop', container.Id, container.Names[0].substring(1));
})
).then(() => reload())
}
variant="light"
color="red"
radius="md"
>
Stop
</Button>
<Button
leftIcon={<IconPlayerPlay />}
onClick={() =>
Promise.all(
selected.map((container) =>
sendDockerCommand('start', container.Id, container.Names[0].substring(1))
)
).then(() => reload())
}
variant="light"
color="green"
radius="md"
>
Start
</Button>
<Button leftIcon={<IconRefresh />} onClick={() => reload()} variant="light" radius="md">
Refresh data
</Button>
<Button
leftIcon={<IconPlus />}
color="indigo"
variant="light"
radius="md"
onClick={() => {
if (selected.length !== 1) {
showNotification({
autoClose: 5000,
title: <Title order={4}>Please only add one service at a time!</Title>,
color: 'red',
message: undefined,
});
} else {
setOpened(true);
}
}}
>
Add to Homarr
</Button>
<Button
leftIcon={<IconTrash />}
color="red"
variant="light"
radius="md"
onClick={() =>
Promise.all(
selected.map((container) => {
if (container.State === 'running') {
return showNotification({
id: container.Id,
title: `Failed to delete ${container.Names[0].substring(1)}`,
message: "You can't delete a running container",
autoClose: 1000,
});
}
return sendDockerCommand('remove', container.Id, container.Names[0].substring(1));
})
).then(() => reload())
}
>
Remove
</Button>
</Group>
);
}

View File

@@ -0,0 +1,49 @@
import { Badge, BadgeVariant, MantineSize } from '@mantine/core';
import Dockerode from 'dockerode';
export interface ContainerStateProps {
state: Dockerode.ContainerInfo['State'];
}
export default function ContainerState(props: ContainerStateProps) {
const { state } = props;
const options: {
size: MantineSize;
radius: MantineSize;
variant: BadgeVariant;
} = {
size: 'md',
radius: 'md',
variant: 'outline',
};
switch (state) {
case 'running': {
return (
<Badge color="green" {...options}>
Running
</Badge>
);
}
case 'created': {
return (
<Badge color="cyan" {...options}>
Created
</Badge>
);
}
case 'exited': {
return (
<Badge color="red" {...options}>
Stopped
</Badge>
);
}
default: {
return (
<Badge color="purple" {...options}>
Unknown
</Badge>
);
}
}
}

View File

@@ -0,0 +1,53 @@
import { ActionIcon, Drawer, Group, LoadingOverlay } from '@mantine/core';
import { IconBrandDocker } from '@tabler/icons';
import axios from 'axios';
import { useEffect, useState } from 'react';
import Docker from 'dockerode';
import ContainerActionBar from './ContainerActionBar';
import DockerTable from './DockerTable';
export default function DockerDrawer(props: any) {
const [opened, setOpened] = useState(false);
const [containers, setContainers] = useState<Docker.ContainerInfo[]>([]);
const [selection, setSelection] = useState<Docker.ContainerInfo[]>([]);
const [visible, setVisible] = useState(false);
function reload() {
setVisible(true);
setTimeout(() => {
axios.get('/api/docker/containers').then((res) => {
setContainers(res.data);
setSelection([]);
setVisible(false);
});
}, 300);
}
useEffect(() => {
reload();
}, []);
// Check if the user has at least one container
if (containers.length < 1) return null;
return (
<>
<Drawer opened={opened} onClose={() => setOpened(false)} padding="xl" size="full">
<ContainerActionBar selected={selection} reload={reload} />
<div style={{ position: 'relative' }}>
<LoadingOverlay transitionDuration={500} visible={visible} />
<DockerTable containers={containers} selection={selection} setSelection={setSelection} />
</div>
</Drawer>
<Group position="center">
<ActionIcon
variant="default"
radius="md"
size="xl"
color="blue"
onClick={() => setOpened(true)}
>
<IconBrandDocker />
</ActionIcon>
</Group>
</>
);
}

View File

@@ -0,0 +1,91 @@
import { Menu, Text, useMantineTheme } from '@mantine/core';
import { showNotification, updateNotification } from '@mantine/notifications';
import {
IconCheck,
IconCodePlus,
IconPlayerPlay,
IconPlayerStop,
IconRotateClockwise,
IconX,
} from '@tabler/icons';
import axios from 'axios';
import Dockerode from 'dockerode';
function sendNotification(action: string, containerId: string, containerName: string) {
showNotification({
id: 'load-data',
loading: true,
title: `${action}ing container ${containerName}`,
message: 'Your password is being checked...',
autoClose: false,
disallowClose: true,
});
axios.get(`/api/docker/container/${containerId}?action=${action}`).then((res) => {
setTimeout(() => {
if (res.data.success === true) {
updateNotification({
id: 'load-data',
title: 'Container restarted',
message: 'Your container was successfully restarted',
icon: <IconCheck />,
autoClose: 2000,
});
}
if (res.data.success === false) {
updateNotification({
id: 'load-data',
color: 'red',
title: 'There was an error restarting your container.',
message: 'Your container has encountered issues while restarting.',
icon: <IconX />,
autoClose: 2000,
});
}
}, 500);
});
}
function restart(container: Dockerode.ContainerInfo) {
sendNotification('restart', container.Id, container.Names[0]);
}
function stop(container: Dockerode.ContainerInfo) {
console.log('stoping container', container.Id);
}
function start(container: Dockerode.ContainerInfo) {
console.log('starting container', container.Id);
}
export default function DockerMenu(props: any) {
const { container }: { container: Dockerode.ContainerInfo } = props;
const theme = useMantineTheme();
if (container === undefined) {
return null;
}
return (
<Menu shadow="lg" radius="md">
<Menu.Label>Actions</Menu.Label>
<Menu.Item icon={<IconRotateClockwise color="orange" />} onClick={() => restart(container)}>
<Text>Restart</Text>
</Menu.Item>
{container.State === 'running' ? (
<Menu.Item icon={<IconPlayerStop color="red" />}>
<Text>Stop</Text>
</Menu.Item>
) : (
<Menu.Item icon={<IconPlayerPlay color="green" />}>
<Text>Start</Text>
</Menu.Item>
)}
{/* <Menu.Item icon={<IconDownload color="blue" />}>
<Text>Pull latest image </Text>
</Menu.Item>
<Menu.Item icon={<IconFileText color="grey" />}>
<Text>Logs</Text>
</Menu.Item> */}
<Menu.Label>Homarr</Menu.Label>
<Menu.Item icon={<IconCodePlus color={theme.primaryColor} />}>
<Text>Add to Homarr</Text>
</Menu.Item>
</Menu>
);
}

View File

@@ -0,0 +1,90 @@
import { Table, Checkbox, Group, Badge, createStyles } from '@mantine/core';
import Dockerode from 'dockerode';
import ContainerState from './ContainerState';
const useStyles = createStyles((theme) => ({
rowSelected: {
backgroundColor:
theme.colorScheme === 'dark'
? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2)
: theme.colors[theme.primaryColor][0],
},
}));
export default function DockerTable({
containers,
selection,
setSelection,
}: {
setSelection: any;
containers: Dockerode.ContainerInfo[];
selection: Dockerode.ContainerInfo[];
}) {
const { classes, cx } = useStyles();
const toggleRow = (container: Dockerode.ContainerInfo) =>
setSelection((current: Dockerode.ContainerInfo[]) =>
current.includes(container) ? current.filter((c) => c !== container) : [...current, container]
);
const toggleAll = () =>
setSelection((current: any) =>
current.length === containers.length ? [] : containers.map((c) => c)
);
const rows = containers.map((element) => {
const selected = selection.includes(element);
return (
<tr key={element.Id} className={cx({ [classes.rowSelected]: selected })}>
<td>
<Checkbox
checked={selection.includes(element)}
onChange={() => toggleRow(element)}
transitionDuration={0}
/>
</td>
<td>{element.Names[0].replace('/', '')}</td>
<td>{element.Image}</td>
<td>
<Group>
{element.Ports.sort((a, b) => a.PrivatePort - b.PrivatePort)
.slice(-3)
.map((port) => (
<Badge key={port.PrivatePort} variant="outline">
{port.PrivatePort}:{port.PublicPort}
</Badge>
))}
{element.Ports.length > 3 && (
<Badge variant="filled">{element.Ports.length - 3} more</Badge>
)}
</Group>
</td>
<td>
<ContainerState state={element.State} />
</td>
</tr>
);
});
return (
<Table captionSide="bottom" highlightOnHover sx={{ minWidth: 800 }} verticalSpacing="sm">
<caption>your docker containers</caption>
<thead>
<tr>
<th style={{ width: 40 }}>
<Checkbox
onChange={toggleAll}
checked={selection.length === containers.length}
indeterminate={selection.length > 0 && selection.length !== containers.length}
transitionDuration={0}
/>
</th>
<th>Name</th>
<th>Image</th>
<th>Ports</th>
<th>State</th>
</tr>
</thead>
<tbody>{rows}</tbody>
</Table>
);
}

View File

@@ -0,0 +1,65 @@
import { TextInput, Group, Button } from '@mantine/core';
import { useForm } from '@mantine/form';
import { useConfig } from '../../tools/state';
import { ColorSelector } from './ColorSelector';
import { OpacitySelector } from './OpacitySelector';
import { AppCardWidthSelector } from './AppCardWidthSelector';
import { ShadeSelector } from './ShadeSelector';
export default function TitleChanger() {
const { config, setConfig } = useConfig();
const form = useForm({
initialValues: {
title: config.settings.title,
logo: config.settings.logo,
favicon: config.settings.favicon,
background: config.settings.background,
},
});
const saveChanges = (values: {
title?: string;
logo?: string;
favicon?: string;
background?: string;
}) => {
setConfig({
...config,
settings: {
...config.settings,
title: values.title,
logo: values.logo,
favicon: values.favicon,
background: values.background,
},
});
};
return (
<Group direction="column" grow mb="lg">
<form onSubmit={form.onSubmit((values) => saveChanges(values))}>
<Group grow direction="column">
<TextInput label="Page title" placeholder="Homarr 🦞" {...form.getInputProps('title')} />
<TextInput label="Logo" placeholder="/img/logo.png" {...form.getInputProps('logo')} />
<TextInput
label="Favicon"
placeholder="/favicon.svg"
{...form.getInputProps('favicon')}
/>
<TextInput
label="Background"
placeholder="/img/background.png"
{...form.getInputProps('background')}
/>
<Button type="submit">Save</Button>
</Group>
</form>
<ColorSelector type="primary" />
<ColorSelector type="secondary" />
<ShadeSelector />
<OpacitySelector />
<AppCardWidthSelector />
</Group>
);
}

View File

@@ -0,0 +1,32 @@
import React from 'react';
import { Group, Text, Slider } from '@mantine/core';
import { useConfig } from '../../tools/state';
export function AppCardWidthSelector() {
const { config, setConfig } = useConfig();
const setappCardWidth = (appCardWidth: number) => {
setConfig({
...config,
settings: {
...config.settings,
appCardWidth,
},
});
};
return (
<Group direction="column" spacing="xs" grow>
<Text>App Width</Text>
<Slider
label={null}
defaultValue={config.settings.appCardWidth}
step={0.2}
min={0.8}
max={2}
styles={{ markLabel: { fontSize: 'xx-small' } }}
onChange={(value) => setappCardWidth(value)}
/>
</Group>
);
}

View File

@@ -0,0 +1,96 @@
import React, { useState } from 'react';
import { ColorSwatch, Group, Popover, Text, useMantineTheme } from '@mantine/core';
import { useConfig } from '../../tools/state';
import { useColorTheme } from '../../tools/color';
interface ColorControlProps {
type: string;
}
export function ColorSelector({ type }: ColorControlProps) {
const { config, setConfig } = useConfig();
const [opened, setOpened] = useState(false);
const { primaryColor, secondaryColor, setPrimaryColor, setSecondaryColor } = useColorTheme();
const theme = useMantineTheme();
const colors = Object.keys(theme.colors).map((color) => ({
swatch: theme.colors[color][6],
color,
}));
const configColor = type === 'primary' ? primaryColor : secondaryColor;
const setConfigColor = (color: string) => {
if (type === 'primary') {
setPrimaryColor(color);
setConfig({
...config,
settings: {
...config.settings,
primaryColor: color,
},
});
} else {
setSecondaryColor(color);
setConfig({
...config,
settings: {
...config.settings,
secondaryColor: color,
},
});
}
};
const swatches = colors.map(({ color, swatch }) => (
<ColorSwatch
component="button"
type="button"
onClick={() => setConfigColor(color)}
key={color}
color={swatch}
size={22}
style={{ color: theme.white, cursor: 'pointer' }}
/>
));
return (
<Group direction="row" spacing={3}>
<Popover
opened={opened}
onClose={() => setOpened(false)}
transitionDuration={0}
target={
<ColorSwatch
component="button"
type="button"
color={theme.colors[configColor][6]}
onClick={() => setOpened((o) => !o)}
size={22}
style={{ display: 'block', cursor: 'pointer' }}
/>
}
styles={{
root: {
marginRight: theme.spacing.xs,
},
body: {
width: 152,
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
},
arrow: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
},
}}
position="bottom"
placement="end"
withArrow
arrowSize={3}
>
<Group spacing="xs">{swatches}</Group>
</Popover>
<Text>{type[0].toUpperCase() + type.slice(1)} color</Text>
</Group>
);
}

View File

@@ -0,0 +1,86 @@
import { Group, Text, SegmentedControl, TextInput } from '@mantine/core';
import { useState } from 'react';
import { useConfig } from '../../tools/state';
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch';
import { WidgetsPositionSwitch } from '../WidgetsPositionSwitch/WidgetsPositionSwitch';
import ConfigChanger from '../Config/ConfigChanger';
import SaveConfigComponent from '../Config/SaveConfig';
import ModuleEnabler from './ModuleEnabler';
import Tip from '../layout/Tip';
export default function CommonSettings(args: any) {
const { config, setConfig } = useConfig();
const matches = [
{ label: 'Google', value: 'https://google.com/search?q=' },
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
{ label: 'Bing', value: 'https://bing.com/search?q=' },
{ label: 'Custom', value: 'Custom' },
];
const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl);
const [searchUrl, setSearchUrl] = useState(
matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom'
);
return (
<Group direction="column" grow mb="lg">
<Group grow direction="column" spacing={0}>
<Text>Search engine</Text>
<Tip>
Use the prefixes <b>!yt</b> and <b>!t</b> in front of your query to search on YouTube or
for a Torrent respectively.
</Tip>
<SegmentedControl
fullWidth
mb="sm"
title="Search engine"
value={
// Match config.settings.searchUrl with a key in the matches array
searchUrl
}
onChange={
// Set config.settings.searchUrl to the value of the selected item
(e) => {
setSearchUrl(e);
setConfig({
...config,
settings: {
...config.settings,
searchUrl: e,
},
});
}
}
data={matches}
/>
{searchUrl === 'Custom' && (
<>
<Tip>%s can be used as a placeholder for the query.</Tip>
<TextInput
label="Query URL"
placeholder="Custom query URL"
value={customSearchUrl}
onChange={(event) => {
setCustomSearchUrl(event.currentTarget.value);
setConfig({
...config,
settings: {
...config.settings,
searchUrl: event.currentTarget.value,
},
});
}}
/>
</>
)}
</Group>
<ColorSchemeSwitch />
<WidgetsPositionSwitch />
<ModuleEnabler />
<ConfigChanger />
<SaveConfigComponent />
<Tip>Upload your config file by dragging and dropping it onto the page!</Tip>
</Group>
);
}

View File

@@ -0,0 +1,44 @@
import { Group, ActionIcon, Anchor, Text } from '@mantine/core';
import { IconBrandDiscord, IconBrandGithub } from '@tabler/icons';
import { CURRENT_VERSION } from '../../../data/constants';
export default function Credits(props: any) {
return (
<Group position="center" direction="row" mr="xs">
<Group spacing={0}>
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
<IconBrandGithub size={18} />
</ActionIcon>
<Text
style={{
position: 'relative',
fontSize: '0.90rem',
color: 'gray',
}}
>
{CURRENT_VERSION}
</Text>
</Group>
<Group spacing={1}>
<Text
style={{
fontSize: '0.90rem',
textAlign: 'center',
color: 'gray',
}}
>
Made with by @
<Anchor
href="https://github.com/ajnart"
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
>
ajnart
</Anchor>
</Text>
<ActionIcon<'a'> component="a" href="https://discord.gg/aCsmEV5RgA" size="lg">
<IconBrandDiscord size={18} />
</ActionIcon>
</Group>
</Group>
);
}

View File

@@ -1,41 +1,35 @@
import { Group, Switch } from '@mantine/core'; import { Checkbox, Group, SimpleGrid, Title } from '@mantine/core';
import * as Modules from '../modules'; import * as Modules from '../modules';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
export default function ModuleEnabler(props: any) { export default function ModuleEnabler(props: any) {
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const modules = Object.values(Modules).map((module) => module); const modules = Object.values(Modules).map((module) => module);
const enabledModules = config.settings.enabledModules ?? [];
modules.filter((module) => enabledModules.includes(module.title));
return ( return (
<Group direction="column"> <Group direction="column">
{modules.map((module) => ( <Title order={4}>Module enabler</Title>
<Switch <SimpleGrid cols={2} spacing="md">
key={module.title} {modules.map((module) => (
size="md" <Checkbox
checked={enabledModules.includes(module.title)} key={module.title}
label={`Enable ${module.title} module`} size="md"
onChange={(e) => { checked={config.modules?.[module.title]?.enabled ?? false}
if (e.currentTarget.checked) { label={`${module.title}`}
onChange={(e) => {
setConfig({ setConfig({
...config, ...config,
settings: { modules: {
...config.settings, ...config.modules,
enabledModules: [...enabledModules, module.title], [module.title]: {
...config.modules?.[module.title],
enabled: e.currentTarget.checked,
},
}, },
}); });
} else { }}
setConfig({ />
...config, ))}
settings: { </SimpleGrid>
...config.settings,
enabledModules: enabledModules.filter((m) => m !== module.title),
},
});
}
}}
/>
))}
</Group> </Group>
); );
} }

View File

@@ -0,0 +1,44 @@
import React from 'react';
import { Group, Text, Slider } from '@mantine/core';
import { useConfig } from '../../tools/state';
export function OpacitySelector() {
const { config, setConfig } = useConfig();
const MARKS = [
{ value: 10, label: '10' },
{ value: 20, label: '20' },
{ value: 30, label: '30' },
{ value: 40, label: '40' },
{ value: 50, label: '50' },
{ value: 60, label: '60' },
{ value: 70, label: '70' },
{ value: 80, label: '80' },
{ value: 90, label: '90' },
{ value: 100, label: '100' },
];
const setConfigOpacity = (opacity: number) => {
setConfig({
...config,
settings: {
...config.settings,
appOpacity: opacity,
},
});
};
return (
<Group direction="column" spacing="xs" grow>
<Text>App Opacity</Text>
<Slider
defaultValue={config.settings.appOpacity || 100}
step={10}
min={10}
marks={MARKS}
styles={{ markLabel: { fontSize: 'xx-small' } }}
onChange={(value) => setConfigOpacity(value)}
/>
</Group>
);
}

View File

@@ -1,114 +1,45 @@
import { import { ActionIcon, Title, Tooltip, Drawer, Tabs, ScrollArea } from '@mantine/core';
ActionIcon, import { useHotkeys } from '@mantine/hooks';
Group,
Modal,
Title,
Text,
Tooltip,
SegmentedControl,
TextInput,
} from '@mantine/core';
import { useColorScheme } from '@mantine/hooks';
import { useState } from 'react'; import { useState } from 'react';
import { Settings as SettingsIcon } from 'tabler-icons-react'; import { IconSettings } from '@tabler/icons';
import { useConfig } from '../../tools/state'; import AdvancedSettings from './AdvancedSettings';
import { ColorSchemeSwitch } from '../ColorSchemeToggle/ColorSchemeSwitch'; import CommonSettings from './CommonSettings';
import ConfigChanger from '../Config/ConfigChanger'; import Credits from './Credits';
import SaveConfigComponent from '../Config/SaveConfig';
import ModuleEnabler from './ModuleEnabler';
function SettingsMenu(props: any) { function SettingsMenu(props: any) {
const { config, setConfig } = useConfig();
const colorScheme = useColorScheme();
const { current, latest } = props;
const matches = [
{ label: 'Google', value: 'https://google.com/search?q=' },
{ label: 'DuckDuckGo', value: 'https://duckduckgo.com/?q=' },
{ label: 'Bing', value: 'https://bing.com/search?q=' },
{ label: 'Custom', value: 'Custom' },
];
const [customSearchUrl, setCustomSearchUrl] = useState(config.settings.searchUrl);
const [searchUrl, setSearchUrl] = useState(
matches.find((match) => match.value === config.settings.searchUrl)?.value ?? 'Custom'
);
return ( return (
<Group direction="column" grow> <Tabs grow>
<Group grow direction="column" spacing={0}> <Tabs.Tab data-autofocus label="Common">
<Text>Search engine</Text> <ScrollArea style={{ height: '78vh' }} offsetScrollbars>
<SegmentedControl <CommonSettings />
fullWidth </ScrollArea>
title="Search engine" </Tabs.Tab>
value={ <Tabs.Tab label="Customizations">
// Match config.settings.searchUrl with a key in the matches array <ScrollArea style={{ height: '78vh' }} offsetScrollbars>
searchUrl <AdvancedSettings />
} </ScrollArea>
onChange={ </Tabs.Tab>
// Set config.settings.searchUrl to the value of the selected item </Tabs>
(e) => {
setSearchUrl(e);
setConfig({
...config,
settings: {
...config.settings,
searchUrl: e,
},
});
}
}
data={matches}
/>
{searchUrl === 'Custom' && (
<TextInput
label="Query URL"
placeholder="Custom query url"
value={customSearchUrl}
onChange={(event) => {
setCustomSearchUrl(event.currentTarget.value);
setConfig({
...config,
settings: {
...config.settings,
searchUrl: event.currentTarget.value,
},
});
}}
/>
)}
</Group>
<ModuleEnabler />
<ColorSchemeSwitch />
<ConfigChanger />
<SaveConfigComponent />
<Text
style={{
alignSelf: 'center',
fontSize: '0.75rem',
textAlign: 'center',
color: '#a0aec0',
}}
>
tip: You can upload your config file by dragging and dropping it onto the page
</Text>
</Group>
); );
} }
export function SettingsMenuButton(props: any) { export function SettingsMenuButton(props: any) {
useHotkeys([['ctrl+L', () => setOpened(!opened)]]);
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
return ( return (
<> <>
<Modal <Drawer
size="xl" size="xl"
radius="md" padding="lg"
title={<Title order={3}>Settings</Title>} position="right"
title={<Title order={5}>Settings</Title>}
opened={props.opened || opened} opened={props.opened || opened}
onClose={() => setOpened(false)} onClose={() => setOpened(false)}
> >
<SettingsMenu /> <SettingsMenu />
</Modal> <Credits />
</Drawer>
<ActionIcon <ActionIcon
variant="default" variant="default"
radius="md" radius="md"
@@ -118,7 +49,7 @@ export function SettingsMenuButton(props: any) {
onClick={() => setOpened(true)} onClick={() => setOpened(true)}
> >
<Tooltip label="Settings"> <Tooltip label="Settings">
<SettingsIcon /> <IconSettings />
</Tooltip> </Tooltip>
</ActionIcon> </ActionIcon>
</> </>

View File

@@ -0,0 +1,97 @@
import React, { useState } from 'react';
import { ColorSwatch, Group, Popover, Text, useMantineTheme, MantineTheme } from '@mantine/core';
import { useConfig } from '../../tools/state';
import { useColorTheme } from '../../tools/color';
export function ShadeSelector() {
const { config, setConfig } = useConfig();
const [opened, setOpened] = useState(false);
const { primaryColor, secondaryColor, primaryShade, setPrimaryShade } = useColorTheme();
const theme = useMantineTheme();
const primaryShades = theme.colors[primaryColor].map((s, i) => ({
swatch: theme.colors[primaryColor][i],
shade: i as MantineTheme['primaryShade'],
}));
const secondaryShades = theme.colors[secondaryColor].map((s, i) => ({
swatch: theme.colors[secondaryColor][i],
shade: i as MantineTheme['primaryShade'],
}));
const setConfigShade = (shade: MantineTheme['primaryShade']) => {
setPrimaryShade(shade);
setConfig({
...config,
settings: {
...config.settings,
primaryShade: shade,
},
});
};
const primarySwatches = primaryShades.map(({ swatch, shade }) => (
<ColorSwatch
component="button"
type="button"
onClick={() => setConfigShade(shade)}
key={Number(shade)}
color={swatch}
size={22}
style={{ color: theme.white, cursor: 'pointer' }}
/>
));
const secondarySwatches = secondaryShades.map(({ swatch, shade }) => (
<ColorSwatch
component="button"
type="button"
onClick={() => setConfigShade(shade)}
key={Number(shade)}
color={swatch}
size={22}
style={{ color: theme.white, cursor: 'pointer' }}
/>
));
return (
<Group direction="row" spacing={3}>
<Popover
opened={opened}
onClose={() => setOpened(false)}
transitionDuration={0}
target={
<ColorSwatch
component="button"
type="button"
color={theme.colors[primaryColor][Number(primaryShade)]}
onClick={() => setOpened((o) => !o)}
size={22}
style={{ display: 'block', cursor: 'pointer' }}
/>
}
styles={{
root: {
marginRight: theme.spacing.xs,
},
body: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
},
arrow: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[8] : theme.white,
},
}}
position="bottom"
placement="end"
withArrow
arrowSize={3}
>
<Group direction="column" spacing="xs">
<Group spacing="xs">{primarySwatches}</Group>
<Group spacing="xs">{secondarySwatches}</Group>
</Group>
</Popover>
<Text>Shade</Text>
</Group>
);
}

View File

@@ -0,0 +1,60 @@
import React, { useState } from 'react';
import { createStyles, Switch, Group } from '@mantine/core';
import { useConfig } from '../../tools/state';
const useStyles = createStyles((theme) => ({
root: {
position: 'relative',
'& *': {
cursor: 'pointer',
},
},
icon: {
pointerEvents: 'none',
position: 'absolute',
zIndex: 1,
top: 3,
},
iconLight: {
left: 4,
color: theme.white,
},
iconDark: {
right: 4,
color: theme.colors.gray[6],
},
}));
export function WidgetsPositionSwitch() {
const { config, setConfig } = useConfig();
const { classes, cx } = useStyles();
const defaultPosition = config?.settings?.widgetPosition || 'right';
const [widgetPosition, setWidgetPosition] = useState(defaultPosition);
const toggleWidgetPosition = () => {
const position = widgetPosition === 'right' ? 'left' : 'right';
setWidgetPosition(position);
setConfig({
...config,
settings: {
...config.settings,
widgetPosition: position,
},
});
};
return (
<Group>
<div className={classes.root}>
<Switch
checked={widgetPosition === 'left'}
onChange={() => toggleWidgetPosition()}
size="md"
/>
</div>
Position widgets on left
</Group>
);
}

View File

@@ -1,24 +1,36 @@
import { Aside as MantineAside, Group } from '@mantine/core'; import { Aside as MantineAside, createStyles } from '@mantine/core';
import { WeatherModule, DateModule, CalendarModule } from '../modules'; import Widgets from './Widgets';
import { ModuleWrapper } from '../modules/moduleWrapper';
const useStyles = createStyles((theme) => ({
hide: {
[theme.fn.smallerThan('xs')]: {
display: 'none',
},
},
burger: {
[theme.fn.largerThan('sm')]: {
display: 'none',
},
},
}));
export default function Aside(props: any) { export default function Aside(props: any) {
const { classes, cx } = useStyles();
return ( return (
<MantineAside <MantineAside
hiddenBreakpoint="md" pr="md"
hiddenBreakpoint="sm"
hidden hidden
className={cx(classes.hide)}
style={{ style={{
border: 'none', border: 'none',
background: 'none',
}} }}
width={{ width={{
base: 'auto', base: 'auto',
}} }}
> >
<Group mt="sm" grow direction="column"> <Widgets />
<ModuleWrapper module={CalendarModule} />
<ModuleWrapper module={DateModule} />
<ModuleWrapper module={WeatherModule} />
</Group>
</MantineAside> </MantineAside>
); );
} }

View File

@@ -0,0 +1,20 @@
import { Global } from '@mantine/core';
import { useConfig } from '../../tools/state';
export function Background() {
const { config } = useConfig();
return (
<Global
styles={{
body: {
minHeight: '100vh',
backgroundImage: `url('${config.settings.background}')` || '',
backgroundPosition: 'center center',
backgroundSize: 'cover',
backgroundRepeat: 'no-repeat',
},
}}
/>
);
}

View File

@@ -1,15 +1,7 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect } from 'react';
import { import { createStyles, Footer as FooterComponent } from '@mantine/core';
createStyles, import { showNotification } from '@mantine/notifications';
Anchor, import { IconAlertCircle as AlertCircle } from '@tabler/icons';
Text,
Group,
ActionIcon,
Footer as FooterComponent,
Alert,
useMantineTheme,
} from '@mantine/core';
import { AlertCircle, BrandGithub } from 'tabler-icons-react';
import { CURRENT_VERSION, REPO_URL } from '../../../data/constants'; import { CURRENT_VERSION, REPO_URL } from '../../../data/constants';
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
@@ -43,31 +35,26 @@ interface FooterCenteredProps {
} }
export function Footer({ links }: FooterCenteredProps) { export function Footer({ links }: FooterCenteredProps) {
const [update, setUpdate] = useState(false);
const theme = useMantineTheme();
const { classes } = useStyles();
const items = links.map((link) => (
<Anchor<'a'>
color="dimmed"
key={link.label}
href={link.link}
sx={{ lineHeight: 1 }}
onClick={(event) => event.preventDefault()}
size="sm"
>
{link.label}
</Anchor>
));
const [latestVersion, setLatestVersion] = useState(CURRENT_VERSION);
const [isOpen, setOpen] = useState(true);
useEffect(() => { useEffect(() => {
// Fetch Data here when component first mounted // Fetch Data here when component first mounted
fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => { fetch(`https://api.github.com/repos/${REPO_URL}/releases/latest`).then((res) => {
res.json().then((data) => { res.json().then((data) => {
setLatestVersion(data.tag_name); if (data.tag_name > CURRENT_VERSION) {
if (data.tag_name !== CURRENT_VERSION) { showNotification({
setUpdate(true); color: 'yellow',
autoClose: false,
title: 'New version available',
icon: <AlertCircle />,
message: `Version ${data.tag_name} is available, update now!`,
});
} else if (data.tag_name < CURRENT_VERSION) {
showNotification({
color: 'orange',
autoClose: 5000,
title: 'You are using a development version',
icon: <AlertCircle />,
message: 'This version of Homarr is still in development! Bugs are expected 🐛',
});
} }
}); });
}); });
@@ -75,72 +62,13 @@ export function Footer({ links }: FooterCenteredProps) {
return ( return (
<FooterComponent <FooterComponent
p={5}
height="auto" height="auto"
style={{ style={{
background: 'none', background: 'none',
border: 'none', border: 'none',
clear: 'both', clear: 'both',
position: 'fixed',
bottom: '0',
left: '0',
}} }}
> children={undefined}
<Group position="apart" direction="row" style={{ alignItems: 'end' }} mr="xs" mb="xs"> />
<Group position="left">
<Alert
// onClick open latest release page
onClose={() => setOpen(false)}
icon={<AlertCircle size={16} />}
title={`Updated version: ${latestVersion} is available. Current version: ${CURRENT_VERSION}`}
withCloseButton
radius="lg"
hidden={CURRENT_VERSION === latestVersion || !isOpen}
variant="outline"
styles={{
root: {
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[6] : 'white',
},
closeButton: {
marginLeft: '5px',
},
}}
children={undefined}
/>
</Group>
<Group position="right">
<Group spacing={0}>
<ActionIcon<'a'> component="a" href="https://github.com/ajnart/homarr" size="lg">
<BrandGithub size={18} />
</ActionIcon>
<Text
style={{
position: 'relative',
fontSize: '0.90rem',
color: 'gray',
}}
>
{CURRENT_VERSION}
</Text>
</Group>
<Text
style={{
fontSize: '0.90rem',
textAlign: 'center',
color: '#a0aec0',
}}
>
Made with by @
<Anchor
href="https://github.com/ajnart"
style={{ color: 'inherit', fontStyle: 'inherit', fontSize: 'inherit' }}
>
ajnart
</Anchor>
</Text>
</Group>
</Group>
</FooterComponent>
); );
} }

View File

@@ -1,9 +1,29 @@
import React from 'react'; import {
import { createStyles, Header as Head, Group, Box } from '@mantine/core'; ActionIcon,
import { Logo } from './Logo'; Box,
import SearchBar from '../modules/search/SearchModule'; Burger,
createStyles,
Drawer,
Group,
Header as Head,
ScrollArea,
Title,
Transition,
} from '@mantine/core';
import { useBooleanToggle } from '@mantine/hooks';
import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem'; import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem';
import {
CalendarModule,
DateModule,
TotalDownloadsModule,
WeatherModule,
DashdotModule,
} from '../modules';
import { ModuleWrapper } from '../modules/moduleWrapper';
import DockerDrawer from '../Docker/DockerDrawer';
import SearchBar from '../modules/search/SearchModule';
import { SettingsMenuButton } from '../Settings/SettingsMenu'; import { SettingsMenuButton } from '../Settings/SettingsMenu';
import { Logo } from './Logo';
const HEADER_HEIGHT = 60; const HEADER_HEIGHT = 60;
@@ -13,21 +33,71 @@ const useStyles = createStyles((theme) => ({
display: 'none', display: 'none',
}, },
}, },
burger: {
[theme.fn.largerThan('sm')]: {
display: 'none',
},
},
})); }));
export function Header(props: any) { export function Header(props: any) {
const [opened, toggleOpened] = useBooleanToggle(false);
const { classes, cx } = useStyles(); const { classes, cx } = useStyles();
const [hidden, toggleHidden] = useBooleanToggle(true);
return ( return (
<Head height="auto"> <Head height="auto">
<Group m="xs" position="apart"> <Group p="xs" position="apart">
<Box className={classes.hide}> <Box className={classes.hide}>
<Logo style={{ fontSize: 22 }} /> <Logo style={{ fontSize: 22 }} />
</Box> </Box>
<Group noWrap> <Group noWrap>
<SearchBar /> <SearchBar />
<DockerDrawer />
<SettingsMenuButton /> <SettingsMenuButton />
<AddItemShelfButton /> <AddItemShelfButton />
<ActionIcon className={classes.burger} variant="default" radius="md" size="xl">
<Burger
opened={!hidden}
onClick={(_) => {
toggleHidden();
toggleOpened();
}}
/>
</ActionIcon>
<Drawer
size="auto"
padding="xl"
position="right"
hidden={hidden}
title={<Title order={3}>Modules</Title>}
opened
onClose={() => {
toggleHidden();
}}
>
<Transition
mounted={opened}
transition="pop-top-right"
duration={300}
timingFunction="ease"
onExit={() => toggleOpened()}
>
{(styles) => (
<div style={styles}>
<ScrollArea offsetScrollbars style={{ height: '90vh' }}>
<Group my="sm" grow direction="column" style={{ width: 300 }}>
<ModuleWrapper module={CalendarModule} />
<ModuleWrapper module={TotalDownloadsModule} />
<ModuleWrapper module={WeatherModule} />
<ModuleWrapper module={DateModule} />
<ModuleWrapper module={DashdotModule} />
</Group>
</ScrollArea>
</div>
)}
</Transition>
</Drawer>
</Group> </Group>
</Group> </Group>
</Head> </Head>

View File

@@ -0,0 +1,14 @@
import React from 'react';
import Head from 'next/head';
import { useConfig } from '../../tools/state';
export function HeaderConfig(props: any) {
const { config } = useConfig();
return (
<Head>
<title>{config.settings.title || 'Homarr 🦞'}</title>
<link rel="shortcut icon" href={config.settings.favicon || '/favicon.svg'} />
</Head>
);
}

View File

@@ -2,6 +2,10 @@ import { AppShell, createStyles } from '@mantine/core';
import { Header } from './Header'; import { Header } from './Header';
import { Footer } from './Footer'; import { Footer } from './Footer';
import Aside from './Aside'; import Aside from './Aside';
import Navbar from './Navbar';
import { HeaderConfig } from './HeaderConfig';
import { Background } from './Background';
import { useConfig } from '../../tools/state';
const useStyles = createStyles((theme) => ({ const useStyles = createStyles((theme) => ({
main: {}, main: {},
@@ -9,8 +13,18 @@ const useStyles = createStyles((theme) => ({
export default function Layout({ children, style }: any) { export default function Layout({ children, style }: any) {
const { classes, cx } = useStyles(); const { classes, cx } = useStyles();
const { config } = useConfig();
const widgetPosition = config?.settings?.widgetPosition === 'left';
return ( return (
<AppShell aside={<Aside />} header={<Header />} footer={<Footer links={[]} />}> <AppShell
header={<Header />}
navbar={widgetPosition ? <Navbar /> : <></>}
aside={widgetPosition ? <></> : <Aside />}
footer={<Footer links={[]} />}
>
<HeaderConfig />
<Background />
<main <main
className={cx(classes.main)} className={cx(classes.main)}
style={{ style={{

View File

@@ -1,24 +1,42 @@
import { Group, Image, Text } from '@mantine/core'; import { Group, Image, Text } from '@mantine/core';
import { NextLink } from '@mantine/next';
import * as React from 'react'; import * as React from 'react';
import { useColorTheme } from '../../tools/color';
import { useConfig } from '../../tools/state';
export function Logo({ style }: any) { export function Logo({ style }: any) {
const { config } = useConfig();
const { primaryColor, secondaryColor } = useColorTheme();
return ( return (
<Group spacing="xs"> <Group spacing="xs">
<Image <Image
width={50} width={50}
src="/imgs/logo.png" src={config.settings.logo || '/imgs/logo.png'}
style={{ style={{
position: 'relative', position: 'relative',
}} }}
/> />
<Text <NextLink
sx={style} href="/"
weight="bold" style={{
variant="gradient" textDecoration: 'none',
gradient={{ from: 'red', to: 'orange', deg: 145 }} position: 'relative',
}}
> >
Homarr <Text
</Text> sx={style}
weight="bold"
variant="gradient"
gradient={{
from: primaryColor,
to: secondaryColor,
deg: 145,
}}
>
{config.settings.title || 'Homarr'}
</Text>
</NextLink>
</Group> </Group>
); );
} }

View File

@@ -1,24 +1,37 @@
import { Group, Navbar as MantineNavbar } from '@mantine/core'; import { createStyles, Navbar as MantineNavbar } from '@mantine/core';
import { WeatherModule, DateModule } from '../modules'; import Widgets from './Widgets';
import { ModuleWrapper } from '../modules/moduleWrapper';
const useStyles = createStyles((theme) => ({
hide: {
[theme.fn.smallerThan('xs')]: {
display: 'none',
},
},
burger: {
[theme.fn.largerThan('sm')]: {
display: 'none',
},
},
}));
export default function Navbar() { export default function Navbar() {
const { classes, cx } = useStyles();
return ( return (
<MantineNavbar <MantineNavbar
hiddenBreakpoint="lg" pl="md"
hiddenBreakpoint="sm"
hidden hidden
className={cx(classes.hide)}
style={{ style={{
border: 'none', border: 'none',
background: 'none',
}} }}
width={{ width={{
base: 'auto', base: 'auto',
}} }}
> >
<Group mt="sm" direction="column" align="center"> <Widgets />
<ModuleWrapper module={DateModule} />
<ModuleWrapper module={WeatherModule} />
<ModuleWrapper module={WeatherModule} />
</Group>
</MantineNavbar> </MantineNavbar>
); );
} }

View File

@@ -0,0 +1,19 @@
import { Text } from '@mantine/core';
interface TipProps {
children: React.ReactNode;
}
export default function Tip(props: TipProps) {
return (
<Text
style={{
fontSize: '0.75rem',
color: 'gray',
marginBottom: '0.5rem',
}}
>
Tip: {props.children}
</Text>
);
}

View File

@@ -0,0 +1,23 @@
import { Group } from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';
import { CalendarModule, DateModule, TotalDownloadsModule, WeatherModule } from '../modules';
import { DashdotModule } from '../modules/dash.';
import { ModuleWrapper } from '../modules/moduleWrapper';
export default function Widgets(props: any) {
const matches = useMediaQuery('(min-width: 800px)');
return (
<>
{matches && (
<Group my="sm" grow direction="column" style={{ width: 300 }}>
<ModuleWrapper module={CalendarModule} />
<ModuleWrapper module={TotalDownloadsModule} />
<ModuleWrapper module={WeatherModule} />
<ModuleWrapper module={DateModule} />
<ModuleWrapper module={DashdotModule} />
</Group>
)}
</>
);
}

View File

@@ -1,12 +1,27 @@
/* eslint-disable react/no-children-prop */ /* eslint-disable react/no-children-prop */
import { Popover, Box, ScrollArea, Divider, Indicator, useMantineTheme } from '@mantine/core'; import {
Box,
Divider,
Indicator,
Popover,
ScrollArea,
createStyles,
useMantineTheme,
} from '@mantine/core';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Calendar } from '@mantine/dates'; import { Calendar } from '@mantine/dates';
import { showNotification } from '@mantine/notifications'; import { IconCalendar as CalendarIcon } from '@tabler/icons';
import { Calendar as CalendarIcon, Check } from 'tabler-icons-react'; import axios from 'axios';
import { RadarrMediaDisplay, SonarrMediaDisplay } from './MediaDisplay';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { IModule } from '../modules'; import { IModule } from '../modules';
import {
SonarrMediaDisplay,
RadarrMediaDisplay,
LidarrMediaDisplay,
ReadarrMediaDisplay,
} from '../common';
import { serviceItem } from '../../../tools/types';
import { useColorTheme } from '../../../tools/color';
export const CalendarModule: IModule = { export const CalendarModule: IModule = {
title: 'Calendar', title: 'Calendar',
@@ -14,72 +29,132 @@ export const CalendarModule: IModule = {
'A calendar module for displaying upcoming releases. It interacts with the Sonarr and Radarr API.', 'A calendar module for displaying upcoming releases. It interacts with the Sonarr and Radarr API.',
icon: CalendarIcon, icon: CalendarIcon,
component: CalendarComponent, component: CalendarComponent,
options: {
sundaystart: {
name: 'Start the week on Sunday',
value: false,
},
},
}; };
export default function CalendarComponent(props: any) { export default function CalendarComponent(props: any) {
const { config } = useConfig(); const { config } = useConfig();
const theme = useMantineTheme();
const { secondaryColor } = useColorTheme();
const useStyles = createStyles((theme) => ({
weekend: {
color: `${secondaryColor} !important`,
},
}));
const [sonarrMedias, setSonarrMedias] = useState([] as any); const [sonarrMedias, setSonarrMedias] = useState([] as any);
const [lidarrMedias, setLidarrMedias] = useState([] as any);
const [radarrMedias, setRadarrMedias] = useState([] as any); const [radarrMedias, setRadarrMedias] = useState([] as any);
const [readarrMedias, setReadarrMedias] = useState([] as any);
const sonarrServices = config.services.filter((service) => service.type === 'Sonarr');
const radarrServices = config.services.filter((service) => service.type === 'Radarr');
const lidarrServices = config.services.filter((service) => service.type === 'Lidarr');
const readarrServices = config.services.filter((service) => service.type === 'Readarr');
const today = new Date();
const { classes, cx } = useStyles();
function getMedias(service: serviceItem | undefined, type: string) {
if (!service || !service.apiKey) {
return Promise.resolve({ data: [] });
}
return axios.post(`/api/modules/calendar?type=${type}`, { ...service });
}
useEffect(() => { useEffect(() => {
// Filter only sonarr and radarr services // Create each Sonarr service and get the medias
const filtered = config.services.filter( const currentSonarrMedias: any[] = [];
(service) => service.type === 'Sonarr' || service.type === 'Radarr' Promise.all(
); sonarrServices.map((service) =>
getMedias(service, 'sonarr')
// Get the url and apiKey for all Sonarr and Radarr services .then((res) => {
const sonarrService = filtered.filter((service) => service.type === 'Sonarr').at(0); currentSonarrMedias.push(...res.data);
const radarrService = filtered.filter((service) => service.type === 'Radarr').at(0); })
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString(); .catch(() => {
if (sonarrService && sonarrService.apiKey) { currentSonarrMedias.push([]);
fetch( })
`${sonarrService?.url}api/calendar?apikey=${sonarrService?.apiKey}&end=${nextMonth}` )
).then((response) => { ).then(() => {
response.ok && setSonarrMedias(currentSonarrMedias);
response.json().then((data) => { });
setSonarrMedias(data); const currentRadarrMedias: any[] = [];
showNotification({ Promise.all(
title: 'Sonarr', radarrServices.map((service) =>
icon: <Check />, getMedias(service, 'radarr')
color: 'green', .then((res) => {
autoClose: 1500, currentRadarrMedias.push(...res.data);
radius: 'md', })
message: `Loaded ${data.length} releases`, .catch(() => {
}); currentRadarrMedias.push([]);
}); })
}); )
} ).then(() => {
if (radarrService && radarrService.apiKey) { setRadarrMedias(currentRadarrMedias);
fetch( });
`${radarrService?.url}api/v3/calendar?apikey=${radarrService?.apiKey}&end=${nextMonth}` const currentLidarrMedias: any[] = [];
).then((response) => { Promise.all(
response.ok && lidarrServices.map((service) =>
response.json().then((data) => { getMedias(service, 'lidarr')
setRadarrMedias(data); .then((res) => {
showNotification({ currentLidarrMedias.push(...res.data);
title: 'Radarr', })
icon: <Check />, .catch(() => {
color: 'green', currentLidarrMedias.push([]);
autoClose: 1500, })
radius: 'md', )
message: `Loaded ${data.length} releases`, ).then(() => {
}); setLidarrMedias(currentLidarrMedias);
}); });
}); const currentReadarrMedias: any[] = [];
} Promise.all(
readarrServices.map((service) =>
getMedias(service, 'readarr')
.then((res) => {
currentReadarrMedias.push(...res.data);
})
.catch(() => {
currentReadarrMedias.push([]);
})
)
).then(() => {
setReadarrMedias(currentReadarrMedias);
});
}, [config.services]); }, [config.services]);
if (sonarrMedias === undefined && radarrMedias === undefined) { const weekStartsAtSunday =
return <Calendar />; (config?.modules?.[CalendarModule.title]?.options?.sundaystart?.value as boolean) ?? false;
}
return ( return (
<Calendar <Calendar
firstDayOfWeek={weekStartsAtSunday ? 'sunday' : 'monday'}
onChange={(day: any) => {}} onChange={(day: any) => {}}
dayStyle={(date) =>
date.getDay() === today.getDay() && date.getDate() === today.getDate()
? {
backgroundColor:
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[0],
}
: {}
}
styles={{
calendarHeader: {
marginRight: 15,
marginLeft: 15,
},
}}
allowLevelChange={false}
dayClassName={(date, modifiers) => cx({ [classes.weekend]: modifiers.weekend })}
renderDay={(renderdate) => ( renderDay={(renderdate) => (
<DayComponent <DayComponent
renderdate={renderdate} renderdate={renderdate}
sonarrmedias={sonarrMedias} sonarrmedias={sonarrMedias}
radarrmedias={radarrMedias} radarrmedias={radarrMedias}
lidarrmedias={lidarrMedias}
readarrmedias={readarrMedias}
/> />
)} )}
/> />
@@ -91,23 +166,37 @@ function DayComponent(props: any) {
renderdate, renderdate,
sonarrmedias, sonarrmedias,
radarrmedias, radarrmedias,
}: { renderdate: Date; sonarrmedias: []; radarrmedias: [] } = props; lidarrmedias,
readarrmedias,
}: { renderdate: Date; sonarrmedias: []; radarrmedias: []; lidarrmedias: []; readarrmedias: [] } =
props;
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
const theme = useMantineTheme();
const day = renderdate.getDate(); const day = renderdate.getDate();
// Itterate over the medias and filter the ones that are on the same day
const readarrFiltered = readarrmedias.filter((media: any) => {
const date = new Date(media.releaseDate);
return date.toDateString() === renderdate.toDateString();
});
const lidarrFiltered = lidarrmedias.filter((media: any) => {
const date = new Date(media.releaseDate);
return date.toDateString() === renderdate.toDateString();
});
const sonarrFiltered = sonarrmedias.filter((media: any) => { const sonarrFiltered = sonarrmedias.filter((media: any) => {
const date = new Date(media.airDate); const date = new Date(media.airDateUtc);
// Return true if the date is renerdate without counting hours and minutes return date.toDateString() === renderdate.toDateString();
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
}); });
const radarrFiltered = radarrmedias.filter((media: any) => { const radarrFiltered = radarrmedias.filter((media: any) => {
const date = new Date(media.inCinemas); const date = new Date(media.inCinemas);
// Return true if the date is renerdate without counting hours and minutes return date.toDateString() === renderdate.toDateString();
return date.getDate() === day && date.getMonth() === renderdate.getMonth();
}); });
if (sonarrFiltered.length === 0 && radarrFiltered.length === 0) { if (
sonarrFiltered.length === 0 &&
radarrFiltered.length === 0 &&
lidarrFiltered.length === 0 &&
readarrFiltered.length === 0
) {
return <div>{day}</div>; return <div>{day}</div>;
} }
@@ -117,14 +206,69 @@ function DayComponent(props: any) {
setOpened(true); setOpened(true);
}} }}
> >
{radarrFiltered.length > 0 && <Indicator size={7} color="yellow" children={null} />} {readarrFiltered.length > 0 && (
{sonarrFiltered.length > 0 && <Indicator size={7} offset={8} color="blue" children={null} />} <Indicator
size={10}
withBorder
style={{
position: 'absolute',
bottom: 8,
left: 8,
}}
color="red"
children={null}
/>
)}
{radarrFiltered.length > 0 && (
<Indicator
size={10}
withBorder
style={{
position: 'absolute',
top: 8,
left: 8,
}}
color="yellow"
children={null}
/>
)}
{sonarrFiltered.length > 0 && (
<Indicator
size={10}
withBorder
style={{
position: 'absolute',
top: 8,
right: 8,
}}
color="blue"
children={null}
/>
)}
{lidarrFiltered.length > 0 && (
<Indicator
size={10}
withBorder
style={{
position: 'absolute',
bottom: 8,
right: 8,
}}
color="green"
children={undefined}
/>
)}
<Popover <Popover
position="left" position="bottom"
radius="lg" radius="lg"
shadow="xl" shadow="xl"
transition="pop" transition="pop"
width={700} styles={{
body: {
boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.1), 0 14px 11px rgba(0, 0, 0, 0.1)',
},
}}
width="auto"
onClose={() => setOpened(false)} onClose={() => setOpened(false)}
opened={opened} opened={opened}
target={day} target={day}
@@ -145,6 +289,24 @@ function DayComponent(props: any) {
{index < radarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />} {index < radarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
</React.Fragment> </React.Fragment>
))} ))}
{sonarrFiltered.length > 0 && lidarrFiltered.length > 0 && (
<Divider variant="dashed" my="xl" />
)}
{lidarrFiltered.map((media: any, index: number) => (
<React.Fragment key={index}>
<LidarrMediaDisplay media={media} />
{index < lidarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
</React.Fragment>
))}
{lidarrFiltered.length > 0 && readarrFiltered.length > 0 && (
<Divider variant="dashed" my="xl" />
)}
{readarrFiltered.map((media: any, index: number) => (
<React.Fragment key={index}>
<ReadarrMediaDisplay media={media} />
{index < readarrFiltered.length - 1 && <Divider variant="dashed" my="xl" />}
</React.Fragment>
))}
</ScrollArea> </ScrollArea>
</Popover> </Popover>
</Box> </Box>

View File

@@ -1,100 +0,0 @@
import { Stack, Image, Group, Title, Badge, Text, ActionIcon, Anchor } from '@mantine/core';
import { Link } from 'tabler-icons-react';
export interface IMedia {
overview: string;
imdbId: any;
title: string;
poster: string;
genres: string[];
seasonNumber?: number;
episodeNumber?: number;
}
function MediaDisplay(props: { media: IMedia }) {
const { media }: { media: IMedia } = props;
return (
<Group noWrap align="self-start" mr={15}>
<Image
radius="md"
fit="cover"
src={media.poster}
alt={media.title}
width={300}
height={400}
/>
<Stack
justify="space-between"
sx={(theme) => ({
height: 400,
})}
>
<Group direction="column">
<Group>
<Title order={3}>{media.title}</Title>
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
<ActionIcon>
<Link />
</ActionIcon>
</Anchor>
</Group>
{media.episodeNumber && media.seasonNumber && (
<Text
style={{
textAlign: 'center',
color: '#a0aec0',
}}
>
Season {media.seasonNumber} episode {media.episodeNumber}
</Text>
)}
<Text align="justify">{media.overview}</Text>
</Group>
{/*Add the genres at the bottom of the poster*/}
<Group>
{media.genres.map((genre: string, i: number) => (
<Badge key={i}>{genre}</Badge>
))}
</Group>
</Stack>
</Group>
);
}
export function RadarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
// Find a poster CoverType
const poster = media.images.find((image: any) => image.coverType === 'poster');
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
imdbId: media.imdbId,
title: media.title,
overview: media.overview,
poster: poster.url,
genres: media.genres,
}}
/>
);
}
export function SonarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
// Find a poster CoverType
const poster = media.series.images.find((image: any) => image.coverType === 'poster');
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
imdbId: media.series.imdbId,
title: media.series.title,
overview: media.series.overview,
poster: poster.url,
genres: media.series.genres,
seasonNumber: media.seasonNumber,
episodeNumber: media.episodeNumber,
}}
/>
);
}

View File

@@ -0,0 +1,193 @@
import {
Image,
Group,
Title,
Badge,
Text,
ActionIcon,
Anchor,
ScrollArea,
createStyles,
} from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';
import { IconLink as Link } from '@tabler/icons';
import { useConfig } from '../../../tools/state';
import { serviceItem } from '../../../tools/types';
export interface IMedia {
overview: string;
imdbId?: any;
artist?: string;
title: string;
poster?: string;
genres: string[];
seasonNumber?: number;
episodeNumber?: number;
}
const useStyles = createStyles((theme) => ({
overview: {
[theme.fn.largerThan('sm')]: {
width: 400,
},
},
}));
export function MediaDisplay(props: { media: IMedia }) {
const { media }: { media: IMedia } = props;
const { classes, cx } = useStyles();
const phone = useMediaQuery('(min-width: 800px)');
return (
<Group position="apart">
<Text>
{media.poster && (
<Image
width={phone ? 250 : 100}
height={phone ? 400 : 160}
style={{
float: 'right',
}}
radius="md"
fit="cover"
src={media.poster}
alt={media.title}
/>
)}
<Group direction="column" style={{ minWidth: phone ? 450 : '65vw' }}>
<Group noWrap mr="sm" className={classes.overview}>
<Title order={3}>{media.title}</Title>
{media.imdbId && (
<Anchor href={`https://www.imdb.com/title/${media.imdbId}`} target="_blank">
<ActionIcon>
<Link />
</ActionIcon>
</Anchor>
)}
</Group>
{media.artist && (
<Text
style={{
textAlign: 'center',
color: 'gray',
}}
>
New release from {media.artist}
</Text>
)}
{media.episodeNumber && media.seasonNumber && (
<Text
style={{
textAlign: 'center',
color: 'gray',
}}
>
Season {media.seasonNumber} episode {media.episodeNumber}
</Text>
)}
</Group>
<Group direction="column" position="apart">
<ScrollArea style={{ height: 280, maxWidth: 700 }}>{media.overview}</ScrollArea>
<Group align="center" position="center" spacing="xs">
{media.genres.slice(-5).map((genre: string, i: number) => (
<Badge size="sm" key={i}>
{genre}
</Badge>
))}
</Group>
</Group>
</Text>
</Group>
);
}
export function ReadarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
const { config } = useConfig();
// Find lidarr in services
const readarr = config.services.find((service: serviceItem) => service.type === 'Readarr');
// Find a poster CoverType
const poster = media.images.find((image: any) => image.coverType === 'cover');
if (!readarr) {
return null;
}
const baseUrl = new URL(readarr.url).origin;
// Remove '/' from the end of the lidarr url
const fullLink = `${baseUrl}${poster.url}`;
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
title: media.title,
poster: fullLink,
artist: media.author.authorName,
overview: media.overview,
genres: media.genres,
}}
/>
);
}
export function LidarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
const { config } = useConfig();
// Find lidarr in services
const lidarr = config.services.find((service: serviceItem) => service.type === 'Lidarr');
// Find a poster CoverType
const poster = media.images.find((image: any) => image.coverType === 'cover');
if (!lidarr) {
return null;
}
const baseUrl = new URL(lidarr.url).origin;
// Remove '/' from the end of the lidarr url
const fullLink = poster ? `${baseUrl}${poster.url}` : undefined;
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
title: media.title,
poster: fullLink,
artist: media.artist.artistName,
overview: media.overview,
genres: media.genres,
}}
/>
);
}
export function RadarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
// Find a poster CoverType
const poster = media.images.find((image: any) => image.coverType === 'poster');
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
imdbId: media.imdbId,
title: media.title,
overview: media.overview,
poster: poster.url,
genres: media.genres,
}}
/>
);
}
export function SonarrMediaDisplay(props: any) {
const { media }: { media: any } = props;
// Find a poster CoverType
const poster = media.series.images.find((image: any) => image.coverType === 'poster');
// Return a movie poster containting the title and the description
return (
<MediaDisplay
media={{
imdbId: media.series.imdbId,
title: media.series.title,
overview: media.series.overview,
poster: poster.url,
genres: media.series.genres,
seasonNumber: media.seasonNumber,
episodeNumber: media.episodeNumber,
}}
/>
);
}

View File

@@ -0,0 +1 @@
export * from './MediaDisplay';

View File

@@ -0,0 +1,233 @@
import { createStyles, useMantineColorScheme, useMantineTheme } from '@mantine/core';
import { IconCalendar as CalendarIcon } from '@tabler/icons';
import axios from 'axios';
import { useEffect, useState } from 'react';
import { useConfig } from '../../../tools/state';
import { serviceItem } from '../../../tools/types';
import { IModule } from '../modules';
const asModule = <T extends IModule>(t: T) => t;
export const DashdotModule = asModule({
title: 'Dash.',
description: 'A module for displaying the graphs of your running Dash. instance.',
icon: CalendarIcon,
component: DashdotComponent,
options: {
cpuMultiView: {
name: 'CPU Multi-Core View',
value: false,
},
storageMultiView: {
name: 'Storage Multi-Drive View',
value: false,
},
useCompactView: {
name: 'Use Compact View',
value: false,
},
graphs: {
name: 'Graphs',
value: ['CPU', 'RAM', 'Storage', 'Network'],
options: ['CPU', 'RAM', 'Storage', 'Network', 'GPU'],
},
},
});
const useStyles = createStyles((theme, _params) => ({
heading: {
marginTop: 0,
marginBottom: 10,
},
table: {
display: 'table',
},
tableRow: {
display: 'table-row',
},
tableLabel: {
display: 'table-cell',
paddingRight: 10,
},
tableValue: {
display: 'table-cell',
whiteSpace: 'pre-wrap',
paddingBottom: 5,
},
graphsContainer: {
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
rowGap: 10,
columnGap: 10,
},
iframe: {
flex: '1 0 auto',
maxWidth: '100%',
height: '140px',
borderRadius: theme.radius.lg,
},
}));
const bpsPrettyPrint = (bits?: number) =>
!bits
? '-'
: bits > 1000 * 1000 * 1000
? `${(bits / 1000 / 1000 / 1000).toFixed(1)} Gb/s`
: bits > 1000 * 1000
? `${(bits / 1000 / 1000).toFixed(1)} Mb/s`
: bits > 1000
? `${(bits / 1000).toFixed(1)} Kb/s`
: `${bits.toFixed(1)} b/s`;
const bytePrettyPrint = (byte: number): string =>
byte > 1024 * 1024 * 1024
? `${(byte / 1024 / 1024 / 1024).toFixed(1)} GiB`
: byte > 1024 * 1024
? `${(byte / 1024 / 1024).toFixed(1)} MiB`
: byte > 1024
? `${(byte / 1024).toFixed(1)} KiB`
: `${byte.toFixed(1)} B`;
const useJson = (service: serviceItem | undefined, url: string) => {
const [data, setData] = useState<any | undefined>();
const doRequest = async () => {
try {
const resp = await axios.get(url, { baseURL: service?.url });
setData(resp.data);
// eslint-disable-next-line no-empty
} catch (e) {}
};
useEffect(() => {
if (service?.url) {
doRequest();
}
}, [service?.url]);
return data;
};
export function DashdotComponent() {
const { config } = useConfig();
const theme = useMantineTheme();
const { classes } = useStyles();
const { colorScheme } = useMantineColorScheme();
const dashConfig = config.modules?.[DashdotModule.title]
.options as typeof DashdotModule['options'];
const isCompact = dashConfig?.useCompactView?.value ?? false;
const dashdotService = config.services.filter((service) => service.type === 'Dash.')[0];
const enabledGraphs = dashConfig?.graphs?.value ?? ['CPU', 'RAM', 'Storage', 'Network'];
const cpuEnabled = enabledGraphs.includes('CPU');
const storageEnabled = enabledGraphs.includes('Storage');
const ramEnabled = enabledGraphs.includes('RAM');
const networkEnabled = enabledGraphs.includes('Network');
const gpuEnabled = enabledGraphs.includes('GPU');
const info = useJson(dashdotService, '/info');
const storageLoad = useJson(dashdotService, '/load/storage');
const totalUsed =
(storageLoad?.layout as any[])?.reduce((acc, curr) => (curr.load ?? 0) + acc, 0) ?? 0;
const totalSize =
(info?.storage?.layout as any[])?.reduce((acc, curr) => (curr.size ?? 0) + acc, 0) ?? 0;
const graphs = [
{
name: 'CPU',
enabled: cpuEnabled,
params: {
multiView: dashConfig?.cpuMultiView?.value ?? false,
},
},
{
name: 'Storage',
enabled: storageEnabled && !isCompact,
params: {
multiView: dashConfig?.storageMultiView?.value ?? false,
},
},
{
name: 'RAM',
enabled: ramEnabled,
},
{
name: 'Network',
enabled: networkEnabled,
spanTwo: true,
},
{
name: 'GPU',
enabled: gpuEnabled,
spanTwo: true,
},
].filter((g) => g.enabled);
return (
<div>
<h2 className={classes.heading}>Dash.</h2>
{!dashdotService ? (
<p>No dash. service found. Please add one to your Homarr dashboard.</p>
) : !info ? (
<p>Cannot acquire information from dash. - are you running the latest version?</p>
) : (
<div className={classes.graphsContainer}>
<div className={classes.table}>
{storageEnabled && isCompact && (
<div className={classes.tableRow}>
<p className={classes.tableLabel}>Storage:</p>
<p className={classes.tableValue}>
{(totalUsed / (totalSize || 1)).toFixed(1)}%{'\n'}
{bytePrettyPrint(totalUsed)} / {bytePrettyPrint(totalSize)}
</p>
</div>
)}
{networkEnabled && (
<div className={classes.tableRow}>
<p className={classes.tableLabel}>Network:</p>
<p className={classes.tableValue}>
{bpsPrettyPrint(info?.network?.speedUp)} Up{'\n'}
{bpsPrettyPrint(info?.network?.speedDown)} Down
</p>
</div>
)}
</div>
{graphs.map((graph) => (
<iframe
className={classes.iframe}
style={
isCompact
? {
width: graph.spanTwo ? '100%' : 'calc(50% - 5px)',
}
: undefined
}
key={graph.name}
title={graph.name}
src={`${
dashdotService.url
}?singleGraphMode=true&graph=${graph.name.toLowerCase()}&theme=${colorScheme}&surface=${(colorScheme ===
'dark'
? theme.colors.dark[7]
: theme.colors.gray[0]
).substring(1)}${isCompact ? '&gap=10' : '&gap=5'}&innerRadius=${theme.radius.lg}${
graph.params
? `&${Object.entries(graph.params)
.map(([key, value]) => `${key}=${value.toString()}`)
.join('&')}`
: ''
}`}
frameBorder="0"
allowTransparency
/>
))}
</div>
)}
</div>
);
}

View File

@@ -0,0 +1 @@
export { DashdotModule } from './DashdotModule';

View File

@@ -1,9 +1,10 @@
import { Group, Text, Title } from '@mantine/core'; import { Group, Text, Title } from '@mantine/core';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Clock } from 'tabler-icons-react'; import { IconClock as Clock } from '@tabler/icons';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { IModule } from '../modules'; import { IModule } from '../modules';
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
export const DateModule: IModule = { export const DateModule: IModule = {
title: 'Date', title: 'Date',
@@ -20,24 +21,20 @@ export const DateModule: IModule = {
export default function DateComponent(props: any) { export default function DateComponent(props: any) {
const [date, setDate] = useState(new Date()); const [date, setDate] = useState(new Date());
const setSafeInterval = useSetSafeInterval();
const { config } = useConfig(); const { config } = useConfig();
const hours = date.getHours(); const isFullTime = config?.modules?.[DateModule.title]?.options?.full?.value ?? true;
const minutes = date.getMinutes(); const formatString = isFullTime ? 'HH:mm' : 'h:mm A';
const isFullTime =
config.settings[`${DateModule.title}.full`] === undefined
? true
: config.settings[`${DateModule.title}.full`];
const formatString = isFullTime ? 'HH:mm' : 'h:mm a';
// Change date on minute change // Change date on minute change
// Note: Using 10 000ms instead of 1000ms to chill a little :) // Note: Using 10 000ms instead of 1000ms to chill a little :)
useEffect(() => { useEffect(() => {
setInterval(() => { setSafeInterval(() => {
setDate(new Date()); setDate(new Date());
}, 1000 * 60); }, 1000 * 60);
}, []); }, []);
return ( return (
<Group p="sm" direction="column"> <Group p="sm" spacing="xs" direction="column">
<Title>{dayjs(date).format(formatString)}</Title> <Title>{dayjs(date).format(formatString)}</Title>
<Text size="xl">{dayjs(date).format('dddd, MMMM D')}</Text> <Text size="xl">{dayjs(date).format('dddd, MMMM D')}</Text>
</Group> </Group>

View File

@@ -0,0 +1,190 @@
import {
Table,
Text,
Tooltip,
Title,
Group,
Progress,
Skeleton,
ScrollArea,
Center,
Image,
} from '@mantine/core';
import { IconDownload as Download } from '@tabler/icons';
import { useEffect, useState } from 'react';
import axios from 'axios';
import { NormalizedTorrent } from '@ctrl/shared-torrent';
import { useViewportSize } from '@mantine/hooks';
import { IModule } from '../modules';
import { useConfig } from '../../../tools/state';
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
import { humanFileSize } from '../../../tools/humanFileSize';
export const DownloadsModule: IModule = {
title: 'Torrent',
description: 'Show the current download speed of supported services',
icon: Download,
component: DownloadComponent,
options: {
hidecomplete: {
name: 'Hide completed torrents',
value: false,
},
},
};
export default function DownloadComponent() {
const { config } = useConfig();
const { height, width } = useViewportSize();
const downloadServices =
config.services.filter(
(service) =>
service.type === 'qBittorrent' ||
service.type === 'Transmission' ||
service.type === 'Deluge'
) ?? [];
const hideComplete: boolean =
(config?.modules?.[DownloadsModule.title]?.options?.hidecomplete?.value as boolean) ?? false;
const [torrents, setTorrents] = useState<NormalizedTorrent[]>([]);
const setSafeInterval = useSetSafeInterval();
const [isLoading, setIsLoading] = useState(true);
useEffect(() => {
setIsLoading(true);
if (downloadServices.length === 0) return;
setSafeInterval(() => {
// Send one request with each download service inside
axios.post('/api/modules/downloads', { config }).then((response) => {
setTorrents(response.data);
setIsLoading(false);
});
}, 5000);
}, []);
if (downloadServices.length === 0) {
return (
<Group direction="column">
<Title order={3}>No supported download clients found!</Title>
<Group>
<Text>Add a download service to view your current downloads...</Text>
<AddItemShelfButton />
</Group>
</Group>
);
}
if (isLoading) {
return (
<>
<Skeleton height={40} mt={10} />
<Skeleton height={40} mt={10} />
<Skeleton height={40} mt={10} />
<Skeleton height={40} mt={10} />
<Skeleton height={40} mt={10} />
</>
);
}
const DEVICE_WIDTH = 576;
const ths = (
<tr>
<th>Name</th>
<th>Size</th>
{width > 576 ? <th>Down</th> : ''}
{width > 576 ? <th>Up</th> : ''}
<th>ETA</th>
<th>Progress</th>
</tr>
);
// Convert Seconds to readable format.
function calculateETA(givenSeconds: number) {
// If its superior than one day return > 1 day
if (givenSeconds > 86400) {
return '> 1 day';
}
// Transform the givenSeconds into a readable format. e.g. 1h 2m 3s
const hours = Math.floor(givenSeconds / 3600);
const minutes = Math.floor((givenSeconds % 3600) / 60);
const seconds = Math.floor(givenSeconds % 60);
// Only show hours if it's greater than 0.
const hoursString = hours > 0 ? `${hours}h ` : '';
const minutesString = minutes > 0 ? `${minutes}m ` : '';
const secondsString = seconds > 0 ? `${seconds}s` : '';
return `${hoursString}${minutesString}${secondsString}`;
}
// Loop over qBittorrent torrents merging with deluge torrents
const rows = torrents
.filter((torrent) => !(torrent.progress === 1 && hideComplete))
.map((torrent) => {
const downloadSpeed = torrent.downloadSpeed / 1024 / 1024;
const uploadSpeed = torrent.uploadSpeed / 1024 / 1024;
const size = torrent.totalSelected;
return (
<tr key={torrent.id}>
<td>
<Tooltip position="top" label={torrent.name}>
<Text
style={{
maxWidth: '30vw',
}}
size="xs"
lineClamp={1}
>
{torrent.name}
</Text>
</Tooltip>
</td>
<td>
<Text size="xs">{humanFileSize(size)}</Text>
</td>
{width > 576 ? (
<td>
<Text size="xs">{downloadSpeed > 0 ? `${downloadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
</td>
) : (
''
)}
{width > 576 ? (
<td>
<Text size="xs">{uploadSpeed > 0 ? `${uploadSpeed.toFixed(1)} Mb/s` : '-'}</Text>
</td>
) : (
''
)}
<td>
<Text size="xs">{torrent.eta <= 0 ? '∞' : calculateETA(torrent.eta)}</Text>
</td>
<td>
<Text>{(torrent.progress * 100).toFixed(1)}%</Text>
<Progress
radius="lg"
color={
torrent.progress === 1 ? 'green' : torrent.state === 'paused' ? 'yellow' : 'blue'
}
value={torrent.progress * 100}
size="lg"
/>
</td>
</tr>
);
});
const easteregg = (
<Center style={{ display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Image fit="cover" height={300} src="https://danjohnvelasco.github.io/images/empty.png" />
</Center>
);
return (
<Group noWrap grow direction="column" mt="xl">
<ScrollArea sx={{ height: 300 }}>
{rows.length > 0 ? (
<Table highlightOnHover>
<thead>{ths}</thead>
<tbody>{rows}</tbody>
</Table>
) : (
easteregg
)}
</ScrollArea>
</Group>
);
}

View File

@@ -0,0 +1,168 @@
import { Text, Title, Group, useMantineTheme, Box, Card, ColorSwatch } from '@mantine/core';
import { IconDownload as Download } from '@tabler/icons';
import { useEffect, useState } from 'react';
import axios from 'axios';
import { NormalizedTorrent } from '@ctrl/shared-torrent';
import { linearGradientDef } from '@nivo/core';
import { Datum, ResponsiveLine } from '@nivo/line';
import { useListState } from '@mantine/hooks';
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
import { useConfig } from '../../../tools/state';
import { humanFileSize } from '../../../tools/humanFileSize';
import { IModule } from '../modules';
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
export const TotalDownloadsModule: IModule = {
title: 'Download Speed',
description: 'Show the current download speed of supported services',
icon: Download,
component: TotalDownloadsComponent,
};
interface torrentHistory {
x: number;
up: number;
down: number;
}
export default function TotalDownloadsComponent() {
const setSafeInterval = useSetSafeInterval();
const { config } = useConfig();
const downloadServices =
config.services.filter(
(service) =>
service.type === 'qBittorrent' ||
service.type === 'Transmission' ||
service.type === 'Deluge'
) ?? [];
const [torrentHistory, torrentHistoryHandlers] = useListState<torrentHistory>([]);
const [torrents, setTorrents] = useState<NormalizedTorrent[]>([]);
const totalDownloadSpeed = torrents.reduce((acc, torrent) => acc + torrent.downloadSpeed, 0);
const totalUploadSpeed = torrents.reduce((acc, torrent) => acc + torrent.uploadSpeed, 0);
useEffect(() => {
if (downloadServices.length === 0) return;
setSafeInterval(() => {
axios.post('/api/modules/downloads', { config }).then((response) => {
setTorrents(response.data);
});
}, 1000);
}, [config.services]);
useEffect(() => {
torrentHistoryHandlers.append({
x: Date.now(),
down: totalDownloadSpeed,
up: totalUploadSpeed,
});
}, [totalDownloadSpeed, totalUploadSpeed]);
if (downloadServices.length === 0) {
return (
<Group direction="column">
<Title order={4}>No supported download clients found!</Title>
<Group noWrap>
<Text>Add a download service to view your current downloads...</Text>
<AddItemShelfButton />
</Group>
</Group>
);
}
const theme = useMantineTheme();
// Load the last 10 values from the history
const history = torrentHistory.slice(-10);
const chartDataUp = history.map((load, i) => ({
x: load.x,
y: load.up,
})) as Datum[];
const chartDataDown = history.map((load, i) => ({
x: load.x,
y: load.down,
})) as Datum[];
return (
<Group noWrap direction="column" grow>
<Title order={4}>Current download speed</Title>
<Group direction="column">
<Group>
<ColorSwatch size={12} color={theme.colors.green[5]} />
<Text>Download: {humanFileSize(totalDownloadSpeed)}/s</Text>
</Group>
<Group>
<ColorSwatch size={12} color={theme.colors.blue[5]} />
<Text>Upload: {humanFileSize(totalUploadSpeed)}/s</Text>
</Group>
</Group>
<Box
style={{
height: 200,
width: '100%',
}}
>
<ResponsiveLine
isInteractive
enableSlices="x"
sliceTooltip={({ slice }) => {
const Download = slice.points[0].data.y as number;
const Upload = slice.points[1].data.y as number;
// Get the number of seconds since the last update.
const seconds = (Date.now() - (slice.points[0].data.x as number)) / 1000;
// Round to the nearest second.
const roundedSeconds = Math.round(seconds);
return (
<Card p="sm" radius="md" withBorder>
<Text size="md">{roundedSeconds} seconds ago</Text>
<Card.Section p="sm">
<Group direction="column">
<Group>
<ColorSwatch size={10} color={theme.colors.green[5]} />
<Text size="md">Download: {humanFileSize(Download)}</Text>
</Group>
<Group>
<ColorSwatch size={10} color={theme.colors.blue[5]} />
<Text size="md">Upload: {humanFileSize(Upload)}</Text>
</Group>
</Group>
</Card.Section>
</Card>
);
}}
data={[
{
id: 'downloads',
data: chartDataUp,
},
{
id: 'uploads',
data: chartDataDown,
},
]}
curve="monotoneX"
yFormat=" >-.2f"
axisTop={null}
axisRight={null}
enablePoints={false}
animate={false}
enableGridX={false}
enableGridY={false}
enableArea
defs={[
linearGradientDef('gradientA', [
{ offset: 0, color: 'inherit' },
{ offset: 100, color: 'inherit', opacity: 0 },
]),
]}
fill={[{ match: '*', id: 'gradientA' }]}
colors={[
// Blue
theme.colors.blue[5],
// Green
theme.colors.green[5],
]}
/>
</Box>
</Group>
);
}

View File

@@ -0,0 +1,2 @@
export { DownloadsModule } from './DownloadsModule';
export { TotalDownloadsModule } from './TotalDownloadsModule';

View File

@@ -1,5 +1,7 @@
export * from './date';
export * from './calendar'; export * from './calendar';
export * from './search'; export * from './dash.';
export * from './date';
export * from './downloads';
export * from './ping'; export * from './ping';
export * from './search';
export * from './weather'; export * from './weather';

View File

@@ -1,14 +1,18 @@
import { Card, Menu, Switch, useMantineTheme } from '@mantine/core'; import {
Button,
Card,
Group,
Menu,
MultiSelect,
Switch,
TextInput,
useMantineColorScheme,
} from '@mantine/core';
import { useConfig } from '../../tools/state'; import { useConfig } from '../../tools/state';
import { IModule } from './modules'; import { IModule } from './modules';
export function ModuleWrapper(props: any) { function getItems(module: IModule) {
const { module }: { module: IModule } = props;
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const enabledModules = config.settings.enabledModules ?? [];
// Remove 'Module' from enabled modules titles
const isShown = enabledModules.includes(module.title);
const theme = useMantineTheme();
const items: JSX.Element[] = []; const items: JSX.Element[] = [];
if (module.options) { if (module.options) {
const keys = Object.keys(module.options); const keys = Object.keys(module.options);
@@ -18,25 +22,107 @@ export function ModuleWrapper(props: any) {
// Loop over all the types with a for each loop // Loop over all the types with a for each loop
types.forEach((type, index) => { types.forEach((type, index) => {
const optionName = `${module.title}.${keys[index]}`; const optionName = `${module.title}.${keys[index]}`;
const moduleInConfig = config.modules?.[module.title];
if (type === 'object') {
items.push(
<MultiSelect
label={module.options?.[keys[index]].name}
data={module.options?.[keys[index]].options ?? []}
defaultValue={
(moduleInConfig?.options?.[keys[index]]?.value as string[]) ??
(values[index].value as string[]) ??
[]
}
searchable
onChange={(value) => {
setConfig({
...config,
modules: {
...config.modules,
[module.title]: {
...moduleInConfig,
options: {
...moduleInConfig?.options,
[keys[index]]: {
...moduleInConfig?.options?.[keys[index]],
value,
},
},
},
},
});
}}
/>
);
}
if (type === 'string') {
items.push(
<form
onSubmit={(e) => {
e.preventDefault();
setConfig({
...config,
modules: {
...config.modules,
[module.title]: {
...config.modules[module.title],
options: {
...config.modules[module.title].options,
[keys[index]]: {
...config.modules[module.title].options?.[keys[index]],
value: (e.target as any)[0].value,
},
},
},
},
});
}}
>
<Group noWrap align="end" position="center" mt={0}>
<TextInput
key={optionName}
id={optionName}
name={optionName}
label={values[index].name}
defaultValue={
(moduleInConfig?.options?.[keys[index]]?.value as string) ??
(values[index].value as string) ??
''
}
onChange={(e) => {}}
/>
<Button type="submit">Save</Button>
</Group>
</form>
);
}
// TODO: Add support for other types // TODO: Add support for other types
if (type === 'boolean') { if (type === 'boolean') {
items.push( items.push(
<Switch <Switch
defaultChecked={ defaultChecked={
// Set default checked to the value of the option if it exists // Set default checked to the value of the option if it exists
config.settings[optionName] ?? (moduleInConfig?.options?.[keys[index]]?.value as boolean) ??
(module.options && module.options[keys[index]].value) ?? (values[index].value as boolean) ??
false false
} }
defaultValue={config.settings[optionName] ?? false}
key={keys[index]} key={keys[index]}
onClick={(e) => { onClick={(e) => {
setConfig({ setConfig({
...config, ...config,
settings: { modules: {
...config.settings, ...config.modules,
enabledModules: [...config.settings.enabledModules], [module.title]: {
[optionName]: e.currentTarget.checked, ...config.modules[module.title],
options: {
...config.modules[module.title].options,
[keys[index]]: {
...config.modules[module.title].options?.[keys[index]],
value: e.currentTarget.checked,
},
},
},
}, },
}); });
}} }}
@@ -46,28 +132,69 @@ export function ModuleWrapper(props: any) {
} }
}); });
} }
// Sussy baka return items;
}
export function ModuleWrapper(props: any) {
const { module }: { module: IModule } = props;
const { colorScheme } = useMantineColorScheme();
const { config, setConfig } = useConfig();
const enabledModules = config.modules ?? {};
// Remove 'Module' from enabled modules titles
const isShown = enabledModules[module.title]?.enabled ?? false;
if (!isShown) { if (!isShown) {
return null; return null;
} }
return ( return (
<Card hidden={!isShown} mx="sm" withBorder radius="lg" shadow="sm"> <Card
{...props}
hidden={!isShown}
withBorder
radius="lg"
shadow="sm"
style={{
background: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '255, 255, 255,'} \
${(config.settings.appOpacity || 100) / 100}`,
borderColor: `rgba(${colorScheme === 'dark' ? '37, 38, 43,' : '233, 236, 239,'} \
${(config.settings.appOpacity || 100) / 100}`,
}}
>
<ModuleMenu
module={module}
styles={{
root: {
position: 'absolute',
top: 12,
right: 12,
},
}}
/>
<module.component />
</Card>
);
}
export function ModuleMenu(props: any) {
const { module, styles } = props;
const items: JSX.Element[] = getItems(module);
return (
<>
{module.options && ( {module.options && (
<Menu <Menu
size="md" size="lg"
shadow="xl" shadow="xl"
closeOnItemClick={false} closeOnItemClick={false}
radius="md" radius="md"
position="left" position="left"
styles={{ styles={{
root: { root: {
position: 'absolute', ...props?.styles?.root,
top: 15,
right: 15,
}, },
body: { body: {
backgroundColor: // Add shadow and elevation to the body
theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[1], boxShadow: '0 0 14px 14px rgba(0, 0, 0, 0.05)',
}, },
}} }}
> >
@@ -77,7 +204,6 @@ export function ModuleWrapper(props: any) {
))} ))}
</Menu> </Menu>
)} )}
<module.component /> </>
</Card>
); );
} }

View File

@@ -14,7 +14,8 @@ interface Option {
[x: string]: OptionValues; [x: string]: OptionValues;
} }
interface OptionValues { export interface OptionValues {
name: string; name: string;
value: boolean; value: boolean | string | string[];
options?: string[];
} }

View File

@@ -6,10 +6,13 @@ export default {
}; };
const service: serviceItem = { const service: serviceItem = {
id: '1',
type: 'Other', type: 'Other',
name: 'YouTube', name: 'YouTube',
icon: 'https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/youtube.png', icon: 'https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/youtube.png',
url: 'https://youtube.com/', url: 'https://youtube.com/',
status: ['200'],
newTab: false,
}; };
export const Default = (args: any) => <PingComponent service={service} />; export const Default = (args: any) => <PingComponent service={service} />;

View File

@@ -1,8 +1,8 @@
import { Indicator, Tooltip } from '@mantine/core'; import { Indicator, Tooltip } from '@mantine/core';
import axios from 'axios'; import axios, { AxiosResponse } from 'axios';
import { motion } from 'framer-motion'; import { motion } from 'framer-motion';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { Plug } from 'tabler-icons-react'; import { IconPlug as Plug } from '@tabler/icons';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { IModule } from '../modules'; import { IModule } from '../modules';
@@ -19,27 +19,53 @@ export default function PingComponent(props: any) {
const { url }: { url: string } = props; const { url }: { url: string } = props;
const [isOnline, setOnline] = useState<State>('loading'); const [isOnline, setOnline] = useState<State>('loading');
const [response, setResponse] = useState(500);
const exists = config.modules?.[PingModule.title]?.enabled ?? false;
function statusCheck(response: AxiosResponse) {
const { status }: { status: string[] } = props;
//Default Status
let acceptableStatus = ['200'];
if (status !== undefined && status.length) {
acceptableStatus = status;
}
// Checks if reported status is in acceptable status array
if (acceptableStatus.indexOf(response.status.toString()) >= 0) {
setOnline('online');
setResponse(response.status);
} else {
setOnline('down');
setResponse(response.status);
}
}
useEffect(() => { useEffect(() => {
if (!config.settings.enabledModules.includes('Ping Services')) { if (!exists) {
return; return;
} }
axios axios
.get('/api/modules/ping', { params: { url } }) .get('/api/modules/ping', { params: { url } })
.then(() => { .then((response) => {
setOnline('online'); statusCheck(response);
}) })
.catch(() => { .catch((error) => {
setOnline('down'); statusCheck(error.response);
}); });
}, []); }, [config.modules?.[PingModule.title]?.enabled]);
if (!config.settings.enabledModules.includes('Ping Services')) { if (!exists) {
return null; return null;
} }
return ( return (
<Tooltip <Tooltip
radius="lg" radius="lg"
style={{ position: 'absolute', bottom: 20, right: 20 }} style={{ position: 'absolute', bottom: 20, right: 20 }}
label={isOnline === 'loading' ? 'Loading...' : isOnline === 'online' ? 'Online' : 'Offline'} label={
isOnline === 'loading'
? 'Loading...'
: isOnline === 'online'
? `Online - ${response}`
: `Offline - ${response}`
}
> >
<motion.div <motion.div
animate={{ animate={{

View File

@@ -1,7 +1,12 @@
import { TextInput, Kbd, createStyles, Text, Popover } from '@mantine/core'; import { Kbd, createStyles, Text, Popover, Autocomplete, Tooltip } from '@mantine/core';
import { useForm, useHotkeys } from '@mantine/hooks'; import { useDebouncedValue, useForm, useHotkeys } from '@mantine/hooks';
import { useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { Search, BrandYoutube, Download } from 'tabler-icons-react'; import {
IconSearch as Search,
IconBrandYoutube as BrandYoutube,
IconDownload as Download,
} from '@tabler/icons';
import axios from 'axios';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { IModule } from '../modules'; import { IModule } from '../modules';
@@ -26,10 +31,24 @@ export default function SearchBar(props: any) {
const { config, setConfig } = useConfig(); const { config, setConfig } = useConfig();
const [opened, setOpened] = useState(false); const [opened, setOpened] = useState(false);
const [icon, setIcon] = useState(<Search />); const [icon, setIcon] = useState(<Search />);
const queryUrl = config.settings.searchUrl || 'https://www.google.com/search?q='; const queryUrl = config.settings.searchUrl ?? 'https://www.google.com/search?q=';
const textInput = useRef<HTMLInputElement>(); const textInput = useRef<HTMLInputElement>();
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]); // Find a service with the type of 'Overseerr'
const form = useForm({
initialValues: {
query: '',
},
});
const [debounced, cancel] = useDebouncedValue(form.values.query, 250);
const [results, setResults] = useState<any[]>([]);
useEffect(() => {
if (form.values.query !== debounced || form.values.query === '') return;
axios
.get(`/api/modules/search?q=${form.values.query}`)
.then((res) => setResults(res.data ?? []));
}, [debounced]);
useHotkeys([['ctrl+K', () => textInput.current && textInput.current.focus()]]);
const { classes, cx } = useStyles(); const { classes, cx } = useStyles();
const rightSection = ( const rightSection = (
<div className={classes.hide}> <div className={classes.hide}>
@@ -39,17 +58,18 @@ export default function SearchBar(props: any) {
</div> </div>
); );
const form = useForm({
initialValues: {
query: '',
},
});
// If enabled modules doesn't contain the module, return null // If enabled modules doesn't contain the module, return null
if (!config.settings.enabledModules.includes(SearchModule.title)) { // If module in enabled
const exists = config.modules?.[SearchModule.title]?.enabled ?? false;
if (!exists) {
return null; return null;
} }
const autocompleteData = results.map((result) => ({
label: result.phrase,
value: result.phrase,
}));
return ( return (
<form <form
onChange={() => { onChange={() => {
@@ -76,43 +96,32 @@ export default function SearchBar(props: any) {
} else if (isTorrent) { } else if (isTorrent) {
window.open(`https://bitsearch.to/search?q=${query.substring(3)}`); window.open(`https://bitsearch.to/search?q=${query.substring(3)}`);
} else { } else {
window.open(`${queryUrl}${values.query}`); window.open(
`${
queryUrl.includes('%s')
? queryUrl.replace('%s', values.query)
: queryUrl + values.query
}`
);
} }
}, 20); }, 20);
})} })}
> >
<Popover <Autocomplete
opened={opened} autoFocus
position="bottom" variant="filled"
placement="start" data={autocompleteData}
width={260} icon={icon}
withArrow ref={textInput}
rightSectionWidth={90}
rightSection={rightSection}
radius="md" radius="md"
trapFocus={false} size="md"
transition="pop-bottom-right" styles={{ rightSection: { pointerEvents: 'none' } }}
onFocusCapture={() => setOpened(true)} placeholder="Search the web..."
onBlurCapture={() => setOpened(false)} {...props}
target={ {...form.getInputProps('query')}
<TextInput />
variant="filled"
icon={icon}
ref={textInput}
rightSectionWidth={90}
rightSection={rightSection}
radius="md"
size="md"
styles={{ rightSection: { pointerEvents: 'none' } }}
placeholder="Search the web..."
{...props}
{...form.getInputProps('query')}
/>
}
>
<Text>
tip: Use the prefixes <b>!yt</b> and <b>!t</b> in front of your query to search on YouTube
or for a Torrent respectively.
</Text>
</Popover>
</form> </form>
); );
} }

View File

@@ -0,0 +1,59 @@
import { Center, Group, RingProgress, Title, useMantineTheme } from '@mantine/core';
import { IconCpu } from '@tabler/icons';
import { useEffect, useState } from 'react';
import axios from 'axios';
import si from 'systeminformation';
import { useListState } from '@mantine/hooks';
import { IModule } from '../modules';
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
export const SystemModule: IModule = {
title: 'System info',
description: 'Show the current CPU usage and memory usage',
icon: IconCpu,
component: SystemInfo,
};
interface ApiResponse {
cpu: si.Systeminformation.CpuData;
os: si.Systeminformation.OsData;
memory: si.Systeminformation.MemData;
load: si.Systeminformation.CurrentLoadData;
}
export default function SystemInfo(args: any) {
const [data, setData] = useState<ApiResponse>();
const setSafeInterval = useSetSafeInterval();
// Refresh data every second
useEffect(() => {
setSafeInterval(() => {
axios.get('/api/modules/systeminfo').then((res) => setData(res.data));
}, 1000);
}, []);
// Update data every time data changes
const [cpuLoadHistory, cpuLoadHistoryHandlers] =
useListState<si.Systeminformation.CurrentLoadData>([]);
// useEffect(() => {
// }, [data]);
const theme = useMantineTheme();
const currentLoad = data?.load?.currentLoad ?? 0;
return (
<Center>
<Group p="sm" direction="column" align="center">
<Title order={3}>Current CPU load</Title>
<RingProgress
size={150}
label={<Center>{`${currentLoad.toFixed(2)}%`}</Center>}
thickness={15}
roundCaps
sections={[{ value: currentLoad ?? 0, color: 'cyan' }]}
/>
</Group>
</Center>
);
}

View File

@@ -0,0 +1 @@
export { SystemModule } from './SystemModule';

View File

@@ -1,24 +1,24 @@
import { Group, Space, Title, Tooltip } from '@mantine/core'; import { Group, Space, Title, Tooltip, Skeleton } from '@mantine/core';
import axios from 'axios'; import axios from 'axios';
import { useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { import {
ArrowDownRight, IconArrowDownRight as ArrowDownRight,
ArrowUpRight, IconArrowUpRight as ArrowUpRight,
Cloud, IconCloud as Cloud,
CloudFog, IconCloudFog as CloudFog,
CloudRain, IconCloudRain as CloudRain,
CloudSnow, IconCloudSnow as CloudSnow,
CloudStorm, IconCloudStorm as CloudStorm,
QuestionMark, IconQuestionMark as QuestionMark,
Snowflake, IconSnowflake as Snowflake,
Sun, IconSun as Sun,
} from 'tabler-icons-react'; } from '@tabler/icons';
import { useConfig } from '../../../tools/state'; import { useConfig } from '../../../tools/state';
import { IModule } from '../modules'; import { IModule } from '../modules';
import { WeatherResponse } from './WeatherInterface'; import { WeatherResponse } from './WeatherInterface';
export const WeatherModule: IModule = { export const WeatherModule: IModule = {
title: 'Weather (beta)', title: 'Weather',
description: 'Look up the current weather in your location', description: 'Look up the current weather in your location',
icon: Sun, icon: Sun,
component: WeatherComponent, component: WeatherComponent,
@@ -27,6 +27,10 @@ export const WeatherModule: IModule = {
name: 'Display in Fahrenheit', name: 'Display in Fahrenheit',
value: false, value: false,
}, },
location: {
name: 'Current location',
value: 'Paris',
},
}, },
}; };
@@ -128,45 +132,57 @@ export function WeatherIcon(props: any) {
export default function WeatherComponent(props: any) { export default function WeatherComponent(props: any) {
// Get location from browser // Get location from browser
const [location, setLocation] = useState({ lat: 0, lng: 0 });
const { config } = useConfig(); const { config } = useConfig();
const [weather, setWeather] = useState({} as WeatherResponse); const [weather, setWeather] = useState({} as WeatherResponse);
const cityInput: string =
(config?.modules?.[WeatherModule.title]?.options?.location?.value as string) ?? 'Paris';
const isFahrenheit: boolean = const isFahrenheit: boolean =
config.settings[`${WeatherModule.title}.freedomunit`] === undefined (config?.modules?.[WeatherModule.title]?.options?.freedomunit?.value as boolean) ?? false;
? false
: config.settings[`${WeatherModule.title}.freedomunit`];
if ('geolocation' in navigator && location.lat === 0 && location.lng === 0) {
navigator.geolocation.getCurrentPosition((position) => {
setLocation({ lat: position.coords.latitude, lng: position.coords.longitude });
});
}
useEffect(() => { useEffect(() => {
axios axios
.get( .get(`https://geocoding-api.open-meteo.com/v1/search?name=${cityInput}`)
`https://api.open-meteo.com/v1/forecast?latitude=${location.lat}&longitude=${location.lng}&daily=weathercode,temperature_2m_max,temperature_2m_min&current_weather=true&timezone=Europe%2FLondon` .then((response) => {
) // Check if results exists
.then((res) => { const { latitude, longitude } = response.data.results
setWeather(res.data); ? response.data.results[0]
: { latitude: 0, longitude: 0 };
axios
.get(
`https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=weathercode,temperature_2m_max,temperature_2m_min&current_weather=true&timezone=Europe%2FLondon`
)
.then((res) => {
setWeather(res.data);
});
}); });
}, []); }, [cityInput]);
if (!weather.current_weather) { if (!weather.current_weather) {
return null; return (
<>
<Skeleton height={40} width={100} mb="xl" />
<Group noWrap direction="row">
<Skeleton height={50} circle />
<Group>
<Skeleton height={25} width={70} mr="lg" />
<Skeleton height={25} width={70} />
</Group>
</Group>
</>
);
} }
function usePerferedUnit(value: number): string { function usePerferedUnit(value: number): string {
return isFahrenheit ? `${(value * (9 / 5)).toFixed(1)}°F` : `${value.toFixed(1)}°C`; return isFahrenheit ? `${(value * (9 / 5) + 32).toFixed(1)}°F` : `${value.toFixed(1)}°C`;
} }
return ( return (
<Group position="left" direction="column"> <Group p="sm" spacing="xs" direction="column">
<Title>{usePerferedUnit(weather.current_weather.temperature)}</Title> <Title>{usePerferedUnit(weather.current_weather.temperature)}</Title>
<Group spacing={0}> <Group spacing={0}>
<WeatherIcon code={weather.current_weather.weathercode} /> <WeatherIcon code={weather.current_weather.weathercode} />
<Space mx="sm" /> <Space mx="sm" />
<span>{weather.daily.temperature_2m_max[0]}°C</span> <span>{usePerferedUnit(weather.daily.temperature_2m_max[0])}</span>
<ArrowUpRight size={16} style={{ right: 15 }} /> <ArrowUpRight size={16} style={{ right: 15 }} />
<Space mx="sm" /> <Space mx="sm" />
<span>{weather.daily.temperature_2m_min[0]}°C</span> <span>{usePerferedUnit(weather.daily.temperature_2m_min[0])}</span>
<ArrowDownRight size={16} /> <ArrowDownRight size={16} />
</Group> </Group>
</Group> </Group>

15
src/middleware.ts Normal file
View File

@@ -0,0 +1,15 @@
import { NextFetchEvent, NextRequest, NextResponse } from 'next/server';
export function middleware(req: NextRequest, ev: NextFetchEvent) {
const ok = req.cookies.get('password') === process.env.PASSWORD;
const url = req.nextUrl.clone();
if (
!ok &&
url.pathname !== '/login' &&
process.env.PASSWORD &&
url.pathname !== '/api/configs/tryPassword'
) {
url.pathname = '/login';
}
return NextResponse.rewrite(url);
}

View File

@@ -78,10 +78,9 @@ export default function NothingFoundBackground() {
<div className={classes.inner}> <div className={classes.inner}>
<Illustration className={classes.image} /> <Illustration className={classes.image} />
<div className={classes.content}> <div className={classes.content}>
<Title className={classes.title}>Nothing to see here</Title> <Title className={classes.title}>Config not found</Title>
<Text color="dimmed" size="lg" align="center" className={classes.description}> <Text color="dimmed" size="lg" align="center" className={classes.description}>
Page you are trying to open does not exist. You may have mistyped the address, or the The config you are trying to access does not exist. Please check the URL and try again.
page has been moved to another URL. If you think this is an error contact support.
</Text> </Text>
<Group position="center"> <Group position="center">
<NextLink href="/"> <NextLink href="/">

View File

@@ -1,8 +1,55 @@
import { Title } from '@mantine/core'; import { GetServerSidePropsContext } from 'next';
import { useRouter } from 'next/router'; import path from 'path';
import fs from 'fs';
import { useEffect } from 'react';
import AppShelf from '../components/AppShelf/AppShelf';
import LoadConfigComponent from '../components/Config/LoadConfig';
import { Config } from '../tools/types';
import { useConfig } from '../tools/state';
import Layout from '../components/layout/Layout';
export default function SlugPage(props: any) { export async function getServerSideProps(
const router = useRouter(); context: GetServerSidePropsContext
const { slug } = router.query; ): Promise<{ props: { config: Config } }> {
return <Title>ok</Title>; const configByUrl = context.query.slug;
const configPath = path.join(process.cwd(), 'data/configs', `${configByUrl}.json`);
const configExists = fs.existsSync(configPath);
if (!configExists) {
// Redirect to 404
context.res.writeHead(301, { Location: '/404' });
context.res.end();
return {
props: {
config: {
name: 'Default config',
services: [],
settings: {
searchUrl: 'https://www.google.com/search?q=',
},
modules: {},
},
},
};
}
const config = fs.readFileSync(configPath, 'utf8');
// Print loaded config
return {
props: {
config: JSON.parse(config),
},
};
}
export default function HomePage(props: any) {
const { config: initialConfig }: { config: Config } = props;
const { setConfig } = useConfig();
useEffect(() => {
setConfig(initialConfig);
}, [initialConfig]);
return (
<Layout>
<AppShelf />
<LoadConfigComponent />
</Layout>
);
} }

View File

@@ -3,17 +3,30 @@ import { useState } from 'react';
import { AppProps } from 'next/app'; import { AppProps } from 'next/app';
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookies } from 'cookies-next';
import Head from 'next/head'; import Head from 'next/head';
import { MantineProvider, ColorScheme, ColorSchemeProvider } from '@mantine/core'; import { MantineProvider, ColorScheme, ColorSchemeProvider, MantineTheme } from '@mantine/core';
import { NotificationsProvider } from '@mantine/notifications'; import { NotificationsProvider } from '@mantine/notifications';
import { useHotkeys } from '@mantine/hooks'; import { useHotkeys } from '@mantine/hooks';
import Layout from '../components/layout/Layout';
import { ConfigProvider } from '../tools/state'; import { ConfigProvider } from '../tools/state';
import { theme } from '../tools/theme'; import { theme } from '../tools/theme';
import { styles } from '../tools/styles';
import { ColorTheme } from '../tools/color';
export default function App(props: AppProps & { colorScheme: ColorScheme }) { export default function App(this: any, props: AppProps & { colorScheme: ColorScheme }) {
const { Component, pageProps } = props; const { Component, pageProps } = props;
const [colorScheme, setColorScheme] = useState<ColorScheme>(props.colorScheme); const [colorScheme, setColorScheme] = useState<ColorScheme>(props.colorScheme);
const [primaryColor, setPrimaryColor] = useState<MantineTheme['primaryColor']>('red');
const [secondaryColor, setSecondaryColor] = useState<MantineTheme['primaryColor']>('orange');
const [primaryShade, setPrimaryShade] = useState<MantineTheme['primaryShade']>(6);
const colorTheme = {
primaryColor,
secondaryColor,
setPrimaryColor,
setSecondaryColor,
primaryShade,
setPrimaryShade,
};
const toggleColorScheme = (value?: ColorScheme) => { const toggleColorScheme = (value?: ColorScheme) => {
const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark'); const nextColorScheme = value || (colorScheme === 'dark' ? 'light' : 'dark');
setColorScheme(nextColorScheme); setColorScheme(nextColorScheme);
@@ -24,28 +37,31 @@ export default function App(props: AppProps & { colorScheme: ColorScheme }) {
return ( return (
<> <>
<Head> <Head>
<title>Homarr 🦞</title>
<meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" /> <meta name="viewport" content="minimum-scale=1, initial-scale=1, width=device-width" />
<link rel="shortcut icon" href="/favicon.svg" />
</Head> </Head>
<ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}> <ColorSchemeProvider colorScheme={colorScheme} toggleColorScheme={toggleColorScheme}>
<MantineProvider <ColorTheme.Provider value={colorTheme}>
theme={{ <MantineProvider
...theme, theme={{
colorScheme, ...theme,
}} primaryColor,
withGlobalStyles primaryShade,
withNormalizeCSS colorScheme,
> }}
<NotificationsProvider limit={2} position="top-right"> styles={{
<ConfigProvider> ...styles,
<Layout> }}
withGlobalStyles
withNormalizeCSS
>
<NotificationsProvider limit={4} position="bottom-left">
<ConfigProvider>
<Component {...pageProps} /> <Component {...pageProps} />
</Layout> </ConfigProvider>
</ConfigProvider> </NotificationsProvider>
</NotificationsProvider> </MantineProvider>
</MantineProvider> </ColorTheme.Provider>
</ColorSchemeProvider> </ColorSchemeProvider>
</> </>
); );

View File

@@ -6,7 +6,6 @@ const stylesServer = createStylesServer();
export default class _Document extends Document { export default class _Document extends Document {
static async getInitialProps(ctx: DocumentContext) { static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx); const initialProps = await Document.getInitialProps(ctx);
// Add your app specific logic here // Add your app specific logic here
return { return {

View File

@@ -51,6 +51,9 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'PUT') { if (req.method === 'PUT') {
return Put(req, res); return Put(req, res);
} }
if (req.method === 'DELETE') {
return Delete(req, res);
}
if (req.method === 'GET') { if (req.method === 'GET') {
return Get(req, res); return Get(req, res);
} }
@@ -59,3 +62,28 @@ export default async (req: NextApiRequest, res: NextApiResponse) => {
message: 'Method not allowed', message: 'Method not allowed',
}); });
}; };
function Delete(req: NextApiRequest, res: NextApiResponse<any>) {
// Get the slug of the request
const { slug } = req.query as { slug: string };
if (!slug) {
return res.status(400).json({
message: 'Wrong request',
});
}
// Loop over all the files in the /data/configs directory
const files = fs.readdirSync('data/configs');
// Strip the .json extension from the file name
const configs = files.map((file) => file.replace('.json', ''));
// If the target is not in the list of files, return an error
if (!configs.includes(slug)) {
return res.status(404).json({
message: 'Target not found',
});
}
// Delete the file
fs.unlinkSync(path.join('data/configs', `${slug}.json`));
return res.status(200).json({
message: 'Configuration deleted with success',
});
}

View File

@@ -0,0 +1,25 @@
import { NextApiRequest, NextApiResponse } from 'next';
function Post(req: NextApiRequest, res: NextApiResponse) {
const { tried } = req.body;
// Try to match the password with the PASSWORD env variable
if (tried === process.env.PASSWORD) {
return res.status(200).json({
success: true,
});
}
return res.status(200).json({
success: false,
});
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'POST') {
return Post(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -0,0 +1,66 @@
import { NextApiRequest, NextApiResponse } from 'next';
import Docker from 'dockerode';
const docker = new Docker();
async function Get(req: NextApiRequest, res: NextApiResponse) {
// Get the slug of the request
const { id } = req.query as { id: string };
const { action } = req.query;
// Get the action on the request (start, stop, restart)
if (action !== 'start' && action !== 'stop' && action !== 'restart' && action !== 'remove') {
return res.status(400).json({
statusCode: 400,
message: 'Invalid action',
});
}
if (!id) {
return res.status(400).json({
message: 'Missing ID',
});
}
// Get the container with the ID
const container = docker.getContainer(id);
// Get the container info
container.inspect((err, data) => {
if (err) {
res.status(500).json({
message: err,
});
}
});
try {
switch (action) {
case 'remove':
await container.remove();
break;
case 'start':
container.start();
break;
case 'stop':
container.stop();
break;
case 'restart':
container.restart();
break;
}
} catch (err) {
res.status(500).json({
message: err,
});
}
return res.status(200).json({
success: true,
});
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a Put or a GET
if (req.method === 'GET') {
return Get(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -0,0 +1,21 @@
import { NextApiRequest, NextApiResponse } from 'next';
import Docker from 'dockerode';
const docker = new Docker();
async function Get(req: NextApiRequest, res: NextApiResponse) {
const containers = await docker.listContainers({ all: true });
return res.status(200).json(containers);
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'GET') {
return Get(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -0,0 +1,70 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';
import { serviceItem } from '../../../tools/types';
async function Post(req: NextApiRequest, res: NextApiResponse) {
// Parse req.body as a ServiceItem
const nextMonth = new Date(new Date().setMonth(new Date().getMonth() + 2)).toISOString();
const lastMonth = new Date(new Date().setMonth(new Date().getMonth() - 2)).toISOString();
const TypeToUrl: { service: string; url: string }[] = [
{
service: 'sonarr',
url: '/api/calendar',
},
{
service: 'radarr',
url: '/api/v3/calendar',
},
{
service: 'lidarr',
url: '/api/v1/calendar',
},
{
service: 'readarr',
url: '/api/v1/calendar',
},
];
const service: serviceItem = req.body;
const { type } = req.query;
if (!type) {
return res.status(400).json({
message: 'Missing required parameter in url: type',
});
}
if (!service) {
return res.status(400).json({
message: 'Missing required parameter in body: service',
});
}
// Match the type to the correct url
const url = TypeToUrl.find((x) => x.service === type);
if (!url) {
return res.status(400).json({
message: 'Invalid type',
});
}
// Get the origin URL
let { href: origin } = new URL(service.url);
if (origin.endsWith('/')) {
origin = origin.slice(0, -1);
}
const pined = `${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`;
const data = await axios.get(
`${origin}${url?.url}?apiKey=${service.apiKey}&end=${nextMonth}&start=${lastMonth}`
);
return res.status(200).json(data.data);
// // Make a request to the URL
// const response = await axios.get(url);
// // Return the response
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'POST') {
return Post(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -0,0 +1,68 @@
import { Deluge } from '@ctrl/deluge';
import { QBittorrent } from '@ctrl/qbittorrent';
import { NormalizedTorrent } from '@ctrl/shared-torrent';
import { Transmission } from '@ctrl/transmission';
import { NextApiRequest, NextApiResponse } from 'next';
import { Config } from '../../../tools/types';
async function Post(req: NextApiRequest, res: NextApiResponse) {
// Get the type of service from the request url
const { config }: { config: Config } = req.body;
const qBittorrentServices = config.services.filter((service) => service.type === 'qBittorrent');
const delugeServices = config.services.filter((service) => service.type === 'Deluge');
const transmissionServices = config.services.filter((service) => service.type === 'Transmission');
const torrents: NormalizedTorrent[] = [];
if (!qBittorrentServices && !delugeServices && !transmissionServices) {
return res.status(500).json({
statusCode: 500,
message: 'Missing services',
});
}
await Promise.all(
qBittorrentServices.map((service) =>
new QBittorrent({
baseUrl: service.url,
username: service.username,
password: service.password,
})
.getAllData()
.then((e) => torrents.push(...e.torrents))
)
);
await Promise.all(
delugeServices.map((service) =>
new Deluge({
baseUrl: service.url,
password: 'password' in service ? service.password : '',
})
.getAllData()
.then((e) => torrents.push(...e.torrents))
)
);
// Map transmissionServices
await Promise.all(
transmissionServices.map((service) =>
new Transmission({
baseUrl: service.url,
username: 'username' in service ? service.username : '',
password: 'password' in service ? service.password : '',
})
.getAllData()
.then((e) => torrents.push(...e.torrents))
)
);
res.status(200).json(torrents);
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'POST') {
return Post(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -7,10 +7,14 @@ async function Get(req: NextApiRequest, res: NextApiResponse) {
await axios await axios
.get(url as string) .get(url as string)
.then((response) => { .then((response) => {
res.status(200).json(response.data); res.status(response.status).json(response.statusText);
}) })
.catch((error) => { .catch((error) => {
res.status(500).json(error); if (error.response) {
res.status(error.response.status).json(error.response.statusText);
} else {
res.status(500).json('Server Error');
}
}); });
// // Make a request to the URL // // Make a request to the URL
// const response = await axios.get(url); // const response = await axios.get(url);

View File

@@ -0,0 +1,19 @@
import axios from 'axios';
import { NextApiRequest, NextApiResponse } from 'next';
async function Get(req: NextApiRequest, res: NextApiResponse) {
const { q } = req.query;
const response = await axios.get(`https://duckduckgo.com/ac/?q=${q}`);
res.status(200).json(response.data);
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'GET') {
return Get(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -0,0 +1,30 @@
import { NextApiRequest, NextApiResponse } from 'next';
import si from 'systeminformation';
async function Get(req: NextApiRequest, res: NextApiResponse) {
const [osInfo, cpuInfo, memInfo, cpuLoad] = await Promise.all([
si.osInfo(),
si.cpu(),
si.mem(),
si.currentLoad(),
]);
const sysinfo = {
cpu: cpuInfo,
os: osInfo,
mem: memInfo,
load: cpuLoad,
};
res.status(200).json(sysinfo);
}
export default async (req: NextApiRequest, res: NextApiResponse) => {
// Filter out if the reuqest is a POST or a GET
if (req.method === 'GET') {
return Get(req, res);
}
return res.status(405).json({
statusCode: 405,
message: 'Method not allowed',
});
};

View File

@@ -1,12 +1,14 @@
import { getCookie, setCookies } from 'cookies-next'; import { getCookie, setCookies } from 'cookies-next';
import { GetServerSidePropsContext } from 'next'; import { GetServerSidePropsContext } from 'next';
import path from 'path';
import fs from 'fs';
import { useEffect } from 'react'; import { useEffect } from 'react';
import AppShelf from '../components/AppShelf/AppShelf'; import AppShelf from '../components/AppShelf/AppShelf';
import LoadConfigComponent from '../components/Config/LoadConfig'; import LoadConfigComponent from '../components/Config/LoadConfig';
import { Config } from '../tools/types'; import { Config } from '../tools/types';
import { useConfig } from '../tools/state'; import { useConfig } from '../tools/state';
import { migrateToIdConfig } from '../tools/migrate';
import { getConfig } from '../tools/getConfig';
import { useColorTheme } from '../tools/color';
import Layout from '../components/layout/Layout';
export async function getServerSideProps({ export async function getServerSideProps({
req, req,
@@ -14,46 +16,31 @@ export async function getServerSideProps({
}: GetServerSidePropsContext): Promise<{ props: { config: Config } }> { }: GetServerSidePropsContext): Promise<{ props: { config: Config } }> {
let cookie = getCookie('config-name', { req, res }); let cookie = getCookie('config-name', { req, res });
if (!cookie) { if (!cookie) {
setCookies('config-name', 'default', { req, res, maxAge: 60 * 60 * 24 * 30 }); setCookies('config-name', 'default', {
req,
res,
maxAge: 60 * 60 * 24 * 30,
sameSite: 'strict',
});
cookie = 'default'; cookie = 'default';
} }
// Check if the config file exists return getConfig(cookie as string);
const configPath = path.join(process.cwd(), 'data/configs', `${cookie}.json`);
if (!fs.existsSync(configPath)) {
return {
props: {
config: {
name: cookie.toString(),
services: [],
settings: {
enabledModules: [],
searchBar: true,
searchUrl: 'https://www.google.com/search?q=',
},
},
},
};
}
const config = fs.readFileSync(configPath, 'utf8');
// Print loaded config
return {
props: {
config: JSON.parse(config),
},
};
} }
export default function HomePage(props: any) { export default function HomePage(props: any) {
const { config: initialConfig }: { config: Config } = props; const { config: initialConfig }: { config: Config } = props;
const { config, loadConfig, setConfig, getConfigs } = useConfig(); const { setConfig } = useConfig();
const { setPrimaryColor, setSecondaryColor } = useColorTheme();
useEffect(() => { useEffect(() => {
setConfig(initialConfig); const migratedConfig = migrateToIdConfig(initialConfig);
setPrimaryColor(migratedConfig.settings.primaryColor || 'red');
setSecondaryColor(migratedConfig.settings.secondaryColor || 'orange');
setConfig(migratedConfig);
}, [initialConfig]); }, [initialConfig]);
return ( return (
<> <Layout>
<AppShelf /> <AppShelf />
<LoadConfigComponent /> <LoadConfigComponent />
</> </Layout>
); );
} }

111
src/pages/login.tsx Normal file
View File

@@ -0,0 +1,111 @@
import React from 'react';
import { PasswordInput, Anchor, Paper, Title, Text, Container, Group, Button } from '@mantine/core';
import { setCookies } from 'cookies-next';
import { useForm } from '@mantine/hooks';
import { showNotification, updateNotification } from '@mantine/notifications';
import axios from 'axios';
import { IconCheck, IconX } from '@tabler/icons';
// TODO: Add links to the wiki articles about the login process.
export default function AuthenticationTitle() {
const form = useForm({
initialValues: {
password: '',
},
});
return (
<Container
size={420}
style={{
height: '100vh',
display: 'flex',
width: 420,
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Title
align="center"
sx={(theme) => ({ fontFamily: `Greycliff CF, ${theme.fontFamily}`, fontWeight: 900 })}
>
Welcome back!
</Title>
<Text color="dimmed" size="sm" align="center" mt={5}>
Please enter the{' '}
<Anchor<'a'> href="#" size="sm" onClick={(event) => event.preventDefault()}>
password
</Anchor>
</Text>
<Paper withBorder shadow="md" p={30} mt={30} radius="md" style={{ width: 420 }}>
<form
onSubmit={form.onSubmit((values) => {
setCookies('password', values.password, {
maxAge: 60 * 60 * 24 * 30,
sameSite: 'lax',
});
showNotification({
id: 'load-data',
loading: true,
title: 'Checking your password',
message: 'Your password is being checked...',
autoClose: false,
disallowClose: true,
});
axios
.post('/api/configs/tryPassword', {
tried: values.password,
})
.then((res) => {
setTimeout(() => {
if (res.data.success === true) {
updateNotification({
id: 'load-data',
color: 'teal',
title: 'Password correct',
message:
'Notification will close in 2 seconds, you can close this notification now',
icon: <IconCheck />,
autoClose: 300,
onClose: () => {
window.location.reload();
},
});
}
if (res.data.success === false) {
updateNotification({
id: 'load-data',
color: 'red',
title: 'Password is wrong, please try again.',
message:
'Notification will close in 2 seconds, you can close this notification now',
icon: <IconX />,
autoClose: 2000,
});
}
}, 500);
});
})}
>
<PasswordInput
id="password"
label="Password"
placeholder="Your password"
required
mt="md"
{...form.getInputProps('password')}
/>
<Group position="apart" mt="md">
<Anchor<'a'> onClick={(event) => event.preventDefault()} href="#" size="sm">
Forgot password?
</Anchor>
</Group>
<Button fullWidth type="submit" mt="xl">
Sign in
</Button>
</form>
</Paper>
</Container>
);
}

55
src/tools/addToHomarr.ts Normal file
View File

@@ -0,0 +1,55 @@
import Dockerode from 'dockerode';
import { Config, MatchingImages, ServiceType } from './types';
async function MatchIcon(name: string) {
const res = await fetch(
`https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
.replace(/\s+/g, '-')
.toLowerCase()}.png`
);
return res.ok ? res.url : '/favicon.svg';
}
function tryMatchType(imageName: string): ServiceType {
// Try to find imageName inside MatchingImages
const match = MatchingImages.find(({ image }) => imageName.includes(image));
if (match) {
return match.type;
}
return 'Other';
}
export function tryMatchService(container: Dockerode.ContainerInfo | undefined) {
if (container === undefined) return {};
const name = container.Names[0].substring(1);
return {
name,
id: container.Id,
type: tryMatchType(container.Image),
url: `${container.Ports.at(0)?.IP}:${container.Ports.at(0)?.PublicPort}`,
icon: `https://cdn.jsdelivr.net/gh/walkxhub/dashboard-icons/png/${name
.replace(/\s+/g, '-')
.toLowerCase()}.png`,
};
}
export default async function addToHomarr(
container: Dockerode.ContainerInfo,
config: Config,
setConfig: (newconfig: Config) => void
) {
setConfig({
...config,
services: [
...config.services,
{
name: container.Names[0].substring(1),
id: container.Id,
type: tryMatchType(container.Image),
url: `localhost:${container.Ports.at(0)?.PublicPort}`,
icon: await MatchIcon(container.Names[0].substring(1)),
},
],
});
}

28
src/tools/color.ts Normal file
View File

@@ -0,0 +1,28 @@
import { createContext, useContext } from 'react';
import { MantineTheme } from '@mantine/core';
type colorThemeContextType = {
primaryColor: MantineTheme['primaryColor'];
secondaryColor: MantineTheme['primaryColor'];
primaryShade: MantineTheme['primaryShade'];
setPrimaryColor: (color: MantineTheme['primaryColor']) => void;
setSecondaryColor: (color: MantineTheme['primaryColor']) => void;
setPrimaryShade: (shade: MantineTheme['primaryShade']) => void;
};
export const ColorTheme = createContext<colorThemeContextType>({
primaryColor: 'red',
secondaryColor: 'orange',
primaryShade: 6,
setPrimaryColor: () => {},
setSecondaryColor: () => {},
setPrimaryShade: () => {},
});
export function useColorTheme() {
const context = useContext(ColorTheme);
if (context === undefined) {
throw new Error('useColorTheme must be used within a ColorTheme.Provider');
}
return context;
}

31
src/tools/getConfig.ts Normal file
View File

@@ -0,0 +1,31 @@
import path from 'path';
import fs from 'fs';
export function getConfig(name: string) {
// Check if the config file exists
const configPath = path.join(process.cwd(), 'data/configs', `${name}.json`);
if (!fs.existsSync(configPath)) {
return {
props: {
configName: name,
config: {
name: name.toString(),
services: [],
settings: {
searchUrl: 'https://www.google.com/search?q=',
},
modules: {},
},
},
};
}
const config = fs.readFileSync(configPath, 'utf8');
// Print loaded config
return {
props: {
configName: name,
config: JSON.parse(config),
},
};
}

View File

@@ -0,0 +1,22 @@
import { useEffect, useRef } from 'react';
export function useSetSafeInterval() {
const timers = useRef<NodeJS.Timer[]>([]);
function setSafeInterval(callback: () => void, delay: number) {
const newInterval = setInterval(callback, delay);
timers.current.push(newInterval);
return newInterval;
}
useEffect(
() => () => {
timers.current.forEach((t) => {
clearInterval(t);
});
},
[]
);
return setSafeInterval;
}

View File

@@ -0,0 +1,31 @@
/**
* Format bytes as human-readable text.
*
* @param bytes Number of bytes.
* @param si True to use metric (SI) units, aka powers of 1000. False to use
* binary (IEC), aka powers of 1024.
* @param dp Number of decimal places to display.
*
* @return Formatted string.
*/
export function humanFileSize(initialBytes: number, si = true, dp = 1) {
const thresh = si ? 1000 : 1024;
let bytes = initialBytes;
if (Math.abs(bytes) < thresh) {
return `${bytes} B`;
}
const units = si
? ['kb', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
let u = -1;
const r = 10 ** dp;
do {
bytes /= thresh;
u += 1;
} while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
return `${bytes.toFixed(dp)} ${units[u]}`;
}

14
src/tools/migrate.ts Normal file
View File

@@ -0,0 +1,14 @@
import { v4 as uuidv4 } from 'uuid';
import { Config } from './types';
export function migrateToIdConfig(config: Config): Config {
// Set the config and add an ID to all the services that don't have one
const services = config.services.map((service) => ({
...service,
id: service.id ?? uuidv4(),
}));
return {
...config,
services,
};
}

Some files were not shown because too many files have changed in this diff Show More