mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
admin: Display last active time of users in admin users table.
Fixes: #2097.
This commit is contained in:
committed by
Tim Abbott
parent
d565990c68
commit
d17b759fa2
@@ -283,11 +283,11 @@ global.compile_template('user_presence_rows');
|
|||||||
activity.set_presence_info(presences, base_time);
|
activity.set_presence_info(presences, base_time);
|
||||||
|
|
||||||
assert.deepEqual(activity.presence_info[alice.user_id],
|
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],
|
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) {
|
function status_from_timestamp(baseline_time, presence) {
|
||||||
var status = 'offline';
|
var status = 'offline';
|
||||||
|
var last_active = 0;
|
||||||
var mobileAvailable = false;
|
var mobileAvailable = false;
|
||||||
var nonmobileAvailable = false;
|
var nonmobileAvailable = false;
|
||||||
_.each(presence, function (device_presence, device) {
|
_.each(presence, function (device_presence, device) {
|
||||||
var age = baseline_time - device_presence.timestamp;
|
var age = baseline_time - device_presence.timestamp;
|
||||||
|
if (last_active < device_presence.timestamp) {
|
||||||
|
last_active = device_presence.timestamp;
|
||||||
|
}
|
||||||
if (is_mobile(device)) {
|
if (is_mobile(device)) {
|
||||||
mobileAvailable = device_presence.pushable || mobileAvailable;
|
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
|
// For testing
|
||||||
|
|||||||
@@ -134,12 +134,21 @@ function populate_users(realm_people_data) {
|
|||||||
});
|
});
|
||||||
bots_table.append(bots_table_html);
|
bots_table.append(bots_table_html);
|
||||||
|
|
||||||
var users_table_html = "";
|
|
||||||
_.each(active_users, function (user) {
|
_.each(active_users, function (user) {
|
||||||
var user_html = templates.render("admin_user_list", {user: user});
|
var activity_rendered;
|
||||||
users_table_html = users_table_html.concat(user_html);
|
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 = "";
|
var deactivated_table_html = "";
|
||||||
_.each(deactivated_users, function (user) {
|
_.each(deactivated_users, function (user) {
|
||||||
|
|||||||
@@ -1059,3 +1059,7 @@ input[type=text]#settings_search {
|
|||||||
#muted_topics_table tbody {
|
#muted_topics_table tbody {
|
||||||
border-bottom: none;
|
border-bottom: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#admin_users_table .last_active {
|
||||||
|
width: 15%;
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,17 +10,22 @@
|
|||||||
<td>
|
<td>
|
||||||
<span class="owner">{{bot_owner}}</span>
|
<span class="owner">{{bot_owner}}</span>
|
||||||
</td>
|
</td>
|
||||||
|
{{else}}
|
||||||
|
<td class="last_active">
|
||||||
|
</td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<td>
|
<td>
|
||||||
{{#if is_active}}
|
<span class="user-status-settings">
|
||||||
<button class="button deactivate btn-danger">
|
{{#if is_active}}
|
||||||
{{t "Deactivate" }}
|
<button class="button deactivate btn-danger">
|
||||||
</button>
|
{{t "Deactivate" }}
|
||||||
{{else}}
|
</button>
|
||||||
<button class="button reactivate btn-warning">
|
{{else}}
|
||||||
{{t "Reactivate" }}
|
<button class="button reactivate btn-warning">
|
||||||
</button>
|
{{t "Reactivate" }}
|
||||||
{{/if}}
|
</button>
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
<span class="user-admin-settings">
|
<span class="user-admin-settings">
|
||||||
{{#if is_active_human}}
|
{{#if is_active_human}}
|
||||||
{{#if is_admin}}
|
{{#if is_admin}}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
<tbody id="admin_users_table" class="admin_user_table">
|
<tbody id="admin_users_table" class="admin_user_table">
|
||||||
<th class="wrapped-cell">{{t "Name" }}</th>
|
<th class="wrapped-cell">{{t "Name" }}</th>
|
||||||
<th>{{t "Email" }}</th>
|
<th>{{t "Email" }}</th>
|
||||||
|
<th class="last_active">{{t "Last active" }}</th>
|
||||||
<th>{{t "Actions" }}</th>
|
<th>{{t "Actions" }}</th>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user