From 1206bc19871830c7efe2abb38eb74ae146b8db01 Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Mon, 11 Mar 2019 12:06:41 +0100 Subject: [PATCH] Add new application setup status for running an application in background --- api/js/framework/fw_base.js | 26 +++++++++++++++++--------- api/js/framework/fw_desktop.js | 2 +- api/js/framework/fw_ui.js | 8 ++++++++ api/src/Framework.php | 4 ++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/api/js/framework/fw_base.js b/api/js/framework/fw_base.js index 78999cbfa7..e48d4f5bbc 100644 --- a/api/js/framework/fw_base.js +++ b/api/js/framework/fw_base.js @@ -75,12 +75,13 @@ var fw_base = (function(){ "use strict"; return Class.extend( var restore = new Object; var restore_count = 0; - var mkRestoreEntry = function(_app, _pos, _url, _active) { + var mkRestoreEntry = function(_app, _pos, _url, _active, _status) { return { 'app': _app, 'position': _pos, 'url': _url, - 'active': _active + 'active': _active, + status: _status }; }; @@ -108,7 +109,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( baseUrl, internalName); //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.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 ((typeof app.opened != 'undefined') && (app.opened !== false)) + if ((typeof app.opened != 'undefined') && (app.opened !== false) || app.status == 5) { defaultApp = null; @@ -131,7 +132,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( url = app.openOnce; restore[this.appData.appName] = mkRestoreEntry(this.appData, app.opened, - url, app.active ? 1 : 0); + url, app.active ? 1 : 0, app.status); 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 * after opening the tab * @param {int} _pos + * @param {status} _status * * @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 if (typeof _pos == 'undefined') _pos = -1; //Create the tab for that application - this.createApplicationTab(_app, _pos); + this.createApplicationTab(_app, _pos, _status); // Response var deferred = new jQuery.Deferred(); @@ -213,6 +215,11 @@ var fw_base = (function(){ "use strict"; return Class.extend( deferred = _app.browser.browse(_url); 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 { this.notifyTabChange(deferred); @@ -473,7 +480,7 @@ var fw_base = (function(){ "use strict"; return Class.extend( * @param {int} _pos * 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 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 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); } }, diff --git a/api/js/framework/fw_desktop.js b/api/js/framework/fw_desktop.js index 2413f0facc..cc3074bad4 100644 --- a/api/js/framework/fw_desktop.js +++ b/api/js/framework/fw_desktop.js @@ -250,7 +250,7 @@ for (var i = 0; i < sorted_restore.length; i++) this.applicationTabNavigate( 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. this.serializedTabState = egw.jsonEncode(this.assembleTabList()); diff --git a/api/js/framework/fw_ui.js b/api/js/framework/fw_ui.js index 1c6f1254c0..0973c6755f 100644 --- a/api/js/framework/fw_ui.js +++ b/api/js/framework/fw_ui.js @@ -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. */ diff --git a/api/src/Framework.php b/api/src/Framework.php index 6a9851154d..f44598437a 100644 --- a/api/src/Framework.php +++ b/api/src/Framework.php @@ -829,6 +829,10 @@ abstract class Framework extends Framework\Extra $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_app = isset($data['icon_app']) ? $data['icon_app'] : $app; $apps[$app]['icon'] = $apps[$app]['icon_hover'] = Image::find($icon_app,Array($icon,'nonav'),'');