formatting, add checks for unRAID version change or empty download folder
This commit is contained in:
parent
0bfd5986b3
commit
39853fc171
|
@ -1,147 +1,163 @@
|
||||||
$(function(){
|
$(function(){
|
||||||
// add switches to title bar
|
// add switches to title bar
|
||||||
$('#title')
|
$('#title')
|
||||||
.append("<span class='status'><input id='uninstallpkg' type='checkbox'></span>")
|
.append("<span class='status'><input id='uninstallpkg' type='checkbox'></span>")
|
||||||
.append("<span class='status'><input id='deletepkg' type='checkbox'></span>");
|
.append("<span class='status'><input id='deletepkg' type='checkbox'></span>");
|
||||||
|
|
||||||
// tablesorter options
|
// tablesorter options
|
||||||
$('#tblPackages').tablesorter({
|
$('#tblPackages').tablesorter({
|
||||||
sortList: [[0,0]],
|
sortList: [[0,0]],
|
||||||
widgets: ['saveSort', 'filter', 'stickyHeaders'],
|
widgets: ['saveSort', 'filter', 'stickyHeaders'],
|
||||||
widgetOptions: {
|
widgetOptions: {
|
||||||
stickyHeaders_filteredToTop: true,
|
stickyHeaders_filteredToTop: true,
|
||||||
filter_hideEmpty: true,
|
filter_hideEmpty: true,
|
||||||
filter_liveSearch: true,
|
filter_liveSearch: true,
|
||||||
filter_saveFilters: true,
|
filter_saveFilters: true,
|
||||||
filter_reset: '.reset',
|
filter_reset: '.reset',
|
||||||
filter_functions: {
|
filter_functions: {
|
||||||
'.filter-version': true,
|
'.filter-version': true,
|
||||||
'.filter-downloaded': true,
|
'.filter-downloaded': true,
|
||||||
'.filter-installed': true
|
'.filter-installed': true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// "uninstall package" switch and cookie
|
// "uninstall package" switch and cookie
|
||||||
$('#uninstallpkg')
|
$('#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_uninstall') == '--uninstall'
|
checked: $.cookie('nerdpack_packages_uninstall') == '--uninstall'
|
||||||
})
|
})
|
||||||
.change(function () {
|
.change(function () {
|
||||||
$.cookie('nerdpack_packages_uninstall', $('#uninstallpkg')[0].checked ? '--uninstall' : '', { expires: 3650 });
|
$.cookie('nerdpack_packages_uninstall', $('#uninstallpkg')[0].checked ? '--uninstall' : '', { expires: 3650 });
|
||||||
});
|
});
|
||||||
|
|
||||||
// "delete package" switch and cookie
|
// "delete package" switch and cookie
|
||||||
$('#deletepkg')
|
$('#deletepkg')
|
||||||
.switchButton({
|
.switchButton({
|
||||||
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', $('#deletepkg')[0].checked ? '--delete' : '', { expires: 3650 });
|
$.cookie('nerdpack_packages_delete', $('#deletepkg')[0].checked ? '--delete' : '', { expires: 3650 });
|
||||||
});
|
});
|
||||||
|
|
||||||
// select all packages switch
|
// select all packages switch
|
||||||
$('#checkall')
|
$('#checkall')
|
||||||
.switchButton({
|
.switchButton({
|
||||||
labels_placement: 'right',
|
labels_placement: 'right',
|
||||||
on_label: 'Select All',
|
on_label: 'Select All',
|
||||||
off_label: 'Select All',
|
off_label: 'Select All',
|
||||||
checked: $.cookie('nerdpack_checkall') == 'yes'
|
checked: $.cookie('nerdpack_checkall') == 'yes'
|
||||||
})
|
})
|
||||||
.change(function () {
|
.change(function () {
|
||||||
var myval = $(this)[0].checked;
|
var myval = $(this)[0].checked;
|
||||||
$.cookie('nerdpack_checkall', myval ? 'yes' : 'no', { expires: 3650 });
|
$.cookie('nerdpack_checkall', myval ? 'yes' : 'no', { expires: 3650 });
|
||||||
$('#tblPackages tbody td:visible .pkgcheckbox').switchButton({checked: myval});
|
$('#tblPackages tbody td:visible .pkgcheckbox').switchButton({checked: myval});
|
||||||
});
|
});
|
||||||
|
|
||||||
// set cookie on apply button press
|
// set cookie on apply button press
|
||||||
$('#btnApply').click(function() {
|
$('#btnApply').click(function() {
|
||||||
checkDepends();
|
checkDepends();
|
||||||
|
|
||||||
$.post('/update.php', $('#package_form').serializeArray(), function() {
|
$.post('/update.php', $('#package_form').serializeArray(), function() {
|
||||||
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=--download'+
|
openBox('/plugins/NerdPack/scripts/packagemanager&arg1=--download'+
|
||||||
'&arg2='+$.cookie('nerdpack_packages_uninstall')+
|
'&arg2='+$.cookie('nerdpack_packages_uninstall')+
|
||||||
'&arg3='+$.cookie('nerdpack_packages_delete'),
|
'&arg3='+$.cookie('nerdpack_packages_delete'),
|
||||||
'Package Manager', 600, 900, true);
|
'Package Manager', 600, 900, true);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
packageQuery();
|
packageQuery();
|
||||||
});
|
});
|
||||||
|
|
||||||
//list all available packages in a table
|
//list all available packages in a table
|
||||||
function packageQuery(force) {
|
function packageQuery(force) {
|
||||||
$('#tblPackages tbody').html("<tr><td colspan='6'><br><i class='fa fa-spinner fa-spin icon'></i><em>Please wait, retrieving plugin information ...</em></td><tr>");
|
$('#tblPackages tbody').html("<tr><td colspan='6'><br><i class='fa fa-spinner fa-spin icon'></i><em>Please wait, retrieving plugin information ...</em></td><tr>");
|
||||||
$.getJSON('/plugins/NerdPack/include/PackageQuery.php', {force: force}, function(packages) {
|
$.getJSON('/plugins/NerdPack/include/PackageQuery.php', {force: force}, function(data) {
|
||||||
$('#tblPackages tbody').empty();
|
$('#tblPackages tbody').empty();
|
||||||
var Ready;
|
var Ready;
|
||||||
var len = packages.length, i = 0;
|
var Count = 0;
|
||||||
for (i; i < len; i++) {
|
var len = data.packages.length, i = 0;
|
||||||
var Update;
|
for (i; i < len; i++) {
|
||||||
if (packages[i].downloadeq == packages[i].downloaded && packages[i].installeq == packages[i].installed){
|
var Update;
|
||||||
Update = "<span><i class='uptodate fa fa-check'></i> up-to-date </span>";
|
if (data.packages[i].downloadeq == data.packages[i].downloaded && data.packages[i].installeq == data.packages[i].installed){
|
||||||
}else{
|
Update = "<span><i class='uptodate fa fa-check'></i> up-to-date </span>";
|
||||||
Update = "<span ><a><i class='updateready fa fa-cloud-download'></i> update ready </a></span>";
|
}else{
|
||||||
Ready = true;
|
Update = "<span ><a><i class='updateready fa fa-cloud-download'></i> update ready </a></span>";
|
||||||
}
|
Ready = true;
|
||||||
|
}
|
||||||
|
|
||||||
var Downloaded = packages[i].downloaded;
|
var Downloaded = data.packages[i].downloaded;
|
||||||
if (packages[i].downloadeq != packages[i].downloaded)
|
if (data.packages[i].downloadeq != data.packages[i].downloaded)
|
||||||
Downloaded = 'old';
|
Downloaded = 'old';
|
||||||
|
|
||||||
var Installed = packages[i].installed;
|
var Installed = data.packages[i].installed;
|
||||||
if (packages[i].installeq != packages[i].installed)
|
if (data.packages[i].installeq != data.packages[i].installed)
|
||||||
Installed = 'old';
|
Installed = 'old';
|
||||||
|
|
||||||
$('#tblPackages tbody').append("<tr>"+
|
var Checked = "";
|
||||||
"<td class='package' title='"+packages[i].desc+"'>"+packages[i].name+"</td>"+ // package name
|
if (data.packages[i].config=="yes"){
|
||||||
"<td>"+Update+"</td>"+ // package status
|
Checked = "checked";
|
||||||
"<td>"+packages[i].size+"</td>"+ // package size
|
Count++;
|
||||||
"<td>"+Downloaded+"</td>"+ // package downloaded
|
}
|
||||||
"<td>"+Installed+"</td>"+ // package installed
|
|
||||||
"<td>"+packages[i].plugins+"</td>"+ // package dependents
|
|
||||||
"<td><input class='pkgcheckbox' id='"+packages[i].pkgname+"' type='checkbox' "+(packages[i].config=="yes"?"checked":"")+">"+
|
|
||||||
"<input class='pkgvalue' type='hidden' id='"+packages[i].pkgname+"_value' name='"+packages[i].pkgnver+"' value='"+packages[i].config+"'></td>"+
|
|
||||||
"</tr>");
|
|
||||||
}
|
|
||||||
if (Ready)
|
|
||||||
$('#btnApply').prop('disabled', false);
|
|
||||||
|
|
||||||
// attach switch buttons to every package checkbox all at once
|
$('#tblPackages tbody').append("<tr>"+
|
||||||
$('.pkgcheckbox')
|
"<td class='package' title='"+data.packages[i].desc+"'>"+data.packages[i].name+"</td>"+ // package name
|
||||||
.switchButton({
|
"<td>"+Update+"</td>"+ // package status
|
||||||
labels_placement: 'right',
|
"<td>"+data.packages[i].size+"</td>"+ // package size
|
||||||
on_label: 'On',
|
"<td>"+Downloaded+"</td>"+ // package downloaded
|
||||||
off_label: 'Off'
|
"<td>"+Installed+"</td>"+ // package installed
|
||||||
})
|
"<td>"+data.packages[i].plugins+"</td>"+ // package dependents
|
||||||
.change(function() {
|
"<td><input class='pkgcheckbox' id='"+data.packages[i].pkgname+"' type='checkbox' "+Checked+">"+
|
||||||
$(this).parent().parent().find('.pkgvalue').val(this.checked ? "yes": "no");
|
"<input class='pkgvalue' type='hidden' id='"+data.packages[i].pkgname+"_value' name='"+data.packages[i].pkgnver+"' value='"+data.packages[i].config+"'></td>"+
|
||||||
if (this.checked)
|
"</tr>");
|
||||||
checkDepends();
|
}
|
||||||
$('#btnApply').prop("disabled", false);
|
if (Ready)
|
||||||
});
|
$('#btnApply').prop('disabled', false);
|
||||||
|
|
||||||
// restore filters
|
// attach switch buttons to every package checkbox all at once
|
||||||
var lastSearch = $('#tblPackages')[0].config.lastSearch;
|
$('.pkgcheckbox')
|
||||||
$('#tblPackages').trigger('update')
|
.switchButton({
|
||||||
.trigger('search', [lastSearch]);
|
labels_placement: 'right',
|
||||||
});
|
on_label: 'On',
|
||||||
|
off_label: 'Off'
|
||||||
|
})
|
||||||
|
.change(function() {
|
||||||
|
$(this).parent().parent().find('.pkgvalue').val(this.checked ? "yes": "no");
|
||||||
|
if (this.checked)
|
||||||
|
checkDepends();
|
||||||
|
$('#btnApply').prop("disabled", false);
|
||||||
|
});
|
||||||
|
|
||||||
|
// restore filters
|
||||||
|
var lastSearch = $('#tblPackages')[0].config.lastSearch;
|
||||||
|
$('#tblPackages').trigger('update')
|
||||||
|
.trigger('search', [lastSearch]);
|
||||||
|
|
||||||
|
if (data.empty == true && Count > 0) {
|
||||||
|
swal({title:'Downloaded Packages Missing!',text:'You either changed unRAID versions or deleted your downloaded packages. Click the Apply button below to download and install your selected packages.',type:'warning',closeOnConfirm: true,},function() {
|
||||||
|
$('#btnApply').prop('disabled', false);
|
||||||
|
$('html, body').animate({
|
||||||
|
scrollTop: $("#btnApply").offset().top
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkDepends() {
|
function checkDepends() {
|
||||||
if ($('#screen')[0].checked) {
|
if ($('#screen')[0].checked) {
|
||||||
$('#utempter').switchButton({checked: true});
|
$('#utempter').switchButton({checked: true});
|
||||||
$('#utempter', '.pkgvalue').val('yes');
|
$('#utempter', '.pkgvalue').val('yes');
|
||||||
}
|
}
|
||||||
if ($('#iotop')[0].checked) {
|
if ($('#iotop')[0].checked) {
|
||||||
$('#python').switchButton({checked: true});
|
$('#python').switchButton({checked: true});
|
||||||
$('#python', '.pkgvalue').val('yes');
|
$('#python', '.pkgvalue').val('yes');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user