##// END OF EJS Templates
channelstream: added testing panel for live-notifications.
channelstream: added testing panel for live-notifications.

File last commit:

r1274:2537ec98 default
r1274:2537ec98 default
Show More
my_account_notifications.html
107 lines | 3.7 KiB | text/html | HtmlLexer
/ rhodecode / templates / admin / my_account / my_account_notifications.html
notifications: replace toggle button with actual toggle element - fixes #4171
r692 <template is="dom-bind" id="notificationsPage">
<iron-ajax id="toggleNotifications"
method="post"
url="${url('my_account_notifications_toggle_visibility')}"
content-type="application/json"
loading="{{changeNotificationsLoading}}"
on-response="handleNotifications"
channelstream: added testing panel for live-notifications.
r1274 handle-as="json">
</iron-ajax>
<iron-ajax id="sendTestNotification"
method="post"
url="${url('my_account_notifications_test_channelstream')}"
content-type="application/json"
on-response="handleTestNotification"
handle-as="json">
</iron-ajax>
notifications: replace toggle button with actual toggle element - fixes #4171
r692
notifications: support real-time notifications with websockets via channelstream
r526 <div class="panel panel-default">
<div class="panel-heading">
styling: capitalisation and spinner colours
r706 <h3 class="panel-title">${_('Your Live Notification Settings')}</h3>
notifications: support real-time notifications with websockets via channelstream
r526 </div>
channelstream: added testing panel for live-notifications.
r1274 <div class="panel-body">
notifications: support real-time notifications with websockets via channelstream
r526
<p><strong>IMPORTANT:</strong> This feature requires enabled channelstream websocket server to function correctly.</p>
<p class="hidden">Status of browser notifications permission: <strong id="browser-notification-status"></strong></p>
notifications: replace toggle button with actual toggle element - fixes #4171
r692 <div class="form">
<div class="fields">
<div class="field">
<div class="label">
styling: capitalisation and spinner colours
r706 <label for="new_email">${_('Notifications Status')}:</label>
notifications: replace toggle button with actual toggle element - fixes #4171
r692 </div>
<div class="checkboxes">
components: completed rhodecode-toggle for notification settings
r727 <rhodecode-toggle id="live-notifications" active="[[changeNotificationsLoading]]" on-change="toggleNotifications" ${'checked' if c.rhodecode_user.get_instance().user_data.get('notification_status') else ''}></rhodecode-toggle>
notifications: replace toggle button with actual toggle element - fixes #4171
r692 </div>
</div>
</div>
</div>
channelstream: added testing panel for live-notifications.
r1274 </div>
</div>
notifications: support real-time notifications with websockets via channelstream
r526
channelstream: added testing panel for live-notifications.
r1274 <div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">${_('Test Notifications')}</h3>
</div>
<div class="panel-body">
<div style="padding: 0px 0px 20px 0px">
<button class="btn" id="test-notification" on-tap="testNotifications">Test flash message</button>
<button class="btn" id="test-notification-live" on-tap="testNotificationsLive">Test live notification</button>
</div>
<h4 id="test-response"></h4>
</div>
</div>
notifications: support real-time notifications with websockets via channelstream
r526 </div>
my_account: fix test notifications for IE10+
r777 <script type="text/javascript">
notifications: replace toggle button with actual toggle element - fixes #4171
r692 /** because im not creating a custom element for this page
* we need to push the function onto the dom-template
* ideally we turn this into notification-settings elements
* then it will be cleaner
*/
var ctrlr = $('#notificationsPage')[0];
ctrlr.toggleNotifications = function(event){
var ajax = $('#toggleNotifications')[0];
channelstream: added testing panel for live-notifications.
r1274 ajax.headers = {"X-CSRF-Token": CSRF_TOKEN};
notifications: replace toggle button with actual toggle element - fixes #4171
r692 ajax.body = {notification_status:event.target.active};
ajax.generateRequest();
};
ctrlr.handleNotifications = function(event){
notifications: fixing bug w/spinner in toggle
r729 $('#live-notifications')[0].checked = event.detail.response;
notifications: replace toggle button with actual toggle element - fixes #4171
r692 };
notifications: support real-time notifications with websockets via channelstream
r526
my_account: fix test notifications for IE10+
r777 ctrlr.testNotifications = function(event){
var levels = ['info', 'error', 'warning', 'success'];
var level = levels[Math.floor(Math.random()*levels.length)];
var payload = {
message: {
channelstream: added testing panel for live-notifications.
r1274 message: 'This is a test notification. ' + new Date(),
my_account: fix test notifications for IE10+
r777 level: level,
force: true
}
};
$.Topic('/notifications').publish(payload);
channelstream: added testing panel for live-notifications.
r1274 };
ctrlr.testNotificationsLive = function(event){
var ajax = $('#sendTestNotification')[0];
ajax.headers = {"X-CSRF-Token": CSRF_TOKEN};
ajax.body = {test_msg: 'Hello !'};
ajax.generateRequest();
};
ctrlr.handleTestNotification = function(event){
var reply = event.detail.response.response;
reply = reply || 'no reply form server';
$('#test-response').html(reply);
};
my_account: fix test notifications for IE10+
r777
notifications: support real-time notifications with websockets via channelstream
r526 </script>
channelstream: added testing panel for live-notifications.
r1274
notifications: replace toggle button with actual toggle element - fixes #4171
r692 </template>