initial commit of file from CVS for smeserver-dhcpmanager on Sat Sep 7 19:51:44 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 19:51:44 +10:00
parent c74767858a
commit f510f789c6
49 changed files with 12045 additions and 2 deletions

View File

@@ -0,0 +1,219 @@
% layout 'default', title => "Sme server 2 - DHCP Manager", share_dir => './';
% content_for 'module' => begin
<div id="module" class="module dhcpman-panel">
% if ($config->{debug} == 1) {
<p>
%= dumper $c->current_route
</p>
% }
<h1><%=$title%></h1>
%= $modul
%if ($dhcp_data->{first}) {
<br><p>
%=$c->render_to_string(inline =>$c->l($dhcp_data->{first}))
</p>
%} elsif ($dhcp_data->{success}) {
<div class='sme-border'>
<h2> Operation Status Report - success</h2><p>
<font color=green>
%= $c->l($dhcp_data->{success});
</font>
</p>
</div>
%} elsif ($dhcp_data->{error}) {
<div class='sme-error'>
<h2> Operation Status Report - error</h2><p>
<font color=red>
%= $c->l($dhcp_data->{error});
</font>
</p>
</div>
%} elsif ($dhcp_data->{error}) {
<div class='sme-warning'>
<h2> Operation Status Report - warning</h2><p>
<font color=orange>
%= $c->l($dhcp_data->{error});
</font>
</p>
</div>
%}
% if ($dhcp_data->{trt} eq 'LEASES') {
%= include 'partials/_dhcpd_leases'
%} elsif ($dhcp_data->{trt} eq 'SCAN') {
%= include 'partials/_dhcpd_scan'
%} 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', onclick=>"showSpinnerLeases()", id=>"scanLeases"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="load" style="display:none">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td><td>
%= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="loadingNetwork" style="display:none">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</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>
%= javascript begin
if (document.getElementById("load")){document.getElementById("load").style.display="none";}
if (document.getElementById("loadingNetwork")){document.getElementById("loadingNetwork").style.display="none";}
function showSpinnerLeases(){
document.getElementById("scanLeases").style.display="none";
document.getElementById("load").style.display="inline";
}
function showSpinnerNetwork(){
document.getElementById("scanNetwork").style.display="none";
document.getElementById("loadingNetwork").style.display="inline";
}
%end
%= stylesheet begin
.spinnerButtonOverlay,
.spinnerButtonOverlay:hover,
.spinnerButtonOverlay:any-link ,
.spinnerButtonOverlay:focus ,
.spinnerButtonOverlay:active {
appearance: auto;
user-select: none;
align-items: flex-start;
cursor: default;
box-sizing: border-box;
background-color: #efefef;
color: black;
padding: 1px 6px;
border-width: 2px;
border-style: outset;
border-color: darkgrey;
border-image: initial;
}
%end
%end
1;

View File

@@ -0,0 +1,113 @@
<div id='dhcpd-leases'>
<table><tr><td>
%= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="load" style="display:true">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td><td>
%= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4'
</td>
</tr>
</table>
% my $btn = l('dhcpd_SAVE/RESTART');
%= form_for '/dhcpd10' => (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 />
%= $c->l("dhcpd_SAVE_TITLE");
<br />
%= submit_button "$btn", class => 'action'
% end
<br>
<table class="sme-border TableSort"><thead>
<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>
</thead>
<tbody>
% foreach my $ip (@$leases) {
<tr>
%= t td => (class => 'sme-border') => $ip->{ip}
%= t td => (class => 'sme-border') => $ip->{name}
<td class='sme-border'>
% if ($ip->{wol} =~ /ACTIVE/) {
<center><%==l $ip->{wol}%></center>
%} else {
<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);"><center><%==l $ip->{wol}%></center></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}%>&name=<%= $ip->{name}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>
</td>
</tr>
%}
</tbody>
</table>
%= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
<br />
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
%= javascript begin
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 (confirm(msg+" IP: "+IP))
{ return true;}
else {event.preventDefault();return false;}
}
%end
</div>

View File

@@ -0,0 +1,63 @@
<div id='dhcpd-scan'>
<table><tr><td>
%= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
<button class ="btn btn-primary spinnerButtonOverlay" type = "submit" id="loadingNetwork1" style="display:true">
Scanning <!--%= $c->l('dhcpd_CONNECTED_IP')-->
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
</button>
</td>
</tr>
</table>
<table class="sme-border TableSort"><thead>
<tr>
<th class='sme-border'>
%=l 'dhcpd_NETWORK_NAME'
</th>
<th class='sme-border'>
%=l 'dhcpd_IP'
</th>
<th class='sme-border'>
%=l 'dhcpd_MAC_ADDRESS'
</th>
</tr>
</thead>
<tbody>
% foreach my $ip (@$scanresults) {
<tr>
%= t td => (class => 'sme-border') => $ip->{Network}
%= t td => (class => 'sme-border') => $ip->{ip}
%= t td => (class => 'sme-border') => $ip->{mac}
</tr>
%}
</tbody>
</table>
%= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
<br />
%= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
%= javascript begin
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;}
}
%end
</div>
%= javascript begin
document.getElementById("loadingNetwork1").style.display="none";
function showSpinnerNetwork1(){
document.getElementById("scanNetwork1").style.display="none";
document.getElementById("loadingNetwork1").style.display="inline";
}
%end