Add new application setup status for running an application in background

This commit is contained in:
Hadi Nategh 2019-03-11 12:06:41 +01:00
parent bec78c475a
commit 1206bc1987
4 changed files with 30 additions and 10 deletions

View File

@ -75,12 +75,13 @@ var fw_base = (function(){ "use strict"; return Class.extend(
var restore = new Object; var restore = new Object;
var restore_count = 0; var restore_count = 0;
var mkRestoreEntry = function(_app, _pos, _url, _active) { var mkRestoreEntry = function(_app, _pos, _url, _active, _status) {
return { return {
'app': _app, 'app': _app,
'position': _pos, 'position': _pos,
'url': _url, 'url': _url,
'active': _active 'active': _active,
status: _status
}; };
}; };
@ -108,7 +109,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
baseUrl, internalName); baseUrl, internalName);
//Create a sidebox menu entry for each application //Create a sidebox menu entry for each application
if (!app.noNavbar) if (!app.noNavbar && app.status != 5)
{ {
this.appData.sidemenuEntry = this.sidemenuUi.addEntry( this.appData.sidemenuEntry = this.sidemenuUi.addEntry(
this.appData.displayName, this.appData.icon, this.appData.displayName, this.appData.icon,
@ -122,7 +123,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
} }
//If the opened field is set, add the application to the restore array. //If the opened field is set, add the application to the restore array.
if ((typeof app.opened != 'undefined') && (app.opened !== false)) if ((typeof app.opened != 'undefined') && (app.opened !== false) || app.status == 5)
{ {
defaultApp = null; defaultApp = null;
@ -131,7 +132,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
url = app.openOnce; url = app.openOnce;
restore[this.appData.appName] = mkRestoreEntry(this.appData, app.opened, restore[this.appData.appName] = mkRestoreEntry(this.appData, app.opened,
url, app.active ? 1 : 0); url, app.active ? 1 : 0, app.status);
restore_count += 1; restore_count += 1;
} }
@ -155,17 +156,18 @@ var fw_base = (function(){ "use strict"; return Class.extend(
* @param {bool} _hidden specifies, whether the application should be set active * @param {bool} _hidden specifies, whether the application should be set active
* after opening the tab * after opening the tab
* @param {int} _pos * @param {int} _pos
* @param {status} _status
* *
* @return {Deferred|null} Deferred Promise, will be resolved when the tab is loaded * @return {Deferred|null} Deferred Promise, will be resolved when the tab is loaded
*/ */
applicationTabNavigate: function(_app, _url, _hidden, _pos) applicationTabNavigate: function(_app, _url, _hidden, _pos, _status)
{ {
//Default the post parameter to -1 //Default the post parameter to -1
if (typeof _pos == 'undefined') if (typeof _pos == 'undefined')
_pos = -1; _pos = -1;
//Create the tab for that application //Create the tab for that application
this.createApplicationTab(_app, _pos); this.createApplicationTab(_app, _pos, _status);
// Response // Response
var deferred = new jQuery.Deferred(); var deferred = new jQuery.Deferred();
@ -213,6 +215,11 @@ var fw_base = (function(){ "use strict"; return Class.extend(
deferred = _app.browser.browse(_url); deferred = _app.browser.browse(_url);
this.setActiveApp(_app); this.setActiveApp(_app);
} }
// load application with status 5 as it will run in the background
else if (_status == 5)
{
deferred = _app.browser.browse(_url);
}
else else
{ {
this.notifyTabChange(deferred); this.notifyTabChange(deferred);
@ -473,7 +480,7 @@ var fw_base = (function(){ "use strict"; return Class.extend(
* @param {int} _pos * @param {int} _pos
* Checks whether the application already owns a tab and creates one if it doesn't exist * Checks whether the application already owns a tab and creates one if it doesn't exist
*/ */
createApplicationTab: function(_app, _pos) createApplicationTab: function(_app, _pos, _status)
{ {
//Default the pos parameter to -1 //Default the pos parameter to -1
if (typeof _pos == 'undefined') if (typeof _pos == 'undefined')
@ -488,7 +495,8 @@ var fw_base = (function(){ "use strict"; return Class.extend(
//Set the tab closeable if there's more than one tab //Set the tab closeable if there's more than one tab
this.tabsUi.setCloseable(this.tabsUi.tabs.length > 1); this.tabsUi.setCloseable(this.tabsUi.tabs.length > 1);
// Do not show tab header if the app is with status 5, means run in background
if (_status == 5) _app.tab.hideTabHeader(true);
} }
}, },

View File

@ -250,7 +250,7 @@
for (var i = 0; i < sorted_restore.length; i++) for (var i = 0; i < sorted_restore.length; i++)
this.applicationTabNavigate( this.applicationTabNavigate(
sorted_restore[i].app, sorted_restore[i].url, i != 0, sorted_restore[i].app, sorted_restore[i].url, i != 0,
sorted_restore[i].position); sorted_restore[i].position, sorted_restore[i]['status']);
//Set the current state of the tabs and activate TabChangeNotification. //Set the current state of the tabs and activate TabChangeNotification.
this.serializedTabState = egw.jsonEncode(this.assembleTabList()); this.serializedTabState = egw.jsonEncode(this.assembleTabList());

View File

@ -468,6 +468,14 @@ egw_fw_ui_tab.prototype.hide = function()
} }
}; };
/**
* hide tab header only
*/
egw_fw_ui_tab.prototype.hideTabHeader = function()
{
jQuery(this.headerDiv).hide();
};
/** /**
* Removes this tab and all its content. * Removes this tab and all its content.
*/ */

View File

@ -829,6 +829,10 @@ abstract class Framework extends Framework\Extra
$apps[$app]['target'] = ''; $apps[$app]['target'] = '';
} }
// take status flag into account as we might use it on client-side.
// for instance: applications with status 5 will run in background
$apps[$app]['status'] = $data['status'];
$icon = isset($data['icon']) ? $data['icon'] : 'navbar'; $icon = isset($data['icon']) ? $data['icon'] : 'navbar';
$icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app; $icon_app = isset($data['icon_app']) ? $data['icon_app'] : $app;
$apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app,Array($icon,'nonav'),''); $apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app,Array($icon,'nonav'),'');