Files
webgui/emhttp/plugins/dynamix.plugin.manager/Plugins.page
2025-09-20 18:02:45 -04:00

169 lines
6.5 KiB
Plaintext
Executable File

Menu="Tasks:50"
Type="xmenu"
Title="Installed Plugins"
Tag="icon-plugins"
Tabs="true"
Code="e944"
---
<?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.
*/
?>
<?
// Remove stale /tmp/plugin/*.plg entries (check that script 'plugin' is not running to avoid clashes)
if (!exec('pgrep --ns $$ -f '."$docroot/plugins/dynamix.plugin.manager/scripts/plugin")) {
foreach (glob("/tmp/plugins/*.{plg,txt}", GLOB_NOSORT+GLOB_BRACE) as $entry) if (!file_exists("/var/log/plugins/".basename($entry))) @unlink($entry);
}
$check = $notify['version'] ? 0 : 1;
?>
<link type="text/css" rel="stylesheet" href="<?autov('/webGui/styles/jquery.filetree.css')?>">
<script src="<?autov('/webGui/javascript/jquery.filetree.js')?>" charset="utf-8"></script>
<script>
const args = {};
function openInstall(cmd,title,plg,func) {
if (cmd == null) {
openPlugin(args.cmd,args.title,args.plg,args.func,1);
return;
}
args.cmd = cmd;
args.title = title;
args.plg = plg;
args.func = func;
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{cmd:'alert'},function(data) {
if (data==0) {
// no alert message - proceed with update
setTimeout(openInstall);
} else {
// show alert message and ask for confirmation
openAlert("showchanges <?=$alerts?>","_(Alert Message)_",'openInstall');
}
});
}
<?if ($display['resize']):?>
function resize(bind) {
var width = [];
var h = $('#plugin_list').height();
var s = Math.max(window.innerHeight-340,330);
if (h>s || bind) {
$('#plugin_list').height(s);
$('#plugin_table tbody tr:first-child td').each(function(){width.push($(this).width());});
$('#plugin_table thead tr th').each(function(i){$(this).width(width[i]);});
if (!bind) $('#plugin_table thead,#plugin_table tbody').addClass('fixed');
}
}
<?endif;?>
function multiRemove() {
if ($('input.remove:checked').length > 1) $('#removeall').show(); else $('#removeall').hide();
}
function updateList() {
var plugin = [];
$('input.update').each(function(){plugin.push($(this).attr('data'));});
var plugins = plugin.join('*');
$('#updateall').hide();
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{cmd:'pending',plugin:plugins},function() {
openPlugin("multiplugin update "+plugins,"_(Update All Plugins)_",":return","loadlist",1);
});
}
function removeList() {
var plugin = [];
$('input.remove:checked').each(function(){plugin.push($(this).attr('data'));});
var plugins = plugin.join('*');
$('#removeall').hide();
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{cmd:'pending',plugin:plugins},function() {
openPlugin("multiplugin remove "+plugins,"_(Remove Selected Plugins)_","","refresh",1);
});
}
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]);
var removeButton = $('input[data="'+row[0].substr(4).replace(/-/g,'.')+'.plg'+'"]');
if (row[2].indexOf('hourglass') >= 0) removeButton.hide(); else removeButton.show();
}
}
}
function initlist() {
timers.plugins = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{init:true,check:<?=$check?>},function(data) {
clearTimeout(timers.plugins);
$('#plugin_list').html(data);
<?if ($display['resize']):?>
resize();
$(window).bind('resize',function(){resize(true);});
<?endif;?>
if (data.search("colspan='6'")==-1) {
$('#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>"});
$('div.spinner.fixed').hide('slow');
loadlist();
}
});
}
function loadlist(id,check) {
if (id) timers.plugins = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.get('/plugins/dynamix.plugin.manager/include/ShowPlugins.php',{audit:id,check:check||<?=$check?>},function(data) {
data = data.split('\0');
var list = $('#plugin_list');
if (id) {
clearTimeout(timers.plugins);
$('div.spinner.fixed').hide('slow');
var cmd = id.split(':');
var tr = 'tr#'+cmd[0].replace(/[\. _]/g,'');
switch (cmd[1]) {
case 'update':
case 'return':
updateInfo(data[0]);
if (data[1] > 1) $('#updateall').show(); else $('#updateall').hide();
break;
case 'remove':
list.find(tr).remove();
break;
case 'install':
if (!list.find(tr).length) list.append(data[0]); loadlist(null,1);
break;
}
} else {
updateInfo(data[0]);
if (data[1] > 1) $('#updateall').show(); else $('#updateall').hide();
}
$('#plugin_table').trigger('update');
$('#checkall').find('input').prop('disabled',false);
});
}
$(function() {
initlist();
$('.tabs-container').append("<span id='checkall' class='status vhshift'><input type='button' value=\"_(Check For Updates)_\" onclick='openPlugin(\"checkall\",\"_(Plugin Update Check)_\",\":return\")' disabled></span>");
$('.tabs-container').append("<span id='updateall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value=\"_(Update All Plugins)_\" onclick='updateList()'></span>");
$('.tabs-container').append("<span id='removeall' class='status vhshift' style='display:none;margin-left:12px'><input type='button' value=\"_(Remove Selected Plugins)_\" onclick='removeList()'></span>");
});
</script>
<div class="TableContainer">
<table class='unraid tablesorter plugins shift' id='plugin_table'>
<thead>
<tr>
<th></th>
<th>_(Plugin)_</th>
<th>_(Author)_</th>
<th>_(Version)_</th>
<th>_(Status)_</th>
<th>_(Uninstall)_</th>
</tr>
</thead>
<tbody id="plugin_list"><tr><td colspan="6"></td><tr></tbody>
</table>
</div>