mirror of
https://github.com/unraid/webgui.git
synced 2026-01-17 23:20:02 -06:00
Plugins page loading improvements
This commit is contained in:
@@ -6,8 +6,8 @@ Tabs="true"
|
||||
Code="e944"
|
||||
---
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, 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,
|
||||
@@ -43,44 +43,60 @@ function resize(bind) {
|
||||
}
|
||||
}
|
||||
<?endif;?>
|
||||
function loadlist(id) {
|
||||
function init() {
|
||||
timers.plugins = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
|
||||
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{audit:id,check:<?=$check?>},function(d) {
|
||||
var data = d.split(/\0/);
|
||||
var list = $('#plugin_list');
|
||||
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{init:true},function(data) {
|
||||
clearTimeout(timers.plugins);
|
||||
if (id) {
|
||||
var cmd = id.split(':');
|
||||
var tr = 'tr#'+cmd[0].replace(/[\. _]/g,'');
|
||||
switch (cmd[1]) {
|
||||
case 'return' : list.html(data[0]); $('#plugin_table').trigger('destroy'); break;
|
||||
case 'remove' : list.find(tr).remove(); break;
|
||||
case 'update' : list.find(tr).remove();
|
||||
case 'install': if (!list.find(tr).length) list.append(data[0]).trigger('update'); break;
|
||||
}
|
||||
} else {
|
||||
list.html(data[0]);
|
||||
}
|
||||
$('#plugin_list').html(data);
|
||||
<?if ($display['resize']):?>
|
||||
resize();
|
||||
$(window).bind('resize',function(){resize(true);});
|
||||
<?endif;?>
|
||||
$('#plugin_table').tablesorter({sortList:[[4,0],[1,0]],sortAppend:[[1,0]],headers:{0:{sorter:false},5:{sorter:false}},textAttribute:'data'});
|
||||
$('.desc_readmore').readmore({maxHeight:80,moreLink:"<a href='#'><i class='fa fa-chevron-down'></i></a>",lessLink:"<a href='#'><i class='fa fa-chevron-up'></i></a>"});
|
||||
if (data[1]>1) $('#updateall').show(); else $('#updateall').hide();
|
||||
<?if ($check):?>
|
||||
$('#checkall').find('input').prop('disabled',false).show();
|
||||
<?endif;?>
|
||||
$('div.spinner.fixed').hide('slow');
|
||||
loadlist();
|
||||
});
|
||||
}
|
||||
function updateInfo(data) {
|
||||
var updates = data.split('\n');
|
||||
for (var n=0,update; update=updates[n]; n++) {
|
||||
var fields = update.split('\r');
|
||||
for (var i=0,field; field=fields[i]; i++) {
|
||||
var row = field.split('::');
|
||||
$('#'+row[0]).attr('data',row[1]).html(row[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function disableButton() {
|
||||
$('#plugin_list').find('input[type=button]').prop('disabled',true);
|
||||
}
|
||||
function loadlist(id) {
|
||||
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{audit:id,check:<?=$check?>},function(d) {
|
||||
var data = d.split(/\0/);
|
||||
var list = $('#plugin_list');
|
||||
if (id) {
|
||||
var cmd = id.split(':');
|
||||
var tr = 'tr#'+cmd[0].replace(/[\. _]/g,'');
|
||||
switch (cmd[1]) {
|
||||
case 'update' :
|
||||
case 'return' : updateInfo(data[0]); break;
|
||||
case 'remove' : list.find(tr).remove(); break;
|
||||
case 'install': if (!list.find(tr).length) list.append(data[0]).trigger('update'); break;
|
||||
}
|
||||
} else {
|
||||
updateInfo(data[0]);
|
||||
}
|
||||
$('#plugin_table').trigger('update');
|
||||
if (data[1]>0) $('#updateall').show(); else $('#updateall').hide();
|
||||
$('#checkall').find('input').prop('disabled',false);
|
||||
});
|
||||
}
|
||||
$(function() {
|
||||
loadlist();
|
||||
init();
|
||||
$('#plugin_tree').fileTree({root:'/boot/',filter:'plg'}, function(file) {$('#plugin_file').val(file);});
|
||||
$('.tabs').append("<span id='updateall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value='<?=_('Update All Plugins')?>' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=updateall\",\"<?=_('Update All Plugins')?>\",600,600,true,\"loadlist\",\":return\")'></span>");
|
||||
<?if ($check):?>
|
||||
$('.tabs').append("<span id='updateall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value='<?=_('Update All Plugins')?>' onclick='disableButton();openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=updateall\",\"<?=_('Update All Plugins')?>\",600,600,true,\"loadlist\",\":return\")'></span>");
|
||||
$('.tabs').append("<span id='checkall' class='status vhshift'><input type='button' value='<?=_('Check For Updates')?>' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkall\",\"<?=_('Plugin Update Check')?>\",600,600,true,\"loadlist\",\":return\")' disabled></span>");
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
<table class='tablesorter plugins shift' id='plugin_table'>
|
||||
|
||||
@@ -16,10 +16,10 @@ Tag="upload"
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$empty = "<tr><td colspan='6'><div class='spinner'></div></td></tr>";
|
||||
$empty = "<tr><td colspan='6'><div class='spinner'></div></td></tr>";
|
||||
$version = $branch = $date = _('unknown');
|
||||
$bzroot = file_exists('/boot/previous/bzroot');
|
||||
$check = $notify['unraidos'] ? 0 : 1;
|
||||
$bzroot = file_exists('/boot/previous/bzroot');
|
||||
$check = $notify['unraidos'] ? 0 : 1;
|
||||
|
||||
if (file_exists('/boot/previous/changes.txt')) {
|
||||
exec("head -n4 /boot/previous/changes.txt",$rows);
|
||||
@@ -77,16 +77,12 @@ function loadlist(id) {
|
||||
<?if ($bzroot):?>
|
||||
$('#previous').show();
|
||||
<?endif;?>
|
||||
<?if ($check):?>
|
||||
$('#checkos').prop('disabled',false);
|
||||
<?endif;?>
|
||||
});
|
||||
}
|
||||
$(function() {
|
||||
loadlist();
|
||||
<?if ($check):?>
|
||||
$('.tabs').append("<span class='status vhshift'><input type='button' id='checkos' value='<?=_('Check for Updates')?>' onclick='openBox(\"/plugins/dynamix.plugin.manager/scripts/plugin&arg1=checkos\",\"<?=_('System Update Check')?>\",600,600,true,\"loadlist\",\":return\")' disabled></span>");
|
||||
<?endif;?>
|
||||
});
|
||||
</script>
|
||||
<table class='tablesorter plugins shift' id='os_table'>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, 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,
|
||||
@@ -27,8 +27,8 @@ function language($method, $arg = '') {
|
||||
|
||||
function check_plugin($arg, &$ncsi) {
|
||||
// Get network connection status indicator (NCSI)
|
||||
if ($ncsi===null) passthru("wget --quiet --spider --timeout=10 --tries=1 http://www.msftncsi.com/ncsi.txt",$ncsi);
|
||||
return $ncsi===0 ? plugin('check',$arg) : false;
|
||||
if ($ncsi===null) $ncsi = exec("wget --spider -nv -T10 -t1 http://www.msftncsi.com/ncsi.txt 2>&1|grep -o 'OK'");
|
||||
return $ncsi ? plugin('check',$arg) : false;
|
||||
}
|
||||
|
||||
function make_link($method, $arg, $extra='') {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, 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,
|
||||
@@ -22,18 +22,81 @@ $system = $_GET['system'] ?? false;
|
||||
$branch = $_GET['branch'] ?? false;
|
||||
$audit = $_GET['audit'] ?? false;
|
||||
$check = $_GET['check'] ?? false;
|
||||
$init = $_GET['init'] ?? false;
|
||||
$empty = true;
|
||||
$install = false;
|
||||
$updates = 0;
|
||||
$builtin = ['unRAIDServer'];
|
||||
$plugins = "/var/log/plugins/*.plg";
|
||||
$ncsi = null; // network connection status indicator
|
||||
$default = "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-check-square-o icon'></i> "._('No plugins installed')."</td><tr>";
|
||||
|
||||
if ($init) {
|
||||
foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) {
|
||||
//only consider symlinks
|
||||
$plugin_file = @readlink($plugin_link);
|
||||
if ($plugin_file===false) continue;
|
||||
//plugin name
|
||||
$name = plugin('name',$plugin_file) ?: basename($plugin_file,".plg");
|
||||
//skip system plugin
|
||||
if (in_array($name,$builtin)) continue;
|
||||
//icon + link
|
||||
$launch = plugin('launch',$plugin_file);
|
||||
if ($icon = plugin('icon',$plugin_file)) {
|
||||
if (substr($icon,-4)=='.png') {
|
||||
if (file_exists("plugins/$name/images/$icon")) {
|
||||
$icon = "plugins/$name/images/$icon";
|
||||
} elseif (file_exists("plugins/$name/$icon")) {
|
||||
$icon = "plugins/$name/$icon";
|
||||
} else {
|
||||
$icon = "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png";
|
||||
}
|
||||
$icon = "<img src='/$icon' class='list'>";
|
||||
} elseif (substr($icon,0,5)=='icon-') {
|
||||
$icon = "<i class='$icon list'></i>";
|
||||
} else {
|
||||
if (substr($icon,0,3)!='fa-') $icon = "fa-$icon";
|
||||
$icon = "<i class='fa $icon list'></i>";
|
||||
}
|
||||
$link = $launch ? "<a href='/$launch' class='list'>$icon</a>" : $icon;
|
||||
} else {
|
||||
$icon = icon($name);
|
||||
$link = $launch ? "<a href='/$launch' class='list'><img src='/$icon' class='list'></a>" : "<img src='/$icon' class='list'>";
|
||||
}
|
||||
//description
|
||||
$readme = "plugins/{$name}/README.md";
|
||||
$desc = file_exists($readme) ? Markdown(file_get_contents($readme)) : Markdown("**{$name}**");
|
||||
//support
|
||||
$support = plugin('support',$plugin_file) ?: "";
|
||||
$support = $support ? "<a href='$support' target='_blank'>"._('Support Thread')."</a>" : "";
|
||||
//author
|
||||
$author = plugin('author',$plugin_file) ?: _('anonymous');
|
||||
//version
|
||||
$version = plugin('version',$plugin_file) ?: _('unknown');
|
||||
$date = str_replace('.','',$version);
|
||||
//status
|
||||
$status = _('unknown');
|
||||
$id = str_replace('.','-',$name);
|
||||
$empty = false;
|
||||
echo "<tr id=\"".str_replace(['.',' ','_'],'',basename($plugin_file,'.plg'))."\">";
|
||||
echo "<td>$link</td>";
|
||||
echo "<td><span class='desc_readmore' style='display:block'>$desc</span> $support</td>";
|
||||
echo "<td>$author</td>";
|
||||
echo "<td id='vid-$id' data='$date'>$version <span class='fa fa-info-circle fa-fw big blue-text'></span></td>";
|
||||
echo "<td id='sid-$id' data='0'><span class='fa fa-spin fa-refresh'></span> $status</td>";
|
||||
echo "<td>".make_link('remove',basename($plugin_file))."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
if ($empty) echo $default;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($audit) {
|
||||
list($plg,$action) = explode(':',$audit);
|
||||
[$plg,$action] = explode(':',$audit);
|
||||
switch ($action) {
|
||||
case 'return' : $check = true; break;
|
||||
case 'remove' : return;
|
||||
case 'install':
|
||||
case 'install': $install = true;
|
||||
case 'update' : $plugins = "/var/log/plugins/$plg.plg"; break;
|
||||
}
|
||||
}
|
||||
@@ -66,45 +129,44 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) {
|
||||
$plugin_file = $tmp_file;
|
||||
}
|
||||
}
|
||||
if ($system || $install) {
|
||||
//link/icon
|
||||
$launch = plugin('launch',$plugin_file);
|
||||
if ($icon = plugin('icon',$plugin_file)) {
|
||||
if (substr($icon,-4)=='.png') {
|
||||
if (file_exists("plugins/$name/images/$icon")) {
|
||||
$icon = "plugins/$name/images/$icon";
|
||||
} elseif (file_exists("plugins/$name/$icon")) {
|
||||
$icon = "plugins/$name/$icon";
|
||||
$launch = plugin('launch',$plugin_file);
|
||||
if ($icon = plugin('icon',$plugin_file)) {
|
||||
if (substr($icon,-4)=='.png') {
|
||||
if (file_exists("plugins/$name/images/$icon")) {
|
||||
$icon = "plugins/$name/images/$icon";
|
||||
} elseif (file_exists("plugins/$name/$icon")) {
|
||||
$icon = "plugins/$name/$icon";
|
||||
} else {
|
||||
$icon = "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png";
|
||||
}
|
||||
$icon = "<img src='/$icon' class='list'>";
|
||||
} elseif (substr($icon,0,5)=='icon-') {
|
||||
$icon = "<i class='$icon list'></i>";
|
||||
} else {
|
||||
$icon = "plugins/dynamix.plugin.manager/images/dynamix.plugin.manager.png";
|
||||
if (substr($icon,0,3)!='fa-') $icon = "fa-$icon";
|
||||
$icon = "<i class='fa $icon list'></i>";
|
||||
}
|
||||
$icon = "<img src='/$icon' class='list'>";
|
||||
} elseif (substr($icon,0,5)=='icon-') {
|
||||
$icon = "<i class='$icon list'></i>";
|
||||
$link = $launch ? "<a href='/$launch' class='list'>$icon</a>" : $icon;
|
||||
} else {
|
||||
if (substr($icon,0,3)!='fa-') $icon = "fa-$icon";
|
||||
$icon = "<i class='fa $icon list'></i>";
|
||||
$icon = icon($name);
|
||||
$link = $launch ? "<a href='/$launch' class='list'><img src='/$icon' class='list'></a>" : "<img src='/$icon' class='list'>";
|
||||
}
|
||||
$link = $launch ? "<a href='/$launch' class='list'>$icon</a>" : $icon;
|
||||
} else {
|
||||
$icon = icon($name);
|
||||
$link = $launch ? "<a href='/$launch' class='list'><img src='/$icon' class='list'></a>" : "<img src='/$icon' class='list'>";
|
||||
}
|
||||
//description
|
||||
$readme = "plugins/{$name}/README.md";
|
||||
if (file_exists($readme))
|
||||
$desc = Markdown(file_get_contents($readme));
|
||||
else
|
||||
$desc = Markdown("**{$name}**");
|
||||
$readme = "plugins/{$name}/README.md";
|
||||
$desc = file_exists($readme) ? Markdown(file_get_contents($readme)) : Markdown("**{$name}**");
|
||||
//author
|
||||
$author = plugin('author',$plugin_file) ?: _('anonymous');
|
||||
$author = plugin('author',$plugin_file) ?: _('anonymous');
|
||||
//support
|
||||
$support = plugin('support',$plugin_file) ?: "";
|
||||
$support = $support ? "<a href='$support' target='_blank'>"._('Support Thread')."</a>" : "";
|
||||
//category
|
||||
$category = plugin('category',$plugin_file) ?: (strpos($version,'-')!==false ? 'next' : 'stable');
|
||||
}
|
||||
//version
|
||||
$version = plugin('version',$plugin_file) ?: _('unknown');
|
||||
$date = str_replace('.','',$version);
|
||||
//support
|
||||
$support = plugin('support',$plugin_file) ?: "";
|
||||
$support = $support ? "<a href='$support' target='_blank'>"._('Support Thread')."</a>" : "";
|
||||
//category
|
||||
$category = plugin('category',$plugin_file) ?: (strpos($version,'-')!==false ? 'next' : 'stable');
|
||||
//status
|
||||
$status = _('unknown');
|
||||
$changes_file = $plugin_file;
|
||||
@@ -141,29 +203,34 @@ foreach (glob($plugins,GLOB_NOSORT) as $plugin_link) {
|
||||
}
|
||||
//write plugin information
|
||||
$empty = false;
|
||||
echo "<tr id=\"".str_replace(['.',' ','_'],'',basename($plugin_file,'.plg'))."\">";
|
||||
echo "<td>$link</td>";
|
||||
echo "<td><span class='desc_readmore' style='display:block'>$desc</span> $support</td>";
|
||||
echo "<td>$author</td>";
|
||||
echo "<td data='$date'>$version</td>";
|
||||
echo "<td data='$rank'>$status</td>";
|
||||
echo "<td>";
|
||||
if ($system) {
|
||||
if ($system || $install) {
|
||||
// regular table construct for system plugin or manual install
|
||||
echo "<tr id=\"".str_replace(['.',' ','_'],'',basename($plugin_file,'.plg'))."\">";
|
||||
echo "<td>$link</td>";
|
||||
echo "<td><span class='desc_readmore' style='display:block'>$desc</span> $support</td>";
|
||||
echo "<td>$author</td>";
|
||||
echo "<td data='$date'>$version</td>";
|
||||
echo "<td data='$rank'>$status</td>";
|
||||
echo "<td>";
|
||||
if ($os) {
|
||||
$regular = ['stable','next'];
|
||||
echo "<select id='change_branch' class='auto' onchange='update_table(this.value)'>";
|
||||
foreach ($regular as $choice) echo mk_options($category,$choice);
|
||||
if (!in_array($category,$regular)) echo mk_options($category,$category);
|
||||
echo "</select>";
|
||||
} else {
|
||||
echo make_link('remove',basename($plugin_file));
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
} else {
|
||||
echo make_link('remove',basename($plugin_file));
|
||||
// selective updates for user plugins
|
||||
$id = str_replace('.','-',$name);
|
||||
echo "vid-$id::$date::$version\rsid-$id::$rank::$status\n";
|
||||
}
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
//remove temporary symlink
|
||||
@unlink("/var/log/plugins/$tmp_plg");
|
||||
}
|
||||
if ($empty) echo "<tr><td colspan='6' style='text-align:center;padding-top:12px'><i class='fa fa-check-square-o icon'></i> "._('No plugins installed')."</td><tr>";
|
||||
if ($empty) echo $default;
|
||||
echo "\0".$updates;
|
||||
?>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2020, Lime Technology
|
||||
* Copyright 2012-2020, Bergware International.
|
||||
/* Copyright 2005-2021, Lime Technology
|
||||
* Copyright 2012-2021, 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,
|
||||
@@ -26,7 +26,10 @@ $_SESSION['locale'] = $unraid['display']['locale'];
|
||||
$_SERVER['REQUEST_URI'] = "scripts";
|
||||
require_once "$docroot/webGui/include/Translations.php";
|
||||
|
||||
|
||||
function apos($text) {
|
||||
// So that "'" doesn't show up in email
|
||||
return str_replace("'","'",$text);
|
||||
}
|
||||
$current = parse_ini_file('/etc/unraid-version');
|
||||
$server = strtoupper($var['NAME']);
|
||||
$output = $unraid['notify']['plugin'];
|
||||
@@ -45,10 +48,9 @@ foreach (glob("/$tmp/*.plg", GLOB_NOSORT) as $file) {
|
||||
$min = plugin('min', $file) ?: $current['version'];
|
||||
// silently suppress bad download of PLG file
|
||||
if (strcmp($new, $old)>0 && !version_compare($min,$current['version'],">")) {
|
||||
// So that "'" doesn't show up in email
|
||||
$event = str_replace("'","'",_("Plugin")." - $name [$new]");
|
||||
$subject = str_replace("'","'",sprintf(_("Notice [%s] - Version update %s"),$server,$new));
|
||||
$description = str_replace("'","'",sprintf(_("A new version of %s is available"),$name));
|
||||
$event = apos(_("Plugin")." - $name [$new]");
|
||||
$subject = apos(sprintf(_("Notice [%s] - Version update %s"),$server,$new));
|
||||
$description = apos(sprintf(_("A new version of %s is available"),$name));
|
||||
exec("$notify -e ".escapeshellarg($event)." -s ".escapeshellarg($subject)." -d ".escapeshellarg($description)." -i ".escapeshellarg("normal $output")." -l '/Plugins' -x");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user