Added another button to upload and send an image.

The text input and its send button for sending an image URL will be removed once we have a true upload image service
This commit is contained in:
Emmanuel ROHEE 2014-08-14 18:53:05 +02:00
parent 39ff6c840f
commit d5bebc9eaa
2 changed files with 20 additions and 2 deletions

View File

@ -402,6 +402,23 @@ angular.module('RoomController', ['ngSanitize'])
}); });
}; };
$scope.imageFileToSend;
$scope.$watch("imageFileToSend", function(newValue, oldValue) {
if ($scope.imageFileToSend) {
// First download the image to the Internet
console.log("Uploading image...");
mFileUpload.uploadFile($scope.imageFileToSend).then(
function(url) {
// Then share the URL
$scope.sendImage(url);
},
function(error) {
$scope.feedback = "Can't upload image";
}
);
}
});
$scope.loadMoreHistory = function() { $scope.loadMoreHistory = function() {
paginate(MESSAGES_PER_PAGINATION); paginate(MESSAGES_PER_PAGINATION);
}; };

View File

@ -75,9 +75,10 @@
<input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage()" placeholder="Image URL"/> <input id="mainInput" ng-model="imageURLToSend" ng-enter="sendImage()" placeholder="Image URL"/>
</td> </td>
<td width="100px"> <td width="100px">
<button ng-click="sendImage(imageURLToSend)">Send Image</button> <button ng-click="sendImage(imageURLToSend)">Send URL</button>
</td> </td>
<td> <td width="100px">
<button m-file-input="imageFileToSend">Send Image</button>
</td> </td>
</tr> </tr>
</table> </table>