Update session indicators periodically (T848)

This commit is contained in:
Aleksander Machniak 2015-12-01 15:55:36 +01:00
parent c9c5b19b52
commit df5e84f052
2 changed files with 34 additions and 19 deletions

View file

@ -177,8 +177,7 @@ function kolab_files_init()
owner: rcmail.env.files_user, owner: rcmail.env.files_user,
interval: rcmail.env.files_interval || 60, interval: rcmail.env.files_interval || 60,
invitationMore: true, invitationMore: true,
invitationChange: manticore_invitation_handler, invitationChange: manticore_invitation_handler
invitationSaved: manticore_invitation_save_handler,
}); });
$.extend(manticore_config, { $.extend(manticore_config, {
@ -1360,13 +1359,6 @@ function manticore_invitation_handler(invitation)
{ {
// make the "More" link clickable // make the "More" link clickable
$('#' + invitation.id).parent('div').click(function() { kolab_files_invitation_dialog(invitation); }); $('#' + invitation.id).parent('div').click(function() { kolab_files_invitation_dialog(invitation); });
// @todo: update session icon state on files list
};
function manticore_invitation_save_handler(invitation)
{
// @todo: update session icon state on files list
}; };
function kolab_files_invitation_dialog(invitation) function kolab_files_invitation_dialog(invitation)
@ -1556,7 +1548,6 @@ rcube_webmail.prototype.files_list_update = function(head)
{ {
var list = this.file_list; var list = this.file_list;
list.clear();
$('thead', list.fixed_header ? list.fixed_header : list.list).html(head); $('thead', list.fixed_header ? list.fixed_header : list.list).html(head);
kolab_files_list_coltypes(); kolab_files_list_coltypes();
file_api.file_list(); file_api.file_list();
@ -1718,6 +1709,7 @@ function kolab_files_ui()
{ {
this.requests = {}; this.requests = {};
this.uploads = []; this.uploads = [];
this.workers = {};
/* /*
// Called on "session expired" session // Called on "session expired" session
@ -2389,11 +2381,18 @@ function kolab_files_ui()
params = {}; params = {};
// reset all pending list requests // reset all pending list requests
for (i in this.requests) { $.each(this.requests, function(i, v) {
this.requests[i].abort(); v.abort();
rcmail.hide_message(i); rcmail.hide_message(i);
delete this.requests[i]; });
}
// reset folder_info workers
$.each(this.workers, function(i, v) {
clearTimeout(v);
});
this.workers = {};
this.requests = {};
if (params.all_folders) { if (params.all_folders) {
params.collection = null; params.collection = null;
@ -2658,13 +2657,23 @@ function kolab_files_ui()
if (!this.response(response) || !response.result) if (!this.response(response) || !response.result)
return; return;
var folder = response.result.folder,
prefix = folder + file_api.env.directory_separator;
if (response.result.sessions) if (response.result.sessions)
this.sessions[response.result.folder] = response.result.sessions; this.sessions[folder] = response.result.sessions;
// update files list with document session info // update files list with document session info
$.each(file_api.env.file_list || [], function(i, file) { $.each(file_api.env.file_list || [], function(i, file) {
// skip files from a different folder (in multi-folder listing)
if (file.filename.indexOf(prefix) !== 0)
return;
var classes = []; var classes = [];
if ($(file.row).is('.selected'))
classes.push('selected');
$.each(response.result.sessions || [], function(session_id, session) { $.each(response.result.sessions || [], function(session_id, session) {
if (file.filename == session.file) { if (file.filename == session.file) {
if ($.inArray('session', classes) < 0) if ($.inArray('session', classes) < 0)
@ -2679,6 +2688,12 @@ function kolab_files_ui()
$(file.row).attr('class', classes.join(' ')); $(file.row).attr('class', classes.join(' '));
}); });
// refresh sessions info in time intervals
if (rcmail.env.files_caps && rcmail.env.files_caps.MANTICORE && (rcmail.file_list || rcmail.env.file))
this.workers[folder] = setTimeout(function() {
file_api.request('folder_info', {folder: folder, sessions: 1}, 'folder_info_response');
}, (rcmail.env.files_interval || 60) * 1000);
}; };
this.file_get = function(file, params) this.file_get = function(file, params)

View file

@ -658,7 +658,7 @@ class kolab_files_engine
$head = ''; $head = '';
foreach ($this->file_list_head($attrib, $a_show_cols) as $cell) { foreach ($this->file_list_head($attrib, $a_show_cols) as $cell) {
$head .= html::tag('td', array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']); $head .= html::tag('th', array('class' => $cell['className'], 'id' => $cell['id']), $cell['html']);
} }
$head = html::tag('tr', null, $head); $head = html::tag('tr', null, $head);