Change styling and add digest cycle to notifications req button

Added confirmation modals to enable/disable notifactions
This commit is contained in:
Sam Chow 2018-05-22 17:38:59 -04:00
parent a875eac350
commit 0cddf98b1f
2 changed files with 33 additions and 19 deletions

View file

@ -209,9 +209,16 @@
} }
if (CookieService.get('quay.enabledDesktopNotifications') === 'on') { if (CookieService.get('quay.enabledDesktopNotifications') === 'on') {
CookieService.putPermanent('quay.enabledDesktopNotifications', 'off'); bootbox.confirm('Are you sure you want to turn off browser notifications?', confirmed => {
CookieService.clear('quay.notifications.mostRecentTimestamp'); if (confirmed) {
$scope.notificationsPermissionsEnabled = false; CookieService.putPermanent('quay.enabledDesktopNotifications', 'off');
CookieService.clear('quay.notifications.mostRecentTimestamp');
$scope.$apply(() => {
$scope.notificationsPermissionsEnabled = false;
});
}
});
} else { } else {
if (Notification.permission === 'default') { if (Notification.permission === 'default') {
Notification.requestPermission() Notification.requestPermission()
@ -219,15 +226,23 @@
if (newPermission === 'granted') { if (newPermission === 'granted') {
CookieService.putPermanent('quay.enabledDesktopNotifications', 'on'); CookieService.putPermanent('quay.enabledDesktopNotifications', 'on');
CookieService.putPermanent('quay.notifications.mostRecentTimestamp', new Date().getTime().toString()); CookieService.putPermanent('quay.notifications.mostRecentTimestamp', new Date().getTime().toString());
$scope.notificationsPermissionsEnabled = true;
} else {
$scope.notificationsPermissionsEnabled = false;
} }
$scope.$apply(() => {
$scope.notificationsPermissionsEnabled = (newPermission === 'granted');
});
}); });
} else if (Notification.permission === 'granted') { } else if (Notification.permission === 'granted') {
CookieService.putPermanent('quay.enabledDesktopNotifications', 'on'); bootbox.confirm('Are you sure you want to turn on browser notifications?', confirmed => {
CookieService.putPermanent('quay.notifications.mostRecentTimestamp', new Date().getTime().toString()); if (confirmed) {
$scope.notificationsPermissionsEnabled = true; CookieService.putPermanent('quay.enabledDesktopNotifications', 'on');
CookieService.putPermanent('quay.notifications.mostRecentTimestamp', new Date().getTime().toString());
$scope.$apply(() => {
$scope.notificationsPermissionsEnabled = true;
});
}
});
} }
} }
}; };

View file

@ -173,17 +173,16 @@
<tr> <tr>
<td>Desktop Notifications:</td> <td>Desktop Notifications:</td>
<td> <td>
<span>Enable Desktop Notifications: <a class="co-modify-link"
<button class="btn btn-default" ng-if="!desktopNotificationsPermissionIsDisabled()"
ng-disabled="desktopNotificationsPermissionIsDisabled()" ng-disabled="desktopNotificationsPermissionIsDisabled()"
ng-click="toggleDesktopNotifications()" ng-click="toggleDesktopNotifications()"
ng-model="notificationsPermissionsEnabled" ng-model="notificationsPermissionsEnabled"
>{{ notificationsPermissionsEnabled ? 'enabled' : 'disabled' }} >{{ notificationsPermissionsEnabled ? 'Enabled' : 'Disabled' }}
</button> </a>
</span>
<span class="help-text" <span class="help-text"
ng-if="desktopNotificationsPermissionIsDisabled()" ng-if="desktopNotificationsPermissionIsDisabled()">
>Note: Desktop notifications have been disabled, or are unavailable, in your browser. Desktop notifications have been disabled, or are unavailable, in your browser.
</span> </span>
</td> </td>
</tr> </tr>