"fix " services list

This commit is contained in:
Samuel Lorch 2023-11-07 19:08:03 +01:00
parent 090b030002
commit c2f1845c36

View file

@ -21,7 +21,7 @@ const displayData = $computed(() => {
data.push({ data.push({
name: services[index].name, name: services[index].name,
value: getServiceValue(services[index]), value: getServiceValue(services[index]),
type: services[index].type, type: Object.keys(services[index].service_type)[0],
comment: services[index].comment, comment: services[index].comment,
}); });
} }
@ -29,11 +29,12 @@ const displayData = $computed(() => {
}); });
function getServiceValue(s: any): string { function getServiceValue(s: any): string {
console.debug('test', Object.keys(s.service_type)[0]);
let value: string; let value: string;
switch (s.type) { switch (Object.keys(s.service_type)[0]) {
case 'tcp': case 'tcp':
case 'udp': case 'udp':
value = getServicePortRange(s); value = getServicePortRange(s.service_type[Object.keys(s.service_type)[0]]);
break; break;
case 'icmp': case 'icmp':
value = 'icmp'; value = 'icmp';
@ -48,10 +49,7 @@ function getServiceValue(s: any): string {
} }
function getServicePortRange(s:any): string { function getServicePortRange(s:any): string {
if (s.dport_end) { return `${s.source}-${s.destination}`;
return `${s.dport_start }-${ s.dport_end}`;
}
return s.dport_start;
} }
async function load(){ async function load(){