@@ -13,6 +13,10 @@ export const DashdotModule = asModule({
1313 icon : CalendarIcon ,
1414 component : DashdotComponent ,
1515 options : {
16+ url : {
17+ name : 'Dash. URL' ,
18+ value : '' ,
19+ } ,
1620 cpuMultiView : {
1721 name : 'CPU Multi-Core View' ,
1822 value : false ,
@@ -88,23 +92,23 @@ const bytePrettyPrint = (byte: number): string =>
8892 ? `${ ( byte / 1024 ) . toFixed ( 1 ) } KiB`
8993 : `${ byte . toFixed ( 1 ) } B` ;
9094
91- const useJson = ( service : serviceItem | undefined , url : string ) => {
95+ const useJson = ( targetUrl : string , url : string ) => {
9296 const [ data , setData ] = useState < any | undefined > ( ) ;
9397
9498 const doRequest = async ( ) => {
9599 try {
96- const resp = await axios . get ( url , { baseURL : service ?. url } ) ;
100+ const resp = await axios . get ( `/api/modules/dashdot? url= ${ url } &base= ${ targetUrl } ` ) ;
97101
98102 setData ( resp . data ) ;
99103 // eslint-disable-next-line no-empty
100104 } catch ( e ) { }
101105 } ;
102106
103107 useEffect ( ( ) => {
104- if ( service ?. url ) {
108+ if ( targetUrl ) {
105109 doRequest ( ) ;
106110 }
107- } , [ service ?. url ] ) ;
111+ } , [ targetUrl ] ) ;
108112
109113 return data ;
110114} ;
@@ -118,17 +122,19 @@ export function DashdotComponent() {
118122 const dashConfig = config . modules ?. [ DashdotModule . title ]
119123 . options as typeof DashdotModule [ 'options' ] ;
120124 const isCompact = dashConfig ?. useCompactView ?. value ?? false ;
121- const dashdotService = config . services . filter ( ( service ) => service . type === 'Dash.' ) [ 0 ] ;
122-
125+ const dashdotService : serviceItem | undefined = config . services . filter (
126+ ( service ) => service . type === 'Dash.'
127+ ) [ 0 ] ;
128+ const dashdotUrl = dashdotService ?. url ?? dashConfig ?. url ?. value ?? '' ;
123129 const enabledGraphs = dashConfig ?. graphs ?. value ?? [ 'CPU' , 'RAM' , 'Storage' , 'Network' ] ;
124130 const cpuEnabled = enabledGraphs . includes ( 'CPU' ) ;
125131 const storageEnabled = enabledGraphs . includes ( 'Storage' ) ;
126132 const ramEnabled = enabledGraphs . includes ( 'RAM' ) ;
127133 const networkEnabled = enabledGraphs . includes ( 'Network' ) ;
128134 const gpuEnabled = enabledGraphs . includes ( 'GPU' ) ;
129135
130- const info = useJson ( dashdotService , '/info' ) ;
131- const storageLoad = useJson ( dashdotService , '/load/storage' ) ;
136+ const info = useJson ( dashdotUrl , '/info' ) ;
137+ const storageLoad = useJson ( dashdotUrl , '/load/storage' ) ;
132138
133139 const totalUsed =
134140 ( storageLoad ?. layout as any [ ] ) ?. reduce ( ( acc , curr ) => ( curr . load ?? 0 ) + acc , 0 ) ?? 0 ;
@@ -166,13 +172,23 @@ export function DashdotComponent() {
166172 } ,
167173 ] . filter ( ( g ) => g . enabled ) ;
168174
175+ if ( dashdotUrl === '' ) {
176+ return (
177+ < div >
178+ < h2 className = { classes . heading } > Dash.</ h2 >
179+ < p >
180+ No dash. service found. Please add one to your Homarr dashboard or set a dashdot URL in
181+ the module options
182+ </ p >
183+ </ div >
184+ ) ;
185+ }
186+
169187 return (
170188 < div >
171189 < h2 className = { classes . heading } > Dash.</ h2 >
172190
173- { ! dashdotService ? (
174- < p > No dash. service found. Please add one to your Homarr dashboard.</ p >
175- ) : ! info ? (
191+ { ! info ? (
176192 < p > Cannot acquire information from dash. - are you running the latest version?</ p >
177193 ) : (
178194 < div className = { classes . graphsContainer } >
@@ -209,9 +225,7 @@ export function DashdotComponent() {
209225 }
210226 key = { graph . name }
211227 title = { graph . name }
212- src = { `${
213- dashdotService . url
214- } ?singleGraphMode=true&graph=${ graph . name . toLowerCase ( ) } &theme=${ colorScheme } &surface=${ ( colorScheme ===
228+ src = { `${ dashdotUrl } ?singleGraphMode=true&graph=${ graph . name . toLowerCase ( ) } &theme=${ colorScheme } &surface=${ ( colorScheme ===
215229 'dark'
216230 ? theme . colors . dark [ 7 ]
217231 : theme . colors . gray [ 0 ]
0 commit comments