Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/homepage/commit/24e25e8953e5eecb6ccd0796dab5651efeae89ab
You should set ROOT_URL correctly, otherwise the web may not work correctly.
2 changed files with
23 additions and
11 deletions
@ -6,16 +6,28 @@ import useWidgetAPI from "utils/proxy/use-widget-api";
export const fritzboxDefaultFields = [ "connectionStatus" , "uptime" , "maxDown" , "maxUp" ] ;
const formatUptime = ( timestamp ) => {
const hours = Math . floor ( timestamp / 3600 ) ;
const minutes = Math . floor ( ( timestamp % 3600 ) / 60 ) ;
const seconds = timestamp % 60 ;
const formatUptime = ( uptimeInSeconds ) => {
const days = Math . floor ( uptimeInSeconds / ( 3600 * 24 ) ) ;
const hours = Math . floor ( ( uptimeInSeconds % ( 3600 * 24 ) ) / 3600 ) ;
const minutes = Math . floor ( ( uptimeInSeconds % 3600 ) / 60 ) ;
const seconds = Math . floor ( uptimeInSeconds ) % 60 ;
const format = ( num ) => String ( num ) . padStart ( 2 , "0" ) ;
const hourDuration = hours > 0 ? ` ${ hours } h ` : "00h" ;
const minDuration = minutes > 0 ? ` ${ minutes } m ` : "00m" ;
const secDuration = seconds > 0 ? ` ${ seconds } s ` : "00s" ;
let uptimeStr = "" ;
if ( days ) {
uptimeStr += ` ${ days } d ` ;
}
if ( uptimeInSeconds >= 3600 ) {
uptimeStr += ` ${ format ( hours ) } h ` ;
}
if ( uptimeInSeconds >= 60 ) {
uptimeStr += ` ${ format ( minutes ) } m ` ;
}
if ( ! days ) {
uptimeStr += ` ${ format ( seconds ) } s ` ;
}
return hourDuration + minDuration + secDuration ;
return uptimeStr ;
} ;
export default function Component ( { service } ) {
@ -50,12 +50,12 @@ export default async function fritzboxProxyHandler(req, res) {
const serviceWidget = await getServiceWidget ( group , service ) ;
if ( ! serviceWidget ) {
res . status ( 500 ) . json ( { error : "Service widget not found" } ) ;
res . status ( 500 ) . json ( { error : { message : "Service widget not found" } } ) ;
return ;
}
if ( ! serviceWidget . url ) {
res . status ( 500 ) . json ( { error : "Service widget url not configured" } ) ;
res . status ( 500 ) . json ( { error : { message : "Service widget url not configured" } } ) ;
return ;
}
@ -91,6 +91,6 @@ export default async function fritzboxProxyHandler(req, res) {
} ) ;
} )
. catch ( ( error ) => {
res . status ( 500 ) . json ( { error : error . message } ) ;
res . status ( 500 ) . json ( { error : { message : error . message } } ) ;
} ) ;
}