csrf
This commit is contained in:
parent
53c4830051
commit
8d8946a66b
|
|
@ -78,6 +78,7 @@
|
|||
orange
|
||||
{% elif user.profile.onlinestatus == 3 %}
|
||||
grey
|
||||
{% endif %}
|
||||
{% else %} grey {% endif %};">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -126,7 +127,7 @@
|
|||
});
|
||||
});
|
||||
|
||||
function updatePresenceLive(e) {
|
||||
function updatePresenceLive() {
|
||||
$.ajax(
|
||||
{
|
||||
type: "GET",
|
||||
|
|
@ -137,23 +138,24 @@
|
|||
success: function( data )
|
||||
{
|
||||
console.log(data);
|
||||
$( ".status-circle" ).each(function( index ) {
|
||||
if(data["onlineusers"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
||||
|
||||
console.log(data["onlineusers"][index+1]);
|
||||
counter = 0;
|
||||
$( ".status-circle" ).each(function( index ) {
|
||||
if(data["user_online_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
||||
$("#" + $(this)[0]["id"]).css("background-color", "green");
|
||||
}
|
||||
else if(data["user_besch_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
||||
$("#" + $(this)[0]["id"]).css("background-color", "red");
|
||||
}
|
||||
else if(data["user_abw_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
||||
$("#" + $(this)[0]["id"]).css("background-color", "orange");
|
||||
}
|
||||
else{
|
||||
$("#" + $(this)[0]["id"]).css("background-color", "grey");
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -43,18 +43,29 @@ def getloggedusers(request):
|
|||
|
||||
@login_required
|
||||
def getloggedusersdata(request):
|
||||
|
||||
user_online_final = []
|
||||
user_besch_final = []
|
||||
user_abw_final = []
|
||||
user_off_final = []
|
||||
|
||||
if request.method == "GET":
|
||||
|
||||
users_online = Room.objects.get(channel_name="agency_" + str(request.user.profile.agency.pk)).get_users()
|
||||
users_agency = User.objects.filter(profile__agency=request.user.profile.agency).exclude(pk=request.user.pk)
|
||||
|
||||
user_online_final = []
|
||||
|
||||
for u in users_agency:
|
||||
if(u in users_online):
|
||||
user_online_final.append("" + str(u.pk))
|
||||
user_online_final.append("" + str(u.pk) + "_" + u.profile.onlinestatus)
|
||||
if(u.profile.onlinestatus == 0):
|
||||
user_online_final.append("" + str(u.pk))
|
||||
elif(u.profile.onlinestatus == 1):
|
||||
user_besch_final.append("" + str(u.pk))
|
||||
elif(u.profile.onlinestatus == 2):
|
||||
user_abw_final.append("" + str(u.pk))
|
||||
elif(u.profile.onlinestatus == 3):
|
||||
user_off_final.append("" + str(u.pk))
|
||||
|
||||
return JsonResponse({"onlineusers" : user_online_final})
|
||||
return JsonResponse({"user_online_final" : user_online_final, "user_besch_final" : user_besch_final, "user_abw_final" : user_abw_final, "user_off_final" : user_off_final})
|
||||
else:
|
||||
return JsonResponse({})
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -135,6 +135,10 @@ def create_profile(sender, instance, created, **kwargs):
|
|||
@receiver(post_save, sender=User)
|
||||
def save_profile(sender, instance, **kwargs):
|
||||
instance.profile.save()
|
||||
user_to_touch = list(Presence.objects.filter(user=instance.pk))[0]
|
||||
user_to_touch
|
||||
Presence.objects.touch(user_to_touch)
|
||||
|
||||
|
||||
|
||||
# SIGNALS FOR GROUPS
|
||||
|
|
|
|||
|
|
@ -674,6 +674,50 @@ $(document).on('click', function (e) {
|
|||
|
||||
<!-- WEBSOCKETS -->
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#chat_alluserscontent").hide();
|
||||
|
||||
ws_string = 'wss://'
|
||||
if (location.protocol !== 'https:') {
|
||||
ws_string = 'ws://'
|
||||
}
|
||||
|
||||
const mainwebsocket = new WebSocket(ws_string+window.location.host+"/ws/")
|
||||
|
||||
mainwebsocket.onmessage = function(e) {
|
||||
if(e["data"] != "presence_update")
|
||||
{
|
||||
var notify = new Notification('Digitale Agentur', {
|
||||
body: e["data"]
|
||||
});
|
||||
loadUnsendNotifications();
|
||||
loadUnviewnNotifications();
|
||||
}
|
||||
else{
|
||||
|
||||
{% if active_link == "chat" %}
|
||||
updatePresenceLive();
|
||||
{% endif %}
|
||||
}
|
||||
};
|
||||
|
||||
mainwebsocket.onclose = function(e) {
|
||||
console.error('Chat socket closed unexpectedly');
|
||||
};
|
||||
|
||||
|
||||
//HEARTBEAT every minute
|
||||
setInterval(function()
|
||||
{
|
||||
mainwebsocket.send(JSON.stringify("heartbeat"));
|
||||
console.log("heartbeat is alive...");
|
||||
},60000);
|
||||
|
||||
|
||||
});
|
||||
|
||||
function changeOnlineStatus(newstat){
|
||||
$.ajax(
|
||||
{
|
||||
|
|
@ -710,62 +754,15 @@ function changeOnlineStatus(newstat){
|
|||
'-webkit-box-shadow' : '0px 0px 4px 5px grey',
|
||||
'-moz-box-shadow': '0px 0px 4px 5px grey',
|
||||
'box-shadow': '0px 0px 4px 5px grey'
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#chat_alluserscontent").hide();
|
||||
|
||||
ws_string = 'wss://'
|
||||
if (location.protocol !== 'https:') {
|
||||
ws_string = 'ws://'
|
||||
}
|
||||
|
||||
const mainwebsocket = new WebSocket(ws_string+window.location.host+"/ws/")
|
||||
|
||||
mainwebsocket.onmessage = function(e) {
|
||||
if(e["data"] != "presence_update")
|
||||
{
|
||||
var notify = new Notification('Digitale Agentur', {
|
||||
body: e["data"]
|
||||
});
|
||||
loadUnsendNotifications();
|
||||
loadUnviewnNotifications();
|
||||
}
|
||||
else{
|
||||
|
||||
{% if active_link == "chat" %}
|
||||
updatePresenceLive(e);
|
||||
{% endif %}
|
||||
}
|
||||
};
|
||||
|
||||
mainwebsocket.onclose = function(e) {
|
||||
console.error('Chat socket closed unexpectedly');
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//HEARTBEAT every minute
|
||||
setInterval(function()
|
||||
{
|
||||
mainwebsocket.send(JSON.stringify("heartbeat"));
|
||||
console.log("heartbeat is alive...");
|
||||
},60000);
|
||||
|
||||
|
||||
});
|
||||
|
||||
window.onerror = function (msg, url, line) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!window.Notification) {
|
||||
console.log('Browser does not support notifications.');
|
||||
|
|
|
|||
Loading…
Reference in New Issue