peterbaumert / netbox-device-view

47 stars 6 forks source link

Support for only numbers as Port without Port in front. #17

Closed deku-m closed 1 year ago

deku-m commented 1 year ago

THere are devices that use only numbers as Ports like in the device-library from netbox > sc-panels. But there are also people that configure there ports like with floornumbers. 1001 1020 etc where 1xxx is the floor number. So they dont use any Port in front of it.

Scherm­afbeelding 2023-07-10 om 22 20 54

And there are also sub ports on some devices like 1.1 or 1.2.

Scherm­afbeelding 2023-07-10 om 22 20 19
peterbaumert commented 1 year ago

Hi, yeah i have to rework the port "preparation" part.

cybarox commented 1 year ago

I have seen you use regex to match the interface name.

You could use this one: ^(?P<type>([a-zA-Z\-_]*))(\/|(?P<dev>[0-9]+).|\s)?((?P<module>[0-9]+).|\s)?((?P<port>[0-9]+))$

Examples: https://regex101.com/r/XM47Bk/3

Maybe you could get the Interface type via interface.type field which is a required field of the interface NetBox object.

Nice project so far!

peterbaumert commented 1 year ago

can you try with v0.1.3 again @deku-m ?

deku-m commented 1 year ago

Hi @peterbaumert,

Tried with (SC-Panel) but for me its not working yet maybe i am doing something wrong?. afbeelding afbeelding

/* Ports are named "SC 1", "SC 2" | "Rear Port 1", "Rear Port 2" and so on */ .deviceview.area.dFront { /* both set to auto to overwrite the 32 columns 2 rows design */ grid-auto-rows: auto; grid-auto-columns: auto; grid-template-areas: "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" } 
.deviceview.area.dRear { /* both set to auto to overwrite the 32 columns 2 rows design */ grid-auto-rows: auto; grid-auto-columns: auto; grid-template-areas: "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24" }

Using device-type: https://github.com/netbox-community/devicetype-library/blob/master/device-types/Generic/SC-24-port-fiber-patch-panel.yaml

peterbaumert commented 1 year ago

Will have a look and get back to you

peterbaumert commented 1 year ago

Seems like css grids dont like numeric only names :D

Can you try with v0.1.4 and

/* Ports are named "1", "2" and so on for front and rear */
.deviceview.area.dFront {
    /* both set to auto to overwrite the 32 columns 2 rows design */
    grid-auto-rows: auto;
    grid-auto-columns: auto;
    grid-template-areas: "p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24";
}
.deviceview.area.dRear {
    /* both set to auto to overwrite the 32 columns 2 rows design */
    grid-auto-rows: auto;
    grid-auto-columns: auto;
    grid-template-areas: "p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24";
}
deku-m commented 1 year ago

Seems like css grids dont like numeric only names :D

Can you try with v0.1.4 and

/* Ports are named "1", "2" and so on for front and rear */
.deviceview.area.dFront {
  /* both set to auto to overwrite the 32 columns 2 rows design */
  grid-auto-rows: auto;
  grid-auto-columns: auto;
  grid-template-areas: "p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24";
}
.deviceview.area.dRear {
  /* both set to auto to overwrite the 32 columns 2 rows design */
  grid-auto-rows: auto;
  grid-auto-columns: auto;
  grid-template-areas: "p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21 p22 p23 p24";
}

This works !