##// END OF EJS Templates
notifications: override material design colors with our colors
ergo -
r705:0122e338 default
parent child Browse files
Show More
@@ -1,9 +1,16 b''
1 1 //Primary CSS
2 2 //--- IMPORTS ------------------//
3 3 @import 'helpers';
4 4 @import 'mixins';
5 5 @import 'rcicons';
6 6 @import 'fonts';
7 7 @import 'variables';
8 8 @import 'type';
9 9 @import 'buttons';
10
11 :root {
12 --primary-color: @rcblue;
13 --light-primary-color: @rclightblue;
14 --dark-primary-color: @rcdarkblue;
15 --primary-text-color: @grey2;
16 }
@@ -1,96 +1,96 b''
1 1 <template is="dom-bind" id="notificationsPage">
2 <style include="shared-styles"></style>
2 <style include="shared-styles" is="custom-style"></style>
3 3 <iron-ajax id="toggleNotifications"
4 4 method="post"
5 5 url="${url('my_account_notifications_toggle_visibility')}"
6 6 content-type="application/json"
7 7 loading="{{changeNotificationsLoading}}"
8 8 on-response="handleNotifications"
9 9 handle-as="json"></iron-ajax>
10 10
11 11 <div class="panel panel-default">
12 12 <div class="panel-heading">
13 13 <h3 class="panel-title">${_('Your live notification settings')}</h3>
14 14 </div>
15 15 <div class="panel-body">
16 16
17 17 <p><strong>IMPORTANT:</strong> This feature requires enabled channelstream websocket server to function correctly.</p>
18 18
19 19 <p class="hidden">Status of browser notifications permission: <strong id="browser-notification-status"></strong></p>
20 20
21 21 <div class="form">
22 22 <!-- fields -->
23 23 <div class="fields">
24 24 <div class="field">
25 25 <div class="label">
26 26 <label for="new_email">${_('Notifications status')}:</label>
27 27 </div>
28 28 <div class="checkboxes">
29 29 <div style="display: inline-block">
30 30 <paper-toggle-button on-change="toggleNotifications" ${'checked' if c.rhodecode_user.get_instance().user_data.get('notification_status') else ''}></paper-toggle-button>
31 31 <paper-tooltip>Toggle your notifications on/off globally.</paper-tooltip>
32 32 </div>
33 33 <template is="dom-if" if="{{changeNotificationsLoading}}">
34 34 <paper-spinner active class="toggle-ajax-spinner"></paper-spinner>
35 35 </template>
36 36 </div>
37 37 </div>
38 38 <div class="buttons">
39 39 <a class="btn btn-default" id="test-notification">Test notification</a>
40 40 </div>
41 41 </div>
42 42 </div>
43 43
44 44 </div>
45 45 </div>
46 46
47 47 <script type="application/javascript">
48 48 /** because im not creating a custom element for this page
49 49 * we need to push the function onto the dom-template
50 50 * ideally we turn this into notification-settings elements
51 51 * then it will be cleaner
52 52 */
53 53 var ctrlr = $('#notificationsPage')[0];
54 54 ctrlr.toggleNotifications = function(event){
55 55 var ajax = $('#toggleNotifications')[0];
56 56 ajax.headers = {"X-CSRF-Token": CSRF_TOKEN}
57 57 ajax.body = {notification_status:event.target.active};
58 58 ajax.generateRequest();
59 59 };
60 60 ctrlr.handleNotifications = function(event){
61 61 $('paper-toggle-button')[0].active = event.detail.response;
62 62 };
63 63
64 64 function checkBrowserStatus(){
65 65 var browserStatus = 'Unknown';
66 66
67 67 if (!("Notification" in window)) {
68 68 browserStatus = 'Not supported'
69 69 }
70 70 else if(Notification.permission === 'denied'){
71 71 browserStatus = 'Denied';
72 72 $('.flash_msg').append('<div class="alert alert-error">Notifications are blocked on browser level - you need to enable them in your browser settings.</div>')
73 73 }
74 74 else if(Notification.permission === 'granted'){
75 75 browserStatus = 'Allowed';
76 76 }
77 77
78 78 $('#browser-notification-status').text(browserStatus);
79 79 };
80 80
81 81 checkBrowserStatus();
82 82
83 83 $('#test-notification').on('click', function(e){
84 84 var levels = ['info', 'error', 'warning', 'success'];
85 85 var level = levels[Math.floor(Math.random()*levels.length)];
86 86 var payload = {
87 87 message: {
88 88 message: 'This is a test notification.',
89 89 level: level,
90 90 testMessage: true
91 91 }
92 92 };
93 93 $.Topic('/notifications').publish(payload);
94 94 })
95 95 </script>
96 96 </template>
General Comments 0
You need to be logged in to leave comments. Login now