Commit 50ec4832 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_web_renderjs_ui] Allow to define and use a service worker

parent 692e466e
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
<script data-renderjs-configuration="language_map" type="text/x-renderjs-configuration">${language_map}</script> <script data-renderjs-configuration="language_map" type="text/x-renderjs-configuration">${language_map}</script>
<script data-renderjs-configuration="default_selected_language" type="text/x-renderjs-configuration">${default_selected_language}</script> <script data-renderjs-configuration="default_selected_language" type="text/x-renderjs-configuration">${default_selected_language}</script>
<script data-renderjs-configuration="website_url_set" type="text/x-renderjs-configuration">${website_url_set}</script> <script data-renderjs-configuration="website_url_set" type="text/x-renderjs-configuration">${website_url_set}</script>
<script data-renderjs-configuration="service_worker_url" type="text/x-renderjs-configuration">${service_worker_url}</script>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
......
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492085733.75</float> <float>1492086207.22</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*globals window, document, RSVP, rJS, /*globals window, document, RSVP, rJS,
URI, location, XMLHttpRequest, console*/ URI, location, XMLHttpRequest, console, navigator*/
/*jslint indent: 2, maxlen: 80*/ /*jslint indent: 2, maxlen: 80*/
(function (window, document, RSVP, rJS, (function (window, document, RSVP, rJS,
XMLHttpRequest, location, console) { XMLHttpRequest, location, console, navigator) {
"use strict"; "use strict";
/*
if (navigator.hasOwnProperty('serviceWorker')) {
// Check if a ServiceWorker already controls the site on load
if (!navigator.serviceWorker.controller) {
// Register the ServiceWorker
navigator.serviceWorker.register('gadget_erp5_serviceworker.js');
}
}
*/
var MAIN_SCOPE = "m"; var MAIN_SCOPE = "m";
function renderMainGadget(gadget, url, options) { function renderMainGadget(gadget, url, options) {
...@@ -239,6 +230,17 @@ ...@@ -239,6 +230,17 @@
.absoluteTo(location.href) .absoluteTo(location.href)
.toString(); .toString();
if (setting.hasOwnProperty('service_worker_url') &&
(setting.service_worker_url !== '')) {
if (navigator.serviceWorker !== undefined) {
// Check if a ServiceWorker already controls the site on load
if (!navigator.serviceWorker.controller) {
// Register the ServiceWorker
navigator.serviceWorker.register(setting.service_worker_url);
}
}
}
return setting_gadget.put("setting", setting); return setting_gadget.put("setting", setting);
}) })
.push(function () { .push(function () {
...@@ -584,4 +586,4 @@ ...@@ -584,4 +586,4 @@
}); });
}(window, document, RSVP, rJS, }(window, document, RSVP, rJS,
XMLHttpRequest, location, console)); XMLHttpRequest, location, console, navigator));
\ No newline at end of file \ No newline at end of file
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>957.35152.14703.9045</string> </value> <value> <string>958.43029.38869.9284</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1487941504.18</float> <float>1492087071.7</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -97,6 +97,7 @@ ...@@ -97,6 +97,7 @@
<list> <list>
<string>my_configuration_panel_gadget_url</string> <string>my_configuration_panel_gadget_url</string>
<string>my_configuration_manifest_url</string> <string>my_configuration_manifest_url</string>
<string>my_configuration_service_worker_url</string>
<string>my_configuration_jio_gadget_url</string> <string>my_configuration_jio_gadget_url</string>
<string>my_configuration_translation_gadget_url</string> <string>my_configuration_translation_gadget_url</string>
<string>my_configuration_router_gadget_url</string> <string>my_configuration_router_gadget_url</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration_service_worker_url</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_reference</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Service Worker URL</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -44,6 +44,7 @@ mapping_dict = { ...@@ -44,6 +44,7 @@ mapping_dict = {
"jio_gadget": web_section.getLayoutProperty("configuration_jio_gadget_url", default="gadget_jio.html"), "jio_gadget": web_section.getLayoutProperty("configuration_jio_gadget_url", default="gadget_jio.html"),
"translation_gadget": web_section.getLayoutProperty("configuration_translation_gadget_url", default="gadget_translation.html"), "translation_gadget": web_section.getLayoutProperty("configuration_translation_gadget_url", default="gadget_translation.html"),
"manifest_url": web_section.getLayoutProperty("configuration_manifest_url", default="gadget_erp5.appcache"), "manifest_url": web_section.getLayoutProperty("configuration_manifest_url", default="gadget_erp5.appcache"),
"service_worker_url": web_section.getLayoutProperty("configuration_service_worker_url", default=""),
"language_map": json.dumps({tmp['id']: portal.Base_translateString(tmp['title'], lang = tmp['id']) for tmp in portal.Localizer.get_languages_map() if tmp['id'] in available_language_set}), "language_map": json.dumps({tmp['id']: portal.Base_translateString(tmp['title'], lang = tmp['id']) for tmp in portal.Localizer.get_languages_map() if tmp['id'] in available_language_set}),
"default_selected_language": portal.Localizer.get_selected_language(), "default_selected_language": portal.Localizer.get_selected_language(),
"website_url_set": json.dumps(website_url_set), "website_url_set": json.dumps(website_url_set),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment