Your ROOT_URL in app.ini is https://git.cloudchain.link/ but you are visiting https://dash.bss.nz/open-source-mirrors/homepage/commit/68c93c65e6cbcbd45c784df3718f78e99f9f7369
You should set ROOT_URL correctly, otherwise the web may not work correctly.
2 changed files with
16 additions and
30 deletions
@ -4,6 +4,16 @@ import Container from "components/services/widget/container";
import Block from "components/services/widget/block" ;
import useWidgetAPI from "utils/proxy/use-widget-api" ;
function fromUnits ( value ) {
const units = [ "B" , "K" , "M" , "G" , "T" , "P" ] ;
const [ number , unit ] = value . split ( " " ) ;
const index = units . indexOf ( unit ) ;
if ( index === - 1 ) {
return 0 ;
}
return parseFloat ( number ) * 1024 * * index ;
}
export default function Component ( { service } ) {
const { t } = useTranslation ( ) ;
@ -27,7 +37,7 @@ export default function Component({ service }) {
return (
< Container >
< Block label = { t ( "sabnzbd.rate" ) } value = { ` ${ queueData . queue . speed } B/s ` } / >
< Block label = { t ( "sabnzbd.rate" ) } value = { t ( "common.bitrate" , { value : fromUnits ( queueData . queue . speed ) * 8 } ) } / >
< Block label = { t ( "sabnzbd.queue" ) } value = { t ( "common.number" , { value : queueData . queue . noofslots } ) } / >
< Block label = { t ( "sabnzbd.timeleft" ) } value = { queueData . queue . timeleft } / >
< / Container >
@ -27,42 +27,18 @@ export default function Component({ service }) {
}
const { torrents } = torrentData . arguments ;
let rateDl = 0 ;
let rateUl = 0 ;
let completed = 0 ;
for ( let i = 0 ; i < torrents . length ; i += 1 ) {
const torrent = torrents [ i ] ;
rateDl += torrent . rateDownload ;
rateUl += torrent . rateUpload ;
if ( torrent . percentDone === 1 ) {
completed += 1 ;
}
}
const rateDl = torrents . reduce ( ( acc , torrent ) => acc + torrent . rateDownload , 0 ) ;
const rateUl = torrents . reduce ( ( acc , torrent ) => acc + torrent . rateUpload , 0 ) ;
const completed = torrents . filter ( ( torrent ) => torrent . percentDone === 1 ) ;
const leech = torrents . length - completed ;
let unitsDl = "KB/s" ;
let unitsUl = "KB/s" ;
rateDl /= 1024 ;
rateUl /= 1024 ;
if ( rateDl > 1024 ) {
rateDl /= 1024 ;
unitsDl = "MB/s" ;
}
if ( rateUl > 1024 ) {
rateUl /= 1024 ;
unitsUl = "MB/s" ;
}
return (
< Container >
< Block label = { t ( "transmission.leech" ) } value = { t ( "common.number" , { value : leech } ) } / >
< Block label = { t ( "transmission.download" ) } value = { ` ${ rateDl . toFixed ( 2 ) } ${ unitsDl } ` } / >
< Block label = { t ( "transmission.download" ) } value = { t ( "common.bitrate" , { value : rateDl * 8 } ) } / >
< Block label = { t ( "transmission.seed" ) } value = { t ( "common.number" , { value : completed } ) } / >
< Block label = { t ( "transmission.upload" ) } value = { ` ${ rateUl . toFixed ( 2 ) } ${ unitsUl } ` } / >
< Block label = { t ( "transmission.upload" ) } value = { t ( "common.bitrate" , { value : rateUl * 8 } ) } / >
< / Container >
) ;
}