]> git.ipfire.org Git - ipfire.org.git/commitdiff
people: Show SIP agent status
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Nov 2019 11:06:48 +0000 (11:06 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 Nov 2019 11:06:48 +0000 (11:06 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/backend/accounts.py
src/backend/talk.py
src/templates/people/modules/agent.html [new file with mode: 0644]
src/templates/people/sip.html
src/web/__init__.py
src/web/people.py

index fcbfd0d77bf0134ea9dfd94c39fe3ad5369e0cf9..a098280def2a9b0cc475f8c093ba81970d3d2796 100644 (file)
@@ -254,6 +254,7 @@ templates_people_messagesdir = $(templates_peopledir)/messages
 templates_people_modules_DATA = \
        src/templates/people/modules/accounts-list.html \
        src/templates/people/modules/accounts-new.html \
+       src/templates/people/modules/agent.html \
        src/templates/people/modules/cdr.html \
        src/templates/people/modules/channels.html \
        src/templates/people/modules/mos.html \
index 18ae2d3194a7e9d1c5248358f0e221d78f6dd6b8..ec29bcf564175c2d2b90c0199a1172e4616d2572 100644 (file)
@@ -826,6 +826,10 @@ class Account(Object):
        def sip_url(self):
                return "%s@ipfire.org" % self.sip_id
 
+       @lazy_property
+       def agent_status(self):
+               return self.backend.talk.freeswitch.get_agent_status(self)
+
        def uses_sip_forwarding(self):
                if self.sip_routing_address:
                        return True
index 34a213156f0c2ab667d787a72d7901f0c91d3b60..4215e7d5a18d81bcdcd3a19bcece8495ccc05a26 100644 (file)
@@ -82,6 +82,12 @@ class Freeswitch(Object):
 
                return conferences
 
+       def get_agent_status(self, account):
+               res = self.db.get("SELECT status FROM agents \
+                       WHERE name = %s", account.sip_url)
+
+               if res:
+                       return res.status
 
 class SIPRegistration(object):
        def __init__(self, freeswitch, data):
diff --git a/src/templates/people/modules/agent.html b/src/templates/people/modules/agent.html
new file mode 100644 (file)
index 0000000..db3e2d2
--- /dev/null
@@ -0,0 +1,30 @@
+{% set status = account.agent_status %}
+
+{% if status %}
+       <div class="card mb-3">
+               <div class="card-body ">
+                       <h6 class="card-title">{{ _("Agent Status") }}</h6>
+
+                       <p class="card-text">
+                               {% if status == "Available" or status == "Available (On Demand)" %}
+                                       <span class="text-success">
+                                               <i class="fas fa-phone"></i>
+                                               {{ _("This agent is currently available") }}
+                                       </span>
+                               {% elif status == "Logged Out" %}
+                                       <span class="text-danger">
+                                               <i class="fas fa-phone-slash"></i>
+                                               {{ _("This agent is currently logged out") }}
+                                       </span>
+                               {% elif status == "On Break" %}
+                                       <span class="text-warning">
+                                               <i class="fas fa-coffee"></i>
+                                               {{ _("This agent is currently on a break") }}
+                                       </span>
+                               {% else %}
+                                       {{ _("Unknown status: %s") % status }}
+                               {% end %}
+                       </p>
+               </div>
+       </div>
+{% end %}
index a5b47cd472fe42d2fcc6e4eee469503eee8ac91a..9379f328119bc3db7cb41f6edbaec82eb29ae7e0 100644 (file)
@@ -7,6 +7,8 @@
 
        {% module Channels(account) %}
 
+       {% module Agent(account) %}
+
        {% module Registrations(account) %}
 
        {% if account.uses_sip_forwarding() %}
index 1ef6445230c33ceb906bb6f69d3fe8e14e7b71cb..be51b6a9f55c4234437e9aee5b8c10984526904c 100644 (file)
@@ -74,6 +74,7 @@ class Application(tornado.web.Application):
 
                                # People
                                "AccountsList"         : people.AccountsListModule,
+                               "Agent"                : people.AgentModule,
                                "CDR"                  : people.CDRModule,
                                "Channels"             : people.ChannelsModule,
                                "MOS"                  : people.MOSModule,
index ea6ea8a574b426a02502517721acf855eb9bbee3..dfc02b5544ed778b5e96386674543dd208334319 100644 (file)
@@ -373,6 +373,11 @@ class AccountsListModule(ui_modules.UIModule):
                return self.render_string("people/modules/accounts-list.html", accounts=accounts)
 
 
+class AgentModule(ui_modules.UIModule):
+       def render(self, account):
+               return self.render_string("people/modules/agent.html", account=account)
+
+
 class CDRModule(ui_modules.UIModule):
        def render(self, account, date=None, limit=None):
                cdr = account.get_cdr(date=date, limit=limit)