-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#358: added basic facility port table on resources page
- Loading branch information
Showing
5 changed files
with
119 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { Component } from "react"; | ||
import Table from "../common/Table"; | ||
|
||
class FacilityPortTable extends Component { | ||
columns = [ | ||
{ | ||
content: (fp) => (<span className="font-monospace">{fp.name}</span>), | ||
path: "name", | ||
label: "Name", | ||
}, | ||
{ | ||
content: (fp) => ( | ||
<div className="w-50"> | ||
{ | ||
fp.vlan_range && fp.vlan_range.length > 0 && | ||
fp.vlan_range.map((range, index) => | ||
<span | ||
className="font-monospace badge bg-primary me-1" | ||
key={`vlan-range-${index}`} | ||
> | ||
{`[${range}]`} | ||
</span> | ||
) | ||
} | ||
</div> | ||
), | ||
path: "vlan_range", | ||
label: "VLAN Range" | ||
}, | ||
{ | ||
content: (fp) => ( | ||
<div className="w-25"> | ||
{ | ||
fp.allocated_vlan_range && fp.allocated_vlan_range.length > 0 && | ||
fp.allocated_vlan_range.map((range, index) => | ||
<span | ||
className="font-monospace badge bg-primary" | ||
key={`allocate-vlan-range-${index}`} | ||
> | ||
{`${range}`} | ||
</span> | ||
) | ||
} | ||
</div> | ||
), | ||
path: "allocated_vlan_range", | ||
label: "Allocated VLAN Range" | ||
} | ||
]; | ||
|
||
render() { | ||
const { facilityPorts, totalCount } = this.props; | ||
return ( | ||
<div> | ||
<div className="d-flex flex-row justify-content-between p-2"> | ||
<div className="fw-bold font-monospace d-flex align-items-center"> | ||
Facility Ports ({totalCount}) | ||
</div> | ||
</div> | ||
<div className="px-2 pb-1"> | ||
<Table | ||
columns={this.columns} | ||
data={facilityPorts} | ||
tStyle={"table-sm"} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default FacilityPortTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default function parseSites(data) { | ||
let abqm_elements = JSON.parse(data.model); | ||
const nodes = abqm_elements.nodes; | ||
const facility_ports = nodes.filter(n => n.Type === "FacilityPort"); | ||
const parsedFacilityPorts = []; | ||
for (const fp of facility_ports) { | ||
parsedFacilityPorts.push({ | ||
"name": fp["Name"], | ||
"vlan_range": JSON.parse(fp["Labels"]).vlan_range, | ||
"allocated_vlan_range": fp["LabelAllocations"] ? JSON.parse(fp["LabelAllocations"]).vlan : [] | ||
}) | ||
} | ||
return parsedFacilityPorts; | ||
} |