csrf
This commit is contained in:
parent
53c4830051
commit
8d8946a66b
|
|
@ -78,6 +78,7 @@
|
||||||
orange
|
orange
|
||||||
{% elif user.profile.onlinestatus == 3 %}
|
{% elif user.profile.onlinestatus == 3 %}
|
||||||
grey
|
grey
|
||||||
|
{% endif %}
|
||||||
{% else %} grey {% endif %};">
|
{% else %} grey {% endif %};">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -126,7 +127,7 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function updatePresenceLive(e) {
|
function updatePresenceLive() {
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
type: "GET",
|
type: "GET",
|
||||||
|
|
@ -137,23 +138,24 @@
|
||||||
success: function( data )
|
success: function( data )
|
||||||
{
|
{
|
||||||
console.log(data);
|
console.log(data);
|
||||||
$( ".status-circle" ).each(function( index ) {
|
counter = 0;
|
||||||
if(data["onlineusers"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
$( ".status-circle" ).each(function( index ) {
|
||||||
|
if(data["user_online_final"].indexOf($(this)[0]["id"].split("_")[2]) !== -1){
|
||||||
console.log(data["onlineusers"][index+1]);
|
|
||||||
$("#" + $(this)[0]["id"]).css("background-color", "green");
|
$("#" + $(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{
|
else{
|
||||||
$("#" + $(this)[0]["id"]).css("background-color", "grey");
|
$("#" + $(this)[0]["id"]).css("background-color", "grey");
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,18 +43,29 @@ def getloggedusers(request):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def getloggedusersdata(request):
|
def getloggedusersdata(request):
|
||||||
|
|
||||||
|
user_online_final = []
|
||||||
|
user_besch_final = []
|
||||||
|
user_abw_final = []
|
||||||
|
user_off_final = []
|
||||||
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
|
|
||||||
users_online = Room.objects.get(channel_name="agency_" + str(request.user.profile.agency.pk)).get_users()
|
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)
|
users_agency = User.objects.filter(profile__agency=request.user.profile.agency).exclude(pk=request.user.pk)
|
||||||
|
|
||||||
user_online_final = []
|
|
||||||
for u in users_agency:
|
for u in users_agency:
|
||||||
if(u in users_online):
|
if(u in users_online):
|
||||||
user_online_final.append("" + str(u.pk))
|
if(u.profile.onlinestatus == 0):
|
||||||
user_online_final.append("" + str(u.pk) + "_" + u.profile.onlinestatus)
|
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:
|
else:
|
||||||
return JsonResponse({})
|
return JsonResponse({})
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -135,6 +135,10 @@ def create_profile(sender, instance, created, **kwargs):
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
def save_profile(sender, instance, **kwargs):
|
def save_profile(sender, instance, **kwargs):
|
||||||
instance.profile.save()
|
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
|
# SIGNALS FOR GROUPS
|
||||||
|
|
|
||||||
|
|
@ -674,6 +674,50 @@ $(document).on('click', function (e) {
|
||||||
|
|
||||||
<!-- WEBSOCKETS -->
|
<!-- WEBSOCKETS -->
|
||||||
<script type="text/javascript">
|
<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){
|
function changeOnlineStatus(newstat){
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
|
|
@ -710,62 +754,15 @@ function changeOnlineStatus(newstat){
|
||||||
'-webkit-box-shadow' : '0px 0px 4px 5px grey',
|
'-webkit-box-shadow' : '0px 0px 4px 5px grey',
|
||||||
'-moz-box-shadow': '0px 0px 4px 5px grey',
|
'-moz-box-shadow': '0px 0px 4px 5px grey',
|
||||||
'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) {
|
window.onerror = function (msg, url, line) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!window.Notification) {
|
if (!window.Notification) {
|
||||||
console.log('Browser does not support notifications.');
|
console.log('Browser does not support notifications.');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue