added dynamic package description tootips
updated tablesorter to v2.25.0 add tablesorter widgets (filter, saveSort, stickyHeaders, hover highlight) added cli options to packagemanager script
This commit is contained in:
parent
71e7008acd
commit
0495315d4f
|
@ -5,27 +5,40 @@ Title="Nerd Pack"
|
||||||
<?php
|
<?php
|
||||||
include("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
|
include("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
|
||||||
|
|
||||||
|
$theme = $display["theme"];
|
||||||
|
$plg_path ="/boot/config/plugins/NerdPack";// plugin path
|
||||||
|
$pkg_path = "$plg_path/packages"; // package path
|
||||||
|
|
||||||
$pkg_repo = "https://api.github.com/repos/eschultz/unraid6-nerdpack/contents/packages";
|
$pkg_repo = "https://api.github.com/repos/eschultz/unraid6-nerdpack/contents/packages";
|
||||||
$repo_file= "/boot/config/plugins/NerdPack/packages.json";
|
$repo_file= "$pkg_path/packages.json";
|
||||||
|
|
||||||
|
$pkg_desc = "https://raw.githubusercontent.com/dmacias72/unRAID-plugins/master/plugins/NerdPack-desc";
|
||||||
|
$desc_file= "$pkg_path/packages-desc";
|
||||||
|
|
||||||
get_content_from_github($pkg_repo, $repo_file);
|
get_content_from_github($pkg_repo, $repo_file);
|
||||||
|
get_content_from_github($pkg_desc, $desc_file);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/plugins/NerdPack/styles/NerdPack.css">
|
||||||
|
<link type="text/css" rel="stylesheet" href="/plugins/NerdPack/styles/NerdPack-<?=$theme;?>.css">
|
||||||
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css">
|
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css">
|
||||||
|
|
||||||
<span class="status" style="display: inline-block; margin-right: 110px;margin-top: -45px;"><input id="removepkg" type="checkbox"></span>
|
<span class="status" style="display: inline-block; margin-right: 110px;margin-top: -45px;"><input id="uninstallpkg" type="checkbox"></span>
|
||||||
<span class="status" style="display: inline-block;margin-top: -45px;"><input id="deletepkg" type="checkbox"></span>
|
<span class="status" style="display: inline-block;margin-top: -45px;"><input id="deletepkg" type="checkbox"></span>
|
||||||
|
|
||||||
<form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame">
|
<form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame">
|
||||||
<input type="hidden" name="#file" value="NerdPack/NerdPack.cfg" />
|
<input type="hidden" name="#file" value="NerdPack/NerdPack.cfg" />
|
||||||
<table style="margin-top:-22px;" class="tablesorter" id="tblPackages">
|
|
||||||
|
<table class="tablesorter hover-highlight" id="tblPackages">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th> Name </th>
|
<th class="filter-name" data-placeholder="Search..."> Name </th>
|
||||||
<th> Version </th>
|
<th class="filter-version" data-placeholder="by status"> Version </th>
|
||||||
<th> Size (kB) </th>
|
<th class="sorter-metric filter-false" data-placeholder="by size"
|
||||||
<th> Downloaded </th>
|
data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B"> Size </th>
|
||||||
<th> Installed </th>
|
<th class="filter-downloaded" data-placeholder="by download"> Downloaded </th>
|
||||||
<th><input id="checkall" type="checkbox"></th>
|
<th class="filter-installed" data-placeholder="by install"> Installed </th>
|
||||||
|
<th class="sorter-false filter-false"><input id="checkall" type="checkbox"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -37,4 +50,6 @@ get_content_from_github($pkg_repo, $repo_file);
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<script type="text/javascript" src="/plugins/NerdPack/javascript/jquery.NerdPack.js"></script>
|
<script type="text/javascript" src="/plugins/NerdPack/javascript/jquery.NerdPack.js"></script>
|
||||||
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
<script type="text/javascript" src="/plugins/NerdPack/javascript/jquery.tablesorter.combined.js"></script>
|
||||||
|
<script type="text/javascript" src="/plugins/NerdPack/javascript/parsers/parser-metric.js"></script>
|
||||||
|
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager
|
/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager --quiet
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
// Progress bar for curl download
|
// Progress bar for curl download
|
||||||
function progress_bar($download_size, $downloaded_size, $upload_size = null, $uploaded_size = null)
|
function progress_bar($download_size, $downloaded_size, $upload_size = null, $uploaded_size = null)
|
||||||
{
|
{
|
||||||
|
ob_start();
|
||||||
static $previousProgress = 0;
|
static $previousProgress = 0;
|
||||||
|
|
||||||
if ($download_size == 0)
|
if ($download_size == 0)
|
||||||
|
@ -29,12 +30,13 @@ function progress_bar($download_size, $downloaded_size, $upload_size = null, $up
|
||||||
|
|
||||||
echo $status_bar;
|
echo $status_bar;
|
||||||
ob_flush();
|
ob_flush();
|
||||||
flush();
|
|
||||||
|
|
||||||
if($progress == 100) {
|
if($progress == 100) {
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ob_end_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Download a file from given url
|
// Download a file from given url
|
||||||
|
@ -81,4 +83,4 @@ function file_check_sha($file, $sha){
|
||||||
$return = ($sha_file == $sha) ? true : false;
|
$return = ($sha_file == $sha) ? true : false;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
function format_size($value, $decimals, $unit='?') {
|
||||||
|
if ($value == '')
|
||||||
|
return 'unknown';
|
||||||
|
|
||||||
|
/* Autodetect unit that's appropriate */
|
||||||
|
if ($unit == '?') {
|
||||||
|
if ($value >= 1099511627776)
|
||||||
|
$unit = 'T';
|
||||||
|
else
|
||||||
|
if ($value >= (1 << 30))
|
||||||
|
$unit = 'G';
|
||||||
|
else
|
||||||
|
if ($value >= (1 << 20))
|
||||||
|
$unit = 'M';
|
||||||
|
else
|
||||||
|
if ($value >= (1 << 10))
|
||||||
|
$unit = 'K';
|
||||||
|
else
|
||||||
|
$unit = 'B';
|
||||||
|
}
|
||||||
|
|
||||||
|
$unit = strtoupper($unit);
|
||||||
|
|
||||||
|
switch ($unit) {
|
||||||
|
case 'T': return number_format($value / (float)1099511627776, $decimals).' TB';
|
||||||
|
case 'G': return number_format($value / (float)(1 << 30), $decimals).' GB';
|
||||||
|
case 'M': return number_format($value / (float)(1 << 20), $decimals).' MB';
|
||||||
|
case 'K': return number_format($value / (float)(1 << 10), $decimals).' kB';
|
||||||
|
case 'B': return $value.' B';
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
?>
|
|
@ -1,24 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
$config_file = "/boot/config/plugins/NerdPack/NerdPack.cfg";
|
require_once("/usr/local/emhttp/plugins/NerdPack/include/NerdPackHelpers.php");
|
||||||
|
|
||||||
$pkg_path = "/boot/config/plugins/NerdPack/packages/"; // package path
|
$plg_path ="/boot/config/plugins/NerdPack";// plugin path
|
||||||
|
$pkg_path = "$plg_path/packages"; // package path
|
||||||
|
$config_file = "$plg_path/NerdPack.cfg";// config file
|
||||||
|
|
||||||
$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : array(); // get package configs
|
$pkg_cfg = (is_file($config_file)) ? parse_ini_file($config_file) : array(); // get package configs
|
||||||
|
|
||||||
$pkgs_downloaded = array_diff( scandir($pkg_path, 1), array(".", "..") ); // get array of packages
|
$pkgs_downloaded = array_diff( scandir($pkg_path, 1), array(".", "..") ); // get array of downloaded packages
|
||||||
|
|
||||||
$pkgs_installed = array_diff( scandir("/var/log/packages", 1), array(".", "..") ); // get array of all installed packages
|
$pkgs_installed = array_diff( scandir("/var/log/packages", 1), array(".", "..") ); // get array of all installed packages
|
||||||
|
|
||||||
$pkgs_file = file_get_contents("/boot/config/plugins/NerdPack/packages.json");
|
$pkgs_desc_file = file_get_contents("$pkg_path/packages-desc");// get package descriptions
|
||||||
|
$pkgs_desc_array = json_decode($pkgs_desc_file, true);
|
||||||
$pkgs_github = json_decode($pkgs_file, true);
|
|
||||||
|
|
||||||
|
$pkgs_github_file = file_get_contents("$pkg_path/packages.json");// get packages
|
||||||
|
$pkgs_github_array = json_decode($pkgs_github_file, true);
|
||||||
|
|
||||||
$pkgs_array = array();
|
$pkgs_array = array();
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($pkgs_github); $i++) {
|
for ($i = 0; $i < sizeof($pkgs_github_array); $i++) {
|
||||||
|
|
||||||
$pkg_nameArray = explode("-", $pkgs_github[$i]["name"]); // split package name into array
|
$pkg_nameArray = explode("-", $pkgs_github_array[$i]["name"]); // split package name into array
|
||||||
|
|
||||||
$pkg_name = $pkg_nameArray[0];
|
$pkg_name = $pkg_nameArray[0];
|
||||||
if (sizeof($pkg_nameArray) > 4){ //if package name has a subset get it
|
if (sizeof($pkg_nameArray) > 4){ //if package name has a subset get it
|
||||||
|
@ -35,7 +38,7 @@ for ($i = 0; $i < sizeof($pkgs_github); $i++) {
|
||||||
|
|
||||||
$pkg = array();
|
$pkg = array();
|
||||||
|
|
||||||
$pkg["name"] = $pkgs_github[$i]["name"]; // add full package name
|
$pkg["name"] = $pkgs_github_array[$i]["name"]; // add full package name
|
||||||
|
|
||||||
$pkg["pkgname"] = $pkg_name; // add package name only
|
$pkg["pkgname"] = $pkg_name; // add package name only
|
||||||
|
|
||||||
|
@ -43,24 +46,26 @@ for ($i = 0; $i < sizeof($pkgs_github); $i++) {
|
||||||
|
|
||||||
$pkg["pkgversion"] = $pkg_version; // add package name with underscored version
|
$pkg["pkgversion"] = $pkg_version; // add package name with underscored version
|
||||||
|
|
||||||
$pkg["size"] = $pkgs_github[$i]["size"]; // add package size
|
$pkg["size"] = format_size($pkgs_github_array[$i]["size"], 1, '?'); // add package size
|
||||||
|
|
||||||
// checks if package name is installed
|
// checks if package name is installed
|
||||||
$pkg["installed"] = preg_grep($pkg_pattern , $pkgs_installed) ? "yes" : "no";
|
$pkg["installed"] = preg_grep($pkg_pattern , $pkgs_installed) ? "yes" : "no";
|
||||||
|
|
||||||
// checks if package is installed equals github exactly
|
// checks if package is installed equals github exactly
|
||||||
$pkg["installeq"] = in_array( pathinfo($pkgs_github[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no";
|
$pkg["installeq"] = in_array( pathinfo($pkgs_github_array[$i]["name"], PATHINFO_FILENAME), $pkgs_installed ) ? "yes" : "no";
|
||||||
|
|
||||||
// checks if package name is downloaded
|
// checks if package name is downloaded
|
||||||
$pkg["downloaded"] = preg_grep($pkg_pattern , $pkgs_downloaded) ? "yes" : "no";
|
$pkg["downloaded"] = preg_grep($pkg_pattern , $pkgs_downloaded) ? "yes" : "no";
|
||||||
|
|
||||||
// checks if package is downloaded equals github exactly
|
// checks if package is downloaded equals github exactly
|
||||||
$pkg["downloadeq"] = in_array( $pkgs_github[$i]["name"], $pkgs_downloaded ) ? "yes" : "no";
|
$pkg["downloadeq"] = in_array( $pkgs_github_array[$i]["name"], $pkgs_downloaded ) ? "yes" : "no";
|
||||||
|
|
||||||
$pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference
|
$pkg["config"] = isset($pkg_cfg["$pkg_nver"]) ? $pkg_cfg["$pkg_nver"] : "no"; // checks config for install preference
|
||||||
|
|
||||||
|
$pkg["desc"] = $pkgs_desc_array["$pkg_name"];
|
||||||
|
|
||||||
$pkgs_array[] = $pkg;
|
$pkgs_array[] = $pkg;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode($pkgs_array);
|
echo json_encode($pkgs_array);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,17 +1,30 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
//tablesorter options
|
//tablesorter options
|
||||||
$('#tblPackages').tablesorter({headers:{5:{sorter:false}}});
|
$('#tblPackages').tablesorter({
|
||||||
|
sortList: [[0,1]],
|
||||||
|
widgets: ['saveSort', 'filter', 'stickyHeaders'],
|
||||||
|
widgetOptions: {
|
||||||
|
stickyHeaders_filteredToTop: true,
|
||||||
|
filter_hideEmpty : true,
|
||||||
|
filter_saveFilters : true,
|
||||||
|
filter_functions: {
|
||||||
|
'.filter-version' : true,
|
||||||
|
'.filter-downloaded' : true,
|
||||||
|
'.filter-installed' : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// "uninstall package" switch and cookie
|
// "uninstall package" switch and cookie
|
||||||
$('#removepkg')
|
$('#uninstallpkg')
|
||||||
.switchButton({
|
.switchButton({
|
||||||
labels_placement: "left",
|
labels_placement: "left",
|
||||||
on_label: 'unInstall On',
|
on_label: 'unInstall On',
|
||||||
off_label: 'unInstall Off',
|
off_label: 'unInstall Off',
|
||||||
checked: $.cookie('nerdpack_packages_remove') == 'remove'
|
checked: $.cookie('nerdpack_packages_uninstall') == '--uninstall'
|
||||||
})
|
})
|
||||||
.change(function () {
|
.change(function () {
|
||||||
$.cookie('nerdpack_packages_remove', $('#removepkg').prop('checked') ? 'remove' : 'donotremove', { expires: 3650 });
|
$.cookie('nerdpack_packages_uninstall', $('#uninstallpkg').prop('checked') ? '--uninstall' : '', { expires: 3650 });
|
||||||
});
|
});
|
||||||
|
|
||||||
// "delete package" switch and cookie
|
// "delete package" switch and cookie
|
||||||
|
@ -20,10 +33,10 @@ $(function(){
|
||||||
labels_placement: "left",
|
labels_placement: "left",
|
||||||
on_label: 'delete On',
|
on_label: 'delete On',
|
||||||
off_label: 'delete Off',
|
off_label: 'delete Off',
|
||||||
checked: $.cookie('nerdpack_packages_delete') == 'delete'
|
checked: $.cookie('nerdpack_packages_delete') == '--delete'
|
||||||
})
|
})
|
||||||
.change(function () {
|
.change(function () {
|
||||||
$.cookie('nerdpack_packages_delete', $('#removepkg').prop('checked') ? 'delete' : 'donotdelete', { expires: 3650 });
|
$.cookie('nerdpack_packages_delete', $('#deletepkg').prop('checked') ? '--delete' : '', { expires: 3650 });
|
||||||
});
|
});
|
||||||
|
|
||||||
// select all packages switch
|
// select all packages switch
|
||||||
|
@ -67,10 +80,10 @@ function packageManager() {
|
||||||
url : "/update.php",
|
url : "/update.php",
|
||||||
data : $('#package_form').serializeArray(),
|
data : $('#package_form').serializeArray(),
|
||||||
success: function() {
|
success: function() {
|
||||||
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=download'+
|
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=--download'+
|
||||||
'&arg2='+$.cookie('nerdpack_packages_remove')+
|
'&arg2='+$.cookie('nerdpack_packages_uninstall')+
|
||||||
'&arg3='+$.cookie('nerdpack_packages_delete'),
|
'&arg3='+$.cookie('nerdpack_packages_delete'),
|
||||||
'Manage Packages',600,900,true);
|
'Package Manager',600,900,true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -92,9 +105,9 @@ function packageQuery() {
|
||||||
|
|
||||||
$("#tblPackages tbody").append(
|
$("#tblPackages tbody").append(
|
||||||
"<tr>"+
|
"<tr>"+
|
||||||
"<td>"+data[i].name+"</td>"+ //package name
|
"<td class='package' title='"+data[i].desc+"'>"+data[i].name+"</td>"+ //package name
|
||||||
"<td>"+Update+"</td>"+ //package status
|
"<td>"+Update+"</td>"+ //package status
|
||||||
"<td>"+(data[i].size / 1000).toFixed(0)+"</td>"+ //package size
|
"<td>"+data[i].size+"</td>"+ //package size
|
||||||
"<td>"+data[i].downloaded+"</td>"+ //package installed
|
"<td>"+data[i].downloaded+"</td>"+ //package installed
|
||||||
"<td>"+data[i].installed+"</td>"+ //package installed
|
"<td>"+data[i].installed+"</td>"+ //package installed
|
||||||
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox'>"+
|
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox'>"+
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,92 @@
|
||||||
|
/*! Parser: metric *//*
|
||||||
|
* Demo: http://jsfiddle.net/Mottie/abkNM/382/
|
||||||
|
* Set the metric name in the header (defaults to 'm|meter'), e.g.
|
||||||
|
* <th data-metric-name-abbr="b|B" data-metric-name-full="byte|Byte|BYTE">HDD Size</th>
|
||||||
|
* <th data-metric-name="m|meter">Distance</th> <!-- data-metric-name is deprecated in v2.22.2 -->
|
||||||
|
*/
|
||||||
|
/*jshint jquery:true */
|
||||||
|
;( function( $ ) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var prefixes = {
|
||||||
|
// 'prefix' : [ base 10, base 2 ]
|
||||||
|
// skipping IEEE 1541 defined prefixes: kibibyte, mebibyte, etc, for now.
|
||||||
|
'Y|Yotta|yotta' : [ 1e24, Math.pow(1024, 8) ], // 1024^8
|
||||||
|
'Z|Zetta|zetta' : [ 1e21, Math.pow(1024, 7) ], // 1024^7
|
||||||
|
'E|Exa|exa' : [ 1e18, Math.pow(1024, 6) ], // 1024^6
|
||||||
|
'P|Peta|peta' : [ 1e15, Math.pow(1024, 5) ], // 1024^5
|
||||||
|
'T|Tera|tera' : [ 1e12, Math.pow(1024, 4) ], // 1024^4
|
||||||
|
'G|Giga|giga' : [ 1e9, Math.pow(1024, 3) ], // 1024^3
|
||||||
|
'M|Mega|mega' : [ 1e6, Math.pow(1024, 2) ], // 1024^2
|
||||||
|
'k|Kilo|kilo' : [ 1e3, 1024 ], // 1024
|
||||||
|
// prefixes below here are rarely, if ever, used in binary
|
||||||
|
'h|hecto' : [ 1e2, 1e2 ],
|
||||||
|
'da|deka' : [ 1e1, 1e1 ],
|
||||||
|
'd|deci' : [ 1e-1, 1e-1 ],
|
||||||
|
'c|centi' : [ 1e-2, 1e-2 ],
|
||||||
|
'm|milli' : [ 1e-3, 1e-3 ],
|
||||||
|
'µ|micro' : [ 1e-6, 1e-6 ],
|
||||||
|
'n|nano' : [ 1e-9, 1e-9 ],
|
||||||
|
'p|pico' : [ 1e-12, 1e-12 ],
|
||||||
|
'f|femto' : [ 1e-15, 1e-15 ],
|
||||||
|
'a|atto' : [ 1e-18, 1e-18 ],
|
||||||
|
'z|zepto' : [ 1e-21, 1e-21 ],
|
||||||
|
'y|yocto' : [ 1e-24, 1e-24 ]
|
||||||
|
},
|
||||||
|
// the \\d+ will not catch digits with spaces, commas or decimals; so use the value from n instead
|
||||||
|
RegLong = '(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(',
|
||||||
|
RegAbbr = '(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(',
|
||||||
|
// make these case-insensitive because we all forget the case for these binary values
|
||||||
|
byteTest = /^[b|bit|byte|o|octet]/i;
|
||||||
|
|
||||||
|
$.tablesorter.addParser({
|
||||||
|
id: 'metric',
|
||||||
|
is: function() {
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
format: function(txt, table, cell, cellIndex) {
|
||||||
|
var unit, isBinary, nameLong, nameAbbr,
|
||||||
|
// default base unit name
|
||||||
|
base = 'm|meter',
|
||||||
|
// process number here to get a numerical format (us or eu)
|
||||||
|
num = $.tablesorter.formatFloat( txt.replace(/[^\w,. \-()]/g, ''), table ),
|
||||||
|
$t = table.config.$headerIndexed[ cellIndex ],
|
||||||
|
regex = $t.data( 'metric' );
|
||||||
|
if ( !regex ) {
|
||||||
|
// stored values
|
||||||
|
unit = ( $t.attr('data-metric-name') || base ).split( '|' );
|
||||||
|
nameLong = $t.attr( 'data-metric-name-full' ) || '';
|
||||||
|
nameAbbr = $t.attr( 'data-metric-name-abbr' ) || '';
|
||||||
|
regex = [ nameLong || unit[1] || unit[0].substring(1), nameAbbr || unit[0] ];
|
||||||
|
isBinary = byteTest.test( regex.join( '' ) );
|
||||||
|
// adding 'data-metric-name-full' which would contain 'byte|BYTE|Byte' etc
|
||||||
|
regex[2] = new RegExp( RegLong + (
|
||||||
|
( nameLong === '' ? '' : nameLong + '|' + nameAbbr ) ||
|
||||||
|
// with data-metric-name='b|byte', we end up with 'b|B|byte|BYTE' - maybe not the best solution for case-insensitivity
|
||||||
|
( ( isBinary ? regex[0].toLowerCase() + '|' + regex[0].toUpperCase() : regex[0] ) + '|' +
|
||||||
|
( isBinary ? regex[1].toLowerCase() + '|' + regex[1].toUpperCase() : regex[1] ) ) ) +
|
||||||
|
')' );
|
||||||
|
// adding 'data-metric-name-abbr' which would contain 'b|B' etc
|
||||||
|
regex[3] = new RegExp( RegAbbr + ( nameAbbr ||
|
||||||
|
( ( isBinary ? regex[1].toLowerCase() + '|' + regex[1].toUpperCase() : regex[1] ) ) ) +
|
||||||
|
')' );
|
||||||
|
$t.data( 'metric', regex );
|
||||||
|
}
|
||||||
|
// find match to full name or abbreviation
|
||||||
|
unit = txt.match( regex[2] ) || txt.match( regex[3] );
|
||||||
|
if ( unit ) {
|
||||||
|
for ( base in prefixes ) {
|
||||||
|
if ( unit[3].match( base ) ) {
|
||||||
|
// exception when using binary prefix
|
||||||
|
// change base for binary use
|
||||||
|
isBinary = byteTest.test( unit[4] ) ? 1 : 0;
|
||||||
|
return num * prefixes[ base ][ isBinary ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
},
|
||||||
|
type: 'numeric'
|
||||||
|
});
|
||||||
|
|
||||||
|
})(jQuery);
|
|
@ -1,10 +1,57 @@
|
||||||
#!/usr/bin/php -q
|
#!/usr/bin/php -q
|
||||||
<?php
|
<?php
|
||||||
|
$usage = <<<EOF
|
||||||
|
|
||||||
|
Process package files in NerdPack config. Download and install,
|
||||||
|
delete and uninstall, based on the config value and [options].
|
||||||
|
|
||||||
|
Usage: packagemanager [options]
|
||||||
|
|
||||||
|
-d, --download download missing packages selected
|
||||||
|
-r, --delete delete packages not selected
|
||||||
|
-q, --quiet supress all packages progress
|
||||||
|
-u, --uninstall uninstall packages not selected
|
||||||
|
-v, --verbose print all packages progress
|
||||||
|
--help display this help and exit
|
||||||
|
--version output version information and exit
|
||||||
|
|
||||||
|
|
||||||
|
EOF;
|
||||||
|
|
||||||
|
$shortopts = "drquv";
|
||||||
|
$longopts = array(
|
||||||
|
"delete",
|
||||||
|
"download",
|
||||||
|
"help",
|
||||||
|
"quiet",
|
||||||
|
"uninstall",
|
||||||
|
"verbose",
|
||||||
|
"version"
|
||||||
|
);
|
||||||
|
$args = getopt($shortopts, $longopts);
|
||||||
|
|
||||||
|
if (array_key_exists("help", $args)) {
|
||||||
|
echo $usage;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array_key_exists("version", $args)) {
|
||||||
|
echo "Package Manager Version: 1.2\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$argd = (array_key_exists("d", $args) || array_key_exists("download", $args));
|
||||||
|
$argq = (array_key_exists("q", $args) || array_key_exists("quiet", $args));
|
||||||
|
$argr = (array_key_exists("r", $args) || array_key_exists("delete", $args));
|
||||||
|
$argu = (array_key_exists("u", $args) || array_key_exists("uninstall", $args));
|
||||||
|
$argv = (array_key_exists("v", $args) || array_key_exists("verbose", $args));
|
||||||
|
|
||||||
require_once("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
|
require_once("/usr/local/emhttp/plugins/NerdPack/include/DownloadHelpers.php");
|
||||||
|
|
||||||
function logger($output) {
|
function logger($output, $quiet) {
|
||||||
shell_exec( "echo '$output' 2>&1 | logger -tnerdpack");
|
shell_exec( "echo '$output' 2>&1 | logger -tnerdpack");
|
||||||
echo "\n".$output."\n";
|
if (!$quiet)
|
||||||
|
echo "\n".$output." \n";
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +70,7 @@ $pkgs_file = (is_file($pkgs_json)) ? file_get_contents($pkgs_json) : array();
|
||||||
|
|
||||||
$pkgs_github = json_decode($pkgs_file, true);
|
$pkgs_github = json_decode($pkgs_file, true);
|
||||||
|
|
||||||
logger("Processing Packages...");
|
logger("Processing Packages...", 0);
|
||||||
|
|
||||||
foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
|
foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
|
||||||
|
|
||||||
|
@ -35,7 +82,7 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
|
||||||
if($pkg_pref == "yes"){
|
if($pkg_pref == "yes"){
|
||||||
|
|
||||||
//if executing from the wegui check status and download if necessary
|
//if executing from the wegui check status and download if necessary
|
||||||
if ($argv[1] == "download"){
|
if ($argd){
|
||||||
|
|
||||||
if(!preg_grep($pkg_pattern, $pkgs_downloaded)) {
|
if(!preg_grep($pkg_pattern, $pkgs_downloaded)) {
|
||||||
|
|
||||||
|
@ -50,37 +97,38 @@ foreach($pkg_cfg as $pkg_name => $pkg_pref) { //get preferences for each package
|
||||||
$pkg_url = array_values($pkg_matches)[0]["download_url"];
|
$pkg_url = array_values($pkg_matches)[0]["download_url"];
|
||||||
$pkg_sha = array_values($pkg_matches)[0]["sha"];
|
$pkg_sha = array_values($pkg_matches)[0]["sha"];
|
||||||
|
|
||||||
logger("Downloading $pkg_gitname package...");
|
logger("Downloading $pkg_gitname package...", $argq);
|
||||||
|
|
||||||
get_file_from_url($pkg_file, $pkg_url);
|
get_file_from_url($pkg_file, $pkg_url);
|
||||||
|
|
||||||
if(file_check_sha($pkg_file, $pkg_sha))
|
if(file_check_sha($pkg_file, $pkg_sha))
|
||||||
logger("$pkg_gitname package downloaded sucessfully!");
|
logger("$pkg_gitname package downloaded sucessfully!", $argq);
|
||||||
else
|
else
|
||||||
logger("$pkg_gitname package download failed!");
|
logger("$pkg_gitname package download failed!", $argq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$pkg_install_status){
|
if (!$pkg_install_status){
|
||||||
$pkg_msg = "Installing";
|
$pkg_msg = "Installing";
|
||||||
$pkg_cmd = "upgradepkg --install-new ".$pkg_path.$pkg_name."* 2>&1";
|
$pkg_cmd = "upgradepkg --install-new ".$pkg_path.$pkg_name."* 2>&1";
|
||||||
}
|
}
|
||||||
}elseif($pkg_pref == "no" && $pkg_install_status && $argv[2] == "remove"){
|
}elseif($pkg_pref == "no" && $pkg_install_status && $argu){
|
||||||
|
|
||||||
$pkg_msg = "Removing";
|
$pkg_msg = "Uninstalling";
|
||||||
$pkg_cmd = "removepkg ".$pkg_path.$pkg_name."* 2>&1";
|
$pkg_cmd = "removepkg ".$pkg_path.$pkg_name."* 2>&1";
|
||||||
if ($argv[3] == "delete"){
|
if ($argr){
|
||||||
$pkg_cmd .= "; rm ".$pkg_path.$pkg_name."* 2>&1";
|
$pkg_cmd .= "; rm ".$pkg_path.$pkg_name."* 2>&1";
|
||||||
$pkg_msg .= " and deleting";
|
$pkg_msg .= " and deleting";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!empty($pkg_cmd)){
|
if(!empty($pkg_cmd)){
|
||||||
logger("$pkg_msg $pkg_name package...");
|
logger("$pkg_msg $pkg_name package...", 0);
|
||||||
shell_exec($pkg_cmd);
|
shell_exec($pkg_cmd);
|
||||||
//$output = shell_exec($pkg_cmd);
|
//$output = shell_exec($pkg_cmd);
|
||||||
//logger($output);
|
//logger($output);
|
||||||
}else
|
}else
|
||||||
logger($pkg_name." package up to date");
|
logger($pkg_name." package up to date", $argq);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger("All packages processed");
|
logger("All packages processed", 0);
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* header */
|
||||||
|
.tablesorter .headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerAsc {
|
||||||
|
background-color:#101010;
|
||||||
|
}
|
||||||
|
.tablesorter .headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerDesc {
|
||||||
|
background-color:#101010;
|
||||||
|
}
|
||||||
|
/* filter widget */
|
||||||
|
.tablesorter .tablesorter-filter-row {
|
||||||
|
background-color: #101010;
|
||||||
|
}
|
||||||
|
.tablesorter .tablesorter-filter-row td {
|
||||||
|
background-color: #101010;
|
||||||
|
border-bottom: #000000 1px solid;
|
||||||
|
}
|
||||||
|
/* filters */
|
||||||
|
.tablesorter input.tablesorter-filter,
|
||||||
|
.tablesorter select.tablesorter-filter {
|
||||||
|
background-color: #000000;
|
||||||
|
border: 1px solid #101010;
|
||||||
|
color: #808080;
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
/* header */
|
||||||
|
.tablesorter .headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerAsc {
|
||||||
|
background-color:#E0E0E0;
|
||||||
|
}
|
||||||
|
.tablesorter .headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerDesc {
|
||||||
|
background-color:#E0E0E0;
|
||||||
|
}
|
||||||
|
/* filter widget */
|
||||||
|
.tablesorter .tablesorter-filter-row {
|
||||||
|
background-color: #E0E0E0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tablesorter .tablesorter-filter-row td {
|
||||||
|
background-color: #E0E0E0;
|
||||||
|
border-bottom: #FFFFFF 1px solid;
|
||||||
|
}
|
||||||
|
/* filters */
|
||||||
|
.tablesorter input.tablesorter-filter,
|
||||||
|
.tablesorter select.tablesorter-filter {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border: 1px solid #E0E0E0;
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
.package {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* header */
|
||||||
|
.tablesorter {
|
||||||
|
font-family:arimo;
|
||||||
|
margin:0 0 15px 0;
|
||||||
|
}
|
||||||
|
.tablesorter .header,
|
||||||
|
.tablesorter .tablesorter-header {
|
||||||
|
background-position: center right;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
cursor: pointer;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.tablesorter .headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerSortUp,
|
||||||
|
.tablesorter .tablesorter-headerAsc {
|
||||||
|
background-image: url(/webGui/images/sort-asc.png);
|
||||||
|
}
|
||||||
|
.tablesorter .headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerSortDown,
|
||||||
|
.tablesorter .tablesorter-headerDesc {
|
||||||
|
background-image: url(/webGui/images/sort-desc.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* tbody */
|
||||||
|
.tablesorter td {
|
||||||
|
padding:4px 20px 4px 6px;
|
||||||
|
vertical-align:middle;
|
||||||
|
text-align:justify;
|
||||||
|
}
|
||||||
|
tablesorter tbody tr.tr_last td{
|
||||||
|
padding:8px 20px 8px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* filter widget */
|
||||||
|
.tablesorter .tablesorter-filter-row td {
|
||||||
|
line-height: normal;
|
||||||
|
text-align: center; /* center the input */
|
||||||
|
-webkit-transition: line-height 0.1s ease;
|
||||||
|
-moz-transition: line-height 0.1s ease;
|
||||||
|
-o-transition: line-height 0.1s ease;
|
||||||
|
transition: line-height 0.1s ease;
|
||||||
|
}
|
||||||
|
/* optional disabled input styling */
|
||||||
|
.tablesorter .tablesorter-filter-row .disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
filter: alpha(opacity=50);
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
/* filters */
|
||||||
|
.tablesorter input.tablesorter-filter,
|
||||||
|
.tablesorter select.tablesorter-filter {
|
||||||
|
width: 95%;
|
||||||
|
height: auto;
|
||||||
|
margin: 1px auto;
|
||||||
|
padding: 1px;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-webkit-transition: height 0.1s ease;
|
||||||
|
-moz-transition: height 0.1s ease;
|
||||||
|
-o-transition: height 0.1s ease;
|
||||||
|
transition: height 0.1s ease;
|
||||||
|
}
|
||||||
|
/* rows hidden by filtering (needed for child rows) */
|
||||||
|
.tablesorter .filtered {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* HOVER ROW highlight colors */
|
||||||
|
table.hover-highlight tbody > tr:hover > td, /* override tablesorter theme row hover */
|
||||||
|
table.hover-highlight tbody > tr.odd:hover > td,
|
||||||
|
table.hover-highlight tbody > tr.even:hover > td {
|
||||||
|
background-color: #9FC2E6;
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************* */
|
||||||
|
/* **** No need to modify the definitions below **** */
|
||||||
|
/* ************************************************* */
|
||||||
|
.hover-highlight td:hover::after, .hover-highlight th:hover::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
height: 999em;
|
||||||
|
left: 0;
|
||||||
|
top: -555em;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
/* required styles */
|
||||||
|
.hover-highlight {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.hover-highlight td, .hover-highlight th {
|
||||||
|
position: relative;
|
||||||
|
outline: 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user