phone: handle call stop
This commit is contained in:
parent
5e455ba44f
commit
97bfd57641
|
@ -8,7 +8,7 @@ msgstr ""
|
|||
"Project-Id-Version: welco 0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2015-11-03 20:24+0100\n"
|
||||
"PO-Revision-Date: 2015-11-03 20:27+0100\n"
|
||||
"PO-Revision-Date: 2015-11-09 16:20+0100\n"
|
||||
"Last-Translator: Frederic Peters <fpeters@entrouvert.com>\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
|
@ -305,7 +305,7 @@ msgstr ""
|
|||
|
||||
#: sources/phone/templates/welco/phone_home.html:36
|
||||
msgid "Current Call:"
|
||||
msgstr "Appel en cours :"
|
||||
msgstr "Appel traité :"
|
||||
|
||||
#: templates/welco/home.html:12
|
||||
msgid "Knowledge Database"
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
{% endif %}
|
||||
|
||||
{% for phonecall in phonecalls %}
|
||||
<div class="phonecall active" data-source-pk="{{phonecall.id}}">
|
||||
<div class="phonecall active" data-source-pk="{{phonecall.id}}"
|
||||
data-active-call-url="{% url 'phone-active-call' pk=phonecall.id %}">
|
||||
<h1>{% trans 'Current Call:' %} <strong>{{phonecall.caller}}</strong></h1>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
|
|
@ -22,6 +22,7 @@ urlpatterns = patterns(
|
|||
'',
|
||||
url(r'^ajax/phone/zone/$', views.zone, name='phone-zone'),
|
||||
url(r'^api/phone/call-event/$', views.call_event, name='phone-call-event'),
|
||||
url(r'^api/phone/active-call/(?P<pk>\w+)/$', views.active_call, name='phone-active-call'),
|
||||
url(r'^api/phone/current-calls/$', views.current_calls, name='phone-current-calls'),
|
||||
url(r'^api/phone/take-line/$', views.take_line, name='phone-take-line'),
|
||||
url(r'^api/phone/release-line/$', views.release_line, name='phone-release-line'),
|
||||
|
|
|
@ -107,6 +107,19 @@ def call_event(request):
|
|||
return HttpResponse(json.dumps({'err': 0}), content_type='application/json')
|
||||
|
||||
|
||||
@login_required
|
||||
def active_call(request, *args, **kwargs):
|
||||
call = PhoneCall.objects.get(id=kwargs.get('pk'))
|
||||
result = {
|
||||
'caller': call.caller,
|
||||
'callee': call.callee,
|
||||
'active': not(bool(call.stop)),
|
||||
'start_timestamp': call.start.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||
}
|
||||
return HttpResponse(json.dumps(result, indent=2),
|
||||
content_type='application/json')
|
||||
|
||||
|
||||
@login_required
|
||||
def current_calls(request):
|
||||
'''Returns the list of current calls for current user as JSON:
|
||||
|
|
|
@ -371,8 +371,24 @@ $(function() {
|
|||
});
|
||||
|
||||
if ($('.source-phone').length) {
|
||||
function check_active_call() {
|
||||
var active_call_url = $('[data-active-call-url]').data('active-call-url');
|
||||
$.ajax({url: active_call_url,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.active === false) {
|
||||
$('<span class="done"> (terminé)</span>').appendTo($('div.phonecall.active h1'));
|
||||
window.setTimeout(check_calls, 1000);
|
||||
} else {
|
||||
window.setTimeout(check_active_call, 5000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check_calls() {
|
||||
if ($('.phonecall').length) { /* active phone call */
|
||||
if ($('.phonecall').length && $('.phonecall .done').length == 0) { /* active phone call */
|
||||
window.setTimeout(check_active_call, 1000);
|
||||
} else {
|
||||
var current_calls_url = $('[data-current-calls]').data('current-calls');
|
||||
$.ajax({url: current_calls_url,
|
||||
|
|
Loading…
Reference in New Issue