Line 463: |
Line 463: |
| </syntaxhighlight>and finally the front panel details is defined: | | </syntaxhighlight>and finally the front panel details is defined: |
| <syntaxhighlight lang="perl"> | | <syntaxhighlight lang="perl"> |
− | else { #PARAMS | + | %} else { #PARAMS |
| + | % my $ip_regex = '^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$'; |
| + | <table><tr><td> |
| + | %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1' |
| + | </td><td> |
| + | %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3' |
| + | </td><td> |
| + | %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2' |
| + | <td> |
| + | </tr> |
| + | </table> |
| + | <hr /> |
| + | <h2> |
| + | %= $c->l("dhcpd_DHCPD_SETTINGS_TITLE") |
| + | </h2> |
| + | % my $btn = l('dhcpd_SAVE/RESTART'); |
| + | %= form_for '/dhcpd5' => (method => 'POST') => begin |
| + | <span class=label> |
| + | %=l 'dhcpd_CHECK_CLIENT_STATUS' |
| + | </span><span class=data> |
| + | % param dhcp_check=>$dhcp_data->{"params"}->{"check"}; |
| + | %=select_field dhcp_check=>$dhcp_data->{"check"} |
| + | </span><br> |
| + | <br /> |
| + | <span class=label> |
| + | %=l 'dhcpd_STATUS_DHCP_SERVER' |
| + | </span><span class=data> |
| + | % param dhcp_enable=>$dhcp_data->{"params"}->{"status"}; |
| + | %=select_field dhcp_enable=>$dhcp_data->{"status"} |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_DHCP_START' |
| + | </span><span class=data> |
| + | % param dhcp_start=>$dhcp_data->{"params"}->{"start"}; |
| + | %=text_field 'dhcp_start',minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_DHCP_END' |
| + | </span><span class=data> |
| + | % param dhcp_end=>$dhcp_data->{"params"}->{"end"}; |
| + | %=text_field 'dhcp_end',minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br><br /> |
| + | |
| + | %= $c->l("dhcpd_CUSTOM_WINSERVER_TITLE"); |
| + | <br /> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_WINSERVER_STATUS' |
| + | </span><span class=data> |
| + | % param dhcp_winscustom=>$dhcp_data->{"params"}->{"winscustom"}; |
| + | %=select_field dhcp_winscustom=>$dhcp_data->{"status"} |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_WINSERVER_ADDRESS' |
| + | </span><span class=data> |
| + | % param dhcp_winsserver=>$dhcp_data->{"smbparams"}->{"WINSServer"}; |
| + | %=text_field 'dhcp_winsserver' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br><br /> |
| + | |
| + | %= $c->l("dhcpd_CUSTOM_DNS_TITLE"); |
| + | <br /> |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_DNS_STATUS' |
| + | </span><span class=data> |
| + | % param dhcp_dnscustom=>$dhcp_data->{"params"}->{"dnscustom"}; |
| + | %=select_field dhcp_dnscustom=>$dhcp_data->{"status"} |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_PRIMARY_DNS_ADDRESS' |
| + | </span><span class=data> |
| + | % param dhcp_dns1server=>$dhcp_data->{"params"}->{"dns1server"}; |
| + | %=text_field 'dhcp_dns1server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_SECONDARY_DNS_ADDRESS' |
| + | </span><span class=data> |
| + | % param dhcp_dns2server=>$dhcp_data->{"params"}->{"dns2server"}; |
| + | %=text_field 'dhcp_dns2server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_TERTIARY_DNS_ADDRESS' |
| + | </span><span class=data> |
| + | % param dhcp_dns3server=>$dhcp_data->{"params"}->{"dns3server"}; |
| + | %=text_field 'dhcp_dns3server' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br> |
| + | |
| + | %= $c->l("dhcpd_CUSTOM_GATEWAY_TITLE"); |
| + | <br /> |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_GATEWAY_STATUS' |
| + | </span><span class=data> |
| + | % param dhcp_gatewaycustom=>$dhcp_data->{"params"}->{"gatewaycustom"}; |
| + | %=select_field dhcp_gatewaycustom=>$dhcp_data->{"status"} |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_GATEWAY_ADDRESS' |
| + | </span><span class=data> |
| + | % param dhcp_gateway=>$dhcp_data->{"params"}->{"gateway"}; |
| + | %=text_field 'dhcp_gateway' ,minlength=>'7',maxlength=>"15",size=>"15",placeholder=>"nnn.nnn.nnn.nnn", pattern=>"$ip_regex" |
| + | </span><br><br /> |
| + | %= $c->l("dhcpd_CUSTOM_LEASETIME_TITLE"); |
| + | <br /> |
| + | <span class=label> |
| + | %=l 'dhcpd_CUSTOM_LEASETIME' |
| + | </span><span class=data> |
| + | % param dhcp_leasetime=>$dhcp_data->{"params"}->{"leasetime"}; |
| + | %=number_field 'dhcp_leasetime' |
| + | </span><br><br /> |
| + | %= submit_button "$btn", class => 'action' |
| + | % end |
| + | %} |
| + | |
| + | </div> |
| + | %end |
| + | </syntaxhighlight>This shows the top few controls for the panel. Note the use of the table to keep the buttons in a row and also the structure of each parameter row involving the <nowiki><span> tags and the <br></nowiki> to create newlines. Use of this structure will keep your panel in line with both the default and the AdminLTE themes. You need not do this of course! |
| + | |
| + | From the form command at the top it can be seen that clicking the "Save/Restart" button will lead to a routing through dhcpd5 which will result in the perl sub "do_update_config" being executed, which will save all the parameters back to the DB. |
| + | |
| + | === The Partials files can be used to keep the structure in mulitple files. === |
| + | We will look at just one to display the lease table. <syntaxhighlight lang="perl"> |
| + | <div id='dhcpd-leases'> |
| <table><tr><td> | | <table><tr><td> |
− | %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1' | + | %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1' |
− | </td><td>
| |
− | %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3'
| |
| </td><td> | | </td><td> |
− | %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2' | + | %= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4' |
− | <td> | + | </td> |
| </tr> | | </tr> |
| </table> | | </table> |
| <hr /> | | <hr /> |
− | <h2>
| |
− | %= $c->l("dhcpd_DHCPD_SETTINGS_TITLE")
| |
− | </h2>
| |
| % my $btn = l('dhcpd_SAVE/RESTART'); | | % my $btn = l('dhcpd_SAVE/RESTART'); |
− | %= form_for '/dhcpd5' => (method => 'POST') => begin
| + | %= form_for '/dhcpd5' => (method => 'POST') => begin |
− | <span class=label>
| + | <span class=label> |
− | %=l 'dhcpd_CHECK_CLIENT_STATUS'
| + | %=l 'dhcpd_CHECK_CLIENT_STATUS' |
− | </span><span class=data>
| + | </span><span class=data> |
− | % param checkclientstatus=>$dhcp_data->{"params"}->{"check"};
| + | % param dhcp_check=>$dhcp_data->{"params"}->{"check"}; |
− | %=select_field checkclientstatus=>$dhcp_data->{"check"}
| + | %=select_field dhcp_check=>$dhcp_data->{"check"} |
− | </span><br>
| + | </span><br> |
− | <br />
| + | <br /> |
− | <span class=label>
| + | %= $c->l("dhcpd_SAVE_TITLE"); |
− | %=l 'dhcpd_STATUS_DHCP_SERVER'
| + | <br /> |
− | </span><span class=data>
| |
− | % param dhcpstatus=>$dhcp_data->{"params"}->{"status"};
| |
− | %=select_field dhcpstatus=>$dhcp_data->{"status"} | |
− | </span><br>
| |
| | | |
− | <span class=label>
| + | %= submit_button "$btn", class => 'action' |
− | %=l 'dhcpd_DHCP_START' | |
− | </span><span class=data>
| |
− | % param dhcpstart=>$dhcp_data->{"params"}->{"start"};
| |
− | %=text_field 'dhcpstart'
| |
− | </span><br>
| |
− |
| |
− | <span class=label>
| |
− | %=l 'dhcpd_DHCP_END'
| |
− | </span><span class=data>
| |
− | % param dhcpend=>$dhcp_data->{"params"}->{"end"};
| |
− | %=text_field 'dhcpend'
| |
− | </span><br><br />
| |
− | ====== snip =============
| |
− | %= submit_button "$btn", class => 'action'
| |
| % end | | % end |
− | %} | + | <br> |
− | </div> | + | |
− | %end | + | <table class="sme-border"><tbody> |
− | </syntaxhighlight>This shows the top few controls for the panel. Note the use of the table to keep the buttons in a row and also the structure of each parameter row involving the <nowiki><span> tags and the <br></nowiki> to create newlines. Use of this structure will keep your panel in line with both the default and the AdminLTE themes. You need not do this of course! | + | <tr> |
| + | <th class='sme-border'> |
| + | %=l 'dhcpd_IP' |
| + | </th> |
| + | <th class='sme-border'> |
| + | %=l 'dhcpd_NETWORK_NAME' |
| + | </th> |
| + | <th class='sme-border'> |
| + | %=l 'dhcpd_STATUS_CLICK_FOR_WOL' |
| + | </th> |
| + | <th class='sme-border'> |
| + | %=l('dhcpd_START_DATE',"") |
| + | </th> |
| + | <th class='sme-border'> |
| + | %=l 'dhcpd_END_DATE' |
| + | </th> |
| + | <th class='sme-border'> |
| + | %=l 'dhcpd_MAC_ADDRESS' |
| + | </th> |
| + | <th class='sme-border' colspan=2> |
| + | %=l 'dhcpd_ACTION' |
| + | </th> |
| + | </tr> |
| + | % foreach my $ip (@$leases) { |
| + | <tr> |
| + | %= t td => (class => 'sme-border') => $ip->{ip} |
| + | %= t td => (class => 'sme-border') => $ip->{name} |
| + | <td class='sme-border'> |
| + | <a href="/smanager/dhcpd9??state=wake_up&MAC=<%= $ip->{mac}%>&name=<%= $ip->{name}%>" onclick="Wol_confirm(event,'<%=$c->l('dhcpd_WAKING_A_REMOTE_COMPUTER')%>',this);"><%=l $ip->{wol}%></a> |
| + | </td> |
| + | %= t td => (class => 'sme-border') => $ip->{start} |
| + | %= t td => (class => 'sme-border') => $ip->{end} |
| + | %= t td => (class => 'sme-border') => $ip->{mac} |
| + | <td class = 'sme-border'> |
| + | <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><%=l 'dhcpd_REMOVE'%></a> |
| + | <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><%=l 'dhcpd_WINPOPUP_ACTION'%></a> |
| + | </td> |
| + | </tr> |
| + | %} |
| + | </tbody> |
| + | </table> |
| + | %= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg" |
| + | <br /> |
| + | %= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd' |
| + | <script> |
| + | //var form = document.getElementById("dhcpd-leases").getElementsByTagName('a'); |
| + | //confirm("Form elements:"+form.length); |
| + | //for (let i = 0; i<form.length; i++) { |
| + | //form[i].onclick = function() { |
| + | // return confirm("html:"+i); |
| + | //} |
| + | //} |
| + | //function Wol_confirm(){ |
| + | // if confirm("Confirm Wake on Lan to be sent to:"+this.href) then window.location.href='' |
| + | //} |
| + | function Wol_confirm(event,msg,current){ |
| + | const getMAC = /.*MAC\=(.*)\&name.*/; |
| + | var MAC = current.href.match(getMAC)[1]; |
| + | if (confirm(msg+": MAC: "+MAC)) |
| + | { return true;} |
| + | else {event.preventDefault();return false;} |
| + | } |
| + | |
| + | function Winpop_confirm(event,msg,current){ |
| + | const getIP = /.*ip\=(.*)/; |
| + | var IP = ": IP: "+current.href.match(getIP)[1]; |
| + | msg = msg.replace("$",IP); |
| + | var retVal = prompt(msg); |
| + | if (retVal) { |
| + | //Write it away in a hidden field |
| + | $hidden = document.getElementById("hiddenMsg"); |
| + | $hidden.value = retVal; |
| + | return true; |
| + | } else {event.preventDefault();return false;} |
| + | } |
| + | |
| + | function Remove_lease_confirm(event,msg,current){ |
| + | const getIP = /.*ip\=(.*)/; |
| + | var IP = current.href.match(getIP)[1]; |
| + | if (prompt(msg+" IP: "+IP)) |
| + | { return true;} |
| + | else {event.preventDefault();return false;} |
| + | } |
| + | |
| + | </script> |
| | | |
− | From the form command at the top it can be seen that clicking the "Save/Restart" button will lead to a routing through dhcpd5 which will result in the perl sub "do_update_config" being executed, which will save all 'the parameters back to the DB.
| |
| | | |
− | === The Partials files can be used to keep the structure in mulitple files. ===
| + | </div> |
− | We will look at just one to display the lease table.
| + | </syntaxhighlight> |
| | | |
| ===Translation Strings files=== | | ===Translation Strings files=== |