#788 Whenever a timeout is detected by an ajax request, a popup dialog warns the user to log-in again.

SVN:trunk[3613]
This commit is contained in:
Denis Flaven
2015-06-25 15:32:30 +00:00
parent 6e92438282
commit 9f92e5e0be
6 changed files with 72 additions and 0 deletions

View File

@@ -117,7 +117,13 @@ EOF
myLayout.addPinBtn( "#tPinMenu", "west" );
EOF;
}
$sJSDisconnectedMessage = json_encode(Dict::S('UI:DisconnectedDlgMessage'));
$sJSTitle = json_encode(Dict::S('UI:DisconnectedDlgTitle'));
$sJSLoginAgain = json_encode(Dict::S('UI:LoginAgain'));
$sJSStayOnThePage = json_encode(Dict::S('UI:StayOnThePage'));
$this->m_sInitScript =
<<< EOF
try
@@ -391,6 +397,26 @@ EOF
$('#logOffBtn>ul').popupmenu();
$('.caselog_header').click( function () { $(this).toggleClass('open').next('.caselog_entry').toggle(); });
$(document).ajaxSend(function(event, jqxhr, options) {
jqxhr.setRequestHeader('X-Combodo-Ajax', 'true');
});
$(document).ajaxError(function(event, jqxhr, options) {
if (jqxhr.status == 401)
{
$('<div>'+$sJSDisconnectedMessage+'</div>').dialog({
modal:true,
title: $sJSTitle,
close: function() { $(this).remove(); },
minWidth: 400,
buttons: [
{ text: $sJSLoginAgain, click: function() { window.location.href= GetAbsoluteUrlAppRoot()+'pages/UI.php' } },
{ text: $sJSStayOnThePage, click: function() { $(this).dialog('close'); } }
]
});
}
});
EOF
);
$sUserPrefs = appUserPreferences::GetAsJSON();

View File

@@ -581,6 +581,13 @@ EOF
{
$sLoginMode = $aAllowedLoginTypes[0]; // First in the list...
}
if (array_key_exists('HTTP_X_COMBODO_AJAX', $_SERVER))
{
// X-Combodo-Ajax is a special header automatically added to all ajax requests
// Let's reply that we're currently logged-out
header('HTTP/1.0 401 Unauthorized');
exit;
}
if (($iOnExit == self::EXIT_HTTP_401) || ($sLoginMode == 'basic'))
{
header('WWW-Authenticate: Basic realm="'.Dict::Format('UI:iTopVersion:Short', ITOP_VERSION));

View File

@@ -92,6 +92,12 @@ class PortalWebPage extends NiceWebPage
$this->add_linked_script("../js/ajaxfileupload.js");
$this->add_linked_script("../js/ckeditor/ckeditor.js");
$this->add_linked_script("../js/ckeditor/adapters/jquery.js");
$sJSDisconnectedMessage = json_encode(Dict::S('UI:DisconnectedDlgMessage'));
$sJSTitle = json_encode(Dict::S('UI:DisconnectedDlgTitle'));
$sJSLoginAgain = json_encode(Dict::S('UI:LoginAgain'));
$sJSStayOnThePage = json_encode(Dict::S('UI:StayOnThePage'));
$this->add_ready_script(
<<<EOF
try
@@ -154,6 +160,25 @@ try
//$('.resizable').resizable(); // Make resizable everything that claims to be resizable !
$('.caselog_header').click( function () { $(this).toggleClass('open').next('.caselog_entry').toggle(); });
$(document).ajaxSend(function(event, jqxhr, options) {
jqxhr.setRequestHeader('X-Combodo-Ajax', 'true');
});
$(document).ajaxError(function(event, jqxhr, options) {
if (jqxhr.status == 401)
{
$('<div>'+$sJSDisconnectedMessage+'</div>').dialog({
modal:true,
title: $sJSTitle,
close: function() { $(this).remove(); },
minWidth: 400,
buttons: [
{ text: $sJSLoginAgain, click: function() { window.location.href= GetAbsoluteUrlAppRoot()+'pages/UI.php' } },
{ text: $sJSStayOnThePage, click: function() { $(this).dialog('close'); } }
]
});
}
});
}
catch(err)
{

View File

@@ -987,5 +987,9 @@ Wenn Aktionen mit Trigger verknüpft sind, bekommt jede Aktion eine Auftragsnumm
'Month-11' => 'November',
'Month-12' => 'Dezember',
'UI:FillAllMandatoryFields' => 'Bitte füllen Sie alle Pflichtfelder',
'UI:DisconnectedDlgMessage' => 'You are disconnected. You must identify yourself to continue using the application.~~',
'UI:DisconnectedDlgTitle' => 'Warning!~~',
'UI:LoginAgain' => 'Login again~~',
'UI:StayOnThePage' => 'Stay on this page~~',
));
?>

View File

@@ -1240,6 +1240,11 @@ When associated with a trigger, each action is given an "order" number, specifyi
'UI:About:Licenses' => 'Licenses',
'UI:About:Modules' => 'Installed modules',
'UI:DisconnectedDlgMessage' => 'You are disconnected. You must identify yourself to continue using the application.',
'UI:DisconnectedDlgTitle' => 'Warning!',
'UI:LoginAgain' => 'Login again',
'UI:StayOnThePage' => 'Stay on this page',
'ExcelExporter:ExportMenu' => 'Excel Export...',
'ExcelExporter:ExportDialogTitle' => 'Excel Export',
'ExcelExporter:ExportButton' => 'Export',

View File

@@ -1082,6 +1082,11 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
'UI:About:Licenses' => 'Licences',
'UI:About:Modules' => 'Modules installés',
'UI:DisconnectedDlgMessage' => 'Vous êtes déconnecté(e). Vous devez vous identifier pour pouvoir continuer à utiliser l\'application.',
'UI:DisconnectedDlgTitle' => 'Attention !',
'UI:LoginAgain' => 'S\'identifier',
'UI:StayOnThePage' => 'Rester sur cette page',
'ExcelExporter:ExportMenu' => 'Exporter pour Excel...',
'ExcelExporter:ExportDialogTitle' => 'Export au format Excel',
'ExcelExporter:ExportButton' => 'Exporter',