mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
related to #1465 added summary to history results
This commit is contained in:
committed by
plegall
parent
5730be596c
commit
6fcedc19a3
@@ -105,6 +105,53 @@ function activateLineOptions() {
|
||||
});
|
||||
}
|
||||
|
||||
function fillSummaryResult(summary) {
|
||||
$(".user-list").empty();
|
||||
|
||||
$(".summary-lines .summary-data").html(summary.NB_LINES);
|
||||
$(".summary-weight .summary-data").html(unit_MB.replace("%s", summary.FILESIZE));
|
||||
$(".summary-users .summary-data").html(summary.USERS);
|
||||
$(".summary-guests .summary-data").html(summary.GUESTS);
|
||||
|
||||
var id_of = [];
|
||||
var user_dot_title = "";
|
||||
|
||||
// not sorted
|
||||
summary.MEMBERS.forEach(keyval => {
|
||||
for (const [key, value] of Object.entries(keyval)) {
|
||||
id_of[key] = value;
|
||||
user_dot_title += key + ", ";
|
||||
}
|
||||
});
|
||||
user_dot_title = user_dot_title.slice(0, -2);
|
||||
$(".user-dot").attr("title", user_dot_title).addClass("tiptip");
|
||||
|
||||
var tmp = 0;
|
||||
//sorted
|
||||
for (const [key, value] of Object.entries(summary.SORTED_MEMBERS)) {
|
||||
if (tmp < 5) {
|
||||
new_user_item = $("#-2").clone();
|
||||
|
||||
new_user_item.removeClass("hide");
|
||||
new_user_item.find(".user-item-name").html(key);
|
||||
new_user_item.data("user-id", id_of[key]);
|
||||
|
||||
new_user_item.on("click", function () {
|
||||
if (current_param.user != id_of[key]) {
|
||||
current_param.user = $(this).data("user-id");
|
||||
addUserFilter(key)
|
||||
fillHistoryResult(current_param);
|
||||
}
|
||||
})
|
||||
$(".user-list").append(new_user_item);
|
||||
$(".user-dot").hide();
|
||||
tmp++;
|
||||
} else {
|
||||
$(".user-dot").show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fillHistoryResult(ajaxParam) {
|
||||
// console.log(current_param);
|
||||
|
||||
@@ -115,13 +162,12 @@ function fillHistoryResult(ajaxParam) {
|
||||
data: ajaxParam,
|
||||
success: function (raw_data) {
|
||||
$(".loading").removeClass("hide");
|
||||
// console.log(ajaxParam.user);
|
||||
// console.log(raw_data);
|
||||
data = raw_data.result["lines"];
|
||||
imageDisplay = raw_data.result["params"].display_thumbnail;
|
||||
// console.log("RESULTS");
|
||||
maxPage = raw_data.result["maxPage"];
|
||||
console.log(data);
|
||||
summary = raw_data.result["summary"];
|
||||
// console.log(raw_data);
|
||||
|
||||
//clear lines before refill
|
||||
$(".tab .search-line").remove();
|
||||
|
||||
@@ -130,6 +176,8 @@ function fillHistoryResult(ajaxParam) {
|
||||
lineConstructor(line, id, imageDisplay)
|
||||
id++
|
||||
});
|
||||
|
||||
fillSummaryResult(summary);
|
||||
},
|
||||
error: function (e) {
|
||||
console.log(e);
|
||||
|
||||
@@ -40,6 +40,7 @@ const str_list = "{'Random photo'|translate}";
|
||||
const str_favorites = "{'Your favorites'|translate}";
|
||||
const str_recent_cats = "{'Recent albums'|translate}";
|
||||
const str_recent_pics = "{'Recent photos'|translate}";
|
||||
const unit_MB = "{"%s MB"|@translate}";
|
||||
{/footer_script}
|
||||
|
||||
{combine_script id='common' load='footer' path='admin/themes/default/js/common.js'}
|
||||
@@ -75,7 +76,6 @@ const str_recent_pics = "{'Recent photos'|translate}";
|
||||
<label>
|
||||
{'Action'|@translate}
|
||||
<select name="types[]" class="elem-type-select user-action-select advanced-filter-select">
|
||||
{* {html_options values=$type_option_values output=$type_option_values|translate selected=$type_option_selected} *}
|
||||
<option value=""></option>
|
||||
<option value="visited">{'Visited'|@translate} </option>
|
||||
<option value="downloaded">{'Downloaded'|@translate} </option>
|
||||
@@ -114,6 +114,36 @@ const str_recent_pics = "{'Recent photos'|translate}";
|
||||
</fieldset>
|
||||
{/if}
|
||||
|
||||
{* Used to be copied in JS *}
|
||||
<span id="-2" class="icon-green summary-user-item hide">
|
||||
<i class="icon-green icon-user-1"> </i>
|
||||
<i class="icon-green icon-plus-circled"> </i>
|
||||
<span class="user-item-name"> User test </span>
|
||||
</span>
|
||||
{* *}
|
||||
|
||||
<div class="search-summary">
|
||||
<div class="summary-lines">
|
||||
<span class="icon-yellow icon-menu summary-icons"></span>
|
||||
<span class="summary-data"> </span>
|
||||
</div>
|
||||
<div class="summary-weight">
|
||||
<span class="icon-purple icon-download summary-icons"></span>
|
||||
<span class="summary-data"> </span>
|
||||
</div>
|
||||
<div class="summary-users">
|
||||
<span class="icon-green icon-user-1 summary-icons"></span>
|
||||
<span class="summary-data"> </span>
|
||||
<div class="user-list">
|
||||
</div>
|
||||
<span class="user-dot icon-green summary-user-item">...</span>
|
||||
</div>
|
||||
<div class="summary-guests">
|
||||
<span class="icon-blue icon-user-1 summary-icons"></span>
|
||||
<span class="summary-data"> </span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if !empty($navbar) }{include file='navigation_bar.tpl'|@get_extent:'navbar'}{/if}
|
||||
|
||||
<div class="container">
|
||||
@@ -584,4 +614,64 @@ jQuery(document).ready( function() {
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
/* Summary */
|
||||
|
||||
.search-summary {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.summary-lines,
|
||||
.summary-weight,
|
||||
.summary-users,
|
||||
.summary-guests {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.summary-icons {
|
||||
padding: 10px;
|
||||
border-radius: 50%;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.summary-users {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.summary-user-item {
|
||||
padding: 2px 10px;
|
||||
border-radius: 20px;
|
||||
margin-left: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.summary-user-item .icon-plus-circled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.summary-user-item:hover .icon-plus-circled {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.summary-user-item:hover .icon-user-1 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.summary-users .summary-data {
|
||||
margin: 0 5px 0 0 !important;
|
||||
}
|
||||
|
||||
.summary-data {
|
||||
font-weight: bold;
|
||||
margin: 0 15px 0 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -839,6 +839,7 @@ SELECT
|
||||
$summary['guests_IP'] = array();
|
||||
|
||||
$result = array();
|
||||
$sorted_members = array();
|
||||
|
||||
foreach ($history_lines as $line)
|
||||
{
|
||||
@@ -940,6 +941,13 @@ SELECT
|
||||
.'" alt="'.$image_title.'" title="'.$image_title.'">';
|
||||
}
|
||||
|
||||
if (isset($sorted_members[$user_name])) {
|
||||
$sorted_members[$user_name] += 1;
|
||||
} else {
|
||||
$sorted_members[$user_name] =1;
|
||||
}
|
||||
|
||||
|
||||
array_push( $result,
|
||||
array(
|
||||
'DATE' => format_date($line['date']),
|
||||
@@ -965,10 +973,60 @@ SELECT
|
||||
$result = array_reverse($result, true);
|
||||
$result = array_slice($result, $param['pageNumber']*100, 100);
|
||||
|
||||
$summary['nb_guests'] = 0;
|
||||
if (count(array_keys($summary['guests_IP'])) > 0)
|
||||
{
|
||||
$summary['nb_guests'] = count(array_keys($summary['guests_IP']));
|
||||
|
||||
// we delete the "guest" from the $username_of hash so that it is
|
||||
// avoided in next steps
|
||||
unset($username_of[ $conf['guest_id'] ]);
|
||||
}
|
||||
|
||||
$summary['nb_members'] = count($username_of);
|
||||
|
||||
$member_strings = array();
|
||||
foreach ($username_of as $user_id => $user_name)
|
||||
{
|
||||
$member_string = $user_name;
|
||||
// ' <a href="';
|
||||
// $member_string.= get_root_url().'admin.php?page=history';
|
||||
// $member_string.= '&search_id='.$page['search_id'];
|
||||
// $member_string.= '&user_id='.$user_id;
|
||||
// $member_string.= '">+</a>';
|
||||
|
||||
$member_strings[] = array($member_string => $user_id);
|
||||
}
|
||||
|
||||
arsort($sorted_members);
|
||||
unset($sorted_members['guest']);
|
||||
|
||||
$search_summary =
|
||||
array(
|
||||
'NB_LINES' => l10n_dec(
|
||||
'%d line filtered', '%d lines filtered',
|
||||
$page['nb_lines']
|
||||
),
|
||||
'FILESIZE' => $summary['total_filesize'] != 0 ? ceil($summary['total_filesize']/1024) : 0,
|
||||
'USERS' => l10n_dec(
|
||||
'%d user', '%d users',
|
||||
$summary['nb_members'] + $summary['nb_guests']
|
||||
),
|
||||
'MEMBERS' => $member_strings,
|
||||
'SORTED_MEMBERS' => $sorted_members,
|
||||
'GUESTS' => l10n_dec(
|
||||
'%d guest', '%d guests',
|
||||
$summary['nb_guests']
|
||||
),
|
||||
);
|
||||
|
||||
unset($name_of_tag);
|
||||
|
||||
return array(
|
||||
'lines' => $result,
|
||||
'lines' => $result,
|
||||
'params' => $param,
|
||||
'maxPage' => $max_page
|
||||
'maxPage' => $max_page,
|
||||
'summary' => $search_summary
|
||||
);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user