templates_voipdir = $(templatesdir)/voip
templates_voip_modules_DATA = \
+ src/templates/voip/modules/outbound-registrations.html \
src/templates/voip/modules/registrations.html
templates_voip_modulesdir = $(templates_voipdir)/modules
return registrations
+ async def get_outbound_registrations(self):
+ registrations = []
+
+ for data in await self.manager.send_action({"Action" : "PJSIPShowRegistrationsOutbound"}):
+ if not data.Event == "OutboundRegistrationDetail":
+ continue
+
+ registration = OutboundRegistration(self.backend, data)
+ registrations.append(registration)
+
+ return registrations
+
class Channel(misc.Object):
def init(self, data):
@property
def roundtrip(self):
return int(self.data.RoundtripUsec) / 1000
+
+
+class OutboundRegistration(misc.Object):
+ def init(self, data):
+ self.data = data
+
+ def __lt__(self, other):
+ if isinstance(other, self.__class__):
+ return self.server < other.server or self.username < other.username
+
+ return NotImplemented
+
+ @lazy_property
+ def uri(self):
+ return urllib.parse.urlparse(self.data.ClientUri)
+
+ @property
+ def server(self):
+ username, _, server = self.uri.path.partition("@")
+
+ return server
+
+ @property
+ def username(self):
+ username, _, server = self.uri.path.partition("@")
+
+ return username
+
+ @property
+ def status(self):
+ return self.data.Status
</div>
</section>
{% end %}
+
+ {% if outbound_registrations %}
+ <section class="section">
+ <div class="container">
+ <h4 class="title is-4">
+ {{ _("Outbound Registrations") }}
+ <span class="tag">{{ len(outbound_registrations) }}</span>
+ </h4>
+
+ {% module VoIPOutboundRegistrations(outbound_registrations) %}
+ </div>
+ </section>
+ {% end %}
{% end block %}
--- /dev/null
+<table class="table is-striped is-fullwidth">
+ <thead>
+ <tr>
+ <th>{{ _("Server") }}</th>
+ <th>{{ _("Username") }}</th>
+ <th>{{ _("Status") }}</th>
+ </tr>
+ </thead>
+
+ <tbody>
+ {% for r in sorted(registrations) %}
+ <tr>
+ {# Server #}
+ <th scope="row">
+ {{ r.server }}
+ </th>
+
+ {# Username #}
+ <td>
+ {{ r.username }}
+ </td>
+
+ {# Status #}
+ <td>
+ {{ r.status }}
+ </td>
+ </tr>
+ {% end %}
+ </tbody>
+</table>
"UsersList" : users.ListModule,
# VoIP
+ "VoIPOutboundRegistrations" :
+ voip.OutboundRegistrationsModule,
"VoIPRegistrations" : voip.RegistrationsModule,
# Wiki
class IndexHandler(base.BaseHandler):
@tornado.web.authenticated
async def get(self):
- registrations, = await asyncio.gather(
+ registrations, outbound_registrations, = await asyncio.gather(
self.backend.asterisk.get_registrations(),
+ self.backend.asterisk.get_outbound_registrations(),
)
- self.render("voip/index.html", registrations=registrations)
+ self.render("voip/index.html", registrations=registrations,
+ outbound_registrations=outbound_registrations)
+
+
+class OutboundRegistrationsModule(ui_modules.UIModule):
+ def render(self, registrations):
+ return self.render_string("voip/modules/outbound-registrations.html",
+ registrations=registrations)
class RegistrationsModule(ui_modules.UIModule):