mirror of
https://github.com/unraid/webgui.git
synced 2026-01-05 00:59:48 -06:00
Add acknowledge all button
This commit is contained in:
@@ -46,6 +46,17 @@ function applyCfg() {
|
||||
$("#applycfg").attr("disabled",true);
|
||||
});
|
||||
}
|
||||
function formatFullInput(input) {
|
||||
return input
|
||||
.split(';')
|
||||
.filter(Boolean) // remove empty trailing entry
|
||||
.map(entry => {
|
||||
let [pci, status] = entry.split(',');
|
||||
status = status.charAt(0).toUpperCase() + status.slice(1).toLowerCase();
|
||||
return `${pci} _(${status})_`;
|
||||
})
|
||||
.join('<br>');
|
||||
}
|
||||
function ackPCI(pcidevice,action) {
|
||||
switch(action) {
|
||||
case 'removed':
|
||||
@@ -60,10 +71,15 @@ function ackPCI(pcidevice,action) {
|
||||
// Add to saved.
|
||||
swaltext = "_(Acknowledge addition of PCI Address)_: "+pcidevice;
|
||||
break;
|
||||
case 'all':
|
||||
// Add to saved.
|
||||
swaltext = "_(Acknowledge all PCI Address modifications)_: <br>"+formatFullInput(pcidevice);
|
||||
break;
|
||||
}
|
||||
swal({title:"Are you sure?",text:swaltext,type:"warning",html:true,showCancelButton:true},function(){
|
||||
$.post('/webGui/include/PCIUpdate.php',{action:action,pciid:pcidevice})
|
||||
$('#t1').load('/webGui/include/SysDevs.php',{table:'t1'});
|
||||
$.post('/webGui/include/PCIUpdate.php',{action:action,pciid:pcidevice}).done(function(d) {
|
||||
if (d == "OK") $('#t1').load('/webGui/include/SysDevs.php',{table:'t1'});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -14,20 +14,38 @@
|
||||
<?
|
||||
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
|
||||
require_once "$docroot/webGui/include/Helpers.php";
|
||||
|
||||
|
||||
function process_action($pciaddr,$action)
|
||||
{
|
||||
global $saved,$current;
|
||||
switch ($action) {
|
||||
case 'removed':
|
||||
unset($saved[$pciaddr]);
|
||||
break;
|
||||
case 'changed':
|
||||
case 'added':
|
||||
$saved[$pciaddr] = $current[$pciaddr];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$savedfile = "/boot/config/savedpcidata.json";
|
||||
$saved = loadSavedData($savedfile);
|
||||
if (!$saved) {echo "ERROR"; return;};
|
||||
|
||||
$current = loadCurrentPCIData();
|
||||
$pciaddr = $_POST['pciid'];
|
||||
switch ($_POST['action']??'') {
|
||||
case 'removed':
|
||||
unset($saved[$pciaddr]);
|
||||
break;
|
||||
case 'changed':
|
||||
case 'added':
|
||||
$current = loadCurrentPCIData();
|
||||
$saved[$pciaddr] = $current[$pciaddr];
|
||||
break;
|
||||
$action = $_POST['action']??'';
|
||||
|
||||
if ($action == 'all') {
|
||||
$pciaddrs = explode(";", $pciaddr);
|
||||
foreach ($pciaddrs as $pciaddraction){
|
||||
$values = explode(',',$pciaddraction);
|
||||
process_action($values[0],$values[1]);
|
||||
}
|
||||
} else {
|
||||
process_action($pciaddr,$action);
|
||||
}
|
||||
file_put_contents($savedfile,json_encode($saved,JSON_PRETTY_PRINT));
|
||||
echo "OK";
|
||||
|
||||
@@ -125,6 +125,7 @@ case 't1':
|
||||
$groups[] = "IOMMU "._("Removed");
|
||||
$groups[] = "\tR[{$removeddata['device']['vendor_id']}:{$removeddata['device']['device_id']}] ".str_replace("0000:","",$removedpci)." ".trim($removeddata['device']['description'],"\n");
|
||||
}
|
||||
$ackparm = "";
|
||||
foreach ($groups as $line) {
|
||||
if (!$line) continue;
|
||||
if ($line[0]=='I') {
|
||||
@@ -166,6 +167,7 @@ case 't1':
|
||||
echo "<i class=\"fa fa-warning fa-fw orange-text\" title=\""._('PCI Change')."\n"._('Click to acknowledge').".\" onclick=\"ackPCI('".htmlentities($pciaddress)."','".htmlentities($pci_device_diffs[$pciaddress]['status'])."')\"></i>";
|
||||
echo _("PCI Device change");
|
||||
echo " "._("Action").":".ucfirst(_($pci_device_diffs[$pciaddress]['status']))." ";
|
||||
$ackparm .= $pciaddress.",".$pci_device_diffs[$pciaddress]['status'].";";
|
||||
if ($pci_device_diffs[$pciaddress]['status']!="removed") echo $pci_device_diffs[$pciaddress]['device']['description'];
|
||||
echo "</td></tr>";
|
||||
if ($pci_device_diffs[$pciaddress]['status']=="changed") {
|
||||
@@ -224,8 +226,10 @@ case 't1':
|
||||
if (file_exists("/var/log/vfio-pci") && filesize("/var/log/vfio-pci")) {
|
||||
echo '<input id="viewlog" type="button" value="'._('View VFIO-PCI Log').'" onclick="openTerminal(\'log\',\'vfio-pci\',\'vfio-pci\')">';
|
||||
}
|
||||
if ($ackparm == "") $ackdisable =" disabled "; else $ackdisable = "";
|
||||
echo '<input id="applycfg" type="submit" disabled value="'._('Bind selected to VFIO at Boot').'" onclick="applyCfg();" '.(isset($noiommu) ? "style=\"display:none\"" : "").'>';
|
||||
echo '<span id="warning"></span>';
|
||||
echo '<input id="applypci" type="submit"'.$ackdisable.' value="'._('Acknowledge all PCI changes').'" onclick="ackPCI(\''.htmlentities($ackparm).'\',\'all\')" >';
|
||||
echo '</td></tr>';
|
||||
echo <<<EOT
|
||||
<script>
|
||||
|
||||
Reference in New Issue
Block a user