Line 119: |
Line 119: |
| So, we'll create the following files for the new SM2 panel(s) for the DHCPManager contrib. | | So, we'll create the following files for the new SM2 panel(s) for the DHCPManager contrib. |
| | | |
− | #/usr/share/smanager/lib/SrvMngr/Controller/Dhcpman.pm | + | #/usr/share/smanager/lib/SrvMngr/Controller/dhcpd.pm |
− | #/usr/share/smanager/lib/SrvMngr/I18N/Modules/Dhcpman/dhcpman_en.lex | + | #/usr/share/smanager/lib/SrvMngr/I18N/Modules/dhcpd/dhcpd_en.lex |
− | #/usr/share/smanager/themes/default/templates/dhcpman.html.ep | + | #/usr/share/smanager/themes/default/templates/dhcpd.html.ep |
− | #/usr/share/smanager/themes/default/templates/partials/_dhcpm_scan.html.ep | + | #/usr/share/smanager/themes/default/templates/partials/_dhcpd_scan.html.ep |
− | #/usr/share/smanager/themes/default/templates/partials/_dhcpm_winpopup.html.ep | + | #/usr/share/smanager/themes/default/templates/partials/_dhcpd_winpopup.html.ep |
− | #/usr/share/smanager/themes/default/templates/partials/_dhcpm_leases.html.ep | + | #/usr/share/smanager/themes/default/templates/partials/_dhcpd_leases.html.ep |
| Quite why the partials have to start with the "_" I am not sure - looks like a convention to "underline" that fact that they are only called internally. | | Quite why the partials have to start with the "_" I am not sure - looks like a convention to "underline" that fact that they are only called internally. |
| | | |
Line 159: |
Line 159: |
| Remember to set Mode = "development" in the mojolicious config file so that Perl run time errors are shown usefully. See above. | | Remember to set Mode = "development" in the mojolicious config file so that Perl run time errors are shown usefully. See above. |
| | | |
− | ==The Controller File (Dhcpman.pm)== | + | ==The Controller File (dhcpd.pm)== |
| | | |
| === Navigation Menu and Routing Tables === | | === Navigation Menu and Routing Tables === |
| Here is the heading for "untested" skeleton for the controller file.:<syntaxhighlight lang="perl"> | | Here is the heading for "untested" skeleton for the controller file.:<syntaxhighlight lang="perl"> |
− | package SrvMngr::Controller::Dhcpman; | + | package SrvMngr::Controller::Dhcpd; |
| #---------------------------------------------------------------------- | | #---------------------------------------------------------------------- |
| # heading : Configuration | | # heading : Configuration |
Line 169: |
Line 169: |
| # navigation : 2000 2500 | | # navigation : 2000 2500 |
| # | | # |
− | # name : dhcpman, method : post, url : /dhcpman, ctlact : Dhcpman#main | + | # name : dhcpd, method : post, url : /dhcpd, ctlact : Dhcpd#main |
− | # name : dhcpman1, method : get, url : /dhcpman1, ctlact : Dhcpman#do_leases | + | # name : dhcpd1, method : get, url : /dhcpd1, ctlact : Dhcpd#do_leases |
− | # name : dhcpman2, method : get, url : /dhcpman2, ctlact : Dhcpman#do_winpopup | + | # name : dhcpd2, method : get, url : /dhcpd2, ctlact : Dhcpd#do_winpopup |
− | # name : dhcpman3, method : get, url : /dhcpman3, ctlact : Dhcpman#do_scan | + | # name : dhcpd3, method : get, url : /dhcpd3, ctlact : Dhcpd#do_scan |
− | # name : dhcpman4, method : get, url : /dhcpman4, ctlact : Dhcpman#do_delete_all_leases | + | # name : dhcpd4, method : get, url : /dhcpd4, ctlact : Dhcpd#do_delete_all_leases |
− | # name : dhcpman5, method : get, url : /dhcpman5, ctlact : Dhcpman#do_update_config | + | # name : dhcpd5, method : get, url : /dhcpd5, ctlact : Dhcpd#do_update_config |
− | # name : dhcpman6, method : get, url : /dhcpman6, ctlact : Dhcpman#do_delete_one_lease | + | # name : dhcpd6, method : get, url : /dhcpd6, ctlact : Dhcpd#do_delete_one_lease |
− | # name : dhcpman7, method : get, url : /dhcpman7, ctlact : Dhcpman#do_refresh_leases | + | # name : dhcpd7, method : get, url : /dhcpd7, ctlact : Dhcpd#do_refresh_leases |
− | # name : dhcpman8, method : get, url : /dhcpman8, ctlact : Dhcpman#winpopup | + | # name : dhcpd8, method : get, url : /dhcpd8, ctlact : Dhcpd#winpopup |
| # | | # |
| # routes : end | | # routes : end |
Line 240: |
Line 240: |
| # ..... | | # ..... |
| $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); | | $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); |
− | $c->render( template => 'dhcpman' ); | + | $c->render( template => 'dhcpd' ); |
| } | | } |
− |
| |
| | | |
| sub do_leases { | | sub do_leases { |
Line 256: |
Line 255: |
| $dhcp_data{"leases") = get_leases_in_array(); | | $dhcp_data{"leases") = get_leases_in_array(); |
| $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); | | $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); |
− | $c->render( template => 'dhcpman' ); | + | $c->render( template => 'dhcpd' ); |
| } | | } |
| | | |
Line 272: |
Line 271: |
| #..... get winpopup details | | #..... get winpopup details |
| $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); | | $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); |
− | $c->render( template => 'dhcpman' ); | + | $c->render( template => 'dhcpd' ); |
| } | | } |
| | | |
Line 288: |
Line 287: |
| dhcp_data{scanresults} = get_scan_results($c); | | dhcp_data{scanresults} = get_scan_results($c); |
| $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); | | $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); |
− | $c->render( template => 'dhcpman' ); | + | $c->render( template => 'dhcpd' ); |
| } | | } |
| | | |
Line 377: |
Line 376: |
| } | | } |
| | | |
| + | 1; |
| </syntaxhighlight> | | </syntaxhighlight> |
| | | |
− | ==The Template Files (dhcpman.html.ep and partials)== | + | ==The Template Files (dhcpd.html.ep and partials)== |
| The top level .ep file starts like this:<syntaxhighlight lang="perl"> | | The top level .ep file starts like this:<syntaxhighlight lang="perl"> |
| % layout 'default', title => "Sme server 2 - DHCP Manager", share_dir => './'; | | % layout 'default', title => "Sme server 2 - DHCP Manager", share_dir => './'; |
Line 428: |
Line 428: |
| | | |
| % if ($dhcp_data->{trt} eq 'LEASES') { | | % if ($dhcp_data->{trt} eq 'LEASES') { |
− | %= include 'partials/_dhcpm_leases' | + | %= include 'partials/_dhcpd_leases' |
| %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') { | | %} elsif ($dhcp_data->{trt} eq 'WINPOPUP') { |
− | %= include 'partials/_dhcpm_winpopup' | + | %= include 'partials/_dhcpd_winpopup' |
| %} elsif ($dhcp_data->{trt} eq 'SCAN') { | | %} elsif ($dhcp_data->{trt} eq 'SCAN') { |
− | %= include 'partials/_dhcpm_scan' | + | %= include 'partials/_dhcpd_scan' |
| %} | | %} |
| </syntaxhighlight>and finally the front panel details is defined:<syntaxhighlight> | | </syntaxhighlight>and finally the front panel details is defined:<syntaxhighlight> |