@ -354,8 +354,12 @@ export function cleanServiceGroups(groups) {
if ( typeof cleanedService . weight !== "number" ) {
cleanedService . weight = 0 ;
}
if ( ! cleanedService . widgets ) cleanedService . widgets = [ ] ;
if ( cleanedService . widget ) {
cleanedService . widgets . push ( cleanedService . widget ) ;
delete cleanedService . widget ;
}
cleanedService . widgets = cleanedService . widgets . map ( ( widgetData , index ) => {
// whitelisted set of keys to pass to the frontend
// alphabetical, grouped by widget(s)
const {
@ -495,7 +499,7 @@ export function cleanServiceGroups(groups) {
// spoolman
spoolIds ,
} = cleanedService. widget;
} = widgetData ;
let fieldsList = fields ;
if ( typeof fields === "string" ) {
@ -507,160 +511,160 @@ export function cleanServiceGroups(groups) {
}
}
cleanedService . widget = {
const widget = {
type ,
fields : fieldsList || null ,
hide _errors : hideErrors || false ,
service _name : service . name ,
service _group : serviceGroup . name ,
index ,
} ;
if ( type === "azuredevops" ) {
if ( userEmail ) cleanedService. widget. userEmail = userEmail ;
if ( repositoryId ) cleanedService. widget. repositoryId = repositoryId ;
if ( userEmail ) widget. userEmail = userEmail ;
if ( repositoryId ) widget. repositoryId = repositoryId ;
}
if ( type === "beszel" ) {
if ( systemId ) cleanedService. widget. systemId = systemId ;
if ( systemId ) widget. systemId = systemId ;
}
if ( type === "coinmarketcap" ) {
if ( currency ) cleanedService. widget. currency = currency ;
if ( symbols ) cleanedService. widget. symbols = symbols ;
if ( slugs ) cleanedService. widget. slugs = slugs ;
if ( defaultinterval ) cleanedService. widget. defaultinterval = defaultinterval ;
if ( currency ) widget. currency = currency ;
if ( symbols ) widget. symbols = symbols ;
if ( slugs ) widget. slugs = slugs ;
if ( defaultinterval ) widget. defaultinterval = defaultinterval ;
}
if ( type === "docker" ) {
if ( server ) cleanedService. widget. server = server ;
if ( container ) cleanedService. widget. container = container ;
if ( server ) widget. server = server ;
if ( container ) widget. container = container ;
}
if ( type === "unifi" ) {
if ( site ) cleanedService. widget. site = site ;
if ( site ) widget. site = site ;
}
if ( type === "proxmox" ) {
if ( node ) cleanedService. widget. node = node ;
if ( node ) widget. node = node ;
}
if ( type === "kubernetes" ) {
if ( namespace ) cleanedService. widget. namespace = namespace ;
if ( app ) cleanedService. widget. app = app ;
if ( podSelector ) cleanedService. widget. podSelector = podSelector ;
if ( namespace ) widget. namespace = namespace ;
if ( app ) widget. app = app ;
if ( podSelector ) widget. podSelector = podSelector ;
}
if ( type === "iframe" ) {
if ( src ) cleanedService. widget. src = src ;
if ( classes ) cleanedService. widget. classes = classes ;
if ( referrerPolicy ) cleanedService. widget. referrerPolicy = referrerPolicy ;
if ( allowPolicy ) cleanedService. widget. allowPolicy = allowPolicy ;
if ( allowFullscreen ) cleanedService. widget. allowFullscreen = allowFullscreen ;
if ( loadingStrategy ) cleanedService. widget. loadingStrategy = loadingStrategy ;
if ( allowScrolling ) cleanedService. widget. allowScrolling = allowScrolling ;
if ( refreshInterval ) cleanedService. widget. refreshInterval = refreshInterval ;
if ( src ) widget. src = src ;
if ( classes ) widget. classes = classes ;
if ( referrerPolicy ) widget. referrerPolicy = referrerPolicy ;
if ( allowPolicy ) widget. allowPolicy = allowPolicy ;
if ( allowFullscreen ) widget. allowFullscreen = allowFullscreen ;
if ( loadingStrategy ) widget. loadingStrategy = loadingStrategy ;
if ( allowScrolling ) widget. allowScrolling = allowScrolling ;
if ( refreshInterval ) widget. refreshInterval = refreshInterval ;
}
if ( [ "opnsense" , "pfsense" ] . includes ( type ) ) {
if ( wan ) cleanedService. widget. wan = wan ;
if ( wan ) widget. wan = wan ;
}
if ( [ "emby" , "jellyfin" ] . includes ( type ) ) {
if ( enableBlocks !== undefined ) cleanedService. widget. enableBlocks = JSON . parse ( enableBlocks ) ;
if ( enableNowPlaying !== undefined ) cleanedService. widget. enableNowPlaying = JSON . parse ( enableNowPlaying ) ;
if ( enableBlocks !== undefined ) widget. enableBlocks = JSON . parse ( enableBlocks ) ;
if ( enableNowPlaying !== undefined ) widget. enableNowPlaying = JSON . parse ( enableNowPlaying ) ;
}
if ( [ "emby" , "jellyfin" , "tautulli" ] . includes ( type ) ) {
if ( expandOneStreamToTwoRows !== undefined )
cleanedService . widget . expandOneStreamToTwoRows = ! ! JSON . parse ( expandOneStreamToTwoRows ) ;
if ( showEpisodeNumber !== undefined )
cleanedService . widget . showEpisodeNumber = ! ! JSON . parse ( showEpisodeNumber ) ;
if ( enableUser !== undefined ) cleanedService . widget . enableUser = ! ! JSON . parse ( enableUser ) ;
widget . expandOneStreamToTwoRows = ! ! JSON . parse ( expandOneStreamToTwoRows ) ;
if ( showEpisodeNumber !== undefined ) widget . showEpisodeNumber = ! ! JSON . parse ( showEpisodeNumber ) ;
if ( enableUser !== undefined ) widget . enableUser = ! ! JSON . parse ( enableUser ) ;
}
if ( [ "sonarr" , "radarr" ] . includes ( type ) ) {
if ( enableQueue !== undefined ) cleanedService. widget. enableQueue = JSON . parse ( enableQueue ) ;
if ( enableQueue !== undefined ) widget. enableQueue = JSON . parse ( enableQueue ) ;
}
if ( type === "truenas" ) {
if ( enablePools !== undefined ) cleanedService. widget. enablePools = JSON . parse ( enablePools ) ;
if ( nasType !== undefined ) cleanedService. widget. nasType = nasType ;
if ( enablePools !== undefined ) widget. enablePools = JSON . parse ( enablePools ) ;
if ( nasType !== undefined ) widget. nasType = nasType ;
}
if ( [ "diskstation" , "qnap" ] . includes ( type ) ) {
if ( volume ) cleanedService. widget. volume = volume ;
if ( volume ) widget. volume = volume ;
}
if ( type === "kopia" ) {
if ( snapshotHost ) cleanedService. widget. snapshotHost = snapshotHost ;
if ( snapshotPath ) cleanedService. widget. snapshotPath = snapshotPath ;
if ( snapshotHost ) widget. snapshotHost = snapshotHost ;
if ( snapshotPath ) widget. snapshotPath = snapshotPath ;
}
if ( [ "glances" , "immich" , "mealie" , "pfsense" , "pihole" ] . includes ( type ) ) {
if ( version ) cleanedService. widget. version = parseInt ( version , 10 ) ;
if ( version ) widget. version = parseInt ( version , 10 ) ;
}
if ( type === "glances" ) {
if ( metric ) cleanedService. widget. metric = metric ;
if ( metric ) widget. metric = metric ;
if ( chart !== undefined ) {
cleanedService. widget. chart = chart ;
widget. chart = chart ;
} else {
cleanedService. widget. chart = true ;
widget. chart = true ;
}
if ( refreshInterval ) cleanedService. widget. refreshInterval = refreshInterval ;
if ( pointsLimit ) cleanedService. widget. pointsLimit = pointsLimit ;
if ( diskUnits ) cleanedService. widget. diskUnits = diskUnits ;
if ( refreshInterval ) widget. refreshInterval = refreshInterval ;
if ( pointsLimit ) widget. pointsLimit = pointsLimit ;
if ( diskUnits ) widget. diskUnits = diskUnits ;
}
if ( type === "mjpeg" ) {
if ( stream ) cleanedService. widget. stream = stream ;
if ( fit ) cleanedService. widget. fit = fit ;
if ( stream ) widget. stream = stream ;
if ( fit ) widget. fit = fit ;
}
if ( type === "openmediavault" ) {
if ( method ) cleanedService. widget. method = method ;
if ( method ) widget. method = method ;
}
if ( type === "openwrt" ) {
if ( interfaceName ) cleanedService. widget. interfaceName = interfaceName ;
if ( interfaceName ) widget. interfaceName = interfaceName ;
}
if ( type === "customapi" ) {
if ( mappings ) cleanedService. widget. mappings = mappings ;
if ( display ) cleanedService. widget. display = display ;
if ( refreshInterval ) cleanedService. widget. refreshInterval = refreshInterval ;
if ( mappings ) widget. mappings = mappings ;
if ( display ) widget. display = display ;
if ( refreshInterval ) widget. refreshInterval = refreshInterval ;
}
if ( type === "calendar" ) {
if ( integrations ) cleanedService. widget. integrations = integrations ;
if ( firstDayInWeek ) cleanedService. widget. firstDayInWeek = firstDayInWeek ;
if ( view ) cleanedService. widget. view = view ;
if ( maxEvents ) cleanedService. widget. maxEvents = maxEvents ;
if ( previousDays ) cleanedService. widget. previousDays = previousDays ;
if ( showTime ) cleanedService. widget. showTime = showTime ;
if ( timezone ) cleanedService. widget. timezone = timezone ;
if ( integrations ) widget. integrations = integrations ;
if ( firstDayInWeek ) widget. firstDayInWeek = firstDayInWeek ;
if ( view ) widget. view = view ;
if ( maxEvents ) widget. maxEvents = maxEvents ;
if ( previousDays ) widget. previousDays = previousDays ;
if ( showTime ) widget. showTime = showTime ;
if ( timezone ) widget. timezone = timezone ;
}
if ( type === "hdhomerun" ) {
if ( tuner !== undefined ) cleanedService. widget. tuner = tuner ;
if ( tuner !== undefined ) widget. tuner = tuner ;
}
if ( type === "healthchecks" ) {
if ( uuid !== undefined ) cleanedService. widget. uuid = uuid ;
if ( uuid !== undefined ) widget. uuid = uuid ;
}
if ( type === "speedtest" ) {
if ( bitratePrecision !== undefined ) {
cleanedService. widget. bitratePrecision = parseInt ( bitratePrecision , 10 ) ;
widget. bitratePrecision = parseInt ( bitratePrecision , 10 ) ;
}
}
if ( type === "stocks" ) {
if ( watchlist ) cleanedService. widget. watchlist = watchlist ;
if ( showUSMarketStatus ) cleanedService. widget. showUSMarketStatus = showUSMarketStatus ;
if ( watchlist ) widget. watchlist = watchlist ;
if ( showUSMarketStatus ) widget. showUSMarketStatus = showUSMarketStatus ;
}
if ( type === "wgeasy" ) {
if ( threshold !== undefined ) cleanedService. widget. threshold = parseInt ( threshold , 10 ) ;
if ( threshold !== undefined ) widget. threshold = parseInt ( threshold , 10 ) ;
}
if ( type === "frigate" ) {
if ( enableRecentEvents !== undefined ) cleanedService. widget. enableRecentEvents = enableRecentEvents ;
if ( enableRecentEvents !== undefined ) widget. enableRecentEvents = enableRecentEvents ;
}
if ( type === "technitium" ) {
if ( range !== undefined ) cleanedService. widget. range = range ;
if ( range !== undefined ) widget. range = range ;
}
if ( type === "lubelogger" ) {
if ( vehicleID !== undefined ) cleanedService. widget. vehicleID = parseInt ( vehicleID , 10 ) ;
if ( vehicleID !== undefined ) widget. vehicleID = parseInt ( vehicleID , 10 ) ;
}
if ( type === "vikunja" ) {
if ( enableTaskList !== undefined ) cleanedService. widget. enableTaskList = ! ! enableTaskList ;
if ( enableTaskList !== undefined ) widget. enableTaskList = ! ! enableTaskList ;
}
if ( type === "prometheusmetric" ) {
if ( metrics ) cleanedService. widget. metrics = metrics ;
if ( refreshInterval ) cleanedService. widget. refreshInterval = refreshInterval ;
if ( metrics ) widget. metrics = metrics ;
if ( refreshInterval ) widget. refreshInterval = refreshInterval ;
}
if ( type === "spoolman" ) {
if ( spoolIds !== undefined ) cleanedService. widget. spoolIds = spoolIds ;
if ( spoolIds !== undefined ) widget. spoolIds = spoolIds ;
}
}
return widget ;
} ) ;
return cleanedService ;
} ) ,
} ) ) ;
@ -693,12 +697,11 @@ export async function getServiceItem(group, service) {
return false ;
}
export default async function getServiceWidget ( group , service ) {
export default async function getServiceWidget ( group , service , index ) {
const serviceItem = await getServiceItem ( group , service ) ;
if ( serviceItem ) {
const { widget } = serviceItem ;
return widget;
const { widget , widgets } = serviceItem ;
return index > - 1 && widgets ? widgets [ index ] : widget;
}
return false ;
}