/[smecontribs]/rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch
ViewVC logotype

Diff of /rpms/smeserver-dhcpmanager/contribs10/smeserver-dhcpmanager-2.0.4-Yet-more-changes-for-SM2-panels.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

Revision 1.2 by brianr, Sun Dec 31 14:45:40 2023 UTC Revision 1.8 by brianr, Tue Jan 23 10:54:38 2024 UTC
# Line 1  Line 1 
1  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm
2  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm     2023-12-19 09:44:56.678590486 +0000
3  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2023-12-31 13:44:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/Controller/Dhcpd.pm 2024-01-23 10:14:00.000000000 +0000
4  @@ -117,22 +117,41 @@  @@ -140,12 +140,12 @@
      $c->render( template => 'dhcpd' );  
  }        
   
 -  
 -sub do_winpopup {  
 -       #  
 -       # call to win pop up  
 -       #  
 +sub netmask2cidr {  
         my $c = shift;  
 -    my $title = $c->l("dhcpd_GLOBAL_WINPOPUP");  
 -    my $modul = '';  
 -    my $trt   = "WINPOPUP";  
 -    $dhcp_data{trt} = $trt;  
 -    $dhcp_data{"first"} = '';  
 -       #..... get winpopup details  
 -    $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );  
 -    $c->render( template => 'dhcpd' );  
 +    #my ($mask, $network) = @_;  
 +       my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');  
 +       my $mask = $nmap_sme->get_value('LocalNetmask');  
 +       my $network = $nmap_sme->get_prop('InternalInterface','Network');  
 +    my @octet = split (/\./, $mask);  
 +    my @bits;  
 +    my $binmask;  
 +    my $binoct;  
 +    my $bitcount=0;  
 +  
 +    foreach (@octet) {  
 +      $binoct = dec2bin($_);  
 +      $binmask = $binmask . substr $binoct, -8;  
 +    }  
 +  
 +    # let's count the 1s  
 +    @bits = split (//,$binmask);  
 +    foreach (@bits) {  
 +      if ($_ eq "1") {  
 +        $bitcount++;  
 +      }  
 +    }  
 +  
 +    my $cidr = $network . "/" . $bitcount;  
 +    return $cidr;  
  }  
   
 +sub dec2bin {  
 +  my $str = unpack("B32", pack("N", shift));  
 +  return $str;  
 +}  
 +  
 +  
  sub do_scan {  
         #  
         # call to show scan results  
 @@ -140,12 +159,13 @@  
5          my $c = shift;          my $c = shift;
6       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");       my $title = $c->l("dhcpd_SCANNING_NETWORK_TITLE");
7       my $modul = '';       my $modul = '';
# Line 64  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 9  diff -urN smeserver-dhcpmanager-2.0.4.ol
9  +    my $trt   = "SCAN";  +    my $trt   = "SCAN";
10       $dhcp_data{trt} = $trt;       $dhcp_data{trt} = $trt;
11       $dhcp_data{"first"} = '';       $dhcp_data{"first"} = '';
12          # ..... get scan results into dhcp_data  -       # ..... get scan results into dhcp_data
13  -       dhcp_data{"scanresults"} = get_scan_results($c);  -       dhcp_data{"scanresults"} = get_scan_results($c);
14  -    $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );  -    $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data );
15  +       $dhcp_data{"cidr"} = netmask2cidr($c);  +       # ..... get scan results into stash for passing to html template
16  +       my @scanresults =  get_scan_results($c);  +       my $dhcp_scanresults = get_scan_results($c);
17  +    $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data, scanresults => @scanresults );  +    $c->stash( title => $title, modul => $modul, "dhcp_data" => \%dhcp_data, "scanresults" => $dhcp_scanresults);
18       $c->render( template => 'dhcpd' );       $c->render( template => 'dhcpd' );
19   }   }
20        
21  @@ -314,7 +334,6 @@  @@ -332,10 +332,10 @@
          }  
      }      
         
 -  
      # - 4 expand templates  
      # changed to new sme standard signal-event  
      system ("/sbin/e-smith/signal-event","workgroup-update") == 0  
 @@ -332,10 +351,10 @@  
22          my $c = shift;          my $c = shift;
23       my $ret = delete_all_leases($c);       my $ret = delete_all_leases($c);
24          if ($ret == 'ok') {          if ($ret == 'ok') {
25  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
26  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_REMOVED_ALL_LEASES";  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
27                  do_leases($c);                  do_leases($c);
28          }                }      
29  -       else {dhcp_data{"error"}=$ret;}  -       else {dhcp_data{"error"}=$ret;}
# Line 94  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 31  diff -urN smeserver-dhcpmanager-2.0.4.ol
31       return ;       return ;
32   }   }
33    
34  @@ -352,17 +371,39 @@  @@ -350,19 +350,19 @@
35         # delete it
36         # If deletion not ok return message
37       # else return "ok"       # else return "ok"
38       my $ret = delete_lease($c);  -    my $ret = delete_lease($c);
39    +    my $ret = delete_one_lease($c);
40          if ($ret == 'ok') {          if ($ret == 'ok') {
41  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";  -               dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
42  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_DELETED_THE_CLIENT";  +               $dhcp_data{"success"}="dhcpd_SUCCESSFULLY_SAVED_SETTINGS";
43                  do_leases($c);                  do_leases($c);
44          }                }      
45  -       else {dhcp_data{"error"}=$ret;}  -       else {dhcp_data{"error"}=$ret;}
# Line 109  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 49  diff -urN smeserver-dhcpmanager-2.0.4.ol
49    
50   sub get_scan_results {   sub get_scan_results {
51          my $c = shift;          my $c = shift;
52  -       #...do it          #...do it
53  -       return "results";  -       return "results";
54  +       my $cidr = netmask2cidr($c);  +       return Scan_Local_Network($c);
 +       my $res = execute_nmap($cidr);  
 +       return $res;  
 +}  
 +  
 +sub execute_nmap {  
 +    my ($ip, $port) = @_;  
 +    my @result;  
 +    my $nmapcmd = qq(/usr/bin/nmap --script smb-os-discovery.nse -p U:137,T:139 $ip| \  
 +             /bin/grep -Ev "MAC|NetBIOS|OS CPE"| /bin/grep -E "scan|done|Computer|OS"| \  
 +             /bin/sed -e 's/Nmap scan/-- Scan/g'|/bin/sed -e 's/done/Done/g'| \  
 +             /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g');  
 +  
 +    open my $nmap, '-|', "$nmapcmd" or die "Can't start nmap: $!";  
 +  
 +    while (my $line = <$nmap>) {  
 +        chomp $line;  
 +        my @fields = split /\s+/, $line;  
 +        push @result, \@fields;  
 +    }  
 +  
 +    close $nmap;  
 +  
 +    return \@result;  
55   }   }
56                    
57    
58  @@ -374,13 +415,45 @@  @@ -374,13 +374,13 @@
59    
60   sub delete_one_lease {   sub delete_one_lease {
61          my $c = shift;            my $c = shift;  
62  -    # ...do it  -    # ...do it
63    +       Perform_Del_Lease($c);
64         return "ok";
65     }
66    
67     sub delete_all_leases {
68            my $c = shift;  
69    -    # ...do it
70    +       Perform_del_all_Lease($c);
71         return "ok";
72     }
73    
74    @@ -391,6 +391,171 @@
75         return @leases;
76     }
77    
78    +
79    +sub Perform_del_all_Lease ($){
80    +
81    +       system ('/bin/echo "" > /var/lib/dhcpd/dhcpd.leases') ==0
82    +                or die "Error while removing all leases: $!";
83    +      
84    +       system ("/sbin/e-smith/signal-event","workgroup-update") == 0
85    +                or die "Error while saving settings: $!";
86    +                  
87    +     return 'ok';
88    +    exit;
89    +}  
90    +
91    +#===============================================================================
92    +#SUBROUTINE: Perform delete lease
93    +#===============================================================================
94    +sub Perform_Del_Lease($){
95    +
96    +    ###Pull CGI object from parameters array
97    +    my $c = shift;
98    +
99    +#my $fred = 1/0;
100  +  +
101  +    ###Pull entry to delete  +    ###Pull entry to delete
102  +    my $ip = $c->param('host');  +    my $ip = $c->param('ip');
103  +    my $name = $c->param('name');  +    my $name = $c->param('name');
104  +       my $name_in_file = '/var/lib/dhcpd/dhcpd.leases'  ;  +       my $name_in_file = '/var/lib/dhcpd/dhcpd.leases'  ;
105  +       my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp'  ;  +       my $name_tmp_file = '/var/lib/dhcpd/dhcpd.leases.tmp'  ;
# Line 171  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 125  diff -urN smeserver-dhcpmanager-2.0.4.ol
125  +    # changed to new sme standard signal-event  +    # changed to new sme standard signal-event
126  +    system ("/sbin/e-smith/signal-event","workgroup-update") == 0  +    system ("/sbin/e-smith/signal-event","workgroup-update") == 0
127  +                or die "Error while saving settings: $!";  +                or die "Error while saving settings: $!";
128       return "ok";  +    ###Return action message
129   }  +    return $c->l('SUCCESSFULLY_DELETED_THE_CLIENT') . ' (' . $name . '/' . $ip .')';
130    +}
131   sub delete_all_leases {  +
132          my $c = shift;    +#===============================================================================
133  -    # ...do it  +#SUBROUTINE: Scan The Local Network
134  +       system ('/bin/echo "" > /var/lib/dhcpd/dhcpd.leases') ==0  +#===============================================================================
135  +                       or die "Error while removing all leases: $!";  +sub dec2bin {
136    +  my $str = unpack("B32", pack("N", shift));
137    +  return $str;
138    +}
139    +
140    +sub netmask2cidr {
141    +    my ($mask, $network) = @_;
142    +    my @octet = split (/\./, $mask);
143    +    my @bits;
144    +    my $binmask;
145    +    my $binoct;
146    +    my $bitcount=0;
147    +
148    +    foreach (@octet) {
149    +      $binoct = dec2bin($_);
150    +      $binmask = $binmask . substr $binoct, -8;
151    +    }
152    +
153    +    # let's count the 1s
154    +    @bits = split (//,$binmask);
155    +    foreach (@bits) {
156    +      if ($_ eq "1") {
157    +        $bitcount++;
158    +      }
159    +    }
160    +    my $cidr = $network . "/" . $bitcount;
161    +    return $cidr;
162    +}
163    +
164    +sub get_mac_address {
165    +       # From the leases file
166    +    my ($ip, $file) = @_;
167    +    open(my $fh, '<', $file) or die "Could not open file '$file' $!";
168    +    my $mac_address = undef;
169    +    my $lease_block;
170    +    while(my $line = <$fh>) {
171    +        if($line =~ /lease $ip {/ .. $line =~ /}/) {
172    +            $lease_block .= $line;
173    +            if($line =~ /}/) {
174    +                if($lease_block =~ /hardware ethernet (\S+);/) {
175    +                    $mac_address = $1;
176    +                    last;
177    +                } else {
178    +                    $lease_block = '';
179    +                }
180    +            }
181    +        }
182    +    }
183    +    close $fh;
184    +    return $mac_address;
185    +}
186    +
187    +sub  trim { my $s = shift; $s =~ s/^\s+|\s+$//g; return $s };
188    +
189    +sub get_mac_address_by_ping {
190    +    my ($ip) = trim(@_);
191    +    # Ping the IP to ensure it's in the ARP table
192    +    my $ping_result = `ping -c 1 -W 1 $ip`;
193    +    #return $ping_result;
194    +    if($ping_result =~ m/1 packets transmitted, 1 received/) {
195    +        # Fetch the ARP table and find the line with the IP address
196    +        my $mac_result = `nmap -PR -sn $ip`;
197    +        #return "*$arp_result *$ip*";
198    +        # If found, return the MAC address
199    +        #if ($arp_result =~ m/.*at ((?:[0-9a-f]{2}\:){5}[0-9a-f]{2})/) {
200    +               if ($mac_result =~ /MAC Address: (..:..:..:..:..:..) /) {
201    +            return $1;
202    +        } else { return "mac not in nmap result";}
203    +    } else { return "no ping";}
204    +    return undef;
205    +}
206    +
207    +
208    +
209    +sub Scan_Local_Network ($) {          
210  +    +  
211  +   system ("/sbin/e-smith/signal-event","workgroup-update") == 0  +        my $nmap_sme = esmith::ConfigDB->open('/home/e-smith/db/configuration');
212  +                       or die "Error while saving settings: $!";  +        my $mask = $nmap_sme->get_value('LocalNetmask');
213  +                            +        my $network = $nmap_sme->get_prop('InternalInterface','Network');
214       return "ok";  +
215   }  +#we start to calculate the method to find the cidr (we want to use network/cidr with nmap)  
216    +   my $cidr = netmask2cidr($mask, $network);
217  @@ -498,13 +571,6 @@  +
218          return @results;  +#ok go to use nmap with nmap -T4 -sP network/cidr
219   }  +       my @nmap_output= `/usr/bin/nmap --script smb-os-discovery.nse -p U:137,T:139 $cidr|
220    +                               /bin/grep -Ev "MAC|NetBIOS|OS CPE"| /bin/grep -E "scan|done|Computer|OS"|
221  -sub winpopup{  +                               /bin/sed -e 's/Nmap scan/-- Scan/g'|/bin/sed -e 's/done/Done/g'|
222  -       my $c = shift;  +                               /bin/sed -e 's/Nmap//g'|/bin/sed -e 's/|/  /g'`;
223  -       # Message in $c->param("winpopupmsg")  +      
224  -    # .... do it  +    my @extracted_output;
225  -    return TRUE;  +    my $leasefile = "/var/lib/dhcpd/dhcpd.leases";
226  -}        +    foreach my $line (@nmap_output) {
227  -  +        if ($line =~ m/Scan report for ([\w\.-]+) \(([\d\.\:]+)\)/) {
228   sub do_wol{  +                       my $ip = $2;
229          my $c = shift;  +                       my $mac = get_mac_address($ip,$leasefile);
230          my $retVal = Perform_Wake_Up($c);  +                       if (!$mac){
231  @@ -536,4 +602,4 @@  +                               $mac = get_mac_address_by_ping($ip);
232    +                       }
233    +#                      if (!$mac) {$mac = "unknown";}
234    +                       my %pair = ('Network' => $1, 'ip' => $ip, 'mac' => $mac);  # $1 => PC Name, $2 => IP Address
235    +                       push @extracted_output, \%pair;
236    +       }
237    +    }
238    +    return \@extracted_output;
239    +}
240    +                
241    +
242    +
243     #=========================================================================
244     # Procedure qui charge le dhcpd.conf
245     # retourne un tableau contenant les informations
246    @@ -536,4 +701,4 @@
247    
248   1;   1;
249    
# Line 209  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 252  diff -urN smeserver-dhcpmanager-2.0.4.ol
252  +        +      
253  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm
254  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm        1970-01-01 01:00:00.000000000 +0100  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm        1970-01-01 01:00:00.000000000 +0100
255  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm    2023-12-30 11:30:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpd/en.pm    2024-01-20 08:46:00.000000000 +0000
256  @@ -0,0 +1,109 @@  @@ -0,0 +1,109 @@
257  +package SrvMngr::I18N::Modules::Dhcpd::en;  +package SrvMngr::I18N::Modules::Dhcpd::en;
258  +use strict;  +use strict;
# Line 322  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 365  diff -urN smeserver-dhcpmanager-2.0.4.ol
365  +1;  +1;
366  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep
367  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep      2023-12-19 09:44:56.680590493 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep      2023-12-19 09:44:56.680590493 +0000
368  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  2023-12-31 13:55:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/dhcpd.html.ep  2024-01-20 17:01:00.000000000 +0000
369  @@ -49,23 +49,30 @@  @@ -49,24 +49,26 @@
370    
371          % if ($dhcp_data->{trt} eq 'LEASES') {          % if ($dhcp_data->{trt} eq 'LEASES') {
372                  %= include 'partials/_dhcpd_leases'                  %= include 'partials/_dhcpd_leases'
373  -       %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') {  -       %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') {
374  -               %= include 'partials/_dhcpd_winpopup'  -               %= include 'partials/_dhcpd_winpopup'
375          %} elsif ($dhcp_data->{trt} eq 'SCAN') {          %} elsif ($dhcp_data->{trt} eq 'SCAN') {
376  -               %= include 'partials/_dhcpd_scan'                  %= include 'partials/_dhcpd_scan'
 +               %= include 'partials/_dhcpd_scanresults'  
377          %} else {                                       #PARAMS          %} else {                                       #PARAMS
378                  % 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])$';                  % 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])$';
379                  <table><tr><td>  -               <table><tr><td>
380  -               %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases"  -               %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases"
381  -               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">  -               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">
382  -                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  -                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
383  +               %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showLeasesSpinner()", id=>"scanLeases"  -                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
384  +               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadLeases" style="display:true">  -               </button>
385  +                 Scanning  -               </td><td>
                   <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  
                 </button>  
 +                
                 </td><td>  
386  -               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3'  -               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3'
387  -               </td><td>  -               </td><td>
388  -               %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2'  -               %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2'
389  +               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showNetworkSpinner()", id=>"scanNetwork"  -               <td>
390  +               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadNetwork" style="display:true">  -               </tr>
391  +                       Scanning  +               <table>
392  +                       <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  +                       <tr>
393  +               </button>  +                       <td>
394  +  +                               %= button_to $c->l('dhcpd_CONNECTED_IP') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases"
395  +               </td>  +                               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">
396  +               <!--  +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
397                  <td>  +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
398  +               %= button_to $c->l('dhcpd_GLOBAL_WINPOPUP') => '/dhcpd2'  +                               </button>
399  +               </td>  +                       </td><td>      
400  +               -->  +                               %= button_to $c->l('dhcpd_SCAN_YOUR_NETWORK') => '/dhcpd3', onclick=>"showSpinnerNetwork()", id=>"scanNetwork"
401                  </tr>  +                               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork" style="display:true">
402    +                                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
403    +                                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
404    +                               </button>
405    +                       </td>
406    +                       </tr>
407                  </table>                    </table>  
408                  <hr />                  <hr />
409  @@ -179,10 +186,15 @@                  <h2>
410   </div>  @@ -180,10 +182,17 @@
411    
412   %= javascript begin   %= javascript begin
413  -  document.getElementById("load").style.display="none";     document.getElementById("load").style.display="none";
414  -  function showSpinner(){  -  function showSpinner(){
415  +  document.getElementById("loadLeases").style.display="none";  +  document.getElementById("loadingNetwork").style.display="none";
416  +  document.getElementById("loadNetwork").style.display="none";  +
417  +  function showLeasesSpinner(){  +  function showSpinnerLeases(){
418            document.getElementById("scanLeases").style.display="none";            document.getElementById("scanLeases").style.display="none";
419  -         document.getElementById("load").style.display="inline";            document.getElementById("load").style.display="inline";
 +         document.getElementById("loadLeases").style.display="inline";  
 +   }  
 +  function showNetworkSpinner(){  
 +         document.getElementById("scanNetwork").style.display="none";  
 +         document.getElementById("loadNetwork").style.display="inline";  
420      }      }
421    +
422    +  function showSpinnerNetwork(){
423    +         document.getElementById("scanNetwork").style.display="none";
424    +         document.getElementById("loadingNetwork").style.display="inline";
425    +   }
426   %end   %end
427    
428     %= stylesheet begin
429    @@ -205,7 +214,6 @@
430         border-color: darkgrey;
431         border-image: initial;
432     }
433    -
434     %end
435    -
436     %end
437    +1;
438  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep
439  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep     2023-12-19 09:44:56.681590497 +0000  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep     2023-12-19 09:44:56.681590497 +0000
440  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2023-12-31 14:11:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep 2024-01-23 10:12:00.000000000 +0000
441  @@ -1,8 +1,8 @@  @@ -1,17 +1,17 @@
442   <div id='dhcpd-leases'>   <div id='dhcpd-leases'>
443          <table><tr><td>          <table><tr><td>
444  -       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases"  -       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinner()", id=>"scanLeases"
445  -       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">  -       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">
446  -         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->  -         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
447  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showLeaseSpinner()", id=>"scanLeases"  -         <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
448  +       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadLease" style="display:true">  -       </button>
449  +         Scanning    -
450            <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>  -       </td><td>
451          </button>  -       %= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4'
452    -       </td>
453    -       </tr>
454    +               %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd1', onclick=>"showSpinnerLeases()", id=>"scanLeases"
455    +               <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="load" style="display:true">
456    +                 Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
457    +                 <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
458    +               </button>
459    +
460    +               </td><td>
461    +               %= button_to $c->l('dhcpd_REMOVE_ALL_LEASES') => '/dhcpd4'
462    +               </td>
463    +               </tr>
464         </table>    
465    -       <hr />
466    +
467            % my $btn = l('dhcpd_SAVE/RESTART');
468            %= form_for '/dhcpd10' => (method => 'POST') => begin
469                    <span class=label>
470  @@ -26,7 +26,7 @@  @@ -26,7 +26,7 @@
471                  %= submit_button "$btn", class => 'action'                  %= submit_button "$btn", class => 'action'
472       % end       % end
# Line 415  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 485  diff -urN smeserver-dhcpmanager-2.0.4.ol
485           % foreach my $ip (@$leases) {           % foreach my $ip (@$leases) {
486           <tr>           <tr>
487                          %= t td => (class => 'sme-border') => $ip->{ip}                          %= t td => (class => 'sme-border') => $ip->{ip}
488  @@ -66,9 +68,12 @@  @@ -65,9 +67,7 @@
489                            %= t td => (class => 'sme-border') => $ip->{end}
490                          %= t td => (class => 'sme-border') => $ip->{mac}                          %= t td => (class => 'sme-border') => $ip->{mac}
491                          <td class = 'sme-border'>                                        <td class = 'sme-border'>              
492                                  <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>  -                               <a href="/smanager/dhcpd6?trt=DEL&ip=<%= $ip->{ip}%>" onclick="Remove_lease_confirm(event,'<%=$c->l('dhcpd_REMOVE_A_DHCP_LEASE_ACTION')%>',this);"><center><%=l 'dhcpd_REMOVE'%></center></a>
493  -                       </td><td class = 'sme-border'>  -                       </td><td class = 'sme-border'>
494  +                       </td>  -                               <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a>
495  +                       <!--  +                               <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 class = 'sme-border'>  
                                 <a href="/smanager/dhcpd8?trt=WIN&ip=<%= $ip->{ip}%>" onclick="Winpop_confirm(event,'<%=$c->l('dhcpd_SENDING_A_WINPOPUP')%>',this);"><center><%=l 'dhcpd_WINPOPUP_ACTION'%></center></a>  
496                          </td>                          </td>
 +                       -->  
497                  </tr>                  </tr>
498                  %}                  %}
499                  </tbody>  @@ -102,7 +102,7 @@
500  @@ -78,6 +83,7 @@                  function Remove_lease_confirm(event,msg,current){
501          %= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'                          const getIP = /.*ip\=(.*)/;
502                            var IP = current.href.match(getIP)[1];
503          %= javascript begin  -                       if (prompt(msg+" IP: "+IP))
504  +               document.getElementById("loadLease").style.display="none";  +                       if (confirm(msg+" IP: "+IP))
505                  function Wol_confirm(event,msg,current){                          { return true;}
506                          const getMAC = /.*MAC\=(.*)\&name.*/;                          else {event.preventDefault();return false;}
507                          var MAC = current.href.match(getMAC)[1];                  }
508  @@ -110,4 +116,4 @@  @@ -110,4 +110,4 @@
509          %end          %end
510    
511    
512  -</div>  -</div>
513  \ No newline at end of file  \ No newline at end of file
514  +</div>  +</div>
515  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep  diff -urN smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep
516  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep        1970-01-01 01:00:00.000000000 +0100  --- smeserver-dhcpmanager-2.0.4.old/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep       1970-01-01 01:00:00.000000000 +0100
517  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scanresults.html.ep    2023-12-31 13:59:00.000000000 +0000  +++ smeserver-dhcpmanager-2.0.4/root/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep   2024-01-20 17:30:00.000000000 +0000
518  @@ -0,0 +1,55 @@  @@ -0,0 +1,63 @@
519  +<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.4/css/jquery.dataTables.css">  +<div id='dhcpd-scan'>
520  +<script type="text/javascript" charset="utf8" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>  +       <table><tr><td>
521  +<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.4/js/jquery.dataTables.js"></script>  +       %= button_to $c->l('dhcpd_REFRESH') => '/dhcpd3', onclick=>"showSpinnerNetwork1()", id=>"scanNetwork1"
522  +  +       <button class ="btn btn-primary spinnerButtonOverlay"  type = "submit" id="loadingNetwork1" style="display:true">
523  +<div id='dhcpd-scanresults'>  +         Scanning  <!--%= $c->l('dhcpd_CONNECTED_IP')-->
524  +  +         <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
525  +%#= 1/0  +       </button>
526  +       %= $c->l('dhcpd_NETWORK_VALUES_FOUND').$dhcp_data->{"cidr"};  +
527  +       %= form_for '/dhcpd10' => (method => 'POST') => begin  +       </td>
528  +       <br />  +       </tr>
529  +       <table id="scanresults" class="sme-border table-sort"><thead>  +      
530    +    </table>          
531    +    <table class="sme-border table-sort"><thead>
532  +               <tr>  +               <tr>
533  +                               <th class='sme-border'>  +                       <th class='sme-border'>
534  +                               %=l 'dhcpd_NETWORK_NAME'  +                               %=l 'dhcpd_NETWORK_NAME'
535  +                       </th>  +                       </th>
536  +                       <th class='sme-border'>  +                       <th class='sme-border'>
# Line 469  diff -urN smeserver-dhcpmanager-2.0.4.ol Line 539  diff -urN smeserver-dhcpmanager-2.0.4.ol
539  +                       <th class='sme-border'>  +                       <th class='sme-border'>
540  +                               %=l 'dhcpd_MAC_ADDRESS'  +                               %=l 'dhcpd_MAC_ADDRESS'
541  +                       </th>  +                       </th>
542  +                       <th class='sme-border'>  +
 +                               %=l 'dhcpd_STATUS_CLICK_FOR_WOL'  
 +                       </th>  
543  +               </tr>  +               </tr>
544  +               </thead>  +               </thead>
545  +               <tbody>  +               <tbody>
546  +               % foreach my $line (@$scanresults) {  +        % foreach my $ip (@$scanresults) {
547  +                       % my @thisline = @$line;  +        <tr>
548  +                       <tr>  +                       %= t td => (class => 'sme-border') => $ip->{Network}
549  +                       <td class='sme-border'>  +                       %= t td => (class => 'sme-border') => $ip->{ip}
550  +                       %= "$thisline[4]";  +                       %= t td => (class => 'sme-border') => $ip->{mac}
551  +                       </td>  +               </tr>
552  +                       <td class='sme-border'>  +               %}
553  +                       %= "$thisline[5]";  +               </tbody>
 +                       </td>  
 +                       <td class='sme-border'>  
 +                       </td>  
 +                       <td class='sme-border'>  
 +                       </td>  
 +                       </tr>  
 +               %}  
554  +       </table>  +       </table>
555  +    % end  +       %= hidden_field "hiddenmsg"=>"", id=>"hiddenmsg"
556    +       <br />
557  +       %= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'  +       %= button_to $c->l('dhcpd_CLICK_HERE_TO_MAIN_PANEL') => '/dhcpd'
558    +
559    +       %= javascript begin
560    +               function Wol_confirm(event,msg,current){
561    +                       const getMAC = /.*MAC\=(.*)\&name.*/;
562    +                       var MAC = current.href.match(getMAC)[1];
563    +                       if (confirm(msg+": MAC: "+MAC))
564    +                       { return true;}
565    +                       else {event.preventDefault();return false;}
566    +               }
567    +
568    +                      
569    +       %end
570    +
571    +
572  +</div>  +</div>
573  +<script>  +%= javascript begin
574  +$(document).ready(function() {  +       document.getElementById("loadingNetwork1").style.display="none";
575  +       $("table.table-sort").each(function() {  +  
576  +               // Enable DataTable on this table  +       function showSpinnerNetwork1(){
577  +               $(this).DataTable();  +         document.getElementById("scanNetwork1").style.display="none";
578  +       });  +         document.getElementById("loadingNetwork1").style.display="inline";
579  +});  +       }
 +</script>  
580  +  +
581    +%end


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed