Skip to content

Commit

Permalink
Merge branch 'dev' into v0.521
Browse files Browse the repository at this point in the history
  • Loading branch information
mackhendricks authored Apr 17, 2019
2 parents 32d0483 + c394864 commit 89f20df
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 31 deletions.
31 changes: 31 additions & 0 deletions dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
function getKamailioStats(elmnt) {
//elmnt.style.backgroundColor = "red";
//elmnt.style.borderColor = "red"
var msg_bar = $(".message-bar");
var reload_button = $('#reloadkam');


$.ajax({
type: "GET",
url: "/v1/kamailio/stats",
dataType: "json",
success: function(msg) {
if (msg.status === 1) {
msg_bar.addClass("alert alert-success");
msg_bar.html("<strong>Success!</strong> Kamailio was reloaded successfully!");
reload_button.removeClass('btn-warning');
reload_button.addClass('btn-primary');
}
else {
msg_bar.addClass("alert alert-danger");
msg_bar.html("<strong>Failed!</strong> Kamailio was NOT reloaded successfully!");
}

msg_bar.show();
msg_bar.slideUp(3000, "linear");
//elmnt.style.backgroundColor = "#337ab7";
//elmnt.style.borderColor = "#2e6da4";
}
});
}

2 changes: 2 additions & 0 deletions gui/dsiprouter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
from modules import flowroute
from modules.domain.domain_routes import domains
import globals
from modules.api.api_routes import api
import settings

# global variables
app = Flask(__name__, static_folder="./static", static_url_path="/static")
app.register_blueprint(domains)
app.register_blueprint(api)
db = loadSession()
numbers_api = flowroute.Numbers()

Expand Down
48 changes: 48 additions & 0 deletions gui/modules/api/api_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from flask import Blueprint, session, render_template,jsonify
from flask import Flask, render_template, request, redirect, abort, flash, session, url_for, send_from_directory
from sqlalchemy import case, func, exc as sql_exceptions
from werkzeug import exceptions as http_exceptions
from database import loadSession, Domain, DomainAttrs, dSIPDomainMapping, dSIPMultiDomainMapping, Dispatcher, Gateways
from shared import *
import settings

db = loadSession()
api = Blueprint('api', __name__)

@api.route("/api/v1/kamailio/stats", methods=['GET'])
def getKamailioStats():
try:
if (settings.DEBUG):
debugEndpoint()

#if not session.get('logged_in'):
# return render_template('index.html', version=settings.VERSION)

payload = {"jsonrpc": "2.0", "method": "tm.stats","id": 1}
#r = requests.get('https://www.google.com',data=payload)
r = requests.get('http://127.0.0.1:5060/api/kamailio',json=payload)
#print(r.text)

return r.text

except sql_exceptions.SQLAlchemyError as ex:
debugException(ex, log_ex=False, print_ex=True, showstack=False)
error = "db"
db.rollback()
db.flush()
return showError(type=error)
except http_exceptions.HTTPException as ex:
debugException(ex, log_ex=False, print_ex=True, showstack=False)
error = "http"
db.rollback()
db.flush()
return showError(type=error)
except Exception as ex:
debugException(ex, log_ex=False, print_ex=True, showstack=False)
error = "server"
db.rollback()
db.flush()
return showError(type=error)
finally:
db.close()

10 changes: 10 additions & 0 deletions gui/static/css/dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.dashboard-metric {
font-size: 80px;
text-align: center;
}

.dashboard-metric-label {
font-size: 35px;
text-align: center;
color: #ddd;
}
15 changes: 15 additions & 0 deletions gui/static/js/dashboard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
function getKamailioStats(elmnt) {


$.ajax({
type: "GET",
url: "/api/v1/kamailio/stats",
dataType: "json",
success: function(msg) {
document.getElementById("dashboard_current_calls").innerHTML=msg.result.current;
document.getElementById("dashboard_calls_inqueue").innerHTML=msg.result.waiting;
document.getElementById("dashboard_total_calls_processed").innerHTML=msg.result.total;
}});
}

getKamailioStats();
100 changes: 69 additions & 31 deletions gui/templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

{% block custom_css %}
{{ link_tag('main') }}
{{ link_tag('dashboard') }}

{% endblock %}

{% block body %}
Expand All @@ -13,38 +15,74 @@
<h3>Kamailio reload: {{ reloadstatus }}</h3>

{% endif %}

<div class="panel panel-default" style="margin-top:5px">
<div class="panel-heading"><h1>Welcome to dSIPRouter v{{ version }}</h1></div>
<div class="panel-body">
Our goal is to make it easier to configure and manage Kamailio for one or more use cases. For the first release we
are focused on the SIP Trunking use case.
This use case consist of using Kamailio to provide SIP Trunking services. There are four main components:
carriers, PBX(s) and endpoints, inbound DID routing and global outbound routing.

<h2>Carriers</h2>
When you install dSIPRouter we installed a set of carriers. If you use one of the provided carriers then you just
have to provision your IP address and enter in a tech prefix
to start using the carrier. Otherwise, you will need to add the carrier.

<h2>PBX(s) and Endpoints</h2>
You can define the IP address of the PBX(s) that you want to provide SIP Trunking services for. You can also
specify the number of digits to strip off an inbound DID and the prefix that you want to
add to an inbound DID. The IP address of the PBX(s) will automatically be added to the access control list of the
switch. If you want to simulate a PBX, you can add your IP address as a PBX and then use a softphone to place a
call. Note, disable registration when you setup the extension of the softphone.

<h2>Inbound DID Mapping</h2>
This is where you define a mapping between a DID and PBX. At this time, the mapping is one-to-one. This means that
one DID can only be mapped to one PBX. In future releases we will support this.

<h2>Global Outbound Routing</h2>
Calls sent to dSIPRouter will be routed out the Global Outbound Routes (GOR). The GOR contains a list of carriers
sepreated by commas. Calls are routed out the carriers based on the order in the list. The next carrier is used if
the previous one fails.
</div>
</div>
<h1 class="page-header">Dashboard</h1>
<div class="row placeholders">
<div class="col-xs-4 col-sm-4 placeholder">
<div class="dashboard-metric-label">Current Calls</div>
<div id="dashboard_current_calls" class="dashboard-metric"></div>
</div>
<div class="col-xs-4 col-sm-4 placeholder">
<div class="dashboard-metric-label">Calls In Queue</div>
<div id="dashboard_calls_inqueue" class="dashboard-metric"></div>
</div>
<div class="col-xs-4 col-sm-4 placeholder">
<div class="dashboard-metric-label">Total Calls Processed</div>
<div id="dashboard_total_calls_processed" class="dashboard-metric"></div>
</div>
</div>
<div class="row container">
<div class="col-xs-4">
<div class="panel panel-default">
<div class="panel-heading">Documentation</div>
<div class="panel-body">
<ul>
<li>Setup SIP Trunking Service
<ul>
<li><a href="https://dsiprouter.readthedocs.io/en/latest/use-cases.html#sip-trunking-using-ip-authentication" target="_blank">Using IP Authentication</a></li>
<li><a href="https://dsiprouter.readthedocs.io/en/latest/use-cases.html#sip-trunking-using-username-password-authentication" target="_blank">Using Username/Password Authentication</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="col-xs-4">
<div class=" panel panel-default">
<div class="panel-heading">Training</div>
<div class="panel-body">
<ul>
<li><a href="https://dopensource.com/product/dsiprouter-admin-course/" target="_blank">dSIPRouter 1 Day Admin Course</a></li>
</ul>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="panel panel-default">
<div class="panel-heading">Support</div>
<div class="panel-body">
<ul>
<li>Paid Support
<ul>
<li><a href="https://dopensource.com/product/dsiprouter-annual-support/" target="_blank">Annual Commercial Support</a></li>
</ul>
</li>
<li>Free Support
<ul>
<li><a href="https://groups.google.com/forum/#!forum/dsiprouter" target="_blank">User Forum</a></li>
</ul>
</li>
<li>Kamailio Consultants Directory
<ul>
<li><a href="https://www.kamailio.org/w/business-directory/" target="_black">Kamailio Business Directory</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}

{% block custom_js %}
{{ script_tag('dashboard') }}
{% endblock %}

0 comments on commit 89f20df

Please sign in to comment.