Skip to content

monitoring specific queue #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
log
log/*
.bundle
7 changes: 6 additions & 1 deletion app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@

get '/' do
erb :index
end
end

get '/queue/:id' do
@queue_name = params[:id]
erb :queue
end
7 changes: 7 additions & 0 deletions events.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
require 'bayeux'

events.asterisk.manager_interface.each do |event|
ahn_log.events "#{event.name} - - #{event.inspect}"
case event.name
when 'Join'
Bayeux.publish('/caller/join', { :id => event.headers['Channel'],
:number => event.headers['CallerIDNum'],
:joinedAt => Time.now.to_i })

Bayeux.publish("/#{event.headers['Queue']}/join", { :id => event.headers['Channel'],
:number => event.headers['CallerIDNum'],
:joinedAt => Time.now.to_i })
when 'Leave'
Bayeux.publish('/caller/leave', { :id => event.headers['Channel'] })

Bayeux.publish("/#{event.headers['Queue']}/leave", { :id => event.headers['Channel'] })
end
end
11 changes: 0 additions & 11 deletions log/adhearsion.log

This file was deleted.

70 changes: 70 additions & 0 deletions views/queue.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<html>
<head>
<title>MiniQ: <%=@queue_name%> </title>
<script src="/faye.js"></script>
<script src="/javascripts/coffee-script.js"></script>
<script src="/javascripts/batman.js"></script>

<script type="text/coffeescript">
class MiniQ extends Batman.App
@global yes

class Caller extends Batman.Model
@persist Batman.LocalStorage
@global yes
@encode 'number', 'joinedAt'

constructor: (id, number, joinedAt) ->
super()
@set 'id', id
@set 'number', number
@set 'joinedAt', joinedAt

@accessor 'holdTime', ->
Math.round (new Date() * 0.001) - @get('joinedAt')

setInterval(=>
@get('all').forEach (caller) ->
caller.set 'holdTime'
, 1000)

MiniQ.run()

client = new Faye.Client('/faye')

client.subscribe '/<%= @queue_name %>/join', (caller) ->
caller = new Caller(caller.id, caller.number, caller.joinedAt)
caller.save()

client.subscribe '/<%= @queue_name %>/leave', (caller) ->
Caller.find caller.id, (errors, caller) ->
caller.destroy()
</script>

<link rel="stylesheet" href="/css/bootstrap.min.css">
<style type="text/css">
.phone-number {
font-size: 30px;
}
.hold-time {
font-size: 25px;
float: right;
color: grey;
font-style: italic;
}
</style>
</head>
<body>

<div class="container">
<h1>Mini Q :: <%=@queue_name%> Call 1-855-TRO-LOLO</h1>
<div class="well" data-foreach-caller="Caller.all.sortedBy.joinedAt">
<span class="phone-number" data-bind="caller.number"></span>
<span class="hold-time">
On hold for <span data-bind="caller.holdTime"></span> seconds
</span>
</div> <!-- /well -->

</div> <!-- /container -->
</body>
</html>