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