System: Settings: Tunables - refactor using base_bootgrid_table partial implemented in https://github.com/opnsense/core/commit/a7a99fcdfe972dacc1a6beada7607e73

This commit is contained in:
Ad Schellevis 2025-01-07 17:20:11 +01:00
parent 50a461ec9b
commit 0e91c2ec81
3 changed files with 35 additions and 31 deletions

View File

@ -34,5 +34,6 @@ class TunablesController extends \OPNsense\Base\IndexController
{
$this->view->pick('OPNsense/Core/tunables');
$this->view->formDialogTunable = $this->getForm('tunable');
$this->view->formGridTunable = $this->getFormGrid('tunable');
}
}

View File

@ -3,11 +3,34 @@
<id>sysctl.tunable</id>
<label>Tunable</label>
<type>text</type>
<grid_view>
<sequence>1</sequence>
</grid_view>
</field>
<field>
<id>sysctl.type</id>
<label>Type</label>
<type>info</type>
<grid_view>
<sequence>2</sequence>
<formatter>tunable_type</formatter>
</grid_view>
</field>
<field>
<id>sysctl.default_value</id>
<label>Default value</label>
<type>info</type>
<grid_view>
<sequence>4</sequence>
</grid_view>
</field>
<field>
<id>sysctl.value</id>
<label>Value</label>
<type>text</type>
<grid_view>
<sequence>3</sequence>
</grid_view>
</field>
<field>
<id>sysctl.descr</id>

View File

@ -26,7 +26,7 @@
<script>
$( document ).ready(function() {
$("#grid").UIBootgrid(
$("#{{formGridTunable['table_id']}}").UIBootgrid(
{ search:'/api/core/tunables/search_item/',
get:'/api/core/tunables/get_item/',
set:'/api/core/tunables/set_item/',
@ -78,41 +78,21 @@
]
});
});
$("#{{formGridTunable['table_id']}} > tfoot > tr > td:eq(0)").append($("#reset_defaults").detach());
$("#reconfigureAct").SimpleActionButton();
});
</script>
<div class="hidden">
<!-- moved into tfoot after load -->
<button id="reset_defaults" class="btn btn-danger btn-xs" data-toggle="tooltip" title="{{ lang._('Default') }}">
<i class="fa fa-trash-o fa-fw"></i>
</button>
</div>
<div class="tab-content content-box">
<table id="grid" class="table table-condensed table-hover table-striped" data-editDialog="DialogTunable" data-editAlert="ChangeMessage">
<thead>
<tr>
<th data-column-id="uuid" data-type="string" data-identifier="true" data-visible="false">{{ lang._('ID') }}</th>
<th data-column-id="tunable" data-type="string">{{ lang._('Tunable') }}</th>
<th data-column-id="type" data-type="string" data-formatter="tunable_type">{{ lang._('Type') }}</th>
<th data-column-id="value" data-type="string">{{ lang._('Value') }}</th>
<th data-column-id="default_value" data-type="string">{{ lang._('Default') }}</th>
<th data-column-id="descr" data-type="string">{{ lang._('Description') }}</th>
<th data-column-id="commands" data-width="7em" data-formatter="commands" data-sortable="false">{{ lang._('Commands') }}</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<td>
<button id="reset_defaults" class="btn btn-danger btn-xs" data-toggle="tooltip" title="{{ lang._('Default') }}">
<i class="fa fa-trash-o fa-fw"></i>
</button>
</td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-primary"><span class="fa fa-fw fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-fw fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table>
{{ partial('layout_partials/base_bootgrid_table', formGridTunable)}}
<div class="col-md-12">
<div id="ChangeMessage" class="alert alert-info" style="display: none" role="alert">
<div id="{{formGridTunable['edit_alert_id']}}" class="alert alert-info" style="display: none" role="alert">
{{ lang._('After changing settings, please remember to apply them with the button below') }}
</div>
<hr/>
@ -127,4 +107,4 @@
</div>
{{ partial("layout_partials/base_dialog",['fields':formDialogTunable,'id':'DialogTunable','label':lang._('Edit Tunable')])}}
{{ partial("layout_partials/base_dialog",['fields':formDialogTunable,'id':formGridTunable['edit_dialog_id'],'label':lang._('Edit Tunable')])}}