Commit 3cec2c32 authored by anne munoz's avatar anne munoz Committed by Adam Wujek

www: Changed enpointconfiguration table

I saw that in the endpointconfiguration.php you relay a lot on an order of parameters. In other words the following line will be displayed correctly:
CONFIG_PORT01_PARAMS="name=wri1,proto=raw,tx=224295,rx=225959,role=slave,fiber=0"
but not when I swap an order of parameters:
CONFIG_PORT01_PARAMS="name=wri1,proto=raw,tx=224295,role=slave,rx=225959,fiber=0"
I'm asking you for that because there are three more new parameters that are optional:
      "ext" (extension) can be one of the following:
        - WR - use White Rabbit as an extension on this port (default if not present)
        - none - no extension on this port
      "dm" (delay mechanism) can be one of the following:
        - e2e - end to end (default if not present)
        - p2p - peer to peer
      "monitor" option to disable ("n") or enable ("y") triggering errors in SNMP on a port; "y" by default

NOW: it allows to change the order and dropdown menu in several parameters
parent 240ac1b8
......@@ -308,6 +308,11 @@ table.altrowstablesmall input {
font-size: 100%;
}
#endpointconfig table.altrowstablesmall input {
width: 45px;
font-size: 100%;
}
table.altrowstabledash {
font-family: verdana,arial,sans-serif;
font-size: 11px;
......
......@@ -34,10 +34,15 @@
$infoname = "Endpoint Configuration";
//$size = "6";
if (strpos($_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],'proto=') !== false)
$header = array ("WR port","Protocol","&#916 Tx","&#916 Rx","Mode","Fiber");
if (strpos($_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],'monitor=') !== false)
$header = array (key=>"key",name=>"WR port",proto=>"Protocol",tx=>"&#916 Tx",rx=>"&#916 Rx",role=>"Mode",fiber=>"Fiber", monitor=>"Monitor", ext=>"Extension", dm=>"Delay Mechanism");
else if (strpos($_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],'proto=') !== false)
$header = array (key=>"key",name=>"WR port",proto=>"Protocol",tx=>"&#916 Tx",rx=>"&#916 Rx",role=>"Mode",fiber=>"Fiber");
else
$header = array ("WR port","&#916 Tx","&#916 Rx","Mode","Fiber");
$header = array (key=>"key",name=>"WR port",tx=>"&#916 Tx",rx=>"&#916 Rx",role=>"Mode",fiber=>"Fiber");
$matrix = array ("key=CONFIG_PORT01_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT01_PARAMS"],
"key=CONFIG_PORT02_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT02_PARAMS"],
"key=CONFIG_PORT03_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT03_PARAMS"],
......@@ -57,8 +62,8 @@
"key=CONFIG_PORT17_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT17_PARAMS"],
"key=CONFIG_PORT18_PARAMS,".$_SESSION["KCONFIG"]["CONFIG_PORT18_PARAMS"],
);
print_multi_form($matrix, $header, $formatID, $class, $infoname, $size);
print_dynamic_multi_form($matrix, $header, $formatID, $class, $infoname, $size);
if(process_multi_form($matrix)){
save_kconfig();
apply_kconfig();
......
......@@ -316,13 +316,124 @@ function print_multi_form($matrix, $header, $formatID, $class, $infoname, $size)
echo '</FORM>';
}
function strposa($haystack, $needles=array(), $offset=0) {
$i = 0;
foreach($needles as $needle) {
if (strstr($needle,$haystack, true)!==false) return $i;
else $i++;
}
return -1;
}
function print_dynamic_multi_form($matrix, $header, $formatID, $class, $infoname, $size){
$names = array("slave", "auto", "non_wr", "none", "master");
$monitor = array("y","n");
$ext = array("WR", "none");
$dm = array("e2e", "p2p");
echo '<FORM method="POST" id="endpointconfig">
<table border="0" align="center" class="'.$class.'" id="'.$formatID.'" >';
if (!empty($infoname)) echo '<tr><th colspan='.count($matrix).'>'.$infoname.'</th></tr>';
// Printing fist line with column names.
if (!empty($header)){
echo "<tr class='sub'>";
foreach ($header as $column =>$c){
if($column!="key"){
echo "<td>".($c)."</td>";
}
}
echo "</tr>";
}
$i = 0;
// Printing the content of the form.
foreach ($matrix as $array){
$first = 0;
$elements = explode(",",$array);
foreach ($header as $column =>$c) {
if(strposa($column, $elements)>-1){
$column2 = explode("=",$elements[strposa($column, $elements)]);
if ($column=="key"){
echo '<INPUT type="hidden" value="'.$column2[1].'" name="key'.$i.'" >';
}
//role
else if ($column=="role"){
echo '<td><select value="'.$column2[1].'" name="'.$column2[0].$i.'" id="selected" class="drop">';
for ($j=0; $j<sizeof($names);$j++){
echo $names[$j];
if($column2[1] == $names[$j]){
echo '<option name="'.$column2[0].$i.'" selected="selected" ">'.$column2[1].'</option>';
}
else{
echo '<option value='. $names[$j] .'>'. $names[$j] .'</option>';
}
}
echo '</select></td>';
}
//monitor
else if ($column=="monitor"){
if($column2[1] == "y")
echo '<td align="center"><INPUT type="checkbox" value="y" name="'.$column2[0].$i.'" class="checkbox" checked></td>';
else
echo '<td align="center"><INPUT type="checkbox" value="n" name="'.$column2[0].$i.'" class="checkbox" ></td>';
}
//extension
else if ($column=="ext"){
echo '<td><select value="'.$column2[1].'"name="'.$column2[0].$i.'" id="selected" class="drop">';
for ($j=0; $j<sizeof($ext);$j++){
if($column2[1] == $ext[$j]){
echo '<option selected="selected" ">'.$column2[1].'</option>';
}
else{
echo '<option value='. $ext[$j] .'>'. $ext[$j] .'</option>';
}
}
echo '</select></td>';
}
//delay mechanistm
else if ($column=="dm"){
echo '<td><select value="'.$column2[1].'" name="'.$column2[0].$i.'" id="selected" class="drop">';
for ($j=0; $j<sizeof($dm);$j++){
if($column2[1] == $dm[$j]){
echo '<option selected="selected" ">'.$column2[1].'</option>';
}
else{
echo '<option value='. $dm[$j] .'>'. $dm[$j] .'</option>';
}
}
echo '</select></td>';
}
//other params
else{
echo '<td align="center"><INPUT size="'.$size.'" type="text" value="'.$column2[1].'" name="'.$column2[0].$i.'" ></td>';
$first = 1;
}
}
}
echo "<tr>";
$i++;
$first = 0;
}
echo '</table>';
echo '<INPUT type="submit" value="Save New Configuration" class="btn last">';
echo '</FORM>';
}
function process_multi_form($matrix){
$modified = false;
$i=0;
if(!empty($_POST)){
$tmp = implode(" ",$_POST);
$fiber = strstr($tmp,'FIBER');
foreach ($matrix as $array){
$elements = explode(",",$array);
......
$( document ).ready(function() {
addColorRows("#alternatecolor1");
columnNonEditable("#alternatecolor1",2);
changeMode();
});
function addColorRows(name){
$("table" + name + " tbody tr:nth-child(odd)").addClass("oddrowcolor");
$("table" + name + " tbody tr:nth-child(even)").addClass("evenrowcolor");
......@@ -7,7 +13,19 @@ function columnNonEditable(id,column){
$(id+" tr > :nth-child("+column+") input").prop("readonly", true);
}
$( document ).ready(function() {
addColorRows("#alternatecolor1");
columnNonEditable("#alternatecolor1",2);
});
function changeMode(){
if($("#endpointconfig").length != 0) {
$(".drop").on('change', function() {
$(this).attr('value',$(this).val());
});
$(".checkbox").on('change', function() {
if($(this).val()=="n")
$(this).attr('value',"y");
else
$(this).attr('value',"n");
});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment