firmware: UX rework done now #4500

Removed more fluff, concepts anf functionality are there.
Plugin conflict labels could probably require improvement,
but the way they work is relatively complicated, but maybe
it is only getting late.

As soon as we have plugin JSON metadata we can ship the
plugin conflict rework as well as that seems to help a lot
when recovering from strange situations (mostly development
things, but we never know).
This commit is contained in:
Franco Fichtner 2021-02-05 00:09:58 +01:00
parent 8158ef8a6c
commit 024bb6a003
2 changed files with 46 additions and 23 deletions

View File

@ -35,7 +35,7 @@
$('#update_status_container').hide();
$('#updatelist').show();
}
$("#checkupdate_progress").addClass("fa fa-spinner fa-pulse");
$("#checkupdate_progress").addClass("fa-pulse");
}
function updateDismiss() {
@ -58,7 +58,7 @@
// request status
ajaxGet('/api/core/firmware/status', {}, function(data,status){
$("#checkupdate_progress").removeClass("fa fa-spinner fa-pulse");
$("#checkupdate_progress").removeClass("fa-pulse");
$('.updatestatus').html(data['status_msg']);
if (data['status'] == "ok") {
@ -128,7 +128,7 @@
$('#updatetab_progress').addClass("fa fa-cog fa-spin");
if ($.upgrade_action == 'maj') {
$("#upgrade_maj").attr("style","");
$("#upgrade_progress_maj").addClass("fa fa-spinner fa-pulse");
$('#updatetab_progress').addClass("fa fa-cog fa-spin");
}
ajaxCall('/api/core/firmware/upgrade', {upgrade:$.upgrade_action}, function() {
@ -316,7 +316,6 @@
}
}
if (data['status'] == 'done') {
$("#upgrade_progress_maj").removeClass("fa fa-spinner fa-pulse");
$('#updatetab_progress').removeClass("fa fa-cog fa-spin");
$('#major-upgrade').hide();
$('#upgrade_maj').prop('disabled', true);
@ -801,8 +800,8 @@
<button type="button" class="close pull-right" style="margin-top: 8px;" data-dismiss="alert" aria-label="{{ lang._('Close') }}">
<span aria-hidden="true">&times;</span>
</button>
<button class='btn btn-primary pull-right' id="upgrade_maj" disabled="disabled">{{ lang._('Upgrade') }} <i id="upgrade_progress_maj"></i> </button>
<button class='btn pull-right' id="checkupdate_maj" style="margin-right: 8px;">{{ lang._('Unlock') }}</button>
<button class='btn btn-primary pull-right' id="upgrade_maj" disabled="disabled"><i class="fa fa-check"></i> {{ lang._('Upgrade') }}</button>
<button class='btn pull-right' id="checkupdate_maj" style="margin-right: 8px;"><i class="fa fa-unlock-alt"></i> {{ lang._('Unlock') }}</button>
<div style="margin-top: 8px;">
{{ lang._('This software release has reached its designated end of life.') }}
{{ lang._('The next major release is:') }}
@ -832,8 +831,8 @@
<strong><div class="updatestatus"></div></strong>
</td>
<td style="vertical-align:middle">
<button class="btn btn-primary" id="upgrade">{{ lang._('Update') }}</button>
<button class="btn btn-default" id="upgrade_dismiss">{{ lang._('Dismiss') }}</button>
<button class="btn btn-primary" id="upgrade"><i class="fa fa-check"></i> {{ lang._('Update') }}</button>
<button class="btn btn-default" id="upgrade_dismiss"><i class="fa fa-times"></i> {{ lang._('Dismiss') }}</button>
</td>
</tr>
</tfoot>
@ -900,10 +899,10 @@
<td style="width: 20px;"></td>
<td style="width: 150px;"></td>
<td>
<button class="btn btn-info" id="checkupdate">{{ lang._('Check for updates') }} <i id="checkupdate_progress"></i></button>
<button class="btn btn-primary" id="checkupdate"><i id="checkupdate_progress" class="fa fa-refresh"></i> {{ lang._('Check for updates') }}</button>
<div class="btn-group" id="audit_actions" style="display:none;">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
{{ lang._('Run an audit') }} <i class="caret"></i>
<i class="fa fa-lock"></i> {{ lang._('Run an audit') }} <i class="caret"></i>
</button>
<ul class="dropdown-menu" role="menu">
<li><a id="audit_security" href="#">{{ lang._('Security') }}</a></li>
@ -912,12 +911,12 @@
</div>
<div class="btn-group" id="plugin_actions" style="display:none;">
<button type="button" class="btn btn-defaul dropdown-toggle" data-toggle="dropdown">
{{ lang._('Resolve plugin conflicts') }} <i class="caret"></i>
<i class="fa fa-exclamation-triangle"></i> {{ lang._('Resolve plugin conflicts') }} <i class="caret"></i>
</button>
<ul class="dropdown-menu" role="menu">
<li><a id="plugin_see" href="#">{{ lang._('View and edit local conflicts') }}</a></li>
<li><a id="plugin_get" href="#">{{ lang._('Run the automatic resolver') }}</a></li>
<li><a id="plugin_set" href="#">{{ lang._('Unregister missing plugins') }}</a></li>
<li><a id="plugin_set" href="#">{{ lang._('Reset the local conflicts') }}</a></li>
</ul>
</div>
</td>

View File

@ -80,10 +80,21 @@ function plugins_set($config, $plugins)
Config::getInstance()->save();
}
function plugins_found($name)
function plugins_found($name, $found = [])
{
$bare = preg_replace('/^os-|-devel$/', '', $name);
return file_exists('/usr/local/opnsense/version/' . $bare);
if (file_exists('/usr/local/opnsense/version/' . $bare)) {
if (!isset($found[$bare])) {
/* backwards compat with non-JSON, remove in 21.7 */
return true;
}
if ($found[$bare] == $name) {
return true;
}
}
return false;
}
function plugins_remove_sibling($name, $plugins)
@ -120,27 +131,40 @@ switch ($action) {
$plugins = plugins_remove_sibling($name, $plugins);
break;
case 'resync':
$unknown = [];
$found = [];
foreach (glob('/usr/local/opnsense/version/*') as $name) {
$name = basename($name);
if (strpos($name, 'base') === 0) {
$filename = basename($name);
if (strpos($filename, 'base') === 0) {
continue;
}
if (strpos($name, 'kernel') === 0) {
if (strpos($filename, 'kernel') === 0) {
continue;
}
if (strpos($name, 'core') === 0) {
if (strpos($filename, 'core') === 0) {
continue;
}
/* XXX when we have JSON data we can read the package name and pick it up */
$unknown[] = "os-{$name}";
$ret = json_decode(@file_get_contents($name), true);
if ($ret == null || !isset($ret['product_id'])) {
/* ignore files without valid metadata */
continue;
}
$found[$filename] = $ret['product_id'];
}
foreach (array_keys($plugins) as $name) {
if (!plugins_found($name)) {
echo "Unregistering plugin: $name" . PHP_EOL;
if (!plugins_found($name, $found)) {
echo "Unregistering missing plugin: $name" . PHP_EOL;
unset($plugins[$name]);
}
}
foreach ($found as $name) {
if (!isset($plugins[$name])) {
echo "Registering misconfigured plugin: $name" . PHP_EOL;
$plugins[$name] = 'yep';
}
$plugins = plugins_remove_sibling($name, $plugins);
}
break;
default:
exit();