Line 211: |
Line 211: |
| | | |
| our $db = esmith::ConfigDB->open() or die("Unable to open Configuration DB"); | | our $db = esmith::ConfigDB->open() or die("Unable to open Configuration DB"); |
| + | our %sme_conf = $db->get('dhcpd')->props; |
| + | our %smb_conf = $db->get('smb')->props; |
| our $adb = esmith::AccountsDB->open() or die("Unable to open accounts DB"); | | our $adb = esmith::AccountsDB->open() or die("Unable to open accounts DB"); |
| | | |
Line 226: |
Line 228: |
| # | | # |
| my $c = shift; | | my $c = shift; |
− | die("hello world"); | + | $dhcp_data{"status"} = [[$c->l('dhcpd_ENABLED'),'enabled'], |
− | $dhcp_data{"first"} = 'dhcp_DESCRIPTION'; | + | [$c->l('dhcpd_DISABLED'),'disabled'] |
| + | ]; |
| + | |
| + | $dhcp_data{"check"} = [[$c->l('dhcpd_ENABLED'),'enabled'], |
| + | [$c->l('dhcpd_DISABLED'),'disabled'] |
| + | ]; |
| + | if (! $sme_conf{'winscustom'} ) { |
| + | $sme_conf{'winscustom'} = 'disabled' ; |
| + | } |
| + | if (! $sme_conf{'dnscustom'} ) { |
| + | $sme_conf{'dnscustom'} = 'disabled' ; |
| + | } |
| + | if ( ! $sme_conf{'leasetime'} ) |
| + | { $sme_conf{'leasetime'} = "86400" ; |
| + | } |
| + | if (! $sme_conf{'gatewaycustom'} ) { |
| + | $sme_conf{'gatewaycustom'} = 'disabled' ; |
| + | } |
| + | #$dhcp_data{"first"} = 'dhcpd_DESCRIPTION'; |
| do_display( $c, %dhcp_data ); | | do_display( $c, %dhcp_data ); |
| } | | } |
Line 237: |
Line 257: |
| my $c = shift; | | my $c = shift; |
| $c->app->log->info( $c->log_req ); | | $c->app->log->info( $c->log_req ); |
− | my $title = $c->l("dhcp_DHCPD_SETTINGS_TITLE"); | + | my $title = $c->l("dhcpd_DHCP manager"); |
| my $modul = ''; | | my $modul = ''; |
| my $trt = "SETTINGS"; | | my $trt = "SETTINGS"; |
| $dhcp_data{trt} = $trt; | | $dhcp_data{trt} = $trt; |
| # Accumulate parameters for Configuration DB | | # Accumulate parameters for Configuration DB |
− | # ..... | + | $dhcp_data{'params'} = \%sme_conf; |
− | $c->stash( title => $title, modul => $modul, dhcp_data => \%dhcp_data ); | + | $dhcp_data{'smbparams'} = \%smb_conf; |
| + | $c->stash( title => $title, |
| + | modul => $modul, |
| + | dhcp_data => \%dhcp_data |
| + | ); |
| $c->render( template => 'dhcpd' ); | | $c->render( template => 'dhcpd' ); |
− | }
| |
| | | |
| sub do_leases { | | sub do_leases { |
Line 257: |
Line 280: |
| $dhcp_data{trt} = $trt; | | $dhcp_data{trt} = $trt; |
| $dhcp_data{"first"} = ''; | | $dhcp_data{"first"} = ''; |
− | $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 => 'dhcpd' ); | | $c->render( template => 'dhcpd' ); |
Line 289: |
Line 312: |
| $dhcp_data{"first"} = ''; | | $dhcp_data{"first"} = ''; |
| # ..... get scan results into dhcp_data | | # ..... get scan results into dhcp_data |
− | 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 => 'dhcpd' ); | | $c->render( template => 'dhcpd' ); |
Line 306: |
Line 329: |
| my $ret = update_config($c); | | my $ret = update_config($c); |
| if ($ret == 'ok') { | | if ($ret == 'ok') { |
− | dhcp_data{"success"}=dhcp_CONFIG_SAVED_OK; | + | dhcp_data{"success"}="dhcp_CONFIG_SAVED_OK"; |
| do_leases($c); | | do_leases($c); |
| } | | } |
Line 321: |
Line 344: |
| my $ret = delete_all_leases($c); | | my $ret = delete_all_leases($c); |
| if ($ret == 'ok') { | | if ($ret == 'ok') { |
− | dhcp_data{"success"}=dhcp_CONFIG_SAVED_OK; | + | dhcp_data{"success"}="dhcp_CONFIG_SAVED_OK"; |
| do_leases($c); | | do_leases($c); |
| } | | } |
Line 341: |
Line 364: |
| my $ret = delete_lease($c); | | my $ret = delete_lease($c); |
| if ($ret == 'ok') { | | if ($ret == 'ok') { |
− | dhcp_data{"success"}=dhcp_CONFIG_SAVED_OK; | + | dhcp_data{"success"}="dhcp_CONFIG_SAVED_OK"; |
| do_leases($c); | | do_leases($c); |
| } | | } |
Line 438: |
Line 461: |
| %= include 'partials/_dhcpd_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 lang="perl"> |
| else { #PARAMS | | else { #PARAMS |
− | #Front parameter panel here...
| + | <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 checkclientstatus=>$dhcp_data->{"params"}->{"check"}; |
| + | %=select_field checkclientstatus=>$dhcp_data->{"check"} |
| + | </span><br> |
| + | <br /> |
| + | <span class=label> |
| + | %=l 'dhcpd_STATUS_DHCP_SERVER' |
| + | </span><span class=data> |
| + | % param dhcpstatus=>$dhcp_data->{"params"}->{"status"}; |
| + | %=select_field dhcpstatus=>$dhcp_data->{"status"} |
| + | </span><br> |
| + | |
| + | <span class=label> |
| + | %=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 |
| %} | | %} |
− |
| |
| </div> | | </div> |
| %end | | %end |
− | </syntaxhighlight> | + | </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! |
− | | |
− | ===Mojolicious Meta Commands===
| |
| | | |
− | ===Perl Commands===
| + | 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. |
| | | |
− | ===Html=== | + | === The Partials files can be used to keep the structure in mulitple files. === |
| + | We will look at just one to display the lease table. |
| | | |
− | ==Translation Strings files== | + | ===Translation Strings files=== |
| Here is a sed script and extra commands to take a formMagick strings file and make it into a lex file suitable for SM2. | | Here is a sed script and extra commands to take a formMagick strings file and make it into a lex file suitable for SM2. |
| | | |