r4877 ability to change cable ID without deleting & re-adding the link (#457)
authorAaron Dummer <aaron@dummer.info>
Sat, 31 Dec 2011 05:21:52 +0000 (05:21 +0000)
committerAaron Dummer <aaron@dummer.info>
Sat, 31 Dec 2011 05:21:52 +0000 (05:21 +0000)
ChangeLog
wwwroot/inc/database.php
wwwroot/inc/interface.php
wwwroot/inc/ophandlers.php

index da97e0d..6fc70c4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@
        update: when an object is contained within another, display the parent's rackspace allocation info when viewing the child (#432) 
        update: added the 'Slot number' attribute to object types which may be mounted in a blade chassis (#474)
        update: added an 'Uncheck all' button to the rackspace allocation page (#490)
+       update: ability to change cable ID without deleting & re-adding the link (#457)
        update: ability to delete IP prefixes from within its properties tab
        update: adding and deleting forms of IP prefixes are separated
 0.19.10 2011-10-17
index 799dd35..bde4545 100644 (file)
@@ -1424,7 +1424,7 @@ function linkPorts ($porta, $portb, $cable = NULL)
                (
                        'porta' => $porta,
                        'portb' => $portb,
-                       'cable' => mb_strlen ($cable) ? $cable : ''
+                       'cable' => mb_strlen ($cable) ? $cable : NULL
                )
        );
        $dbxlink->exec ('UNLOCK TABLES');
@@ -1449,6 +1449,17 @@ function linkPorts ($porta, $portb, $cable = NULL)
        unset ($result);
 }
 
+function commitUpdatePortLink ($port_id, $cable = NULL)
+{
+       return usePreparedUpdateBlade
+       (
+               'Link',
+               array ('cable' => mb_strlen ($cable) ? $cable : NULL),
+               array ('porta' => $port_id, 'portb' => $port_id),
+               'OR'
+       );
+}
+
 function commitUnlinkPort ($port_id)
 {
        // fetch and log existing link
index 877d81c..7193dd0 100644 (file)
@@ -1172,7 +1172,7 @@ function renderPortsForObject ($object_id)
                echo "<td><input type=text name=port_label tabindex=101></td><td>";
                printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 102), $prefs['selected']);
                echo "<td><input type=text name=port_l2address tabindex=103 size=18 maxlength=24></td>\n";
-               echo "<td colspan=3>&nbsp;</td><td>";
+               echo "<td colspan=4>&nbsp;</td><td>";
                printImageHREF ('add', 'add a port', TRUE, 104);
                echo "</td></tr></form>";
        }
@@ -1202,7 +1202,7 @@ function renderPortsForObject ($object_id)
        
        echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
        echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>L2 address</th>";
-       echo "<th class=tdcenter colspan=2>Cable, Remote object and port</th><th class=tdcenter>(Un)link or (un)reserve</th><th>&nbsp;</th></tr>\n";
+       echo "<th class=tdcenter colspan=2>Remote object and port</th><th>Cable ID</th><th class=tdcenter>(Un)link or (un)reserve</th><th>&nbsp;</th></tr>\n";
        if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
                printNewItemTR ($prefs);
 
@@ -1248,11 +1248,12 @@ function renderPortsForObject ($object_id)
                echo "<td><input type=text name=l2address value='${port['l2address']}' size=18 maxlength=24></td>\n";
                if ($port['remote_object_id'])
                {
-                       echo "<td>${port['cableid']} " .
+                       echo "<td>" .
                                formatLoggedSpan ($port['last_log'], formatPortLink ($port['remote_object_id'], $port['remote_object_name'], $port['remote_id'], NULL)) .
                                "</td>";
                        echo "<td> " . formatLoggedSpan ($port['last_log'], $port['remote_name'], 'underline') .
                                "<input type=hidden name=reservation_comment value=''></td>";
+                       echo "<td><input type=text name=cable value='${port['cableid']}'></td>";
                        echo "<td class=tdcenter><a href='".
                                makeHrefProcess(array(
                                        'op'=>'unlinkPort', 
@@ -1266,6 +1267,7 @@ function renderPortsForObject ($object_id)
                {
                        echo "<td>" . formatLoggedSpan ($port['last_log'], 'Reserved:', 'strong underline') . "</td>";
                        echo "<td><input type=text name=reservation_comment value='${port['reservation_comment']}'></td>";
+                       echo "<td></td>";
                        echo "<td class=tdcenter><a href='".
                                makeHrefProcess(array(
                                        'op'=>'useup',
@@ -1277,8 +1279,7 @@ function renderPortsForObject ($object_id)
                }
                else
                {
-                       //echo "<td>&nbsp;</td><td>&nbsp;</td><td class=tdcenter><a href='javascript:;'";
-                       echo "<td>&nbsp;</td><td>&nbsp;</td><td class=tdcenter><span";
+                       echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td class=tdcenter><span";
                        $helper_args = array
                        (
                                'port' => $port['id'],
index fb8ce6e..d09250c 100644 (file)
@@ -548,9 +548,11 @@ function editPortForObject ()
        assertUIntArg ('port_id');
        assertUIntArg ('port_type_id');
        assertStringArg ('reservation_comment', TRUE);
+       assertStringArg ('cable', TRUE);
        genericAssertion ('l2address', 'l2address0');
        genericAssertion ('name', 'string');
        commitUpdatePort ($sic['object_id'], $sic['port_id'], $sic['name'], $sic['port_type_id'], $sic['label'], $sic['l2address'], $sic['reservation_comment']);
+       commitUpdatePortLink ($sic['port_id'], $sic['cable']);
        return showFuncMessage (__FUNCTION__, 'OK', array ($_REQUEST['name']));
 }