Fix up action commands for Groups and Host panels

This commit is contained in:
Brian Read 2024-12-15 17:17:32 +00:00
parent 1b1b99955b
commit 55269fd685
2 changed files with 47 additions and 21 deletions

View File

@ -39,8 +39,25 @@
%= t td => (class => 'sme-border') => $group->key %= t td => (class => 'sme-border') => $group->key
%= t td => (class => 'sme-border') => $group->prop('Description') %= t td => (class => 'sme-border') => $group->prop('Description')
<td class='sme-border' style="min-width:15em"> <td class='sme-border' style="min-width:15em">
<a href='groups2?CsrfDef=TOKEN&trt=UPD&group=<%= $group->key%>'><button class='sme-modify-button' title=<%=l('MODIFY')%>><%=l('MODIFY') %></button></a> %my $modify_text = l('MODIFY'); # Localized text
<a href='groups2?CsrfDef=TOKEN&trt=DEL&group=<%= $group->key%>'><button class='sme-remove-button' title=<%=l('REMOVE')%>><%=l('REMOVE') %></button></a> %my $csrf_token = "TOKEN"; # CSRF token for security
%my $group_name = $group->key; # group name extracted from the data structure
%my $actionModify = qq{
% <button type='button' class='sme-modify-button' title='$modify_text'
% onclick="window.location.href='groups2?CsrfDef=$csrf_token&trt=UPD&group=$group_name'">
% $modify_text
% </button>
%};
%my $remove_text = l('REMOVE'); # Localized text
%my $csrf_token = "TOKEN"; # CSRF token for security
%my $group_name = $group->key; # group name extracted from the data structure
%my $actionRemove = qq{
% <button type='button' class='sme-remove-button' title='$remove_text'
% onclick="window.location.href='groups2?CsrfDef=$csrf_token&trt=DEL&group=$group_name'">
% $remove_text
% </button>
%};
<%= $c->render_to_string(inline => $actionModify) %> <%= $c->render_to_string(inline => $actionRemove) %>
</td> </td>
</tr> </tr>
% } % }

View File

@ -49,25 +49,34 @@
%= t td => (class => 'sme-border') => $_->{'IP'}; %= t td => (class => 'sme-border') => $_->{'IP'};
%= t td => (class => 'sme-border') => $_->{'MACAddress'}; %= t td => (class => 'sme-border') => $_->{'MACAddress'};
%= t td => (class => 'sme-border') => $_->{'Comment'}; %= t td => (class => 'sme-border') => $_->{'Comment'};
% my ($actionModify, $actionRemove) = '&nbsp;';
% if ($_->{'static'} ne 'yes') {
% $actionModify = "<a href='hostentriesd?CsrfDef=TOKEN&trt=UPD&Hostname=" . $_->{'HostName'} . "'>" . "<button class='sme-modify-button' title=".l('MODIFY').">".l('MODIFY')."</button>" . "</a>";
% $actionRemove = "<a href='hostentriesd?CsrfDef=TOKEN&trt=DEL&Hostname=" . $_->{'HostName'} . "'>" . "<button class='sme-remove-button' title=".l('REMOVE').">".l('REMOVE')."</button>" . "</a>";
% }
<td class='sme-border' style="min-width:15em"> <td class='sme-border' style="min-width:15em">
<%= $c->render_to_string(inline => $actionModify) %> % my ($actionModify, $actionRemove) = '&nbsp;';
<%= $c->render_to_string(inline => $actionRemove) %> %my $static = $_->{'static'} || "no";
</td> % if ($static ne 'yes') {
%my $modify_text = l('MODIFY'); # Localized text
</tr> %my $csrf_token = "TOKEN"; # CSRF token for security
%my $hostentries_name = $_->{'HostName'}; # hostentries name extracted from the data structure
%$actionModify = qq{
% <button type='button' class='sme-modify-button' title='$modify_text'
% onclick="window.location.href='hostentriesd?CsrfDef=$csrf_token&trt=UPD&Hostname=$hostentries_name'">
% $modify_text
% </button>
%};
%my $remove_text = l('REMOVE'); # Localized text
%my $csrf_token = "TOKEN"; # CSRF token for security
%#my $hostentries_name = $_->{'HostName'}; # hostentries name extracted from the data structure
%$actionRemove = qq{
% <button type='button' class='sme-remove-button' title='$remove_text'
% onclick="window.location.href='hostentriesd?CsrfDef=$csrf_token&trt=DEL&Hostname=$hostentries_name'">
% $remove_text
% </button>
%};
% }
<%= $c->render_to_string(inline => $actionModify) %> <%= $c->render_to_string(inline => $actionRemove) %>
</td>
</tr>
% } % }
</tbody> </tbody>
</table> </table>
</p>
% } % }
</div> </div>