Skip to content

Commit

Permalink
Merge pull request #62 from atlanticwave-sdx/code-refactor-2.0
Browse files Browse the repository at this point in the history
Code refactor 2.0
  • Loading branch information
usmanazFIU authored Aug 21, 2024
2 parents 3f377a8 + 385b214 commit b1c4d26
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
16 changes: 13 additions & 3 deletions modules/circuits/controllers/NodesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ function find_subnode_by_id($nodes_array,$node_id){

foreach ($sub_nodes as $key2 => $value2) {
// code...
if($value2['id']==$node_id){
$ports=$value2['ports'];
foreach($ports as $key3=>$value3){
if($value3['id']==$node_id){

$temp2=array();
array_push($temp2,$value['latitude']);
Expand All @@ -321,6 +323,7 @@ function find_subnode_by_id($nodes_array,$node_id){

}
}
}
}

return $temp;
Expand Down Expand Up @@ -371,9 +374,10 @@ function find_subnode_by_id($nodes_array,$node_id){

foreach ($links as $key => $value) {
// code...
$latlng=find_subnode_by_id($nodes_array,$value->ports[0]->node);
$latlng2=find_subnode_by_id($nodes_array,$value->ports[1]->node);
$latlng=find_subnode_by_id($nodes_array,$value->ports[0]);
$latlng2=find_subnode_by_id($nodes_array,$value->ports[1]);
if(!empty($latlng)&&!empty($latlng2)){
//echo "here";
$temp_node=array();
$temp_node['link']=$latlng['node']."-".$latlng2['node'];
$temp_node['latlngs']=array(
Expand All @@ -400,6 +404,12 @@ function find_subnode_by_id($nodes_array,$node_id){
}

}

//echo"<pre>";print_r($nodes_array);echo"</pre>";
//echo"<pre>";print_r($latlng_array);echo"</pre>";
//echo"<pre>";print_r($links_array);echo"</pre>";

//exit();

return $this->render('nodes/nodes',['nodes_array'=>$nodes_array,'latlng_array'=>$latlng_array,'links_array'=>$links_array,'meican_url'=>$meican_url]);
}
Expand Down
30 changes: 26 additions & 4 deletions modules/circuits/views/nodes/nodes/list-connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,33 @@ function formatJsonData(data) {

formattedData += `<strong>Id:</strong> ${data.id || ''}<br>`;
formattedData += `<strong>Name:</strong> ${data.name || ''}<br>`;
if(data.description!==undefined){
formattedData += `<strong>Description:</strong> ${data.description || ''}<br>`;
}

if(data.scheduling!==undefined){
if(data.scheduling.start_time!==undefined){
formattedData += `<strong>Start Time:</strong> ${data.scheduling.start_time || ''}<br>`;
}
}

if(data.scheduling!==undefined){
if(data.scheduling.end_time!==undefined){
formattedData += `<strong>End Time:</strong> ${data.scheduling.end_time || ''}<br>`;
}
}

if(data.qos_metrics!==undefined){
formattedData += `<strong>QoS Metrics:</strong><br>`;
formattedData += `<div style="padding-left: 20px;">${formatQosMetrics(data.qos_metrics)}</div>`;
}

if(data.notifications!==undefined){
formattedData += `<strong>Notifications:</strong><br>`;
data.notifications.forEach((notification, index) => {
formattedData += `<div style="padding-left: 20px;"><strong>Email ${index + 1}: </strong>${formatNotificationData(notification)}</div></div>`;
});
}

formattedData += `<strong>Endpoints:</strong><br>`;
data.endpoints.forEach((endpoint, index) => {
Expand All @@ -208,7 +224,7 @@ function formatJsonData(data) {
function formatEndpointData(endpoint) {
let formattedEndpointData = '';
formattedEndpointData += `<strong>ID:</strong> ${endpoint.id || ''}<br>`;
formattedEndpointData += `<strong>VLAN:</strong> ${endpoint.label_range || ''}<br>`;
formattedEndpointData += `<strong>VLAN:</strong> ${endpoint.vlan || ''}<br>`;
return formattedEndpointData;
}

Expand All @@ -223,9 +239,15 @@ function formatNotificationData(notification) {
function formatQosMetrics(qosMetrics) {
let formattedQosMetrics = '';
if (qosMetrics) {
formattedQosMetrics += `<strong>Minimum Bandwidth:</strong> ${qosMetrics.min_bw.value || ''} (Strict: ${qosMetrics.min_bw.strict ? 'Yes' : 'No'})<br>`;
formattedQosMetrics += `<strong>Maximum Delay:</strong> ${qosMetrics.max_delay.value || ''} (Strict: ${qosMetrics.max_delay.strict ? 'Yes' : 'No'})<br>`;
formattedQosMetrics += `<strong>Maximum OXPs:</strong> ${qosMetrics.max_number_oxps.value || ''} (Strict: ${qosMetrics.max_number_oxps.strict ? 'Yes' : 'No'})<br>`;
if(qosMetrics.min_bw!==undefined){
formattedQosMetrics += `<strong>Minimum Bandwidth:</strong> ${qosMetrics.min_bw.value || ''} (Strict: ${qosMetrics.min_bw.strict ? 'Yes' : 'No'})<br>`;
}
if(qosMetrics.max_delay!==undefined){
formattedQosMetrics += `<strong>Maximum Delay:</strong> ${qosMetrics.max_delay.value || ''} (Strict: ${qosMetrics.max_delay.strict ? 'Yes' : 'No'})<br>`;
}
if(qosMetrics.max_number_oxps!==undefined){
formattedQosMetrics += `<strong>Maximum OXPs:</strong> ${qosMetrics.max_number_oxps.value || ''} (Strict: ${qosMetrics.max_number_oxps.strict ? 'Yes' : 'No'})<br>`;
}
}
return formattedQosMetrics;
}
Expand Down
6 changes: 3 additions & 3 deletions modules/circuits/views/nodes/nodes/nodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<br>VLAN:</br>
<select class="form-control" id="endpoint_1_vlan" name="endpoint_1_vlan" placeholder="vlan" required>
<option value="any" title="Any available VLAN ID is chosen">any</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">number</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">VLAN ID</option>
<option value="untagged" title="Transports Ethernet frames without IEEE 802.1Q Ethertype">untagged</option>
<option value="VLAN range" title="Range of VLANs, e.g., '50:55'">VLAN range</option>
<option value="all" title="Transport all Ethernet frames with and without IEEE 802.Q Ethertype">all</option>
Expand All @@ -125,7 +125,7 @@
<br>VLAN:</br>
<select class="form-control" id="endpoint_2_vlan" name="endpoint_2_vlan" placeholder="vlan" required>
<option value="any" title="Any available VLAN ID is chosen">any</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">number</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">VLAN ID</option>
<option value="untagged" title="Transports Ethernet frames without IEEE 802.1Q Ethertype">untagged</option>
<option value="VLAN range" title="Range of VLANs, e.g., '50:55'">VLAN range</option>
<option value="all" title="Transport all Ethernet frames with and without IEEE 802.Q Ethertype">all</option>
Expand Down Expand Up @@ -532,7 +532,7 @@ interfaceSelect.className = 'form-control';
};
vlanSelect.innerHTML = `
<option value="any" title="Any available VLAN ID chosen">any</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">number</option>
<option value="number" title="Specific VLAN ID, e.g., '50'">VLAN ID</option>
<option value="untagged" title="Transport Ethernet frames without IEEE 802.1Q Ethertype">untagged</option>
<option value="VLAN range" title="Range of VLANs, e.g., '50:55'">VLAN range</option>
<option value="all" title="Transport all Ethernet frames with and without IEEE 802.Q Ethertype">all</option>
Expand Down

0 comments on commit b1c4d26

Please sign in to comment.