[Libreoffice-commits] online.git: loleaflet/dist loleaflet/main.js loleaflet/src loolwsd.xml.in wsd/FileServer.cpp wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Thu May 11 06:01:48 UTC 2017


 loleaflet/dist/loleaflet.html |    2 ++
 loleaflet/main.js             |   18 ++++++++++--------
 loleaflet/src/map/Map.js      |    6 ++----
 loolwsd.xml.in                |    5 +++++
 wsd/FileServer.cpp            |    4 ++++
 wsd/LOOLWSD.cpp               |    2 ++
 6 files changed, 25 insertions(+), 12 deletions(-)

New commits:
commit 954a37a06c9611ea7795aa1e5030170099db6e3e
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Thu May 11 00:02:38 2017 -0400

    Configurable timeouts
    
    Timeouts to dimming the doc in the browser
    are now configurable from WSD and is relayed
    to loleflet as expected.
    
    Out of focus timeout is now 60 seconds.
    
    Change-Id: I8452e30976f6a81b0c3bb3ba5774daa244c1640c
    Reviewed-on: https://gerrit.libreoffice.org/37489
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/loleaflet/dist/loleaflet.html b/loleaflet/dist/loleaflet.html
index bfa9ad3e..0d587090 100644
--- a/loleaflet/dist/loleaflet.html
+++ b/loleaflet/dist/loleaflet.html
@@ -87,6 +87,8 @@
       window.access_token = '%ACCESS_TOKEN%';
       window.access_token_ttl = '%ACCESS_TOKEN_TTL%';
       window.loleaflet_logging = '%LOLEAFLET_LOGGING%';
+      window.outOfFocusTimeoutSecs = %OUT_OF_FOCUS_TIMEOUT_SECS%;
+      window.idleTimeoutSecs = %IDLE_TIMEOUT_SECS%;
     </script>
     <script src="/loleaflet/%VERSION%/branding.js"></script> <!-- logo onclick handler -->
     <script src="/loleaflet/%VERSION%/bundle.js"></script>
diff --git a/loleaflet/main.js b/loleaflet/main.js
index 2b001df4..fed59570 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -103,15 +103,17 @@ if (wopiSrc != '') {
 
 document.title = title;
 var map = L.map('map', {
-    server: host,
-    doc: docURL,
-    docParams: docParams,
-    permission: permission,
-    timestamp: timestamp,
-    documentContainer: 'document-container',
-    debug: debugMode,
+	server: host,
+	doc: docURL,
+	docParams: docParams,
+	permission: permission,
+	timestamp: timestamp,
+	documentContainer: 'document-container',
+	debug: debugMode,
 	wopi: isWopi,
-	alwaysActive: alwaysActive
+	alwaysActive: alwaysActive,
+	idleTimeoutSecs: idleTimeoutSecs,  // Dim when user is idle.
+	outOfFocusTimeoutSecs: outOfFocusTimeoutSecs, // Dim after switching tabs.
 });
 // toolbar.js (loaded in <script> tag accesses map as global variable,
 // so expose it
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 49cb285c..0e8d6311 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -18,9 +18,7 @@ L.Map = L.Evented.extend({
 		defaultZoom: 10,
 		tileWidthTwips: 3840,
 		tileHeightTwips: 3840,
-		urlPrefix: 'lool',
-		idleTimeoutSecs: 15 * 60,  // Dim when user is idle.
-		outOfFocusTimeoutSecs: 30, // Dim after switching tabs.
+		urlPrefix: 'lool'
 	},
 
 	lastActiveTime: Date.now(),
@@ -897,7 +895,7 @@ L.Map = L.Evented.extend({
 		var map = this;
 		vex.timer = setTimeout(function() {
 			map._dim();
-		}, this.options.outOfFocusTimeoutSecs * 1000);
+		}, map.options.outOfFocusTimeoutSecs * 1000);
 	},
 
 	_onLostFocus: function () {
diff --git a/loolwsd.xml.in b/loolwsd.xml.in
index 449d9797..eed51283 100644
--- a/loolwsd.xml.in
+++ b/loolwsd.xml.in
@@ -17,6 +17,11 @@
         <idle_timeout_secs desc="The maximum number of seconds before unloading an idle document. Defaults to 1 hour." type="uint" default="3600">3600</idle_timeout_secs>
     </per_document>
 
+    <per_view desc="View-specific settings.">
+        <out_of_focus_timeout_secs desc="The maximum number of seconds before dimming and stopping updates when the browser tab is no longer in focus. Defaults to 60 seconds." type="uint" default="60">60</out_of_focus_timeout_secs>
+        <idle_timeout_secs desc="The maximum number of seconds before dimming and stopping updates when the user is no longer active (even if the browser is in focus). Defaults to 15 minutes." type="uint" default="900">900</idle_timeout_secs>
+    </per_view>
+
     <loleaflet_html desc="Allows UI customization by replacing the single endpoint of loleaflet.html" type="string" default="loleaflet.html">loleaflet.html</loleaflet_html>
 
     <logging>
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index c61df9fa..ad665fb2 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -454,6 +454,10 @@ void FileServerRequestHandler::preprocessFile(const HTTPRequest& request, Poco::
     const auto& config = Application::instance().config();
     const auto loleafletLogging = config.getString("loleaflet_logging", "false");
     Poco::replaceInPlace(preprocess, std::string("%LOLEAFLET_LOGGING%"), loleafletLogging);
+    const auto outOfFocusTimeoutSecs= config.getString("per_view.out_of_focus_timeout_secs", "60");
+    Poco::replaceInPlace(preprocess, std::string("%OUT_OF_FOCUS_TIMEOUT_SECS%"), outOfFocusTimeoutSecs);
+    const auto idleTimeoutSecs= config.getString("per_view.idle_timeout_secs", "900");
+    Poco::replaceInPlace(preprocess, std::string("%IDLE_TIMEOUT_SECS%"), idleTimeoutSecs);
 
     const std::string mimeType = "text/html";
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index e1397d92..bdf0f67d 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -623,6 +623,8 @@ void LOOLWSD::initialize(Application& self)
             { "num_prespawn_children", "1" },
             { "per_document.max_concurrency", "4" },
             { "per_document.idle_timeout_secs", "3600" },
+            { "per_view.out_of_focus_timeout_secs", "60" },
+            { "per_view.idle_timeout_secs", "900" },
             { "loleaflet_html", "loleaflet.html" },
             { "logging.color", "true" },
             { "logging.level", "trace" },


More information about the Libreoffice-commits mailing list