From e5257b21b3cb6a1823159273b07a0ada25cdf8a8 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Mon, 18 Aug 2014 17:11:08 +0200 Subject: Support room alias in rooms URL (ex: http://127.0.0.1:8000/#/room/#public:localhost:8080) --- webclient/room/room-controller.js | 43 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'webclient/room') diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index b859f3d7e8..999c48f02d 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -108,8 +108,11 @@ angular.module('RoomController', ['ngSanitize']) function($scope, $http, $timeout, $routeParams, $location, matrixService, eventStreamService, eventHandlerService) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; + + // Room ids. Checked, computed and resolved in onInit $scope.room_id = $routeParams.room_id; - $scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id); + $scope.room_alias = undefined; + $scope.state = { user_id: matrixService.config().user_id, events_from: "END", // when to start the event stream from. @@ -342,7 +345,45 @@ angular.module('RoomController', ['ngSanitize']) $scope.onInit = function() { // $timeout(function() { document.getElementById('textInput').focus() }, 0); console.log("onInit"); + + // Does the room ID provided in the URL? + if ($scope.room_id) { + // Yes, we can start right now + $scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id); + onInit2(); + } + else { + // No, the URL contains the room alias. Get this alias. + // ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080 + if (3 === location.hash.split("#").length) { + $scope.room_alias = "#" + location.hash.split("#")[2]; + } + else { + // In case of issue, go to the default page + console.log("Error: cannot extract room alias"); + $location.path("/"); + return; + } + + console.log("Resolving alias: " + $scope.room_alias); + + // Need a room ID required in Matrix API requests + matrixService.resolveRoomAlias($scope.room_alias).then(function(response) { + $scope.room_id = response.data.room_id; + console.log(" -> Room ID: " + $scope.room_id); + + // Now, we can start + onInit2(); + }, + function () { + // In case of issue, go to the default page + console.log("Error: cannot resolve room alias"); + $location.path("/"); + }); + } + }; + var onInit2 = function() { // Join the room matrixService.join($scope.room_id).then( function() { -- cgit 1.5.1 From 43772d0b15f749e2e4356097560cca3c86e1e4e6 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Mon, 18 Aug 2014 17:40:05 +0200 Subject: Support urlencoded room aliases in room URL --- webclient/app.js | 4 ++-- webclient/room/room-controller.js | 42 +++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 17 deletions(-) (limited to 'webclient/room') diff --git a/webclient/app.js b/webclient/app.js index 193c11d461..a3d1505f81 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -33,13 +33,13 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider', templateUrl: 'login/login.html', controller: 'LoginController' }). - when('/room/:room_id', { + when('/room/:room_id_or_alias', { templateUrl: 'room/room.html', controller: 'RoomController' }). when('/room/', { // room URL with room alias in it (ex: http://127.0.0.1:8000/#/room/#public:localhost:8080) will come here. // The reason is that 2nd hash key breaks routeProvider parameters cutting so that the URL will not match with - // the previous '/room/:room_id' URL rule + // the previous '/room/:room_id_or_alias' URL rule templateUrl: 'room/room.html', controller: 'RoomController' }). diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 999c48f02d..d130a28fd7 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -109,8 +109,8 @@ angular.module('RoomController', ['ngSanitize']) 'use strict'; var MESSAGES_PER_PAGINATION = 30; - // Room ids. Checked, computed and resolved in onInit - $scope.room_id = $routeParams.room_id; + // Room ids. Computed and resolved in onInit + $scope.room_id = undefined; $scope.room_alias = undefined; $scope.state = { @@ -347,27 +347,39 @@ angular.module('RoomController', ['ngSanitize']) console.log("onInit"); // Does the room ID provided in the URL? - if ($scope.room_id) { - // Yes, we can start right now + var room_id_or_alias; + if ($routeParams.room_id_or_alias) { + room_id_or_alias = decodeURIComponent($routeParams.room_id_or_alias); + } + + if (room_id_or_alias && '!' === room_id_or_alias[0]) { + // Yes. We can start right now + $scope.room_id = room_id_or_alias; $scope.room_alias = matrixService.getRoomIdToAliasMapping($scope.room_id); onInit2(); } else { - // No, the URL contains the room alias. Get this alias. - // ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080 - if (3 === location.hash.split("#").length) { - $scope.room_alias = "#" + location.hash.split("#")[2]; + // No. The URL contains the room alias. Get this alias. + if (room_id_or_alias) { + // The room alias was passed urlencoded, use it as is + $scope.room_alias = room_id_or_alias; } - else { - // In case of issue, go to the default page - console.log("Error: cannot extract room alias"); - $location.path("/"); - return; + else { + // Else get the room alias by hand from the URL + // ie: extract #public:localhost:8080 from http://127.0.0.1:8000/#/room/#public:localhost:8080 + if (3 === location.hash.split("#").length) { + $scope.room_alias = "#" + location.hash.split("#")[2]; + } + else { + // In case of issue, go to the default page + console.log("Error: cannot extract room alias"); + $location.path("/"); + return; + } } - console.log("Resolving alias: " + $scope.room_alias); - // Need a room ID required in Matrix API requests + console.log("Resolving alias: " + $scope.room_alias); matrixService.resolveRoomAlias($scope.room_alias).then(function(response) { $scope.room_id = response.data.room_id; console.log(" -> Room ID: " + $scope.room_id); -- cgit 1.5.1 From 301e55d11da31a505bba58abb1dbb2caf766a5c3 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Mon, 18 Aug 2014 17:49:50 +0200 Subject: In members list, on avatar mouseover, show a tooltip with the user matrix id --- webclient/room/room.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'webclient/room') diff --git a/webclient/room/room.html b/webclient/room/room.html index 106a9dfd15..1c6a44f6fc 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -11,8 +11,12 @@
- - + {{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }} +
{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}
{{ member.displayname ? "" : member.id.substr(member.id.indexOf(':')) }}
-- cgit 1.5.1 From cdc5ffe2a2457e50790ab73cf4ceffa0c552a14d Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 18 Aug 2014 17:14:43 +0100 Subject: show private room_ids rather than nulls in notifs if there is no room_alias --- webclient/room/room-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webclient/room') diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index d130a28fd7..1414fbbe6a 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -147,7 +147,7 @@ angular.module('RoomController', ['ngSanitize']) if (document.hidden) { var notification = new window.Notification( ($scope.members[event.user_id].displayname || event.user_id) + - " (" + $scope.room_alias + ")", + " (" + ($scope.room_alias || $scope.room_id) + ")", // FIXME: don't leak room_ids here { "body": event.content.body, "icon": $scope.members[event.user_id].avatar_url, -- cgit 1.5.1 From c3f1548bb4b485aef00ac67079cea7e65216d4d4 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 19 Aug 2014 08:58:53 +0200 Subject: Added link to user profile pages --- webclient/room/room-controller.js | 5 +++++ webclient/room/room.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'webclient/room') diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index d130a28fd7..bb9167d9df 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -433,6 +433,11 @@ angular.module('RoomController', ['ngSanitize']) }); }; + // Open the user profile page + $scope.goToUserPage = function(user_id) { + $location.path("user/" + user_id); + }; + $scope.leaveRoom = function() { matrixService.leave($scope.room_id).then( diff --git a/webclient/room/room.html b/webclient/room/room.html index 1c6a44f6fc..36bd95c1bb 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -10,7 +10,7 @@
-
+ {{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }} Date: Tue, 19 Aug 2014 09:06:21 +0200 Subject: Use $location.url to open the user profile page. The user page URL is then the one expected: http://127.0.0.1:8000/#/user/@Manu:localhost:8080 insteaf of http://127.0.0.1:8000/#/user/@Manu:localhost:8080#public:localhost:8080 --- webclient/room/room-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webclient/room') diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index bb9167d9df..8878c3d209 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -435,7 +435,7 @@ angular.module('RoomController', ['ngSanitize']) // Open the user profile page $scope.goToUserPage = function(user_id) { - $location.path("user/" + user_id); + $location.url("/user/" + user_id); }; $scope.leaveRoom = function() { -- cgit 1.5.1