diff options
Diffstat (limited to 'webclient/settings')
-rw-r--r-- | webclient/settings/settings-controller.js | 21 | ||||
-rw-r--r-- | webclient/settings/settings.html | 25 |
2 files changed, 39 insertions, 7 deletions
diff --git a/webclient/settings/settings-controller.js b/webclient/settings/settings-controller.js index f7d5e8eb75..3a9060ebae 100644 --- a/webclient/settings/settings-controller.js +++ b/webclient/settings/settings-controller.js @@ -25,7 +25,7 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu displayName: $scope.config.displayName, avatarUrl: $scope.config.avatarUrl }; - + $scope.$watch("profile.avatarFile", function(newValue, oldValue) { if ($scope.profile.avatarFile) { console.log("Uploading new avatar file..."); @@ -143,4 +143,23 @@ angular.module('SettingsController', ['matrixService', 'mFileUpload', 'mFileInpu } ); }; + + + /*** Desktop notifications section ***/ + $scope.settings = { + notifications: undefined + }; + + // If the browser supports it, check the desktop notification state + if ("Notification" in window) { + $scope.settings.notifications = window.Notification.permission; + } + + $scope.requestNotifications = function() { + console.log("requestNotifications"); + window.Notification.requestPermission(function (permission) { + console.log(" -> User decision: " + permission); + $scope.settings.notifications = permission; + }); + }; }]); \ No newline at end of file diff --git a/webclient/settings/settings.html b/webclient/settings/settings.html index 453a4fc35f..d06a0083fa 100644 --- a/webclient/settings/settings.html +++ b/webclient/settings/settings.html @@ -52,7 +52,25 @@ </table> </div> <br/> - + + <h3>Desktop notifications</h3> + <div ng-switch="settings.notifications"> + <div ng-switch-when="granted"> + Notifications are enabled. + </div> + <div ng-switch-when="denied"> + You have denied permission for notifications.<br/> + To enable it, reset the notification setting for this web site into your browser settings. + </div> + <div ng-switch-when="default"> + <button ng-click="requestNotifications()">Click here to enable them</button> + </div> + <div ng-switch-default=""> + Sorry, your browser does not support notifications. + </div> + </div> + <br/> + <h3>Configuration</h3> <div> <div>Home server: {{ config.homeserver }} </div> @@ -60,11 +78,6 @@ <div>Access token: {{ config.access_token }} </div> </div> <br/> - - <div> - <div><button ng-click="requestNotifications()">Request notifications</button></div> - </div> - <br/> {{ feedback }} |