From 4847045259a631a2f1e03fd9751df301e6589560 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Tue, 23 Sep 2014 13:36:58 +0100 Subject: [PATCH] send messages to users from the home page (SYWEB-19) --- webclient/home/home-controller.js | 30 ++++++++++++++++++++++++++++++ webclient/home/home.html | 13 ++++++++++--- webclient/user/user-controller.js | 3 ++- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js index e35219beb..a535d439d 100644 --- a/webclient/home/home-controller.js +++ b/webclient/home/home-controller.js @@ -42,6 +42,10 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen displayName: "", avatarUrl: "" }; + + $scope.newChat = { + user: "" + }; var refresh = function() { @@ -112,6 +116,32 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen } ); }; + + // FIXME: factor this out between user-controller and home-controller etc. + $scope.messageUser = function() { + + // FIXME: create a new room every time, for now + + matrixService.create(null, 'private').then( + function(response) { + // This room has been created. Refresh the rooms list + var room_id = response.data.room_id; + console.log("Created room with id: "+ room_id); + + matrixService.invite(room_id, $scope.newChat.user).then( + function() { + $scope.feedback = "Invite sent successfully"; + $scope.$parent.goToPage("/room/" + room_id); + }, + function(reason) { + $scope.feedback = "Failure: " + JSON.stringify(reason); + }); + }, + function(error) { + $scope.feedback = "Failure: " + JSON.stringify(error.data); + }); + }; + $scope.onInit = function() { // Load profile data diff --git a/webclient/home/home.html b/webclient/home/home.html index 5a1e18e1d..0af382916 100644 --- a/webclient/home/home.html +++ b/webclient/home/home.html @@ -17,7 +17,7 @@
{{ config.user_id }}
- +

Recent conversations


@@ -52,17 +52,24 @@
- + private
- +
+
+
+ + +
+
+
{{ feedback }} diff --git a/webclient/user/user-controller.js b/webclient/user/user-controller.js index 3940db668..0dbfa325d 100644 --- a/webclient/user/user-controller.js +++ b/webclient/user/user-controller.js @@ -38,7 +38,8 @@ angular.module('UserController', ['matrixService']) $scope.user.avatar_url = response.data.avatar_url; } ); - + + // FIXME: factor this out between user-controller and home-controller etc. $scope.messageUser = function() { // FIXME: create a new room every time, for now