#1264 checkbox size delete

adapted front end and back end to use checkboces to delete the sizes
This commit is contained in:
Louis
2020-11-20 09:27:24 +01:00
committed by plegall
parent 7c2d071f28
commit 1db2188db8
4 changed files with 82 additions and 180 deletions
+14 -5
View File
@@ -164,7 +164,15 @@ DELETE
}
case 'derivatives':
{
clear_derivative_cache($_GET['type']);
$types_str = $_GET['type'];
if ($types_str == "all") {
clear_derivative_cache($_GET['type']);
} else {
$types = explode('_', $types_str);
foreach ($types as $type_to_clear) {
clear_derivative_cache($type_to_clear);
}
}
break;
}
@@ -231,15 +239,15 @@ DELETE
// +-----------------------------------------------------------------------+
$template->set_filenames(array('maintenance'=>'maintenance_actions.tpl'));
$pwg_token = get_pwg_token();
$url_format = get_root_url().'admin.php?page=maintenance&action=%s&pwg_token='.get_pwg_token();
$purge_urls[l10n('All')] = sprintf($url_format, 'derivatives').'&type=all';
$purge_urls[l10n('All')] = 'all';
foreach(ImageStdParams::get_defined_type_map() as $params)
{
$purge_urls[ l10n($params->type) ] = sprintf($url_format, 'derivatives').'&type='.$params->type;
$purge_urls[ l10n($params->type) ] = $params->type;
}
$purge_urls[ l10n(IMG_CUSTOM) ] = sprintf($url_format, 'derivatives').'&type='.IMG_CUSTOM;
$purge_urls[ l10n(IMG_CUSTOM) ] = IMG_CUSTOM;
$php_current_timestamp = date("Y-m-d H:i:s");
$db_version = pwg_get_db_version();
@@ -273,6 +281,7 @@ $template->assign(
'U_PHPINFO' => sprintf($url_format, 'phpinfo'),
'PHP_DATATIME' => $php_current_timestamp,
'DB_DATATIME' => $db_current_date,
'pwg_token' => $pwg_token
)
);
@@ -1,106 +0,0 @@
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'}
{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"}
{footer_script}
const confirm_msg = '{"Yes, I am sure"|@translate}';
const cancel_msg = "{"No, I have changed my mind"|@translate}";
$(".lock-gallery-button").each(function() {
const gallery_tip = '{"A locked gallery is only visible to administrators"|@translate|@escape:'javascript'}';
let title = '{"Are you sure you want to lock the gallery?"|@translate}';
let confirm_msg_gallery = '{"Yes, I want to lock the gallery"|@translate}';
let cancel_msg_gallery = '{"Keep it unlocked"|@translate}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg,
alert_content: gallery_tip
});
});
$(".purge-history-detail-button").each(function() {
const title = '{"Purge history detail"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".purge-history-summary-button").each(function() {
const title = '{"Purge history summary"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".purge-search-history-button").each(function() {
const title = '{"Purge search history"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".delete-all-sizes-button").each(function() {
const title = '{"Are you sure you want to delete all sizes?"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
{/footer_script}
<div class="titrePage">
<h2>{'Maintenance'|@translate}</h2>
</div>
<ul>
{if (isset($U_MAINT_LOCK_GALLERY))}
<li><a href="{$U_MAINT_LOCK_GALLERY}" class="lock-gallery-button">{'Lock gallery'|@translate}</a></li>
{else}
<li><a href="{$U_MAINT_UNLOCK_GALLERY}">{'Unlock gallery'|@translate}</a></li>
{/if}
</ul>
<ul>
{foreach from=$advanced_features item=feature}
<li><a href="{$feature.URL}">{$feature.CAPTION}</a></li>
{/foreach}
</ul>
<ul>
<li><a href="{$U_MAINT_CATEGORIES}">{'Update albums informations'|@translate}</a></li>
<li><a href="{$U_MAINT_IMAGES}">{'Update photos information'|@translate}</a></li>
</ul>
<ul>
<li><a href="{$U_MAINT_DATABASE}">{'Repair and optimize database'|@translate}</a></li>
<li><a href="{$U_MAINT_C13Y}">{'Reinitialize check integrity'|@translate}</a></li>
</ul>
<ul>
<li><a href="{$U_MAINT_USER_CACHE}">{'Purge user cache'|@translate}</a></li>
<li><a href="{$U_MAINT_ORPHAN_TAGS}">{'Delete orphan tags'|@translate}</a></li>
<li><a href="{$U_MAINT_HISTORY_DETAIL}" class="purge-history-detail-button">{'Purge history detail'|@translate}</a></li>
<li><a href="{$U_MAINT_HISTORY_SUMMARY}" class="purge-history-summary-button">{'Purge history summary'|@translate}</a></li>
<li><a href="{$U_MAINT_SESSIONS}">{'Purge sessions'|@translate}</a></li>
<li><a href="{$U_MAINT_FEEDS}">{'Purge never used notification feeds'|@translate}</a></li>
<li><a href="{$U_MAINT_SEARCH}" class="purge-search-history-button">{'Purge search history'|@translate}</a></li>
<li><a href="{$U_MAINT_COMPILED_TEMPLATES}">{'Purge compiled templates'|@translate}</a></li>
<li>{'Delete multiple size images'|@translate}:
{foreach from=$purge_derivatives key=name item=url name=loop}
<a href="{$url}"{if $smarty.foreach.loop.first} class="delete-all-sizes-button"{/if}>{$name}</a>{if !$smarty.foreach.loop.last}, {/if}{/foreach}
</li>
</ul>
<fieldset id="environment">
<legend><i class="icon-cog"></i> {'Environment'|@translate}</legend>
<ul>
<li><a href="{$PHPWG_URL}" class="externalLink">Piwigo</a> {$PWG_VERSION} <a href="{$U_CHECK_UPGRADE}" class="icon-arrows-cw">{'Check for upgrade'|@translate}</a></li>
<li>{'Operating system'|@translate}: {$OS}</li>
<li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" class="externalLink">{'Show info'|@translate}</a>) [{$PHP_DATATIME}]</li>
<li>{$DB_ENGINE}: {$DB_VERSION} [{$DB_DATATIME}]</li>
{if isset($GRAPHICS_LIBRARY)}
<li>{'Graphics Library'|@translate}: {$GRAPHICS_LIBRARY}</li>
{/if}
</ul>
</fieldset>
@@ -53,15 +53,46 @@ $(".delete-all-sizes-button").each(function() {
$(".delete-size-check").click(function () {
if ($(this).attr('data-selected') == '1') {
$(this).attr('data-selected', '0');
removeSelectedItem($(this).attr('data-id'));
$(this).find("i").hide();
} else {
$(this).attr('data-selected', '1');
addSelectedItem($(this).attr('data-id'));
$(this).find("i").show();
}
//updateSelectionSize();
$(this).trigger("change");
});
$(".delete-size-check:first").change(function() {
if ($(this).attr('data-selected') == '1') {
$(".delete-size-check").hide();
$(".delete-size-check").attr("data-selected", "1");
$(this).show();
} else {
$(".delete-size-check").show();
$(".delete-size-check").attr("data-selected", "0");
}
})
const delete_deriv_URL = "admin.php?page=maintenance&action=derivatives&";
$(".delete-size-check").change(function() {
let delete_deriv_with_token = delete_deriv_URL + "pwg_token=" + "{$pwg_token}&";
let types_str = '';
let selected = []
$(".delete-size-check").each(function () {
if ($(this).attr("data-selected") == '1') {
selected.push($(this).attr("name"));
}
})
if (selected.length == 0) {
$(".delete-sizes").attr("href", "");
} else {
if (selected[0] == "all") {
types_str = "all";
} else {
types_str = selected.join("_");
}
console.log(selected);
$(".delete-sizes").attr("href", delete_deriv_with_token + "type=" + types_str);
}
})
{/footer_script}
<div class="titrePage">
@@ -78,7 +109,7 @@ $(".delete-size-check").click(function () {
{/if}
<a href="{$U_MAINT_CATEGORIES}" class="icon-folder-open maintenance-action">{'Update albums informations'|@translate}</a>
<a href="{$U_MAINT_IMAGES}" class="icon-info-circled-1 maintenance-action">{'Update photos information'|@translate}</a>
<a href="{$U_MAINT_DATABASE}" class="icon-ok maintenance-action">{'Repair and optimize database'|@translate}</a>
<a href="{$U_MAINT_DATABASE}" class="icon-database maintenance-action">{'Repair and optimize database'|@translate}</a>
<a href="{$U_MAINT_C13Y}" class="icon-ok maintenance-action">{'Reinitialize check integrity'|@translate}</a>
</div>
</fieldset>
@@ -90,27 +121,23 @@ $(".delete-size-check").click(function () {
<a href="{$U_MAINT_HISTORY_DETAIL}" class="icon-back-in-time maintenance-action purge-history-detail-button">{'Purge history detail'|@translate}</a>
<a href="{$U_MAINT_HISTORY_SUMMARY}" class="icon-back-in-time maintenance-action purge-history-summary-button">{'Purge history summary'|@translate}</a>
<a href="{$U_MAINT_SESSIONS}" class="icon-th-list maintenance-action">{'Purge sessions'|@translate}</a>
<a href="{$U_MAINT_FEEDS}" class="maintenance-action">{'Purge never used notification feeds'|@translate}</a>
<a href="{$U_MAINT_FEEDS}" class="icon-bell maintenance-action">{'Purge never used notification feeds'|@translate}</a>
<a href="{$U_MAINT_SEARCH}" class="icon-search maintenance-action purge-search-history-button">{'Purge search history'|@translate}</a>
<a href="{$U_MAINT_COMPILED_TEMPLATES}" class="icon-file maintenance-action">{'Purge compiled templates'|@translate}</a>
<div style="display:flex;flex-wrap: wrap;">
<a href="{$U_MAINT_COMPILED_TEMPLATES}" class="icon-doc maintenance-action">{'Purge compiled templates'|@translate}</a>
</div>
</fieldset>
<div class="delete-size-checks">
<span style="font-weight:bold">{'Delete multiple size images'|@translate}</span>
<div style="display:flex;flex-wrap:wrap">
<div class="delete-check-container">
{foreach from=$purge_derivatives key=name item=url name=loop}
<div class="delete-size-check" style="margin-left:15px;margin-bottom:10px;display:flex">
<span class="select-checkbox" style="display:inline-block"><i class="icon-ok" style="margin-left:8px"></i></span><span style="font-size:14px;margin-left:5px;padding-top:2px;">{$name}</span>
<div class="delete-size-check" data-selected="0" name="{$url}">
<span class="select-checkbox"><i class="icon-ok" style="margin-left:8px"></i></span><span style="font-size:14px;margin-left:5px;padding-top:2px;">{$name}</span>
</div>
{/foreach}
</div>
</div>
<a class="icon-ok maintenance-action" style="display:block;width:max-content;text-align:left;margin-left:20px">Delete these sizes</a>
<!--
{foreach from=$purge_derivatives key=name item=url name=loop}
<a href="{$url}"{if $smarty.foreach.loop.first} class="delete-all-sizes-button"{/if}>{$name}</a>{if !$smarty.foreach.loop.last}, {/if}{/foreach}
-->
<a class="icon-ok maintenance-action delete-sizes">Delete these sizes</a>
<style>
.maintenance-action {
@@ -126,4 +153,28 @@ $(".delete-size-check").click(function () {
margin-left:20px;
margin-bottom:20px;
}
.delete-check-container {
display:flex;
flex-wrap:wrap;
}
.delete-size-check {
margin-left:15px;
margin-bottom:10px;
display:flex;
cursor:pointer
}
.select-checkbox {
display:inline-block;
}
.delete-sizes {
display:block;
width:max-content;
text-align:left;
margin-left:20px
}
</style>
@@ -1,62 +1,10 @@
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
{combine_script id='jquery.confirm' load='footer' require='jquery' path='themes/default/js/plugins/jquery-confirm.min.js'}
{combine_css path="themes/default/js/plugins/jquery-confirm.min.css"}
{footer_script}
const confirm_msg = '{"Yes, I am sure"|@translate}';
const cancel_msg = "{"No, I have changed my mind"|@translate}";
$(".lock-gallery-button").each(function() {
const gallery_tip = '{"A locked gallery is only visible to administrators"|@translate|@escape:'javascript'}';
let title = '{"Are you sure you want to lock the gallery?"|@translate}';
let confirm_msg_gallery = '{"Yes, I want to lock the gallery"|@translate}';
let cancel_msg_gallery = '{"Keep it unlocked"|@translate}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg,
alert_content: gallery_tip
});
});
$(".purge-history-detail-button").each(function() {
const title = '{"Purge history detail"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".purge-history-summary-button").each(function() {
const title = '{"Purge history summary"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".purge-search-history-button").each(function() {
const title = '{"Purge search history"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
$(".delete-all-sizes-button").each(function() {
const title = '{"Are you sure you want to delete all sizes?"|@translate|@escape:'javascript'}';
$(this).pwg_jconfirm_follow_href({
alert_title: title,
alert_confirm: confirm_msg,
alert_cancel: cancel_msg
});
});
{/footer_script}
<div class="titrePage">
<h2>{'Maintenance'|@translate}</h2>
</div>
<fieldset id="environment">
<legend><i class="icon-cog"></i> {'Environment'|@translate}</legend>
<ul>
<legend><span class="icon-television icon-red"></span> {'Environment'|@translate}</legend>
<ul style="font-weight:bold">
<li><a href="{$PHPWG_URL}" class="externalLink">Piwigo</a> {$PWG_VERSION} <a href="{$U_CHECK_UPGRADE}" class="icon-arrows-cw">{'Check for upgrade'|@translate}</a></li>
<li>{'Operating system'|@translate}: {$OS}</li>
<li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" class="externalLink">{'Show info'|@translate}</a>) [{$PHP_DATATIME}]</li>