mirror of https://github.com/zulip/zulip.git
admin: Display last active time of users in admin users table.
Fixes: #2097.
This commit is contained in:
parent
d565990c68
commit
d17b759fa2
|
@ -283,11 +283,11 @@ global.compile_template('user_presence_rows');
|
|||
activity.set_presence_info(presences, base_time);
|
||||
|
||||
assert.deepEqual(activity.presence_info[alice.user_id],
|
||||
{ status: 'active', mobile: false}
|
||||
{ status: 'active', mobile: false, last_active: 500}
|
||||
);
|
||||
|
||||
assert.deepEqual(activity.presence_info[fred.user_id],
|
||||
{ status: 'idle', mobile: false}
|
||||
{ status: 'idle', mobile: false, last_active: 500}
|
||||
);
|
||||
}());
|
||||
|
||||
|
|
|
@ -400,10 +400,14 @@ exports.update_huddles = function () {
|
|||
|
||||
function status_from_timestamp(baseline_time, presence) {
|
||||
var status = 'offline';
|
||||
var last_active = 0;
|
||||
var mobileAvailable = false;
|
||||
var nonmobileAvailable = false;
|
||||
_.each(presence, function (device_presence, device) {
|
||||
var age = baseline_time - device_presence.timestamp;
|
||||
if (last_active < device_presence.timestamp) {
|
||||
last_active = device_presence.timestamp;
|
||||
}
|
||||
if (is_mobile(device)) {
|
||||
mobileAvailable = device_presence.pushable || mobileAvailable;
|
||||
}
|
||||
|
@ -432,7 +436,9 @@ function status_from_timestamp(baseline_time, presence) {
|
|||
}
|
||||
}
|
||||
});
|
||||
return {status: status, mobile: !nonmobileAvailable && mobileAvailable };
|
||||
return {status: status,
|
||||
mobile: !nonmobileAvailable && mobileAvailable,
|
||||
last_active: last_active };
|
||||
}
|
||||
|
||||
// For testing
|
||||
|
|
|
@ -134,12 +134,21 @@ function populate_users(realm_people_data) {
|
|||
});
|
||||
bots_table.append(bots_table_html);
|
||||
|
||||
var users_table_html = "";
|
||||
_.each(active_users, function (user) {
|
||||
var user_html = templates.render("admin_user_list", {user: user});
|
||||
users_table_html = users_table_html.concat(user_html);
|
||||
var activity_rendered;
|
||||
var row = $(templates.render("admin_user_list", {user: user}));
|
||||
if (people.is_current_user(user.email)) {
|
||||
activity_rendered = timerender.render_date(new XDate());
|
||||
} else if (activity.presence_info[user.user_id]) {
|
||||
// XDate takes number of milliseconds since UTC epoch.
|
||||
var last_active = activity.presence_info[user.user_id].last_active * 1000;
|
||||
activity_rendered = timerender.render_date(new XDate(last_active));
|
||||
} else {
|
||||
activity_rendered = $("<span></span>").text(i18n.t("Never"));
|
||||
}
|
||||
row.find(".last_active").append(activity_rendered);
|
||||
users_table.append(row);
|
||||
});
|
||||
users_table.append(users_table_html);
|
||||
|
||||
var deactivated_table_html = "";
|
||||
_.each(deactivated_users, function (user) {
|
||||
|
|
|
@ -1059,3 +1059,7 @@ input[type=text]#settings_search {
|
|||
#muted_topics_table tbody {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
#admin_users_table .last_active {
|
||||
width: 15%;
|
||||
}
|
||||
|
|
|
@ -10,17 +10,22 @@
|
|||
<td>
|
||||
<span class="owner">{{bot_owner}}</span>
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="last_active">
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
{{#if is_active}}
|
||||
<button class="button deactivate btn-danger">
|
||||
{{t "Deactivate" }}
|
||||
</button>
|
||||
{{else}}
|
||||
<button class="button reactivate btn-warning">
|
||||
{{t "Reactivate" }}
|
||||
</button>
|
||||
{{/if}}
|
||||
<span class="user-status-settings">
|
||||
{{#if is_active}}
|
||||
<button class="button deactivate btn-danger">
|
||||
{{t "Deactivate" }}
|
||||
</button>
|
||||
{{else}}
|
||||
<button class="button reactivate btn-warning">
|
||||
{{t "Reactivate" }}
|
||||
</button>
|
||||
{{/if}}
|
||||
</span>
|
||||
<span class="user-admin-settings">
|
||||
{{#if is_active_human}}
|
||||
{{#if is_admin}}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<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>
|
||||
<th>{{t "Actions" }}</th>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
Loading…
Reference in New Issue