##// END OF EJS Templates
notifications: make styling match the design
ergo -
r704:e3c25eda default
parent child Browse files
Show More
@@ -1,15 +1,9 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 'legacy_code_styles';
9 @import 'type';
8 @import 'type';
10 @import 'alerts';
11 @import 'buttons';
9 @import 'buttons';
12 @import 'tags';
13 @import 'examples';
14 @import 'login';
15 @import 'comments';
@@ -1,23 +1,24 b''
1 <link rel="import" href="../../../../../../bower_components/paper-button/paper-button.html">
1 <link rel="import" href="../../../../../../bower_components/paper-button/paper-button.html">
2 <link rel="import" href="../rhodecode-unsafe-html/rhodecode-unsafe-html.html">
2 <link rel="import" href="../rhodecode-unsafe-html/rhodecode-unsafe-html.html">
3 <dom-module id="rhodecode-toast">
3 <dom-module id="rhodecode-toast">
4 <template>
4 <template>
5 <style include="shared-styles"></style>
5 <link rel="stylesheet" href="rhodecode-toast.css">
6 <link rel="stylesheet" href="rhodecode-toast.css">
6
7
7 <paper-toast id="p-toast" duration="0" horizontal-offset="100" horizontal-align="auto" vertical-align="top" always-on-top>
8 <paper-toast id="p-toast" duration="0" horizontal-offset="100" horizontal-align="auto" vertical-align="top" always-on-top>
8 <div class="toast-message-holder">
9 <div class="toast-message-holder">
9 <template is="dom-repeat" items="{{toasts}}">
10 <template is="dom-repeat" items="{{toasts}}">
10 <div class="toast-notification">
11 <div class="toast-notification">
11 <span class$="toast-level {{item.level}}">{{item.level}}</span>
12 <span class$="toast-level {{item.level}}">{{item.level}}</span>
12 <rhodecode-unsafe-html text="{{item.message}}"></rhodecode-unsafe-html>
13 <rhodecode-unsafe-html text="{{item.message}}"></rhodecode-unsafe-html>
13 </div>
14 </div>
14 </template>
15 </template>
15 </div>
16 </div>
16 <div class="toast-close">
17 <div class="toast-close">
17 <paper-button on-tap="dismissNotifications" class="btn btn-info">{{_gettext('Close now')}}</paper-button>
18 <paper-button on-tap="dismissNotifications" class="btn btn-primary">{{_gettext('Close now')}}</paper-button>
18 </div>
19 </div>
19 </paper-toast>
20 </paper-toast>
20 </template>
21 </template>
21
22
22 <script src="rhodecode-toast.js"></script>
23 <script src="rhodecode-toast.js"></script>
23 </dom-module>
24 </dom-module>
@@ -1,39 +1,44 b''
1 @import '../../../../css/variables';
2
1 paper-toast{
3 paper-toast{
2 width: 100%;
4 width: 100%;
3 min-width: 400px;
5 min-width: 400px;
4 --paper-toast-background-color: #ffffff;
6 --paper-toast-background-color: #ffffff;
5 --paper-toast-color: #000000;
7 --paper-toast-color: #000000;
6 }
8 }
7 paper-toast a{
9 paper-toast a{
8 font-weight: bold
10 font-weight: bold
9 }
11 }
10
12
11 .toast-message-holder {
13 .toast-message-holder {
12 width: ~'calc(100% - 150px)';
14 width: ~'calc(100% - 150px)';
13 display: inline-block;
15 display: inline-block;
14 }
16 }
15 .toast-close {
17 .toast-close {
16 display: inline-block;
18 display: inline-block;
17 width: 145px;
19 width: 145px;
18 text-align: right;
20 text-align: right;
19 float: right;
21 float: right;
20 }
22 }
21 .toast-notification {
23 .toast-notification {
22 padding: 10px 0 10px 0;
24 padding: 10px 0 10px 0;
23 }
25 }
24
26
25 .toast-level {
27 .toast-level {
26 display: inline-block;
28 display: inline-block;
27 min-width: 100px;
29 min-width: 100px;
28 font-weight: bold;
30 font-weight: bold;
29 text-transform: uppercase;
31 text-transform: uppercase;
30 &.info, &.success {
32 &.info{
31 color: #0ac878;
33 color: @alert4;
34 }
35 &.success {
36 color: @alert1;
32 }
37 }
33 &.error, &.danger {
38 &.error, &.danger {
34 color: #e85e4d;
39 color: @alert2;
35 }
40 }
36 &.warning {
41 &.warning {
37 color: #ffc854;
42 color: @alert3;
38 }
43 }
39 }
44 }
@@ -1,96 +1,96 b''
1 <template is="dom-bind" id="notificationsPage">
1 <template is="dom-bind" id="notificationsPage">
2 <style include="shared-styles"></style>
2 <style include="shared-styles"></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 <div style="display: inline-block">
30 <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>
31 <paper-tooltip>Toggle your notifications on/off globally.</paper-tooltip>
32 </div>
32 </div>
33 <template is="dom-if" if="{{changeNotificationsLoading}}">
33 <template is="dom-if" if="{{changeNotificationsLoading}}">
34 <paper-spinner active class="toggle-ajax-spinner"></paper-spinner>
34 <paper-spinner active class="toggle-ajax-spinner"></paper-spinner>
35 </template>
35 </template>
36 </div>
36 </div>
37 </div>
37 </div>
38 <div class="buttons">
38 <div class="buttons">
39 <a class="btn btn-info" id="test-notification">Test notification</a>
39 <a class="btn btn-default" id="test-notification">Test notification</a>
40 </div>
40 </div>
41 </div>
41 </div>
42 </div>
42 </div>
43
43
44 </div>
44 </div>
45 </div>
45 </div>
46
46
47 <script type="application/javascript">
47 <script type="application/javascript">
48 /** because im not creating a custom element for this page
48 /** because im not creating a custom element for this page
49 * we need to push the function onto the dom-template
49 * we need to push the function onto the dom-template
50 * ideally we turn this into notification-settings elements
50 * ideally we turn this into notification-settings elements
51 * then it will be cleaner
51 * then it will be cleaner
52 */
52 */
53 var ctrlr = $('#notificationsPage')[0];
53 var ctrlr = $('#notificationsPage')[0];
54 ctrlr.toggleNotifications = function(event){
54 ctrlr.toggleNotifications = function(event){
55 var ajax = $('#toggleNotifications')[0];
55 var ajax = $('#toggleNotifications')[0];
56 ajax.headers = {"X-CSRF-Token": CSRF_TOKEN}
56 ajax.headers = {"X-CSRF-Token": CSRF_TOKEN}
57 ajax.body = {notification_status:event.target.active};
57 ajax.body = {notification_status:event.target.active};
58 ajax.generateRequest();
58 ajax.generateRequest();
59 };
59 };
60 ctrlr.handleNotifications = function(event){
60 ctrlr.handleNotifications = function(event){
61 $('paper-toggle-button')[0].active = event.detail.response;
61 $('paper-toggle-button')[0].active = event.detail.response;
62 };
62 };
63
63
64 function checkBrowserStatus(){
64 function checkBrowserStatus(){
65 var browserStatus = 'Unknown';
65 var browserStatus = 'Unknown';
66
66
67 if (!("Notification" in window)) {
67 if (!("Notification" in window)) {
68 browserStatus = 'Not supported'
68 browserStatus = 'Not supported'
69 }
69 }
70 else if(Notification.permission === 'denied'){
70 else if(Notification.permission === 'denied'){
71 browserStatus = 'Denied';
71 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>')
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 else if(Notification.permission === 'granted'){
74 else if(Notification.permission === 'granted'){
75 browserStatus = 'Allowed';
75 browserStatus = 'Allowed';
76 }
76 }
77
77
78 $('#browser-notification-status').text(browserStatus);
78 $('#browser-notification-status').text(browserStatus);
79 };
79 };
80
80
81 checkBrowserStatus();
81 checkBrowserStatus();
82
82
83 $('#test-notification').on('click', function(e){
83 $('#test-notification').on('click', function(e){
84 var levels = ['info', 'error', 'warning', 'success'];
84 var levels = ['info', 'error', 'warning', 'success'];
85 var level = levels[Math.floor(Math.random()*levels.length)];
85 var level = levels[Math.floor(Math.random()*levels.length)];
86 var payload = {
86 var payload = {
87 message: {
87 message: {
88 message: 'This is a test notification.',
88 message: 'This is a test notification.',
89 level: level,
89 level: level,
90 testMessage: true
90 testMessage: true
91 }
91 }
92 };
92 };
93 $.Topic('/notifications').publish(payload);
93 $.Topic('/notifications').publish(payload);
94 })
94 })
95 </script>
95 </script>
96 </template>
96 </template>
General Comments 0
You need to be logged in to leave comments. Login now