mirror of
				https://github.com/karl0ss/homepage.git
				synced 2025-10-31 14:34:00 +00:00 
			
		
		
		
	Feature: Romm Widget (#2663)
--------- Co-authored-by: Karl Hudgell <karl.hudgell@bjss.com> Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									0cdc354ead
								
							
						
					
					
						commit
						f6ca3f57f7
					
				
							
								
								
									
										12
									
								
								docs/widgets/services/romm.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								docs/widgets/services/romm.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,12 @@ | |||||||
|  | --- | ||||||
|  | title: Romm | ||||||
|  | description: Romm Widget Configuration | ||||||
|  | --- | ||||||
|  | 
 | ||||||
|  | Allowed fields: `["platforms", "totalRoms"]`. | ||||||
|  | 
 | ||||||
|  | ```yaml | ||||||
|  | widget: | ||||||
|  |   type: Romm | ||||||
|  |   url: http://romm.host.or.ip | ||||||
|  | ``` | ||||||
| @ -115,6 +115,7 @@ nav: | |||||||
|       - widgets/services/qnap.md |       - widgets/services/qnap.md | ||||||
|       - widgets/services/radarr.md |       - widgets/services/radarr.md | ||||||
|       - widgets/services/readarr.md |       - widgets/services/readarr.md | ||||||
|  |       - widgets/services/romm.md | ||||||
|       - widgets/services/rutorrent.md |       - widgets/services/rutorrent.md | ||||||
|       - widgets/services/sabnzbd.md |       - widgets/services/sabnzbd.md | ||||||
|       - widgets/services/scrutiny.md |       - widgets/services/scrutiny.md | ||||||
|  | |||||||
| @ -796,6 +796,10 @@ | |||||||
|         "noEventsToday": "No events for today!", |         "noEventsToday": "No events for today!", | ||||||
|         "noEventsFound": "No events found" |         "noEventsFound": "No events found" | ||||||
|     }, |     }, | ||||||
|  |     "romm": { | ||||||
|  |         "platforms": "Platforms", | ||||||
|  |         "totalRoms": "Total ROMs" | ||||||
|  |     }, | ||||||
|     "netdata": { |     "netdata": { | ||||||
|       "warnings": "Warnings", |       "warnings": "Warnings", | ||||||
|       "criticals": "Criticals" |       "criticals": "Criticals" | ||||||
|  | |||||||
| @ -87,6 +87,7 @@ const components = { | |||||||
|   qnap: dynamic(() => import("./qnap/component")), |   qnap: dynamic(() => import("./qnap/component")), | ||||||
|   radarr: dynamic(() => import("./radarr/component")), |   radarr: dynamic(() => import("./radarr/component")), | ||||||
|   readarr: dynamic(() => import("./readarr/component")), |   readarr: dynamic(() => import("./readarr/component")), | ||||||
|  |   romm: dynamic(() => import("./romm/component")), | ||||||
|   rutorrent: dynamic(() => import("./rutorrent/component")), |   rutorrent: dynamic(() => import("./rutorrent/component")), | ||||||
|   sabnzbd: dynamic(() => import("./sabnzbd/component")), |   sabnzbd: dynamic(() => import("./sabnzbd/component")), | ||||||
|   scrutiny: dynamic(() => import("./scrutiny/component")), |   scrutiny: dynamic(() => import("./scrutiny/component")), | ||||||
|  | |||||||
							
								
								
									
										32
									
								
								src/widgets/romm/component.jsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								src/widgets/romm/component.jsx
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | |||||||
|  | import Container from "components/services/widget/container"; | ||||||
|  | import Block from "components/services/widget/block"; | ||||||
|  | import useWidgetAPI from "utils/proxy/use-widget-api"; | ||||||
|  | 
 | ||||||
|  | export default function Component({ service }) { | ||||||
|  |   const { widget } = service; | ||||||
|  | 
 | ||||||
|  |   const { data: response, error: responseError } = useWidgetAPI(widget, "statistics"); | ||||||
|  | 
 | ||||||
|  |   if (responseError) { | ||||||
|  |     return ( | ||||||
|  |       <Container service={service}> | ||||||
|  |         <Block label="Error" value={responseError.message} /> | ||||||
|  |       </Container> | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   if (responseError) { | ||||||
|  |     return <Container service={service} error={responseError} />; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   if (response) { | ||||||
|  |     const platforms = response.filter((x) => x.rom_count !== 0).length; | ||||||
|  |     const totalRoms = response.reduce((total, stat) => total + stat.rom_count, 0); | ||||||
|  |     return ( | ||||||
|  |       <Container service={service}> | ||||||
|  |         <Block label="romm.platforms" value={platforms} /> | ||||||
|  |         <Block label="romm.totalRoms" value={totalRoms} /> | ||||||
|  |       </Container> | ||||||
|  |     ); | ||||||
|  |   } | ||||||
|  | } | ||||||
							
								
								
									
										14
									
								
								src/widgets/romm/widget.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/widgets/romm/widget.js
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,14 @@ | |||||||
|  | import genericProxyHandler from "utils/proxy/handlers/generic"; | ||||||
|  | 
 | ||||||
|  | const widget = { | ||||||
|  |   api: "{url}/api/{endpoint}", | ||||||
|  |   proxyHandler: genericProxyHandler, | ||||||
|  | 
 | ||||||
|  |   mappings: { | ||||||
|  |     statistics: { | ||||||
|  |       endpoint: "platforms", | ||||||
|  |     }, | ||||||
|  |   }, | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default widget; | ||||||
| @ -101,6 +101,7 @@ import watchtower from "./watchtower/widget"; | |||||||
| import whatsupdocker from "./whatsupdocker/widget"; | import whatsupdocker from "./whatsupdocker/widget"; | ||||||
| import xteve from "./xteve/widget"; | import xteve from "./xteve/widget"; | ||||||
| import urbackup from "./urbackup/widget"; | import urbackup from "./urbackup/widget"; | ||||||
|  | import romm from "./romm/widget"; | ||||||
| 
 | 
 | ||||||
| const widgets = { | const widgets = { | ||||||
|   adguard, |   adguard, | ||||||
| @ -186,6 +187,7 @@ const widgets = { | |||||||
|   qnap, |   qnap, | ||||||
|   radarr, |   radarr, | ||||||
|   readarr, |   readarr, | ||||||
|  |   romm, | ||||||
|   rutorrent, |   rutorrent, | ||||||
|   sabnzbd, |   sabnzbd, | ||||||
|   scrutiny, |   scrutiny, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 GitHub
							GitHub