diff --git a/client/css/style.css b/client/css/style.css index aaed0a37..807aae85 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -252,6 +252,14 @@ kbd { color: #7f8c8d; } +.session-list strong { + display: block; +} + +.session-list p { + margin-bottom: 10px; +} + #chat .invite .from::before { content: "\f003"; /* http://fontawesome.io/icon/envelope-o/ */ color: #2ecc40; @@ -668,6 +676,7 @@ kbd { width: 100%; } +#windows p, #windows label, #settings .error { font-size: 14px; diff --git a/client/index.html b/client/index.html index 5b170e63..26f4c4f4 100644 --- a/client/index.html +++ b/client/index.html @@ -198,15 +198,14 @@ -
Loading…
"); + socket.emit("sessions:get"); + } + focus(); }); diff --git a/client/js/socket-events/index.js b/client/js/socket-events/index.js index 23a5e961..b0064665 100644 --- a/client/js/socket-events/index.js +++ b/client/js/socket-events/index.js @@ -17,3 +17,4 @@ require("./sync_sort"); require("./topic"); require("./users"); require("./sign_out"); +require("./sessions_list"); diff --git a/client/js/socket-events/sessions_list.js b/client/js/socket-events/sessions_list.js new file mode 100644 index 00000000..9d77df46 --- /dev/null +++ b/client/js/socket-events/sessions_list.js @@ -0,0 +1,31 @@ +"use strict"; + +const $ = require("jquery"); +const socket = require("../socket"); +const templates = require("../../views"); + +socket.on("sessions:list", function(data) { + data.sort((a, b) => b.lastUse - a.lastUse); + + let html = ""; + data.forEach((connection) => { + if (connection.current) { + $("#session-current").html(templates.session(connection)); + return; + } + + html += templates.session(connection); + }); + + if (html.length === 0) { + html = "You are not currently logged in to any other device.
"; + } + + $("#session-list").html(html); +}); + +$("#settings").on("click", ".remove-session", function() { + socket.emit("sign-out", $(this).data("token")); + + return false; +}); diff --git a/client/views/index.js b/client/views/index.js index 50f6a93f..118fa60c 100644 --- a/client/views/index.js +++ b/client/views/index.js @@ -34,6 +34,7 @@ module.exports = { msg_unhandled: require("./msg_unhandled.tpl"), network: require("./network.tpl"), image_viewer: require("./image_viewer.tpl"), + session: require("./session.tpl"), unread_marker: require("./unread_marker.tpl"), user: require("./user.tpl"), user_filtered: require("./user_filtered.tpl"), diff --git a/client/views/session.tpl b/client/views/session.tpl new file mode 100644 index 00000000..d3d5cbd8 --- /dev/null +++ b/client/views/session.tpl @@ -0,0 +1,17 @@ +
+{{#if current}}
+ {{agent}}
+ {{ip}}
+{{else}}
+
+
+ {{agent}}
+ {{ip}}
+
+ {{#if active}}
+ Currently active
+ {{else}}
+ Last used on
+ {{/if}}
+{{/if}}
+