mirror of
https://github.com/unraid/webgui.git
synced 2026-05-12 15:20:29 -05:00
Add pages
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
Menu="UNRAID-OS"
|
||||
Title="Wake On LAN"
|
||||
Icon="icon-packages"
|
||||
Icon="fa-bell"
|
||||
Tag="server"
|
||||
---
|
||||
<?PHP
|
||||
@@ -14,6 +14,32 @@ Tag="server"
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
|
||||
if (count($_POST)) {
|
||||
$cfg = NULL ;
|
||||
if ($_POST['#apply'] == "_(Save)_") {
|
||||
foreach($_POST as $postkey=>$data) {
|
||||
if ($postkey=="#apply") continue;
|
||||
$keys = explode(";",$postkey);
|
||||
if (count($keys) >1) $update_file[$keys[1]][$keys[2]][$keys[0]]=$data;
|
||||
}
|
||||
|
||||
foreach($update_file as $type => $types) {
|
||||
foreach($types as $name => $details) {
|
||||
if ($details['user_mac'] == "") $details['user_mac'] = "None Defined";
|
||||
if ($details['user_mac'] == "None Defined" && $details['enable'] == "enable") unset($update_file[$type][$name]) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($_POST) ;
|
||||
file_put_contents("/boot/config/wol.json",json_encode($update_file));
|
||||
#echo '<meta http-equiv="refresh" content="0;url=/Tools">';
|
||||
echo '<meta http-equiv="refresh" content="0">';
|
||||
#unset($_SESSION['csrf_token']);
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
<script src="/webGui/javascript/jquery.tablesorter.widgets.js"></script>
|
||||
|
||||
@@ -70,50 +96,26 @@ function showWOLupdate() {
|
||||
});
|
||||
}
|
||||
|
||||
function textedit(module) {
|
||||
var i=module;
|
||||
$('#text'+module).prop('disabled', false);
|
||||
$('#save'+module).attr('hidden', false);
|
||||
$('#text'+module).attr('hidden', false);
|
||||
}
|
||||
|
||||
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 maccreate(name) {
|
||||
|
||||
$.getJSON("/plugins/dynamix.vm.manager/include/VMajax.php?action=generate-mac", function( data ) {
|
||||
if (data.mac) {
|
||||
$('#'+name).val(data.mac);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function textsave(module,remove = false) {
|
||||
var i=module;
|
||||
$('#text'+module).prop('disabled', true);
|
||||
$('#save'+module).attr('hidden', true);
|
||||
var x = (remove) ? "" : document.getElementById("text" + module).value;
|
||||
$.post('/webGui/include/WOL.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.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>";
|
||||
}
|
||||
}
|
||||
}
|
||||
$('#t1').trigger("updateCell",[document.getElementById('text'+module), false, null]);
|
||||
$('#t1').trigger("updateCell",[document.getElementById('status'+module), false, null]);
|
||||
},"json");
|
||||
}
|
||||
|
||||
|
||||
showWOL("all",true);
|
||||
</script>
|
||||
|
||||
:sysWOL_intro_help:
|
||||
:WOL_intro_help:
|
||||
|
||||
<form autocomplete="off" onsubmit="return false;"><span><input class="t1 search" id="wolsearch" type="search" placeholder="Search..." onchange="filterWOL();"></span></form>
|
||||
<pre><form id="sysWOL" 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>
|
||||
<pre><form name="WOL" id="WOL" method="POST" class="js-confirm-leave" >
|
||||
<table name="t1"id='t1' class="t1 unraid tablesorter" >
|
||||
<tr><td><div class="spinner"></div></td></tr></table></pre><br>
|
||||
<input type="button" value="_(Done)_" onclick="done()">
|
||||
<input type="submit" name="#apply" id='#apply' value="_(Save)_" >
|
||||
</form>
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
Menu="OtherSettings"
|
||||
Type="xmenu"
|
||||
Title="Wake on Lan Settings"
|
||||
Icon="fa-bell"
|
||||
Tag="share-alt"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
exec("ls --indicator-style=none /sys/class/net|grep -P '^eth[1-9][0-9]*$'",$ports);
|
||||
$disabled = _var($var,'fsState')!='Stopped' ? 'disabled' : '';
|
||||
$width = [166,300];
|
||||
$file = '/boot/config/wol.cfg';
|
||||
$current = parse_ini_file($file);
|
||||
?>
|
||||
<script>
|
||||
showStatus('pid','unraidwold');
|
||||
</script>
|
||||
<form markdown="1" name="WOLsettings" method="POST" action="/update.php" target="progressFrame" >
|
||||
<input type="hidden" name="#file" value="<?=$file;?>">
|
||||
<input type="hidden" name="#command" value="/webGui/scripts/action_wol">
|
||||
|
||||
_(Enable Wake on Lan)_:
|
||||
: <select name="WOLenabled" >
|
||||
<?=mk_option($current['WOLenabled'], "no", _('No'))?>
|
||||
<?=mk_option($current['WOLenabled'], "yes", _('Yes'))?>
|
||||
</select>
|
||||
|
||||
:WOL_enable_help:
|
||||
|
||||
_(Enable Docker actions)_:
|
||||
|
||||
: <select name="runDocker" >
|
||||
<?=mk_option($current['runDocker'], "y", _('Yes'))?>
|
||||
<?=mk_option($current['runDocker'], "n", _('No'))?>
|
||||
</select>
|
||||
|
||||
:run_Docker_help:
|
||||
|
||||
_(Enable LXC actions)_:
|
||||
: <select name="runLXC" >
|
||||
<?=mk_option($current['runLXC'], "y", _('Yes'))?>
|
||||
<?=mk_option($current['runLXC'], "n", _('No'))?>
|
||||
</select>
|
||||
|
||||
:run_LXC_help:
|
||||
|
||||
_(Enable VM actions)_:
|
||||
: <select name="runVM" >
|
||||
<?=mk_option($current['runVM'], "y", _('Yes'))?>
|
||||
<?=mk_option($current['runVM'], "n", _('No'))?>
|
||||
</select>
|
||||
|
||||
:run_VM_help:
|
||||
|
||||
_(Interface to listern on)_
|
||||
: <select id="Interface" name="INTERFACE" >
|
||||
<?=mk_option(_var($eth0,'INTERFACE'),'eth0','eth0','selected')?>
|
||||
<?foreach ($ports as $port):?>
|
||||
<?if (!locked('eth0',$port)) echo mk_option_check($current['INTERFACE'],$port,$port)?>
|
||||
<?endforeach;?>
|
||||
</select>
|
||||
|
||||
_(Interface promiscous mode)_
|
||||
: <select id="Ifmode" name="Ifmode" >
|
||||
<?=mk_option($current['ifmode'], "n", _('No'))?>
|
||||
<?=mk_option($current['ifmode'], "y", _('Yes'))?>
|
||||
</select>
|
||||
|
||||
:eth_bonding_members_help:
|
||||
|
||||
|
||||
: <input type="submit" value="_(Apply)_" disabled><input type="button" value="_(Done)_" onclick="done()">
|
||||
</form>
|
||||
@@ -25,7 +25,7 @@ require_once "/usr/local/emhttp/plugins/dynamix.vm.manager/include/libvirt.php";
|
||||
$vms = $lv->get_domains();
|
||||
sort($vms,SORT_NATURAL);
|
||||
foreach($vms as $vm){
|
||||
$arry['VM'][$vm]['interfaces'] = $lv->get_nic_info($vm);
|
||||
$arrEntries['VM'][$vm]['interfaces'] = $lv->get_nic_info($vm);
|
||||
$arry['VM'][$vm]['name'] = $vm;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ foreach ($lxc as $lxcname) {
|
||||
$arry['LXC'][$lxcname]['name'] = $lxcname;
|
||||
}
|
||||
|
||||
if (is_file("/tmp/wol.json")) $user_mac = json_decode(file_get_contents("/tmp/wol.json"),true); else $user_mac = [];
|
||||
if (is_file("/boot/config/wol.json")) $user_mac = json_decode(file_get_contents("/boot/config/wol.json"),true); else $user_mac = [];
|
||||
|
||||
foreach($arry as $key => $data) {
|
||||
$type=$key;
|
||||
@@ -55,7 +55,7 @@ foreach($arry as $key => $data) {
|
||||
if (isset($user_mac[$type][$name])) {
|
||||
$name=$name;
|
||||
#var_dump($name);
|
||||
$arry[$type][$name]['enable'] = $user_mac[$type][$name]['enable']? "enable" : "disabled";
|
||||
$arry[$type][$name]['enable'] = $user_mac[$type][$name]['enable'];
|
||||
$arry[$type][$name]['user_mac'] = strtolower($user_mac[$type][$name]['user_mac']);
|
||||
} else {
|
||||
$arry[$type][$name]['enable'] = 'enable';
|
||||
@@ -67,50 +67,30 @@ foreach($arry as $key => $data) {
|
||||
switch ($_POST['table']) {
|
||||
|
||||
case 't1load':
|
||||
$arrModules = $arry;
|
||||
$init = false;
|
||||
if (is_file($sysdrvinit)) $init = file_get_contents($sysdrvinit);
|
||||
$arrMacs = $arry;
|
||||
$html = "<thead><tr><th>"._('Service')."</th><th>"._('Name')."</th><th>"._('Mac Address')."</th><th>"._('Enabled')."</th><th>"._('User Mac Address')."</th></tr></thead>";
|
||||
$html .= "<tbody>";
|
||||
ksort($arrModules);
|
||||
foreach($arrModules as $modname => $m) {
|
||||
foreach($m as $module) {
|
||||
if ($modname == "") continue;
|
||||
if (is_file("/boot/config/modprobe.d/$modname.conf")) {
|
||||
$modprobe = file_get_contents("/boot/config/modprobe.d/$modname.conf");
|
||||
$state = strpos($modprobe, "blacklist");
|
||||
$modprobe = explode(PHP_EOL,$modprobe);
|
||||
if($state !== false) {$state = "Disabled";} else $state="Custom";
|
||||
$module['state'] = $state;
|
||||
$module['modprobe'] = $modprobe;
|
||||
} else {
|
||||
if (is_file("/etc/modprobe.d/$modname.conf")) {
|
||||
$modprobe = file_get_contents("/etc/modprobe.d/$modname.conf");
|
||||
$state = strpos($modprobe, "blacklist");
|
||||
$modprobe = explode(PHP_EOL,$modprobe);
|
||||
if($state !== false) {$state = "Disabled";} else $state="System";
|
||||
$module['state'] = $state;
|
||||
$module['modprobe'] = $modprobe;
|
||||
}
|
||||
}
|
||||
$html .= "<tr id='row$modname'>";
|
||||
if ($supportpage) {
|
||||
if ($module['support'] == false) {
|
||||
$supporthtml = "";
|
||||
} else {
|
||||
$supporturl = $module['supporturl'];
|
||||
$pluginname = $module['plugin'];
|
||||
$supporthtml = "<span id='link$modname'><a href='$supporturl' target='_blank'><i title='"._("Support page $pluginname")."' class='fa fa-phone-square'></i></a></span>";
|
||||
}
|
||||
}
|
||||
if (!empty($module["version"])) $version = " (".$module["version"].")"; else $version = "";
|
||||
ksort($arrMacs);
|
||||
foreach($arrMacs as $systype => $m) {
|
||||
foreach($m as $macaddr) {
|
||||
if ($systype == "") continue;
|
||||
|
||||
$html .= "<tr id='row$systype'>";
|
||||
$macs = "";
|
||||
foreach($module['interfaces'] as $intdetail)
|
||||
foreach($macaddr['interfaces'] as $intdetail)
|
||||
{
|
||||
$macs .= " {$intdetail['mac']}" ;
|
||||
}
|
||||
$html .= "<td>$modname</td>";
|
||||
$html .= "<td>{$module['name']}</td><td id=\"status$modname\">$macs</td><td>{$module['enable']}</td><td>{$module['user_mac']}</td></tr>";
|
||||
$html .= "<td>$systype</td>";
|
||||
$selecttypename="enable;".$systype.";".$macaddr['name'];
|
||||
$mactypename=htmlspecialchars("user_mac;".$systype.";".$macaddr['name']);
|
||||
$mactypeid=htmlspecialchars("user_mac".$systype."".$macaddr['name']);
|
||||
$user_mac_str = '<input type="text" name="'.$mactypename.'" id="'.$mactypeid.'" class="narrow" value="'.htmlspecialchars($macaddr['user_mac']).'" title="'._("random mac, you can supply your own").'" /><a><i onclick="maccreate(\''.$mactypeid.'\')" class="fa fa-refresh mac_generate" title="re-generate random mac address"></i></a>';
|
||||
$html .= "<td>{$macaddr['name']}</td><td id=\"status$systype\">$macs</td><td>";
|
||||
$html .="<select name='$selecttypename' class='audio narrow'>";
|
||||
$html .= mk_option($macaddr["enable"] , "disable", _("Disabled"));
|
||||
$html .= mk_option($macaddr["enable"] , "enable", _("Enabled"));
|
||||
$html .= "</select></td><td>".$user_mac_str."</td></tr>";
|
||||
$text = "";
|
||||
}
|
||||
}
|
||||
@@ -118,21 +98,15 @@ case 't1load':
|
||||
|
||||
$rtn = array();
|
||||
$rtn['html'] = $html;
|
||||
if ($init !== false) {$init = true; unlink($sysdrvinit);}
|
||||
$rtn['init'] = $init;
|
||||
echo json_encode($rtn);
|
||||
break;
|
||||
|
||||
case "update":
|
||||
$conf = $_POST['conf'];
|
||||
$module = $_POST['module'];
|
||||
if ($conf == "") $error = unlink("/boot/config/modprobe.d/$module.conf"); else $error = file_put_contents("/boot/config/modprobe.d/$module.conf",$conf);
|
||||
getmodules($module);
|
||||
$return = $arrModules[$module];
|
||||
$return['supportpage'] = $supportpage;
|
||||
if (is_array($return["modprobe"]))$return["modprobe"] = implode("\n",$return["modprobe"]);
|
||||
if ($error !== false) $return["error"] = false; else $return["error"] = true;
|
||||
echo json_encode($return);
|
||||
break;
|
||||
case "macaddress":
|
||||
$seed = 1;
|
||||
$prefix = '52:54:AA';
|
||||
$prefix.':'.$lv->macbyte(($seed * rand()) % 256).':'.$lv->macbyte(($seed * rand()) % 256).':'.$lv->macbyte(($seed * rand()) % 256);
|
||||
echo json_encode(['mac' => $prefix]);
|
||||
break;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -7,8 +7,5 @@ table#t1 tbody tr td:nth-child(3){width:15%}
|
||||
table#t1 tbody tr td:nth-child(4){width:20%}
|
||||
table#t1 tbody tr td:nth-child(5){width:25%;padding-right:0}
|
||||
table.t1.tablesorter .filtered{display:none}
|
||||
textarea[id^=text]{width:90%;margin:0!important;padding:0!important;float:right}
|
||||
span[id^=save]{margin:0!important;padding:0!important}
|
||||
span.pin{display:inline-block;float:left}
|
||||
i.pin{margin:0!important;padding:2px 0!important;float:left;clear:both}
|
||||
.tablesorter-header-inner{font-family:clear-sans;font-weight:bold}
|
||||
#macform .mac_generate{cursor:pointer;margin-left:-5px;color:#08C;font-size:1.3rem;transform:translate(0px, 2px)}
|
||||
Reference in New Issue
Block a user