From 207ef144c5e5d7db16d42c6f15b8efc33a354e92 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 16 Aug 2014 01:07:23 +0100 Subject: display mtime_age in webclient --- webclient/app.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js index 58d3942c65..3f4c5f30f8 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -94,6 +94,26 @@ matrixWebClient } }; }]) + .filter('duration', function() { + return function(time) { + if (!time) return; + var t = parseInt(time / 1000); + var s = t % 60; + var m = parseInt(t / 60) % 60; + var h = parseInt(t / (60 * 60)) % 24; + var d = parseInt(t / (60 * 60 * 24)); + if (t < 60) { + return s + "s" + } + if (t < 60 * 60) { + return m + "m " + s + "s"; + } + if (t < 24 * 60 * 60) { + return h + "h " + m + "m"; + } + return d + "d " + h + "h"; + } + }) .filter('to_trusted', ['$sce', function($sce){ return function(text) { return $sce.trustAsHtml(text); -- cgit 1.4.1 From ce4ca473cbafce0fc71a2b4e69e35caa8f251595 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 16 Aug 2014 13:22:47 +0100 Subject: order the members list by most recently active --- webclient/app.js | 15 ++++++++++++++- webclient/room/room.html | 11 +++++------ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js index 3f4c5f30f8..9cdf926425 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -114,7 +114,20 @@ matrixWebClient return d + "d " + h + "h"; } }) - .filter('to_trusted', ['$sce', function($sce){ + .filter('orderMembersList', function($sce) { + return function(members) { + var filtered = []; + angular.forEach(members, function(value, key) { + value["id"] = key; + filtered.push( value ); + }); + filtered.sort(function (a, b) { + return ((a["mtime_age"] || 10e10)> (b["mtime_age"] || 10e10) ? 1 : -1); + }); + return filtered; + }; + }) + .filter('unsafe', ['$sce', function($sce) { return function(text) { return $sce.trustAsHtml(text); }; diff --git a/webclient/room/room.html b/webclient/room/room.html index f08cb61763..5712ce9b4f 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -9,15 +9,14 @@
- + -
- + - -
+
{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}{{ member.displayname ? "" : member.id.substr(member.id.indexOf(':')) }}
- {{ info.mtime_age | duration }} {{ info.mtime_age ? "ago" : "" }} + + {{ member.mtime_age | duration }} {{ member.mtime_age ? "ago" : "" }}
-- cgit 1.4.1 From e4770bb039ba5f24dc3185748baeccb3c8c0c537 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 16 Aug 2014 13:30:34 +0100 Subject: make presence timestamps less verbose --- webclient/app.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js index 9cdf926425..f6ce69e403 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -106,12 +106,12 @@ matrixWebClient return s + "s" } if (t < 60 * 60) { - return m + "m " + s + "s"; + return m + "m "; // + s + "s"; } if (t < 24 * 60 * 60) { - return h + "h " + m + "m"; + return h + "h "; // + m + "m"; } - return d + "d " + h + "h"; + return d + "d "; // + h + "h"; } }) .filter('orderMembersList', function($sce) { -- cgit 1.4.1 From fe25e65f3f6c4bce9b61c8136cbd0585455321a3 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 16 Aug 2014 20:48:05 +0100 Subject: disambiguate identical displaynames --- webclient/app.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js index f6ce69e403..a6668da6eb 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -117,12 +117,34 @@ matrixWebClient .filter('orderMembersList', function($sce) { return function(members) { var filtered = []; + + var displayNames = {}; angular.forEach(members, function(value, key) { value["id"] = key; filtered.push( value ); + if (value["displayname"]) { + if (!displayNames[value["displayname"]]) { + displayNames[value["displayname"]] = []; + } + displayNames[value["displayname"]].push(key); + } }); + + // FIXME: we shouldn't disambiguate displayNames on every orderMembersList + // invocation but keep track of duplicates incrementally somewhere + angular.forEach(displayNames, function(value, key) { + if (value.length > 1) { + console.log(key + ": " + value); + for (i=0; i < value.length; i++) { + var v = value[i]; + members[v].displayname += " (" + v + ")"; + console.log(v + " " + members[v]); + }; + } + }); + filtered.sort(function (a, b) { - return ((a["mtime_age"] || 10e10)> (b["mtime_age"] || 10e10) ? 1 : -1); + return ((a["mtime_age"] || 10e10) > (b["mtime_age"] || 10e10) ? 1 : -1); }); return filtered; }; -- cgit 1.4.1 From f1d140eea8536023d92eedd31fee4bf8984b5638 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Sat, 16 Aug 2014 22:02:52 +0100 Subject: remove log spam --- webclient/app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js index a6668da6eb..c4794e6abc 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -134,11 +134,11 @@ matrixWebClient // invocation but keep track of duplicates incrementally somewhere angular.forEach(displayNames, function(value, key) { if (value.length > 1) { - console.log(key + ": " + value); + // console.log(key + ": " + value); for (i=0; i < value.length; i++) { var v = value[i]; members[v].displayname += " (" + v + ")"; - console.log(v + " " + members[v]); + // console.log(v + " " + members[v]); }; } }); -- cgit 1.4.1 From 0b5674ccc5e636249f0bf746a81af814dc4c8700 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Mon, 18 Aug 2014 10:44:29 +0200 Subject: Do not start the event stream if the user is not logged in (=if he does not has an access token yet) Add isUserLoggedIn to check this. --- webclient/app-controller.js | 2 +- webclient/app.js | 5 ++--- webclient/components/matrix/matrix-service.js | 19 ++++++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) (limited to 'webclient/app.js') diff --git a/webclient/app-controller.js b/webclient/app-controller.js index ff4cb6e69e..96656e12c3 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -52,7 +52,7 @@ angular.module('MatrixWebClientController', ['matrixService']) } }; - if (matrixService.config()) { + if (matrixService.isUserLoggedIn()) { eventStreamService.resume(); } diff --git a/webclient/app.js b/webclient/app.js index c4794e6abc..8d64db92d3 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -63,9 +63,8 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider', }]); matrixWebClient.run(['$location', 'matrixService', 'eventStreamService', function($location, matrixService, eventStreamService) { - // If we have no persistent login information, go to the login page - var config = matrixService.config(); - if (!config || !config.access_token) { + // If user auth details are not in cache, go to the login page + if (!matrixService.isUserLoggedIn()) { eventStreamService.stop(); $location.path("login"); } diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 0cc85db28e..c52c94c310 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -318,12 +318,21 @@ angular.module('matrixService', []) }; return doRequest("GET", path, params); }, - - // - testLogin: function() { - + + // Indicates if user authentications details are stored in cache + isUserLoggedIn: function() { + var config = this.config(); + + // User is considered logged in if his cache is not empty and contains + // an access token + if (config && config.access_token) { + return true; + } + else { + return false; + } }, - + /****** Permanent storage of user information ******/ // Returns the current config -- cgit 1.4.1