File tree Expand file tree Collapse file tree
server/reportmanager/templates/layouts Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232 < script src ="{% static 'js/params.js' %} "/> </ script>
3333 < script src = "{% static 'js/cookie-csrf.js' %}" /> </ script >
3434
35- < script >
36- ( ( ) => {
37- const notify_badge_class = 'badge' ;
38- const notify_api_url = '/inbox/notifications/api/unread_count/' ;
39- const notify_fetch_count = '5' ;
40- const notify_refresh_period = 0 ;
41- const consecutive_misfires = 0 ;
42-
43- function fill_notification_badge ( data ) {
44- const badges = document . getElementsByClassName ( notify_badge_class ) ;
45- for ( let i = 0 ; i < badges . length | 0 ; i ++ ) {
46- badges [ i ] . innerHTML = data ;
47- }
48- }
49-
50- function fetch_api_data ( ) {
51- fetch ( notify_api_url + '?max=' + notify_fetch_count , { credentials : 'same-origin' } )
52- . then ( response => {
53- if ( response . ok ) {
54- response . json ( )
55- . then ( data => {
56- fill_notification_badge ( data . unread_count ) ;
57- } )
58- if ( notify_refresh_period ) {
59- setTimeout ( fetch_api_data , notify_refresh_period ) ;
60- }
61- } else {
62- swal ( 'Oops' , E_SERVER_ERROR , 'error' ) ;
63- console . debug ( response ) ;
64- }
65- } )
66- . catch ( e => {
67- fill_notification_badge ( '!' ) ;
68- } ) ;
69- }
70-
71- document . addEventListener ( "DOMContentLoaded" , fetch_api_data )
72- } ) ( )
73- </ script >
74-
7535{% endblock js%}
7636{% if debug %}
7737 < script >
You can’t perform that action at this time.
0 commit comments