From 2a44558fbd719fc6d0beb13e658c28e534e36cdb Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 29 Oct 2014 11:03:58 +0000 Subject: [PATCH 01/14] Fix SYWEB-128 : Auto-scroll broken if not exactly at bottom of list. Added a small 10px buffer so if the list isn't quite at the bottom it still actually scrolls. --- webclient/room/room-controller.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 78520a829..31aed71d7 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -133,7 +133,9 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) // Do not autoscroll to the bottom to display the new event if the user is not at the bottom. // Exception: in case where the event is from the user, we want to force scroll to the bottom var objDiv = document.getElementById("messageTableWrapper"); - if ((objDiv.offsetHeight + objDiv.scrollTop >= objDiv.scrollHeight) || force) { + // add a 10px buffer to this check so if the message list is not *quite* + // at the bottom it still scrolls since it basically is at the bottom. + if ((10 + objDiv.offsetHeight + objDiv.scrollTop >= objDiv.scrollHeight) || force) { $timeout(function() { objDiv.scrollTop = objDiv.scrollHeight; From ed241ba032ff21fbf122dddbd23ce54d18a172d5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 29 Oct 2014 11:29:26 +0000 Subject: [PATCH 02/14] Implement SYWEB-58: Clicking a notification now takes you to that room. --- webclient/app-controller.js | 2 +- webclient/components/matrix/event-handler-service.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/webclient/app-controller.js b/webclient/app-controller.js index 7d6120755..e4b7cd286 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -53,7 +53,7 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even * Open a given page. * @param {String} url url of the page */ - $scope.goToPage = function(url) { + $rootScope.goToPage = function(url) { $location.url(url); }; diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index b1580b3d8..d9e1fe31c 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -238,6 +238,12 @@ function(matrixService, $rootScope, $q, $timeout, mPresence) { "body": message, "icon": member ? member.avatar_url : undefined }); + + notification.onclick = function() { + console.log("notification.onclick() room=" + event.room_id); + $rootScope.goToPage('room/' + (event.room_id)); + }; + $timeout(function() { notification.close(); }, 5 * 1000); From 70137409ed13da80fe1722f1bd0638936a14bff1 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 29 Oct 2014 15:02:30 +0000 Subject: [PATCH 03/14] SYWEB-98: Add a 'Redact' button to the event info modal dialog. I think this is better than overriding the right-click contextual menu. Currently clicking this button does nothing. --- webclient/room/room-controller.js | 21 ++++++++++++++++++--- webclient/room/room.html | 13 +++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 31aed71d7..c4014b2fe 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -985,10 +985,25 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) }; $scope.openJson = function(content) { - console.log("Displaying modal dialog for " + JSON.stringify(content)); + $scope.event_selected = content; + // scope this so the template can check power levels and enable/disable + // buttons + $scope.pow = matrixService.getUserPowerLevel; + var modalInstance = $modal.open({ - template: "
" + angular.toJson(content, true) + "
" + templateUrl: 'eventInfoTemplate.html', + controller: 'EventInfoController', + scope: $scope }); }; -}]); +}]) +.controller('EventInfoController', function($scope, $modalInstance) { + console.log("Displaying modal dialog for >>>> " + JSON.stringify($scope.event_selected)); + $scope.redact = function() { + console.log("User level = "+$scope.pow($scope.room_id, $scope.state.user_id)+ + " Redact level = "+$scope.events.rooms[$scope.room_id]["m.room.ops_levels"].content.redact_level); + console.log("Redact event >> " + JSON.stringify($scope.event_selected)); + $modalInstance.dismiss(); + }; +}); diff --git a/webclient/room/room.html b/webclient/room/room.html index e753b037f..5293a579d 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -1,5 +1,18 @@
+ +
[matrix]
From 6d4617960d0223c13f8145b31df86e1f1f8d43ec Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 29 Oct 2014 15:31:50 +0000 Subject: [PATCH 04/14] SYWEB-98: Add redactEvent matrix API call. --- webclient/components/matrix/matrix-service.js | 8 +++++++ webclient/room/room-controller.js | 22 ++++++++++++++++++- webclient/room/room.html | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index a4f0568bc..1840cf46c 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -438,6 +438,14 @@ angular.module('matrixService', []) return this.sendMessage(room_id, msg_id, content); }, + redactEvent: function(room_id, event_id) { + var path = "/rooms/$room_id/redact/$event_id"; + path = path.replace("$room_id", room_id); + path = path.replace("$event_id", event_id); + var content = {}; + return doRequest("POST", path, undefined, content); + }, + // get a snapshot of the members in a room. getMemberList: function(room_id) { // Like the cmd client, escape room ids diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index c4014b2fe..841b5cccd 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -995,6 +995,26 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) controller: 'EventInfoController', scope: $scope }); + + modalInstance.result.then(function(action) { + if (action === "redact") { + var eventId = $scope.event_selected.event_id; + console.log("Redacting event ID " + eventId); + matrixService.redactEvent( + $scope.event_selected.room_id, + eventId + ).then(function(response) { + console.log("Redaction = " + JSON.stringify(response)); + }, function(error) { + console.error("Failed to redact event: "+JSON.stringify(error)); + if (error.data.error) { + $scope.feedback = error.data.error; + } + }); + } + }, function() { + // any dismiss code + }); }; }]) @@ -1004,6 +1024,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput']) console.log("User level = "+$scope.pow($scope.room_id, $scope.state.user_id)+ " Redact level = "+$scope.events.rooms[$scope.room_id]["m.room.ops_levels"].content.redact_level); console.log("Redact event >> " + JSON.stringify($scope.event_selected)); - $modalInstance.dismiss(); + $modalInstance.close("redact"); }; }); diff --git a/webclient/room/room.html b/webclient/room/room.html index 5293a579d..85ae0eeca 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -6,7 +6,7 @@