diff --git a/client/components/Session.vue b/client/components/Session.vue
new file mode 100644
index 00000000..6af7d64f
--- /dev/null
+++ b/client/components/Session.vue
@@ -0,0 +1,55 @@
+
+
+
+
+ {{ session.agent }}
+
+ {{ session.ip }}
+
+
+
+
+ Currently active
+
+
+ Last used on
+
+
+
Loading…
++ You are not currently logged in to any other device.' +
+ +Loading…
"); - socket.emit("sessions:get"); - }); - if (data.fileUpload) { upload.initialize(data.fileUploadMaxFileSize); } diff --git a/client/js/socket-events/sessions_list.js b/client/js/socket-events/sessions_list.js index 91e2a57a..dd47ee14 100644 --- a/client/js/socket-events/sessions_list.js +++ b/client/js/socket-events/sessions_list.js @@ -1,37 +1,8 @@ "use strict"; - -const $ = require("jquery"); -const Auth = require("../auth"); const socket = require("../socket"); -const templates = require("../../views"); +const {vueApp} = require("../vue"); 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() { - const token = $(this).data("token"); - - if (token) { - socket.emit("sign-out", token); - } else { - socket.emit("sign-out"); - Auth.signout(); - } + vueApp.$store.commit("sessions", data); }); diff --git a/client/js/store.js b/client/js/store.js index b4015184..bab7f57d 100644 --- a/client/js/store.js +++ b/client/js/store.js @@ -8,6 +8,7 @@ export default new Vuex.Store({ isConnected: false, isNotified: false, activeWindow: null, + sessions: [], }, mutations: { isConnected(state, payload) { @@ -22,5 +23,12 @@ export default new Vuex.Store({ currentNetworkConfig(state, payload) { state.currentNetworkConfig = payload; }, + sessions(state, payload) { + state.sessions = payload; + }, + }, + getters: { + currentSession: (state) => state.sessions.find((item) => item.current), + otherSessions: (state) => state.sessions.filter((item) => !item.current), }, }); diff --git a/client/views/session.tpl b/client/views/session.tpl deleted file mode 100644 index 7951bfc4..00000000 --- a/client/views/session.tpl +++ /dev/null @@ -1,25 +0,0 @@ -
-
-
- {{agent}}
-
- {{ip}}
-
-{{#unless current}}
-
- {{#if active}}
- Currently active
- {{else}}
- Last used on
- {{/if}}
-{{/unless}}
-