From c3a774e414324746c484ad21d19c4be4e2167cd0 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Fri, 29 Aug 2014 17:11:03 +0200 Subject: Show desktop notification state. Provide help if the user has previously denied permission to display them. --- webclient/app-controller.js | 7 ------- webclient/settings/settings-controller.js | 21 ++++++++++++++++++++- webclient/settings/settings.html | 25 +++++++++++++++++++------ 3 files changed, 39 insertions(+), 14 deletions(-) (limited to 'webclient') diff --git a/webclient/app-controller.js b/webclient/app-controller.js index 80474bb8df..775113bc87 100644 --- a/webclient/app-controller.js +++ b/webclient/app-controller.js @@ -69,13 +69,6 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even $scope.logout(); }); - $scope.requestNotifications = function() { - if (window.Notification) { - console.log("Notification.permission: " + window.Notification.permission); - window.Notification.requestPermission(function(){}); - } - }; - }]); 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 @@
- + +

Desktop notifications

+
+
+ Notifications are enabled. +
+
+ You have denied permission for notifications.
+ To enable it, reset the notification setting for this web site into your browser settings. +
+
+ +
+
+ Sorry, your browser does not support notifications. +
+
+
+

Configuration

Home server: {{ config.homeserver }}
@@ -60,11 +78,6 @@
Access token: {{ config.access_token }}

- -
-
-
-
{{ feedback }} -- cgit 1.4.1