From: Thierry Parmentelat Date: Tue, 31 Aug 2010 10:37:02 +0000 (+0200) Subject: default is DHCP - virtual interface fields get disabled if unclicked X-Git-Tag: plewww-4.3-48~4 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=5599b78dd300a1146e9a9b4641f6423ea54f8ab6;p=plewww.git default is DHCP - virtual interface fields get disabled if unclicked --- diff --git a/planetlab/nodes/interface.js b/planetlab/nodes/interface.js index 0eea2d5..0d0ed81 100644 --- a/planetlab/nodes/interface.js +++ b/planetlab/nodes/interface.js @@ -191,4 +191,11 @@ function interfaceSubmit () { } } +function updateVirtualArea () { + var is_virtual=$('virtual').checked; + $('ifname').disabled = ! is_virtual; + $('alias').disabled = ! is_virtual; +} +Event.observe(window, 'load', updateMethodFields); +Event.observe(window, 'load', updateVirtualArea); diff --git a/planetlab/nodes/interface.php b/planetlab/nodes/interface.php index 338b9b8..a2d13c2 100644 --- a/planetlab/nodes/interface.php +++ b/planetlab/nodes/interface.php @@ -15,6 +15,7 @@ require_once 'linetabs.php'; require_once 'details.php'; require_once 'table.php'; require_once 'toggle.php'; +require_once 'prototype.php'; require_once 'plc_drupal.php'; include 'plc_header.php'; @@ -89,8 +90,7 @@ $form=$details->form_start(l_actions(),$form_variables, $details->start(); if ($mode == 'add') - // would have preferred 'dhcp' as a default but could not figure how to trigger updateMethodFields on startup - $method_default = 'static'; + $method_default = 'dhcp'; else $method_default = $interface['method']; $method_select = $form->select_html ("method", @@ -131,8 +131,10 @@ switch ($mode) { $is_primary = (count($node['interface_ids']) == 0); if ( ! $is_primary) { // default is to create virtual interfaces - $details->th_th($form->checkbox_html('is-virtual','yes',array('checked'=>'checked')), - "Virtual Interface"); + $details->th_th("Virtual Interface", + $form->checkbox_html('is-virtual','yes',array('id'=>'virtual', + 'checked'=>'checked', + 'onChange'=>'updateVirtualArea()'))); $details->th_td("Interface name","eth0",'ifname'); $details->th_td("alias (leave empty if unsure)","",'alias'); }