@ -33,6 +33,15 @@ export async function servicesFromConfig() {
} ) ) ,
} ) ) ,
} ) ) ;
} ) ) ;
// add default weight to services based on their position in the configuration
servicesArray . forEach ( ( group , groupIndex ) => {
group . services . forEach ( ( service , serviceIndex ) => {
if ( ! service . weight ) {
servicesArray [ groupIndex ] . services [ serviceIndex ] . weight = ( serviceIndex + 1 ) * 100 ;
}
} ) ;
} ) ;
return servicesArray ;
return servicesArray ;
}
}
@ -152,6 +161,7 @@ export async function servicesFromKubernetes() {
href : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /href ` ] || getUrlFromIngress ( ingress ) ,
href : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /href ` ] || getUrlFromIngress ( ingress ) ,
name : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /name ` ] || ingress . metadata . name ,
name : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /name ` ] || ingress . metadata . name ,
group : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /group ` ] || "Kubernetes" ,
group : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /group ` ] || "Kubernetes" ,
weight : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /weight ` ] || '0' ,
icon : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /icon ` ] || '' ,
icon : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /icon ` ] || '' ,
description : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /description ` ] || '' ,
description : ingress . metadata . annotations [ ` ${ ANNOTATION _BASE } /description ` ] || '' ,
} ;
} ;
@ -201,6 +211,17 @@ export function cleanServiceGroups(groups) {
name : serviceGroup . name ,
name : serviceGroup . name ,
services : serviceGroup . services . map ( ( service ) => {
services : serviceGroup . services . map ( ( service ) => {
const cleanedService = { ... service } ;
const cleanedService = { ... service } ;
if ( typeof service . weight === 'string' ) {
const weight = parseInt ( service . weight , 10 ) ;
if ( Number . isNaN ( weight ) ) {
cleanedService . weight = 0 ;
} else {
cleanedService . weight = weight ;
}
}
if ( typeof cleanedService . weight !== "number" ) {
cleanedService . weight = 0 ;
}
if ( cleanedService . widget ) {
if ( cleanedService . widget ) {
// whitelisted set of keys to pass to the frontend
// whitelisted set of keys to pass to the frontend