Sysdrivers: Updates

Add remove button and confirmation
Fix sort issues by updating cells
Code tidy
This commit is contained in:
SimonFair
2023-07-29 09:39:36 +01:00
parent c30405434a
commit f36e307de0
3 changed files with 26 additions and 13 deletions

View File

@@ -135,37 +135,44 @@ function textedit(module) {
}
function textsave(module) {
function removecfg(module)
{
swal({title:"_(Proceed)_?",text:"_(Remove custom modprobe.d configuration?)_: "+module,type:'warning',html:true,showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(p){if (p) textsave(module, true); else return false;});
}
function textsave(module,remove = false) {
var i=module ;
$('#text'+module).prop('disabled', true);
$('#save'+module).attr('hidden', true);
var x = document.getElementById("text" + module).value;
if (remove) x = "" ; else var x = document.getElementById("text" + module).value;
$.post('/webGui/include/SysDrivers.php',{table:'update',module:module,conf:x},function(data){
if(data) {
formHasUnsavedChanges=false;
$('#text'+module).val(data.modprobe) ;
$('#status'+module).html(data.state) ;
if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3)
if (data.state == "Custom") {
$('#bin'+module).show();
} else {
$('#bin'+module).hide();
}
if (data.modprobe == "") $('#text'+module).attr('hidden', true); else $('#text'+module).attr('rows', 3);
if (data.supportpage == true) {
if (data.support == true) {
document.getElementById("link" + module).innerHTML = "<a href='" + data.supporturl + "'target='_blank'><i title='" + _("Support page")_ + "' class='fa fa-phone-square'></i></a>" ;
}
}
}
//showDriversupdate() ;
$('#t1').trigger("updateCell",[document.getElementById('text'+module), false, null]);
$('#t1').trigger("updateCell",[document.getElementById('status'+module), false, null]);
var message = "_(System Drivers)_: _(A reboot is required to apply changes)_";
addRebootNotice(message);
},"json");
}
$('.tabs').append("<span class='status'><span class='lite label'>_(Select View)_:</span><select id='select' onchange='showDrivers(this.value)'><option value='all' >All Drivers</option><option value='inuse' selected >Inuse Drivers</option></select>");
showDrivers("all",true) ;
</script>
<form autocomplete="off" onsubmit="return false;"><span><input class="search" id="driversearch" type="search" placeholder="Search..." onchange="filterDrivers();"></span></form>
<pre><form id="sysdrivers" class="js-confirm-leave" onsubmit="return false"><table id='t1' class="t1 disk_status tablesorter " ><tr><td><div class="spinner"></div></td></tr></table></form></pre><br>
<input type="button" value="_(Done)_" onclick="done()"><input type="button" id="rebuild" value="_(Rebuild Modules)_" onclick="showDriversupdate()">
<input type="button" value="_(Done)_" onclick="done()"><input type="button" id="rebuild" value="_(Rebuild Modules)_" onclick="showDriversupdate()">

View File

@@ -84,12 +84,19 @@ switch ($_POST['table']) {
$text = "" ;
if (is_array($module["modprobe"])) {
$text = implode("\n",$module["modprobe"]) ;
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a><span><textarea id=\"text".$modname."\" rows=3 disabled>$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
} else $html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a><span><textarea id=\"text".$modname."\" rows=1 hidden disabled >$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>" ;
$hidden = "" ;
if ($module['state'] == "System") $hidden = "hidden" ;
$html .= " <a class='info' href=\"#\" id=\"bin$modname\" $hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>" ;
$html .= "<span><textarea id=\"text".$modname."\" rows=3 disabled>$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
} else {
$html .= "<td><span><a class='info' href=\"#\"><i title='"._("Edit Modprobe config")."' onclick=\"textedit('".$modname."');return false;\" id=\"icon'.$modname.'\" class='fa fa-edit'></i></a>" ;
$html .= " <a class='info' href=\"#\" id=\"bin$modnam\" hidden><i title='"._("Delete Modprobe config")."' onclick=\"removecfg('".$modname."',true);return false;\" class='fa fa-trash'></i></a><span>" ;
$html .= "<textarea id=\"text".$modname."\" rows=1 hidden disabled >$text</textarea><span id=\"save$modname\" hidden onclick=\"textsave('".$modname."');return false;\" ><a class='info' href=\"#\"><i title='"._("Save Modprobe config")."' class='fa fa-save' ></i></a></span></td></tr>";
}
}
$html .= "</tbody>" ;
#if ($init) {unlink($sysdrvinit) ; $init = true ;}
$rtn = array() ;
$rtn['html'] = $html ;
if ($init !== false) {$init = true ; unlink($sysdrvinit) ;}

View File

@@ -24,7 +24,6 @@ function getmodules($line) {
$modprobe = "" ;
$desc = $file = $pluginfile = $option = $filename = $depends = $support = $supporturl = $dir = $state = null ;
$name = $line ;
#echo $line ;
$modname = shell_exec("modinfo $name > /dev/null") ;
if ($modname != null) $modname = trim($modname,"\n") ;
$output=null ;