changes for sockets
This commit is contained in:
parent
9636c57aa8
commit
a87df693bf
|
@ -204,6 +204,12 @@ class Admin::TicketsController < OrbitAdminController
|
||||||
rescue e
|
rescue e
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
url = "/admin/tickets/#{tq.ticket.id.to_s}#response_#{response.id.to_s}"
|
||||||
|
Fiber.new{
|
||||||
|
params[:user_tags].each do |user_id|
|
||||||
|
WebsocketRails["tag_notifications_for_#{user_id}".to_sym].trigger(:new_notification_recieved, {"ticket_link" => "<a href='#{url}'>#{tq.ticket.subject}</a>", "total_ticket_count" => Ticket.get_ticket_unread_count_for_user(user_id), "blink_message" => "#{current_user.name} tagged you!"})
|
||||||
|
end
|
||||||
|
}.resume
|
||||||
end
|
end
|
||||||
render :partial => "response", :object => response
|
render :partial => "response", :object => response
|
||||||
else
|
else
|
||||||
|
@ -216,7 +222,7 @@ class Admin::TicketsController < OrbitAdminController
|
||||||
if !response.nil?
|
if !response.nil?
|
||||||
response.read_by << current_user.id.to_s if !response.read_by.include?(current_user.id.to_s)
|
response.read_by << current_user.id.to_s if !response.read_by.include?(current_user.id.to_s)
|
||||||
response.save
|
response.save
|
||||||
data = {"success" => true, "user_id" => current_user.id.to_s}
|
data = {"success" => true, "user_id" => current_user.id.to_s, "total_ticket_count" => Ticket.get_ticket_unread_count_for_user(current_user)}
|
||||||
else
|
else
|
||||||
data = {"success" => false}
|
data = {"success" => false}
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,7 +47,11 @@ class Ticket
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_ticket_unread_count_for_user(user)
|
def self.get_ticket_unread_count_for_user(user)
|
||||||
|
if user.instance_of?(User)
|
||||||
tqrs = TicketQueryResponse.where(:user_tags.in => [user.id.to_s], :read_by.nin => [user.id.to_s])
|
tqrs = TicketQueryResponse.where(:user_tags.in => [user.id.to_s], :read_by.nin => [user.id.to_s])
|
||||||
|
elsif user.instance_of?(String)
|
||||||
|
tqrs = TicketQueryResponse.where(:user_tags.in => [user], :read_by.nin => [user])
|
||||||
|
end
|
||||||
unread_tickets = []
|
unread_tickets = []
|
||||||
tqrs.each do |tqr|
|
tqrs.each do |tqr|
|
||||||
unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? && tqr.ticket_query.ticket.status != "closed"
|
unread_tickets << tqr.ticket_query.ticket if !tqr.ticket_query.nil? && !tqr.ticket_query.ticket.nil? && tqr.ticket_query.ticket.status != "closed"
|
||||||
|
|
|
@ -261,7 +261,7 @@ $(document).ready(function(){
|
||||||
},
|
},
|
||||||
placeholder: "Tag Members"
|
placeholder: "Tag Members"
|
||||||
});
|
});
|
||||||
|
readbyFunction();
|
||||||
})
|
})
|
||||||
$(".reopen-back-btn").on("click",function(){
|
$(".reopen-back-btn").on("click",function(){
|
||||||
for (instance in CKEDITOR.instances) {
|
for (instance in CKEDITOR.instances) {
|
||||||
|
@ -363,10 +363,7 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var timer = null;
|
var readbyFunction = function(){
|
||||||
$(document).on("scroll",function(){
|
|
||||||
clearTimeout(timer);
|
|
||||||
timer = setTimeout(function(){
|
|
||||||
var responses_seen = $("div[data-user-tags*=" + user_id + "]:in-viewport");
|
var responses_seen = $("div[data-user-tags*=" + user_id + "]:in-viewport");
|
||||||
$.each(responses_seen,function(){
|
$.each(responses_seen,function(){
|
||||||
var el = $(this),
|
var el = $(this),
|
||||||
|
@ -380,11 +377,17 @@ $(document).ready(function(){
|
||||||
}).done(function(data){
|
}).done(function(data){
|
||||||
if(data.success){
|
if(data.success){
|
||||||
avatar.addClass("read");
|
avatar.addClass("read");
|
||||||
|
notificationManager.setNotificationNumber(data.total_ticket_count);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},1000);
|
}
|
||||||
|
|
||||||
|
var timer = null;
|
||||||
|
$(document).on("scroll",function(){
|
||||||
|
clearTimeout(timer);
|
||||||
|
timer = setTimeout(readbyFunction,1000);
|
||||||
})
|
})
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue