Change admin active users list to render progressively.

This commit is contained in:
Brock Whittaker 2017-04-20 12:58:46 -07:00 committed by Tim Abbott
parent 1a8a8b6d0c
commit 8c715a79b9
2 changed files with 50 additions and 32 deletions

View File

@ -90,12 +90,6 @@ function failed_listing_users(xhr) {
}
function populate_users(realm_people_data) {
var users_table = $("#admin_users_table");
var deactivated_users_table = $("#admin_deactivated_users_table");
// Clear table rows, but not the table headers
users_table.find("tr.user_row").remove();
deactivated_users_table.find("tr.user_row").remove();
var active_users = [];
var deactivated_users = [];
var bots = [];
@ -131,22 +125,37 @@ function populate_users(realm_people_data) {
},
}).init();
_.each(active_users, function (user) {
var activity_rendered;
var row = $(templates.render("admin_user_list", {user: user, can_modify: page_params.is_admin}));
if (people.is_current_user(user.email)) {
activity_rendered = timerender.render_date(new XDate());
} else {
var last_active_date = presence.last_active_date(user.user_id);
if (last_active_date) {
activity_rendered = timerender.render_date(last_active_date);
var $users_table = $("#admin_users_table");
list_render($users_table, active_users, {
name: "users_table_list",
modifier: function (item) {
var activity_rendered;
if (people.is_current_user(item.email)) {
activity_rendered = timerender.render_date(new XDate());
} else if (presence.presence_info[item.user_id]) {
// XDate takes number of milliseconds since UTC epoch.
var last_active = presence.presence_info[item.user_id].last_active * 1000;
activity_rendered = timerender.render_date(new XDate(last_active));
} else {
activity_rendered = $("<span></span>").text(i18n.t("Unknown"));
}
}
row.find(".last_active").append(activity_rendered);
users_table.append(row);
});
var $row = $(templates.render("admin_user_list", {user: item, can_modify: page_params.is_admin}));
$row.find(".last_active").append(activity_rendered);
return $row;
},
filter: {
element: $users_table.closest(".settings-section").find(".search"),
callback: function (item, value) {
return (
item.full_name.toLowerCase().match(value) ||
item.email.toLowerCase().match(value)
);
},
},
}).init();
var $deactivated_users_table = $("#admin_deactivated_users_table");
list_render($deactivated_users_table, deactivated_users, {

View File

@ -1,15 +1,24 @@
<div id="admin-user-list" class="settings-section" data-name="user-list-admin">
<div class="settings-section-title"><i class="icon-vector-user settings-section-icon"></i>
{{t "Users" }}</div>
<table class="table table-condensed table-striped wrapped-table">
<tbody id="admin_users_table" class="admin_user_table">
<th class="wrapped-cell">{{t "Name" }}</th>
<th>{{t "Email" }}</th>
<th class="last_active">{{t "Last active" }}</th>
{{#if is_admin}}
<th>{{t "Actions" }}</th>
{{/if}}
</tbody>
</table>
<div id="admin_page_users_loading_indicator"></div>
<div class="settings-section-title">
<div class="table-title">
<i class="icon-vector-user settings-section-icon"></i>
{{t "Users" }}
</div>
<input type="text" class="search" placeholder="{{t 'Search users' }}" />
<div class="clear-float"></div>
</div>
<div class="progressive-table-wrapper">
<table class="table table-condensed table-striped wrapped-table">
<thead>
<th class="wrapped-cell">{{t "Name" }}</th>
<th>{{t "Email" }}</th>
<th class="last_active">{{t "Last active" }}</th>
{{#if is_admin}}
<th>{{t "Actions" }}</th>
{{/if}}
</thead>
<tbody id="admin_users_table" class="admin_user_table"></tbody>
</table>
</div>
<div id="admin_page_users_loading_indicator"></div>
</div>