farridav / django-jazzmin

Jazzy theme for Django
https://django-jazzmin.readthedocs.io
MIT License
1.61k stars 285 forks source link

Sir please guide me #148

Closed puneetramp closed 4 years ago

puneetramp commented 4 years ago

Currently i am working on a project , and in there admin panel i use jazzmin theme for admin panel . and my client requirement is to chat with admin from the website , website front i am using angular , and plan to integrate the chat front end side with firebase . But I am little but confuse fo admin panel theme for the chat , Suddenly i see the code in your base.html function connect() { var ws = new WebSocket('ws://{{request.META.HTTP_HOST}}/ws/stream/{{request.user.department.name}}'); ws.onopen = function() { // subscribe to some channels ws.send(JSON.stringify({command: 'join'})); };

      ws.onmessage = function(e) {
        var ndata = JSON.parse(e.data)
        var html_notify = '<li>\
                        <a href="/sales/sales/{0}/change/">\
                          <i class="fa fa-shopping-cart text-green"></i>  {1}\
                          <small class="timestamp">{2}</small>\
                        </a>\
                      </li>'
        if(ndata.command == "join"){

            $('.notifications-menu').find('.header').text('You have '+ndata.notifications.length+' notifications')
            $('.notifications-menu').find('.header').attr('total-notify', ndata.notifications.length)
            $('.notifications-menu').find('.label-warning').text(ndata.notifications.length)
            $('.notifications-menu').find('.menu').empty()
            ndata.notifications.forEach(function(note){
                $('.notifications-menu').find('.menu').append(html_notify.f(note.sales, note.message, note.updated_at))
            })
        }
        else if(ndata.command == "join"){
            var old_text = parseInt($('.notifications-menu').find('.header').attr('total-notify'))
            $('.notifications-menu').find('.header').text('You have '+(old_text+ndata.notifications.length)+' notifications')
            $('.notifications-menu').find('.label-warning').text((old_text+ndata.notifications.length))
            ndata.notifications.forEach(function(note){
                $('.notifications-menu').find('.menu').prepend(html_notify.f(note.sales, note.message, note.updated_at))
            })
        }
      };

      ws.onclose = function(e) {
        console.log('Socket is closed. Reconnect will be attempted in 1 second.', e.reason);
        setTimeout(function() {
          connect();
        }, 1000);
      };

      ws.onerror = function(err) {
        console.error('Socket encountered error: ', err.message, 'Closing socket');
        ws.close();
      };
    }

why this code? Is this code is for socket integration for chat ? If it is thn how we get the template for chat in admin side please let me know sir

farridav commented 4 years ago

I don't think this code is coming from Jazzmin, though feel free to point me towards it in the git repo.

Jazzmin does not need web sockets, it's used for admin styling and is predominantly HTML, CSS, and as little JavaScript as we can get away with, and python to integrate into Django.

Feel free to open a new issue if there is something directly related to jazzmin that we can help with.