fixes #1567 Plugins filters and badged now updates with search

This commit is contained in:
Matthieu Leproux
2021-11-22 11:16:24 +01:00
parent bffdf960d5
commit bdc5399108
2 changed files with 77 additions and 64 deletions
+5 -64
View File
@@ -1,5 +1,4 @@
function setDisplayClassic() { function setDisplayClassic() {
console.log("DISPLAY CLASSIC");
$(".pluginContainer").removeClass("line").removeClass("compact").addClass("classic"); $(".pluginContainer").removeClass("line").removeClass("compact").addClass("classic");
$(".pluginDesc").show(); $(".pluginDesc").show();
@@ -13,7 +12,6 @@ function setDisplayClassic() {
} }
function setDisplayCompact() { function setDisplayCompact() {
console.log("DISPLAY COMPACT");
$(".pluginContainer").removeClass("line").addClass("compact").removeClass("classic"); $(".pluginContainer").removeClass("line").addClass("compact").removeClass("classic");
$(".pluginDesc").hide(); $(".pluginDesc").hide();
@@ -27,7 +25,6 @@ function setDisplayCompact() {
} }
function setDisplayLine() { function setDisplayLine() {
console.log("DISPLAY LINE");
$(".pluginContainer").addClass("line").removeClass("compact").removeClass("classic"); $(".pluginContainer").addClass("line").removeClass("compact").removeClass("classic");
$(".pluginDesc").show(); $(".pluginDesc").show();
@@ -61,17 +58,7 @@ function normalTitle() {
} }
} }
function actualizeFilterBadges() {
$("label[for='seeAll'] .filter-badge").html(nb_plugin.all);
$("label[for='seeActive'] .filter-badge").html(nb_plugin.active);
$("label[for='seeInactive'] .filter-badge").html(nb_plugin.inactive);
$("label[for='seeOther'] .filter-badge").html(nb_plugin.other);
}
function activatePlugin(id) { function activatePlugin(id) {
console.log("Plugin activated");
console.log(id);
$("#"+id+" .switch").attr("disabled", true); $("#"+id+" .switch").attr("disabled", true);
$.ajax({ $.ajax({
@@ -92,7 +79,7 @@ function activatePlugin(id) {
nb_plugin.active += 1; nb_plugin.active += 1;
nb_plugin.inactive -= 1; nb_plugin.inactive -= 1;
actualizeFilterBadges(); actualizeFilter();
} }
}, },
error: function (e) { error: function (e) {
@@ -104,15 +91,12 @@ function activatePlugin(id) {
$("#" + id + " .PluginActionError").delay(1500).fadeOut(2500); $("#" + id + " .PluginActionError").delay(1500).fadeOut(2500);
} }
}).done(function (data) { }).done(function (data) {
console.log(data);
$("#"+id+" .switch").attr("disabled", false); $("#"+id+" .switch").attr("disabled", false);
$("#" + id + " .AddPluginSuccess").fadeOut(3000); $("#" + id + " .AddPluginSuccess").fadeOut(3000);
}) })
} }
function disactivatePlugin(id) { function disactivatePlugin(id) {
console.log("Plugin disactivated");
console.log(id);
$("#"+id+" .switch").attr("disabled", true); $("#"+id+" .switch").attr("disabled", true);
$.ajax({ $.ajax({
@@ -133,7 +117,7 @@ function disactivatePlugin(id) {
nb_plugin.inactive += 1; nb_plugin.inactive += 1;
nb_plugin.active -= 1; nb_plugin.active -= 1;
actualizeFilterBadges(nb_plugin.all, nb_plugin.active, nb_plugin.inactive, nb_plugin.other) actualizeFilter();
} }
}, },
error: function (e) { error: function (e) {
@@ -145,17 +129,12 @@ function disactivatePlugin(id) {
$("#" + id + " .PluginActionError").delay(1500).fadeOut(2500); $("#" + id + " .PluginActionError").delay(1500).fadeOut(2500);
} }
}).done(function (data) { }).done(function (data) {
console.log(data);
$("#"+id+" .switch").attr("disabled", false); $("#"+id+" .switch").attr("disabled", false);
$("#" + id + " .DeactivatePluginSuccess").fadeOut(3000); $("#" + id + " .DeactivatePluginSuccess").fadeOut(3000);
}) })
} }
function deletePlugin(id, name) { function deletePlugin(id, name) {
console.log("Plugin deletetion");
console.log(id);
console.log(pwg_token);
$.alert({ $.alert({
title : deleted_plugin_msg.replace("%s",name), title : deleted_plugin_msg.replace("%s",name),
content: function() { content: function() {
@@ -171,11 +150,10 @@ function deletePlugin(id, name) {
success: function (data) { success: function (data) {
if (data.stat === "ok") { if (data.stat === "ok") {
$("#"+id).remove(); $("#"+id).remove();
nb_plugin.inactive -=1;
nb_plugin.all -=1;
actualizeFilter(); actualizeFilter();
} }
nb_plugin.inactive -=1;
nb_plugin.all -=1;
actualizeFilterBadges();
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
@@ -192,10 +170,6 @@ function deletePlugin(id, name) {
} }
function restorePlugin(id) { function restorePlugin(id) {
console.log("Plugin restoration");
console.log(id);
console.log(pwg_token);
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
@@ -227,10 +201,6 @@ function restorePlugin(id) {
} }
function uninstallPlugin(id) { function uninstallPlugin(id) {
console.log("Plugin uninstallated");
console.log(id);
console.log(pwg_token);
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
dataType: 'json', dataType: 'json',
@@ -241,11 +211,9 @@ function uninstallPlugin(id) {
pwg_token: pwg_token, pwg_token: pwg_token,
format: 'json' }, format: 'json' },
success: function (data) { success: function (data) {
console.log(data);
console.log("it works (uninstallated)");
nb_plugin.other -=1; nb_plugin.other -=1;
nb_plugin.all -=1; nb_plugin.all -=1;
actualizeFilterBadges(); actualizeFilter()
}, },
error: function (e) { error: function (e) {
console.log(e); console.log(e);
@@ -254,24 +222,8 @@ function uninstallPlugin(id) {
}) })
} }
function actualizeFilter() {
$(".filterLabel").hide();
$(".pluginMiniBox").each(function () {
if ($(this).hasClass("plugin-active")) {
$("label[for='seeActive']").show();
}
if ($(this).hasClass("plugin-inactive")) {
$("label[for='seeInactive']").show();
}
if (($(this).hasClass("plugin-merged")) || ($(this).hasClass("plugin-missing"))) {
$("label[for='seeOther']").show();
}
})
}
$(document).ready(function () { $(document).ready(function () {
actualizeFilter(); actualizeFilter();
actualizeFilterBadges();
if (!$.cookie("pwg_plugin_manager_view")) { if (!$.cookie("pwg_plugin_manager_view")) {
$.cookie("pwg_plugin_manager_view", "classic"); $.cookie("pwg_plugin_manager_view", "classic");
@@ -319,13 +271,11 @@ $(document).ready(function () {
$("#seeAll").on("change", function () { $("#seeAll").on("change", function () {
console.log("All");
$(".pluginMiniBox").show(); $(".pluginMiniBox").show();
$('.search-input').trigger("input"); $('.search-input').trigger("input");
}) })
$("#seeActive").on("change", function () { $("#seeActive").on("change", function () {
console.log("Active");
$(".pluginMiniBox").show(); $(".pluginMiniBox").show();
$(".pluginMiniBox").each(function () { $(".pluginMiniBox").each(function () {
if (!$(this).hasClass("plugin-active")) { if (!$(this).hasClass("plugin-active")) {
@@ -336,7 +286,6 @@ $(document).ready(function () {
}) })
$("#seeInactive").on("change", function () { $("#seeInactive").on("change", function () {
console.log("Inactive");
$(".pluginMiniBox").show(); $(".pluginMiniBox").show();
$(".pluginMiniBox").each(function () { $(".pluginMiniBox").each(function () {
if (!$(this).hasClass("plugin-inactive")) { if (!$(this).hasClass("plugin-inactive")) {
@@ -347,7 +296,6 @@ $(document).ready(function () {
}) })
$("#seeOther").on("change", function () { $("#seeOther").on("change", function () {
console.log("Other");
$(".pluginMiniBox").show(); $(".pluginMiniBox").show();
$(".pluginMiniBox").each(function () { $(".pluginMiniBox").each(function () {
if (($(this).hasClass("plugin-active") || $(this).hasClass("plugin-inactive"))) { if (($(this).hasClass("plugin-active") || $(this).hasClass("plugin-inactive"))) {
@@ -357,8 +305,6 @@ $(document).ready(function () {
$('.search-input').trigger("input"); $('.search-input').trigger("input");
}) })
console.log(nb_plugin);
/* Plugin Actions */ /* Plugin Actions */
/** /**
* Activate / Deactivate * Activate / Deactivate
@@ -369,7 +315,6 @@ $(document).ready(function () {
if ($(this).find("#toggleSelectionMode").is(':checked')) { if ($(this).find("#toggleSelectionMode").is(':checked')) {
activatePlugin($(this).parent().parent().attr("id")); activatePlugin($(this).parent().parent().attr("id"));
console.log("activatePlugin");
$(this).parent().parent().addClass("plugin-active").removeClass("plugin-inactive"); $(this).parent().parent().addClass("plugin-active").removeClass("plugin-inactive");
if ($(this).parent().parent().find(".pluginUnavailableAction").attr("href")) { if ($(this).parent().parent().find(".pluginUnavailableAction").attr("href")) {
@@ -377,7 +322,6 @@ $(document).ready(function () {
} }
} else { } else {
disactivatePlugin($(this).parent().parent().attr("id")) disactivatePlugin($(this).parent().parent().attr("id"))
console.log("disactivatePlugin");
$(this).parent().parent().removeClass("plugin-active").addClass("plugin-inactive"); $(this).parent().parent().removeClass("plugin-active").addClass("plugin-inactive");
$(this).parent().parent().find(".pluginActionLevel1").removeClass("pluginActionLevel1").addClass("pluginUnavailableAction"); $(this).parent().parent().find(".pluginActionLevel1").removeClass("pluginActionLevel1").addClass("pluginUnavailableAction");
@@ -412,7 +356,6 @@ $(document).ready(function () {
$(".pluginContent").find('.dropdown-option.delete-plugin-button').on('click', function () { $(".pluginContent").find('.dropdown-option.delete-plugin-button').on('click', function () {
let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim(); let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim();
let plugin_id = $(this).closest(".pluginContent").parent().attr("id"); let plugin_id = $(this).closest(".pluginContent").parent().attr("id");
console.log($(this).closest(".pluginContent").parent().attr("id"));
$.confirm({ $.confirm({
title: delete_plugin_msg.replace("%s",plugin_name), title: delete_plugin_msg.replace("%s",plugin_name),
buttons: { buttons: {
@@ -437,7 +380,6 @@ $(document).ready(function () {
$(".pluginContent").find('.dropdown-option.plugin-restore').on('click', function () { $(".pluginContent").find('.dropdown-option.plugin-restore').on('click', function () {
let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim(); let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim();
let plugin_id = $(this).closest(".pluginContent").parent().attr("id"); let plugin_id = $(this).closest(".pluginContent").parent().attr("id");
console.log($(this).closest(".pluginContent").parent().attr("id"));
$.confirm({ $.confirm({
title: restore_plugin_msg.replace('%s', plugin_name), title: restore_plugin_msg.replace('%s', plugin_name),
buttons: { buttons: {
@@ -462,7 +404,6 @@ $(document).ready(function () {
$(".pluginContent").find('.uninstall-plugin-button').on('click', function () { $(".pluginContent").find('.uninstall-plugin-button').on('click', function () {
let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim(); let plugin_name = $(this).closest(".pluginContent").find(".pluginMiniBoxNameCell").html().trim();
let plugin_id = $(this).closest(".pluginContent").parent().attr("id"); let plugin_id = $(this).closest(".pluginContent").parent().attr("id");
console.log($(this).closest(".pluginContent").parent().attr("id"));
$.confirm({ $.confirm({
title: restore_plugin_msg.replace('%s', plugin_name), title: restore_plugin_msg.replace('%s', plugin_name),
buttons: { buttons: {
@@ -146,6 +146,10 @@ jQuery(document).ready(function() {
jQuery(".pluginFilter input").on("input", function() { jQuery(".pluginFilter input").on("input", function() {
let text = jQuery(this).val().toLowerCase(); let text = jQuery(this).val().toLowerCase();
var searchNumber = 0; var searchNumber = 0;
var searchActive = 0;
var searchInactive = 0;
var searchOther = 0;
$(".pluginMiniBox").each(function() { $(".pluginMiniBox").each(function() {
if (text == "") { if (text == "") {
@@ -162,7 +166,23 @@ jQuery(document).ready(function() {
if ($("#seeOther").is(":checked") && (jQuery(this).hasClass("plugin-merged") || jQuery(this).hasClass("plugin-missing"))) { if ($("#seeOther").is(":checked") && (jQuery(this).hasClass("plugin-merged") || jQuery(this).hasClass("plugin-missing"))) {
jQuery(this).show(); jQuery(this).show();
} }
if ($(this).hasClass("plugin-active")) {
searchActive++;
}
if ($(this).hasClass("plugin-inactive")) {
searchInactive++;
}
if (($(this).hasClass("plugin-merged") || $(this).hasClass("plugin-missing"))) {
searchOther++;
}
searchNumber++ searchNumber++
nb_plugin.all = searchNumber;
nb_plugin.active = searchActive;
nb_plugin.inactive = searchInactive;
nb_plugin.other = searchOther;
} else { } else {
jQuery(".nbPluginsSearch").show(); jQuery(".nbPluginsSearch").show();
let name = jQuery(this).find(".pluginMiniBoxNameCell").text().toLowerCase(); let name = jQuery(this).find(".pluginMiniBoxNameCell").text().toLowerCase();
@@ -182,11 +202,33 @@ jQuery(document).ready(function() {
if ($("#seeOther").is(":checked") && (jQuery(this).hasClass("plugin-merged") || jQuery(this).hasClass("plugin-missing"))) { if ($("#seeOther").is(":checked") && (jQuery(this).hasClass("plugin-merged") || jQuery(this).hasClass("plugin-missing"))) {
jQuery(this).show(); jQuery(this).show();
} }
if ($(this).hasClass("plugin-active")) {
searchActive++;
}
if ($(this).hasClass("plugin-inactive")) {
searchInactive++;
}
if (($(this).hasClass("plugin-merged") || $(this).hasClass("plugin-missing"))) {
searchOther++;
}
nb_plugin.all = searchNumber;
nb_plugin.active = searchActive;
nb_plugin.inactive = searchInactive;
nb_plugin.other = searchOther;
} else { } else {
jQuery(this).hide(); jQuery(this).hide();
nb_plugin.all = searchNumber;
nb_plugin.active = searchActive;
nb_plugin.inactive = searchInactive;
nb_plugin.other = searchOther;
} }
} }
}) })
actualizeFilter();
if (searchNumber == 0) { if (searchNumber == 0) {
jQuery(".nbPluginsSearch").html(nothing_found); jQuery(".nbPluginsSearch").html(nothing_found);
@@ -213,6 +255,36 @@ $(document).mouseup(function (e) {
}) })
}); });
function actualizeFilter() {
$("label[for='seeAll'] .filter-badge").html(nb_plugin.all);
$("label[for='seeActive'] .filter-badge").html(nb_plugin.active);
$("label[for='seeInactive'] .filter-badge").html(nb_plugin.inactive);
$("label[for='seeOther'] .filter-badge").html(nb_plugin.other);
$(".filterLabel").show();
$(".pluginMiniBox").each(function () {
if (nb_plugin.active == 0) {
$("label[for='seeActive']").hide();
if ($("#seeActive").is(":checked")) {
$("#seeAll").trigger("click")
}
}
if (nb_plugin.inactive == 0) {
$("label[for='seeInactive']").hide();
if ($("#seeInactive").is(":checked")) {
$("#seeAll").trigger("click")
}
}
if (nb_plugin.other == 0) {
$("label[for='seeOther']").hide();
if ($("#seeOther").is(":checked")) {
$("#seeAll").trigger("click")
}
}
})
}
jQuery(".pluginMiniBox").each(function(index){ jQuery(".pluginMiniBox").each(function(index){
let myplugin = jQuery(this); let myplugin = jQuery(this);
myplugin.find(".showOptions").click(function(){ myplugin.find(".showOptions").click(function(){