mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 17:14:46 +00:00
dismiss/capture installed plugins for https://github.com/opnsense/core/issues/1663
This commit is contained in:
parent
383a8fe8f1
commit
d60990f8d5
@ -556,6 +556,46 @@ class FirmwareController extends ApiControllerBase
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* install missing configured plugins
|
||||
* @param string $pkg_name package name to reinstall
|
||||
* @return array status
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function acceptConfiguredPluginsAction()
|
||||
{
|
||||
$this->sessionClose(); // long running action, close session
|
||||
$response = array();
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$info = $this->infoAction();
|
||||
$installed_plugins = array();
|
||||
if (isset($info['plugin'])) {
|
||||
foreach ($info['plugin'] as $plugin) {
|
||||
if (!empty($plugin['installed']) && !empty($plugin['provided'])) {
|
||||
$installed_plugins[] = $plugin['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
$config = Config::getInstance()->object();
|
||||
if (!isset($config->system->firmware)) {
|
||||
$config->system->addChild('firmware');
|
||||
}
|
||||
if (!isset($config->system->firmware->plugins)) {
|
||||
$config->system->firmware->addChild('plugins');
|
||||
}
|
||||
$config->system->firmware->plugins = implode(",", $installed_plugins);
|
||||
$response['plugins'] = $installed_plugins;
|
||||
$response['status'] = "ok";
|
||||
Config::getInstance()->save();
|
||||
} else {
|
||||
$response['status'] = 'failure';
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* install package
|
||||
* @param string $pkg_name package name to install
|
||||
|
||||
@ -482,11 +482,16 @@
|
||||
let $tr = $("<tr id='plugin_install_tr'/>");
|
||||
let $td = $("<td colspan=5 style='text-align:center;'>");
|
||||
$td.append('<button class="btn btn-default reinstall_missing_plugins"><i class="fa fa-refresh"></i> {{ lang._('Install missing plugins') }}</button>');
|
||||
$td.append(' ');
|
||||
$td.append('<button class="btn btn-default accept_plugins"><i class="fa fa-check"></i> {{ lang._('Accept plugins') }}</button>');
|
||||
$tr.append($td);
|
||||
$('#pluginlist > tbody').prepend($tr);
|
||||
$(".reinstall_missing_plugins").tooltip({
|
||||
'title': '{{ lang._('According to the configuration there is a mismatch between the installed and configured plugins') }}'
|
||||
});
|
||||
$(".accept_plugins").tooltip({
|
||||
'title': '{{ lang._('Accept current state, capture installed plugins to config') }}'
|
||||
});
|
||||
$(".reinstall_missing_plugins").click(function(){
|
||||
$(".reinstall_missing_plugins > i.fa").addClass("fa-pulse");
|
||||
ajaxCall('/api/core/firmware/installConfiguredPlugins', {}, function(data,status) {
|
||||
@ -494,6 +499,12 @@
|
||||
$("#plugin_install_tr").remove();
|
||||
});
|
||||
});
|
||||
$(".accept_plugins").click(function(){
|
||||
ajaxCall('/api/core/firmware/acceptConfiguredPlugins', {}, function(data,status) {
|
||||
$(".plugin_missing").removeClass("text-warning");
|
||||
$("#plugin_install_tr").remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$("#changeloglist > tbody").empty();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user