diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/inc/database.php racktables/wwwroot/inc/database.php
--- racktables2/wwwroot/inc/database.php 2012-04-19 12:29:26.749825940 +0200
+++ racktables/wwwroot/inc/database.php 2012-04-19 12:20:06.809828661 +0200
@@ -728,6 +728,7 @@ SELECT
(SELECT PortInnerInterface.iif_name FROM PortInnerInterface WHERE PortInnerInterface.id = Port.iif_id) AS iif_name,
(SELECT Dictionary.dict_value FROM Dictionary WHERE Dictionary.dict_key = Port.type) AS oif_name,
IF(la.porta, la.cable, lb.cable) AS cableid,
+ IF(la.porta, la.cable_dict_key, lb.cable_dict_key) AS cable_dict_key,
IF(la.porta, pa.id, pb.id) AS remote_id,
IF(la.porta, pa.name, pb.name) AS remote_name,
IF(la.porta, pa.object_id, pb.object_id) AS remote_object_id,
@@ -1452,19 +1453,44 @@ function getAllIPv4Allocations ()
return $ret;
}
-function linkPorts ($porta, $portb, $cable = NULL)
+function linkPorts ($porta, $portb, $cable = NULL, $cable_type = NULL, $update = false)
{
if ($porta == $portb)
throw new InvalidArgException ('porta/portb', $porta, "Ports can't be the same");
global $dbxlink;
- $dbxlink->exec ('LOCK TABLES Link WRITE');
+ # the many locks are necessary. otherwise commitUnlinkPort could not access these tables:
+ $dbxlink->exec ('LOCK TABLES Link WRITE, Port AS pa WRITE, Port AS pb WRITE , Object WRITE, RackObject WRITE, PortLog WRITE');
$result = usePreparedSelectBlade
(
- 'SELECT COUNT(*) FROM Link WHERE porta IN (?,?) OR portb IN (?,?)',
+ 'SELECT * FROM Link WHERE porta IN (?,?) OR portb IN (?,?)',
array ($porta, $portb, $porta, $portb)
);
- if ($result->fetchColumn () != 0)
+ if ( $update )
+ {
+ $a = $result->fetch();
+ if( $a ){
+ if( ($a['porta'] == $porta && $a['portb'] == $portb) || ($a['portb'] == $porta && $a['porta'] == $portb) )
+ {
+ // update!
+ $dbxlink->exec ('UNLOCK TABLES');
+ usePreparedUpdateBlade(
+ 'Link',
+ array (
+ 'cable' => ( mb_strlen ($cable) ? $cable : NULL ) ,
+ 'cable_dict_key' => ( mb_strlen ($cable_type) ? intval($cable_type) : NULL )
+ ),
+ array( 'porta' => $a['porta'], 'portb' => $a['portb'] )
+ );
+
+ return ;
+ }else{
+ commitUnlinkPort($porta);
+ commitUnlinkPort($portb);
+ }
+ }
+ }
+ else if ($result->fetch ())
{
$dbxlink->exec ('UNLOCK TABLES');
return "Port ${porta} or ${portb} is already linked";
@@ -1483,7 +1509,8 @@ function linkPorts ($porta, $portb, $cab
(
'porta' => $porta,
'portb' => $portb,
- 'cable' => mb_strlen ($cable) ? $cable : NULL
+ 'cable' => mb_strlen ($cable) ? $cable : NULL,
+ 'cable_dict_key' => mb_strlen ($cable_type) ? intval($cable_type) : NULL
)
);
$dbxlink->exec ('UNLOCK TABLES');
@@ -2812,9 +2839,10 @@ function commitUpdateUserAccount ($id, $
function getPortOIFCompat ()
{
$query =
- "select type1, type2, d1.dict_value as type1name, d2.dict_value as type2name from " .
+ "select type1, type2, d1.dict_value as type1name, d2.dict_value as type2name, cable_chapter_id , c.name as cable_chapter_name from " .
"PortCompat as pc inner join Dictionary as d1 on pc.type1 = d1.dict_key " .
"inner join Dictionary as d2 on pc.type2 = d2.dict_key " .
+ "left join Chapter as c on pc.cable_chapter_id = c.id ".
'ORDER BY type1name, type2name';
$result = usePreparedSelectBlade ($query);
return $result->fetchAll (PDO::FETCH_ASSOC);
diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/inc/interface.php racktables/wwwroot/inc/interface.php
--- racktables2/wwwroot/inc/interface.php 2012-04-16 09:51:40.040216558 +0200
+++ racktables/wwwroot/inc/interface.php 2012-04-19 12:20:06.813828661 +0200
@@ -1246,7 +1246,24 @@ function renderPortsForObject ($object_i
'object_id'=>$object_id)).
"'>";
printImageHREF ('cut', 'Unlink this port');
- echo "";
+ echo "";
+ echo " $port['id'],
+ );
+ $popup_args = 'height=700, width=400, location=no, menubar=no, '.
+ 'resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no';
+ echo " ondblclick='window.open(\"" . makeHrefForHelper ('portlist', $helper_args);
+ echo "\",\"findlink\",\"${popup_args}\");'";
+ // end of onclick=
+ echo " onclick='window.open(\"" . makeHrefForHelper ('portlist', $helper_args);
+ echo "\",\"findlink\",\"${popup_args}\");'";
+ // end of onclick=
+ echo '>';
+ // end of
+ printImageHREF ('plug', 'Link this port');
+ echo "";
}
elseif (strlen ($port['reservation_comment']))
{
@@ -3418,7 +3435,7 @@ function renderOIFCompatViewer()
$order = 'odd';
$last_left_oif_id = NULL;
echo '
';
- echo 'From interface | To interface |
';
+ echo 'From interface | To interface | Cable |
';
foreach (getPortOIFCompat() as $pair)
{
if ($last_left_oif_id != $pair['type1'])
@@ -3426,14 +3443,20 @@ function renderOIFCompatViewer()
$order = $nextorder[$order];
$last_left_oif_id = $pair['type1'];
}
- echo "${pair['type1name']} | ${pair['type2name']} |
";
+ echo "${pair['type1name']} | ${pair['type2name']} | ${pair['cable_chapter_name']} |
";
}
echo '
';
}
function renderOIFCompatEditor()
{
- function printNewitemTR()
+ $raw_chaplist = getChapterList();
+ $chaplist = array();
+ $chaplist[0]='';
+ foreach( $raw_chaplist as $chapter ){
+ $chaplist[$chapter['id']]= htmlspecialchars( $chapter['name'] );
+ }
+ function printNewitemTR($chaplist_local)
{
printOpFormIntro ('add');
echo '';
@@ -3442,6 +3465,10 @@ function renderOIFCompatEditor()
printSelect (readChapter (CHAP_PORTTYPE), array ('name' => 'type1'));
echo ' | ';
printSelect (readChapter (CHAP_PORTTYPE), array ('name' => 'type2'));
+ echo ' | ';
+ printSelect( $chaplist_local, array( 'name' => 'cable_chapter_id' ) );
+ echo ' | ';
+ printImageHREF ('add', 'add pair', TRUE);
echo ' |
';
}
@@ -3466,9 +3493,9 @@ function renderOIFCompatEditor()
startPortlet ('interface by interface');
$last_left_oif_id = NULL;
echo '
';
- echo ' | From Interface | To Interface |
';
+ echo ' | From Interface | To Interface | Cable | |
';
if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
- printNewitemTR();
+ printNewitemTR($chaplist);
foreach (getPortOIFCompat() as $pair)
{
if ($last_left_oif_id != $pair['type1'])
@@ -3476,13 +3503,19 @@ function renderOIFCompatEditor()
$order = $nextorder[$order];
$last_left_oif_id = $pair['type1'];
}
+ printOpFormIntro('upd',array('type1'=>$pair['type1'], 'type2' => $pair['type2']) );
echo "";
echo '';
printImageHREF ('delete', 'remove pair');
- echo " | ${pair['type1name']} | ${pair['type2name']} |
";
+ echo "${pair['type1name']} | ${pair['type2name']} | ";
+ echo '';
+ printSelect($chaplist, array('name'=>'cable_chapter_id'), $pair['cable_chapter_id']);
+ echo ' | ';
+ printImageHREF ('save', 'Save changes', TRUE);
+ echo " | ";
}
if (getConfigVar ('ADDNEW_AT_TOP') != 'yes')
- printNewitemTR();
+ printNewitemTR($chaplist);
echo '
';
finishPortlet();
}
diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/inc/navigation.php racktables/wwwroot/inc/navigation.php
--- racktables2/wwwroot/inc/navigation.php 2012-04-16 09:51:40.044216558 +0200
+++ racktables/wwwroot/inc/navigation.php 2012-04-19 12:20:06.813828661 +0200
@@ -435,6 +435,7 @@ $tabhandler['portmap']['default'] = 'ren
$tabhandler['portmap']['edit'] = 'renderOIFCompatEditor';
$ophandler['portmap']['edit']['add'] = 'tableHandler';
$ophandler['portmap']['edit']['del'] = 'tableHandler';
+$ophandler['portmap']['edit']['upd'] = 'tableHandler';
$ophandler['portmap']['edit']['addPack'] = 'addOIFCompatPack';
$ophandler['portmap']['edit']['delPack'] = 'delOIFCompatPack';
diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/inc/ophandlers.php racktables/wwwroot/inc/ophandlers.php
--- racktables2/wwwroot/inc/ophandlers.php 2012-04-19 12:29:26.757825940 +0200
+++ racktables/wwwroot/inc/ophandlers.php 2012-04-19 12:20:06.813828661 +0200
@@ -262,6 +262,21 @@ $opspec_list['portmap-edit-add'] = array
(
array ('url_argname' => 'type1', 'assertion' => 'uint'),
array ('url_argname' => 'type2', 'assertion' => 'uint'),
+ array ('url_argname' => 'cable_chapter_id', 'assertion' => 'uint0', 'if_empty' => 'NULL' )
+ ),
+);
+$opspec_list['portmap-edit-upd'] = array
+(
+ 'table' => 'PortCompat',
+ 'action' => 'UPDATE',
+ 'set_arglist' => array
+ (
+ array ('url_argname' => 'cable_chapter_id', 'assertion' => 'uint0', 'if_empty' => 'NULL'),
+ ),
+ 'where_arglist' => array
+ (
+ array ('url_argname' => 'type1', 'assertion' => 'uint'),
+ array ('url_argname' => 'type2', 'assertion' => 'uint')
),
);
$opspec_list['portmap-edit-del'] = array
diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/inc/popup.php racktables/wwwroot/inc/popup.php
--- racktables2/wwwroot/inc/popup.php 2012-04-16 09:51:40.044216558 +0200
+++ racktables/wwwroot/inc/popup.php 2012-04-19 12:39:08.649823113 +0200
@@ -34,7 +34,7 @@ function getProximateRacks ($rack_id, $p
return $ret;
}
-function findSparePorts ($port_info, $filter)
+function getSparePorts($port_info, $filter)
{
$qparams = array ();
$query = "
@@ -45,37 +45,34 @@ SELECT
p.iif_id,
p.type as oif_id,
pii.iif_name,
- d.dict_value as oif_name,
p.object_id,
o.name as object_name
FROM Port p
INNER JOIN Object o ON o.id = p.object_id
INNER JOIN PortInnerInterface pii ON p.iif_id = pii.id
-INNER JOIN Dictionary d ON d.dict_key = p.type
";
// porttype filter (non-strict match)
$query .= "
INNER JOIN (
- SELECT Port.id FROM Port
+ SELECT p2.id FROM Port p2
INNER JOIN
(
- SELECT DISTINCT pic2.iif_id
+ SELECT DISTINCT pic2.iif_id, pic2.oif_id
FROM PortInterfaceCompat pic2
INNER JOIN PortCompat pc ON pc.type2 = pic2.oif_id
";
if ($port_info['iif_id'] != 1)
{
- $query .= " INNER JOIN PortInterfaceCompat pic ON pic.oif_id = pc.type1 WHERE pic.iif_id = ? AND ";
+ $query .= " INNER JOIN PortInterfaceCompat pic ON pic.oif_id = pc.type1 WHERE pic.iif_id = ? ";
$qparams[] = $port_info['iif_id'];
}
else
{
- $query .= " WHERE pc.type1 = ? AND ";
+ $query .= " WHERE pc.type1 = ? ";
$qparams[] = $port_info['oif_id'];
}
$query .= "
- pic2.iif_id <> 1
- ) AS sub1 USING (iif_id)
+ ) AS sub1 ON p2.iif_id = sub1.iif_id AND ( p2.iif_id <> 1 OR p2.type = sub1.oif_id )
UNION
SELECT Port.id
FROM Port
@@ -113,42 +110,104 @@ INNER JOIN (
// ordering
$query .= ' ORDER BY o.name';
- $ret = array();
- $result = usePreparedSelectBlade ($query, $qparams);
-
- $rows_by_pn = array();
- $prev_object_id = NULL;
+ return usePreparedSelectBlade ($query, $qparams);
+}
+
+function getLinkPortJavascript($port_info, $ports)
+{
+ $required_oif = array();
+ $required_iif = array();
+ $required_chapter = array();
+ if( count($ports) == 0 ){
+ return '';
+ }
+ $jsports = array();
+ $compat = array();
+ $buffer = array('$(function($){');
+ $buffer[]='var PORT = { id:'.$port_info['id'].', name:"'.addslashes($port_info['name']).'",';
+ $buffer[]=' object_name:"'.addslashes($port_info['object_name']).'",';
+ $buffer[]=' oif_id:'.($port_info['oif_id'] ? $port_info['oif_id'] : 'null').', ';
+ $buffer[]=' iif_id:'.$port_info['iif_id'].', ';
+ $buffer[]=' cable:"'.addslashes($port_info['cableid']).'", ';
+ $buffer[]=' cable_dict_key:'.($port_info['cable_dict_key'] ? $port_info['cable_dict_key'] : 'null' ).', ';
+ $buffer[]=' remote_id:'.($port_info['remote_id'] ? $port_info['remote_id'] : 'null').'};';
+ $buffer[]='var PORTS = [';
- // fetch port rows from the DB
- while (TRUE)
+ $required_iif[$port_info['iif_id']]=true;
+ if( $port_info['oif_id'] ) $required_oif[$port_info['oif_id']]=true;
+ foreach( $ports as $port ){
+ $required_iif[ $port['iif_id'] ]=true;
+ if( $port['oif_id'] ) $required_oif[$port['oif_id']]=true;
+ $buffer[]=' { id:'.$port['id'].', name:"'.addslashes($port['name']).'", object_name:"'.addslashes($port['object_name']).'", oif_id:'.($port['oif_id'] ? $port['oif_id'] : 'null').', iif_id:'.$port['iif_id'].', reservation:"'.addslashes($port['reservation_comment']).'"},';
+ }
+ $buffer[]='];';
+
+ $incom = usePreparedSelectBlade('SELECT * FROM PortInterfaceCompat WHERE iif_id IN ('.questionMarks(count($required_iif)).') ORDER BY iif_id ', array_keys($required_iif));
+ $buffer[]='var INNER_OUTER_COMPATIBILITY = {';
+ $last_iif_id = null;
+ foreach( $incom as $in )
{
- $row = $result->fetch (PDO::FETCH_ASSOC);
- if (isset ($prev_object_id) and (! $row or $row['object_id'] != $prev_object_id))
+ if( $in['iif_id'] != $last_iif_id )
{
- // handle sorted object's portlist
- foreach (sortPortList ($rows_by_pn) as $ports_subarray)
- foreach ($ports_subarray as $port_row)
- {
- $port_description = $port_row['object_name'] . ' -- ' . $port_row['name'];
- if (count ($ports_subarray) > 1)
- {
- $if_type = $port_row['iif_id'] == 1 ? $port_row['oif_name'] : $port_row['iif_name'];
- $port_description .= " ($if_type)";
- }
- if (! empty ($port_row['reservation_comment']))
- $port_description .= ' -- ' . $port_row['reservation_comment'];
- $ret[$port_row['id']] = $port_description;
- }
- $rows_by_pn = array();
+ if( $last_iif_id != null )
+ {
+ $buffer[]=' ],';
+ }
+ $buffer[]=' '.$in['iif_id'].': [';
+ $last_iif_id = $in['iif_id'];
}
- $prev_object_id = $row['object_id'];
- if ($row)
- $rows_by_pn[$row['name']][] = $row;
- else
- break;
+ $required_oif[$in['oif_id']]=true;
+ $buffer[]=' '.$in['oif_id'].',';
}
+ if( $last_iif_id != null )
+ {
+ $buffer[]=' ]';
+ }
+ $buffer[]='};';
- return $ret;
+ $query ='SELECT * FROM PortCompat pc'.
+ ' WHERE type1 IN ('.questionMarks(count($required_oif)).') AND type2 IN ('.questionMarks(count($required_oif)).');';
+ $types = usePreparedSelectBlade($query, array_merge( array_keys($required_oif), array_keys($required_oif) ) );
+ foreach( $types as $type ){
+ @$compat[ $type['type1'] ][ $type['type2'] ] = array( 'cable_chapter_id'=> ($type['cable_chapter_id'] ? intval($type['cable_chapter_id']) : 'null') );
+ if( $type['cable_chapter_id'] ) $required_chapter[intval($type['cable_chapter_id'])] = true;
+ }
+ $buffer[]='var OUTER_COMPATIBILITY = {';
+ foreach( $compat as $a => $sub ){
+ $buffer[]=' '.$a.': { ';
+ foreach( $sub as $b => $info ){
+ $buffer[]=' '.$b.': {cable_chapter_id:'.$info['cable_chapter_id'].'},';
+ }
+ $buffer[]=' },';
+ }
+ $buffer[]='};';
+ if( $required_chapter ){
+ $buffer[]='var CABLES = {';
+ $last_chapter_id = -1;
+ foreach( array_keys($required_chapter) as $chapter_id ){
+ $chapter = cookOptgroups( readChapter( $chapter_id, 'o' ) );
+ $buffer[]= $chapter_id.': [';
+ foreach( $chapter as $group => $entries ){
+ $buffer[]= ' {name: "'.addslashes($group).'", values:[';
+ foreach( $entries as $key => $value ){
+ $buffer[]= ' {key: '.$key.', value: "'.addslashes($value).'"},';
+ }
+ $buffer[]=' ]},';
+ }
+ $buffer[]='],';
+ }
+ $buffer[]='};';
+ }else{
+ $buffer[]='var CABLES = {};';
+ }
+ $oifs = usePreparedSelectBlade('SELECT dict_key,dict_value FROM Dictionary WHERE chapter_id = 2 AND dict_key IN ('.questionMarks(count($required_oif)).');', array_keys($required_oif));
+ $buffer[]='var OIF = {};';
+ foreach( $oifs as $oif ){
+ $buffer[]='OIF['.$oif['dict_key'].']= "'.addslashes($oif['dict_value']).'";';
+ }
+ $buffer[]=' initializeLinkportForm( PORT, PORTS, INNER_OUTER_COMPATIBILITY, OUTER_COMPATIBILITY, CABLES, OIF )';
+ $buffer[]='});';
+ return join("\n",$buffer);
}
// Return a list of all objects which are possible parents
@@ -221,131 +280,66 @@ function renderPopupObjectSelector()
function handlePopupPortLink()
{
+ global $dbxlink;
assertUIntArg ('port');
assertUIntArg ('remote_port');
assertStringArg ('cable', TRUE);
$port_info = getPortInfo ($_REQUEST['port']);
$remote_port_info = getPortInfo ($_REQUEST['remote_port']);
- $POIFC = getPortOIFCompat();
- if (isset ($_REQUEST['port_type']) and isset ($_REQUEST['remote_port_type']))
- {
- $type_local = $_REQUEST['port_type'];
- $type_remote = $_REQUEST['remote_port_type'];
- }
- else
- {
- $type_local = $port_info['oif_id'];
- $type_remote = $remote_port_info['oif_id'];
- }
- $matches = FALSE;
- $js_table = '';
- foreach ($POIFC as $pair)
- if ($pair['type1'] == $type_local && $pair['type2'] == $type_remote)
- {
- $matches = TRUE;
- break;
+ $dbxlink->beginTransaction();
+ try{
+
+ if( $port_info['iif_id'] != 1 ){
+ // updateable
+ assertUIntArg ('local_oif');
+ if( $_POST['local_oif'] != $port_info['oif_id'] ){
+ commitUpdatePortOIF( $port_info['id'], $_POST['local_oif']);
+ $port_info['oif_id'] = intval($_POST['local_oif']);
+ }
}
- else
- $js_table .= "POIFC['${pair['type1']}-${pair['type2']}'] = 1;\n";
-
- if ($matches)
- {
- if ($port_info['oif_id'] != $type_local)
- commitUpdatePortOIF ($port_info['id'], $type_local);
- if ($remote_port_info['oif_id'] != $type_remote)
- commitUpdatePortOIF ($remote_port_info['id'], $type_remote);
- linkPorts ($port_info['id'], $remote_port_info['id'], $_REQUEST['cable']);
- showOneLiner
- (
- 8,
- array
+ if( $remote_port_info['iif_id'] != 1 ){
+ // updateable
+ assertUIntArg ('remote_oif');
+ if( $_POST['remote_oif'] != $remote_port_info['oif_id'] ){
+ commitUpdatePortOIF( $remote_port_info['id'], $_POST['remote_oif']);
+ $remote_port_info['oif_id'] = intval($_POST['remote_oif']);
+ }
+ }
+ // now check compat
+ $compat = usePreparedSelectBlade('SELECT * FROM PortCompat WHERE ( type1 = ? AND type2 = ? ) OR ( type2 = ? AND type1= ? ) ',
+ array( $port_info['oif_id'],$remote_port_info['oif_id'],$port_info['oif_id'],$remote_port_info['oif_id']) )->fetchAll();
+ if( !$compat ){
+ throw new InvalidRequestArgException('oif_id', '', 'Ports are not compatible');
+ }else{
+ // :)
+ $cable_type = null;
+ if( $compat[0]['cable_chapter_id'] && $_POST['cable_type'] ){
+ assertUIntArg('cable_type',true);
+ $cable_type = $_POST['cable_type'];
+ }
+ linkPorts( $port_info['id'], $remote_port_info['id'], $_POST['cable'], $cable_type, true );
+ $dbxlink->commit();
+ showOneLiner
(
- formatPortLink ($port_info['id'], $port_info['name'], NULL, NULL),
- formatPort ($remote_port_info),
- )
- );
- addJS (<<';
- echo '';
- echo '';
- echo '';
- echo '';
- echo '';
- echo 'The ports you have selected are not compatible. Please select a compatible transceiver pair.';
- echo '
';
- echo formatPort ($port_info) . ' ';
- if ($port_info['iif_id'] == 1)
- {
- echo formatPortIIFOIF ($port_info);
- echo '';
- }
- else
- {
- echo '';
+ , true);
+ return;
}
- echo ' — ';
- if ($remote_port_info['iif_id'] == 1)
- {
- echo formatPortIIFOIF ($remote_port_info);
- echo '';
- }
- else
- {
- echo '';
- }
- echo ' ' . formatPort ($remote_port_info);
- echo '
✕ Not compatible port types
';
- echo '✔ Compatible port types
';
- echo '';
+ }catch( Exception $e ){
+ $dbxlink->rollBack();
+ throw $e;
}
+ return renderPopupPortSelector();
}
function renderPopupPortSelector()
@@ -353,6 +347,7 @@ function renderPopupPortSelector()
assertUIntArg ('port');
$port_id = $_REQUEST['port'];
$port_info = getPortInfo ($port_id);
+
$in_rack = isset ($_REQUEST['in_rack']);
// fill port filter structure
@@ -379,11 +374,27 @@ function renderPopupPortSelector()
! empty ($filter['objects']) ||
! empty ($filter['ports'])
)
- $spare_ports = findSparePorts ($port_info, $filter);
-
+ $ports_with_current = $ports = getSparePorts($port_info, $filter)->fetchAll();
+ if( $port_info['remote_id'] ){
+ $current = $ports_with_current[]= getPortInfo($port_info['remote_id']);
+ }
+ addJS('js/link_port_form.js');
+ addJS(getLinkPortJavascript($port_info, $ports_with_current),true);
+ addCSS (<<<'END'
+.reserved {
+ text-decoration: line-through;
+}
+.compatible {
+ background: #afa;
+}
+.incompatible {
+ background: #faa;
+}
+END
+ , TRUE);
// display search form
echo 'Link ' . formatPort ($port_info) . ' to...';
- echo '
';
+ echo '
';
}
function renderPopupIPv4Selector()
diff -rupN '--exclude=.git' '--exclude=secret.php' racktables2/wwwroot/js/link_port_form.js racktables/wwwroot/js/link_port_form.js
--- racktables2/wwwroot/js/link_port_form.js 1970-01-01 01:00:00.000000000 +0100
+++ racktables/wwwroot/js/link_port_form.js 2012-04-19 12:20:06.813828661 +0200
@@ -0,0 +1,147 @@
+function initializeLinkportForm( PORT, PORTS, INNER_OUTER_COMPATIBILITY, OUTER_COMPATIBILITY, CABLES, OIF ){
+ var $remote_port = $('#remote_port'),$remote_oif = $('#remote_oif'),$local_oif = $('#local_oif'),$cable_type = $('#cable_type'), $submit = $('#submit'), $reservation = $('#reservation');
+ var compatClass = function(a,b){
+ if( !a || !b ){
+ return '';
+ }else if( !OUTER_COMPATIBILITY[a] || !OUTER_COMPATIBILITY[a][b] ){
+ return 'incompatible';
+ }else{
+ return 'compatible';
+ }
+ }
+ var updateSelects = function(){
+ var rp = $remote_port.val(), ro = $remote_oif.val(), lo = $local_oif.val(), ct = $cable_type.val();
+ if( ro ) ro = parseInt(ro);
+ if( !lo ){
+ lo = PORT.oif_id;
+ }else{
+ lo = parseInt(lo);
+ }
+ if( !rp ){
+ rp = PORT.remote_id;
+ }
+ if( !ct ){
+ ct = PORT.cable_dict_key;
+ }
+ //remote_oif
+ $remote_oif.empty();
+ var remote_port;
+ if( rp ){
+ remote_port = $.grep(PORTS,function(p){ return p.id == rp })[0];
+ if( !ro || remote_port.iif_id == 1 || INNER_OUTER_COMPATIBILITY[ remote_port.iif_id ].indexOf(ro) == -1 ){
+ ro = remote_port.oif_id;
+ }
+ if( remote_port.reservation == "" ){
+ $reservation.closest('p').hide();
+ }else{
+ $reservation.text( remote_port.reservation );
+ $reservation.closest('p').show();
+ }
+ if( remote_port.iif_id != 1 ){
+ $remote_oif.closest('p').show();
+ $remote_oif.attr('disabled',false);
+ }else{
+ $remote_oif.closest('p').hide();
+ $remote_oif.attr('disabled',true);
+ }
+ var rps = INNER_OUTER_COMPATIBILITY[ remote_port.iif_id ];
+ rps.sort(function(a,b){
+ return OIF[a].localeCompare(OIF[b]);
+ }).forEach( function(oif){
+ $('