forked from DGNum/gestioCOF
ws update for history and transfer pages
This commit is contained in:
parent
f8aa67721c
commit
1ea334341b
|
@ -7,6 +7,7 @@
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/bootstrap-datetimepicker.min.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/bootstrap-datetimepicker.min.css' %}">
|
||||||
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/multiple-select.css' %}">
|
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/multiple-select.css' %}">
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/moment.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/moment.js' %}"></script>
|
||||||
|
@ -223,6 +224,35 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----
|
||||||
|
// Synchronization
|
||||||
|
// -----
|
||||||
|
|
||||||
|
|
||||||
|
websocket_msg_default = {'opegroups':[],'opes':[]}
|
||||||
|
|
||||||
|
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||||
|
var location_host = window.location.host;
|
||||||
|
var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host;
|
||||||
|
socket = new ReconnectingWebSocket(websocket_protocol+"://" + location_url + "/ws/k-fet/k-psul/");
|
||||||
|
socket.onmessage = function(e) {
|
||||||
|
data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
||||||
|
|
||||||
|
for (var i=0; i<data['opegroups'].length; i++) {
|
||||||
|
if (data['opegroups'][i]['add'] &&
|
||||||
|
moment(data['opegroups'][i]['at']).isBefore(moment($to_date.val()).add(15, 'minutes'))) {
|
||||||
|
khistory.addOpeGroup(data['opegroups'][i]);
|
||||||
|
} else if (data['opegroups'][i]['cancellation']) {
|
||||||
|
khistory.cancelOpeGroup(data['opegroups'][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i=0; i<data['opes'].length; i++) {
|
||||||
|
if (data['opes'][i]['cancellation']) {
|
||||||
|
khistory.cancelOpe(data['opes'][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
getHistory();
|
getHistory();
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{% block extra_head %}
|
{% block extra_head %}
|
||||||
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/jquery-ui.min.css' %}">
|
<link rel="stylesheet" style="text/css" href="{% static 'kfet/css/jquery-ui.min.css' %}">
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/js.cookie.js' %}"></script>
|
||||||
|
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-ui.min.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script>
|
||||||
<script type="text/javascript" src="{% static 'kfet/js/moment.js' %}"></script>
|
<script type="text/javascript" src="{% static 'kfet/js/moment.js' %}"></script>
|
||||||
|
@ -162,6 +163,27 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -----
|
||||||
|
// Synchronization
|
||||||
|
// -----
|
||||||
|
|
||||||
|
|
||||||
|
websocket_msg_default = {'opes':[]}
|
||||||
|
|
||||||
|
var websocket_protocol = window.location.protocol == 'https:' ? 'wss' : 'ws';
|
||||||
|
var location_host = window.location.host;
|
||||||
|
var location_url = window.location.pathname.startsWith('/gestion/') ? location_host + '/gestion' : location_host;
|
||||||
|
socket = new ReconnectingWebSocket(websocket_protocol+"://" + location_url + "/ws/k-fet/k-psul/");
|
||||||
|
socket.onmessage = function(e) {
|
||||||
|
data = $.extend({}, websocket_msg_default, JSON.parse(e.data));
|
||||||
|
|
||||||
|
for (var i=0; i<data['opes'].length; i++) {
|
||||||
|
if (data['opes'][i]['cancellation']) {
|
||||||
|
khistory.cancelOpe(data['opes'][i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getHistory();
|
getHistory();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue