Commit 510cf1a7 authored by Eugene Shen's avatar Eugene Shen

Refactor and JSLint configurator files

Store only text content in jIO instead of the full stringified message,
rename message properties and recolour old messages to deal with that,
move jIO and MappingStorage scripts around in chat box and room HTML,
use room in queries because room is in the TextPost property sheet,
make the chat box redirect to chat connect if user_email is falsy,
completely refactor configurator files to delete custom settings,
remove requireSetting, and pass JSLint on all of them; finally,
store ID in mapping_id property in preparation for more fun.
parent da50ea6d
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
<title>>Chat Room Gadget</title> <title>>Chat Room Gadget</title>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<script src="handlebars.js"></script> <script src="handlebars.js"></script>
<script src="jio_mappingstorage.js"></script>
<script src="gadget_erp5_chat_room.js"></script> <script src="gadget_erp5_chat_room.js"></script>
<script class="connect-form-template" type="text/x-handlebars-template"> <script class="connect-form-template" type="text/x-handlebars-template">
<label> <label>
......
...@@ -147,6 +147,12 @@ ...@@ -147,6 +147,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -206,4 +212,63 @@ ...@@ -206,4 +212,63 @@
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>eyqs</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41620.48534.44868</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1492008152.73</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -8,11 +8,12 @@ ...@@ -8,11 +8,12 @@
// State is set in erp5_page_chat_box. // State is set in erp5_page_chat_box.
// The following function is acquired from erp5_page_chat_box. // The following function is acquired from erp5_page_chat_box.js
.declareAcquiredMethod("joinNewRoom", "joinNewRoom") .declareAcquiredMethod("joinNewRoom", "joinNewRoom")
// The following functions are all acquired from erp5_page_launcher. // The following functions are all acquired from erp5_launcher_nojqm.js.
.declareAcquiredMethod("jio_put", "jio_put") .declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_get", "jio_get") .declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_repair", "jio_repair") .declareAcquiredMethod("jio_repair", "jio_repair")
......
...@@ -143,6 +143,12 @@ ...@@ -143,6 +143,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -202,4 +208,63 @@ ...@@ -202,4 +208,63 @@
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>eyqs</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41781.6927.63641</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1492012150.54</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<title>OfficeJS Chat</title> <title>OfficeJS Chat</title>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<script src="handlebars.js"></script> <script src="handlebars.js"></script>
<script src="gadget_global.js"></script> <script src="gadget_global.js"></script>
<script src="gadget_erp5_page_chat_box.js"></script> <script src="gadget_erp5_page_chat_box.js"></script>
......
...@@ -147,6 +147,12 @@ ...@@ -147,6 +147,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -206,4 +212,63 @@ ...@@ -206,4 +212,63 @@
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>eyqs</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41714.1894.49698</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1492008152.15</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -237,7 +237,7 @@ ...@@ -237,7 +237,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41680.17002.58555</string> </value> <value> <string>958.41791.24067.34747</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492006100.28</float> <float>1492013661.62</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -142,6 +142,12 @@ ...@@ -142,6 +142,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent> <persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value> </value>
</item> </item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -201,4 +207,63 @@ ...@@ -201,4 +207,63 @@
</tuple> </tuple>
</pickle> </pickle>
</record> </record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>eyqs</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41727.25173.10461</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1492008933.86</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -11,59 +11,18 @@ ...@@ -11,59 +11,18 @@
*/ */
/* Store the given connection settings.
* Parameters: all from the connect form,
* - user_email: an email, which acts as a username, example: eugene@abc.xyz
* - default_jio_type: the type of storage to select by default
* for sharing chat messages, example: erp5
* - default_erp5_url: the ERP5 URL to select by default, example:
* https://softinst75770.host.vifib.net/erp5/web_site_module/hateoas
* - default_dav_url: the WebDAV URL to select by default for sharing,
* example: https://softinst75722.host.vifib.net/share
* Effects:
* - setSetting: user_email, default_jio_type,
* default_erp5_url, default_dav_url
* - redirect to the front page
*/
function setConnectConfiguration(gadget, event) {
var i, field, queue = new RSVP.Queue(),
fields = ["user_email", "default_jio_type",
"default_erp5_url", "default_dav_url"],
callSetting = function (setting) {
return function () {
return gadget.setSetting(setting, event.target[setting].value);
};
};
// must call setSetting synchronously; RSVP.all causes race conditions
for (i = 0; i < fields.length; i += 1) {
field = fields[i];
if (event.target.hasOwnProperty(field) && event.target[field].value) {
queue.push(callSetting(field));
}
}
return queue
.push(function () {
return gadget.redirect();
});
}
rJS(window) rJS(window)
// Neither state to set nor ready to initialize. // Neither state to set nor ready to initialize.
// The following functions are all acquired from erp5_page_launcher. // The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
/* Render the gadget. // Update header, page_title to "Connect to Chat".
* Effects: update header, page_title to "Connect to Chat"
*/
.declareMethod("render", function () { .declareMethod("render", function () {
var gadget = this; var gadget = this;
...@@ -74,6 +33,46 @@ ...@@ -74,6 +33,46 @@
}) })
/* Store the given connection settings.
* Parameters: all from the connect form,
* - user_email: an email, which acts as a username, example: eyqs@abc.xyz
* - default_jio_type: the type of storage to select by default
* for sharing chat messages, example: erp5
* - default_erp5_url: the ERP5 URL to select by default, example:
* https://softinst75770.host.vifib.net/erp5/web_site_module/hateoas
* - default_dav_url: the WebDAV URL to select by default, example:
* https://softinst75722.host.vifib.net/share
* Effects:
* - setSetting: user_email, default_jio_type,
* default_erp5_url, default_dav_url
* - redirect to the front page
*/
.declareMethod("setConnectConfiguration", function (event) {
var i, field, gadget = this,
queue = new RSVP.Queue(),
fields = ["user_email", "default_jio_type",
"default_erp5_url", "default_dav_url"],
callSetting = function (setting) {
return function () {
return gadget.setSetting(setting, event.target[setting].value);
};
};
// must call setSetting synchronously; RSVP.all causes race conditions
for (i = 0; i < fields.length; i += 1) {
field = fields[i];
if (event.target.hasOwnProperty(field) && event.target[field].value) {
queue.push(callSetting(field));
}
}
return queue
.push(function () {
return gadget.redirect({command: "display"});
});
})
/* Manually click submit button when the right button is clicked, /* Manually click submit button when the right button is clicked,
* so that HTML5 form validation is automatically used. * so that HTML5 form validation is automatically used.
*/ */
...@@ -87,7 +86,7 @@ ...@@ -87,7 +86,7 @@
.onEvent("submit", function (event) { .onEvent("submit", function (event) {
var gadget = this; var gadget = this;
return setConnectConfiguration(gadget, event); return gadget.setConnectConfiguration(event);
}); });
}(window, RSVP, rJS)); }(window, RSVP, rJS));
\ No newline at end of file
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41616.27300.46916</string> </value> <value> <string>958.41780.54327.47889</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492002551.39</float> <float>1492012847.47</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41673.52064.42257</string> </value> <value> <string>958.41805.52664.20462</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492005762.42</float> <float>1492013630.58</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/* global window, RSVP, rJS, btoa */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/* jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */ /*global window, RSVP, rJS, btoa */
(function (window, RSVP, rJS, btoa) { (function (window, RSVP, rJS, btoa) {
'use strict'; "use strict";
/* Settings required: /* Settings used:
* - jio_general_query * - jio_query, default: ""
* - user_email, or be redirected * - indexeddb_database_name, default: "officejs"
* Settings used:
* - connect_page, default: ''
* - indexeddb_database_name, default: 'jio'
* Settings modified: * Settings modified:
* - jio_storage_name, to: 'dav' * - jio_storage_name, to: "dav"
* - jio_storage_description * - jio_storage_description
* - redirect_after_reload, to: {command: 'display', options: {page: 'sync'}} * - redirect_after_reload, to: {command: "display", options: {page: "sync"}}
*/ */
/* Generate a generic jIO configuration for WebDAV storage
* Parameters:
* - dav_url: the WebDAV URL from the configuration form,
* example: https://softinst75722.host.vifib.net/share
* - dav_user: the WebDAV username, example: eyqs
* - dav_pass: the WebDAV password, example: correct horse battery staple
* - get setting: jio_general_query, indexeddb_database_name
* Effects:
* - set setting:
* jio_storage_name, jio_storage_description, redirect_after_reload
* - reload, then redirect to sync
*/
function setDavConfiguration(gadget, event) {
return new RSVP.Queue()
.push(function () {
return gadget.setSetting('jio_storage_name', 'dav');
})
.push(function () {
return RSVP.all([
gadget.getSetting('jio_general_query'),
gadget.getSetting('indexeddb_database_name', 'jio'),
]);
})
.push(function (setting_list) {
const dav_url = event.target.dav_url.value;
const dav_user = event.target.dav_user.value;
const dav_pass = event.target.dav_pass.value;
const configuration = {
type: 'replicate',
query: {
query: setting_list[0],
limit: [0, 16777215],
},
use_remote_post: true,
conflict_handling: 2,
check_local_deletion: false,
local_sub_storage: {
type: 'query',
sub_storage: {
type: 'uuid',
sub_storage: {
type: 'indexeddb',
database: setting_list[1],
},
},
},
remote_sub_storage: {
type: 'query',
sub_storage: {
type: 'drivetojiomapping',
sub_storage: {
type: 'dav',
url: dav_url,
basic_login: btoa(dav_user + ':' + dav_pass),
with_credentials: true,
},
},
},
};
return gadget.setSetting('jio_storage_description', configuration);
})
.push(function () {
return gadget.setSetting('redirect_after_reload', {
command: 'display',
options: {page: 'sync'},
});
})
.push(function () {
return gadget.reload();
})
}
rJS(window) rJS(window)
// Neither state to set nor ready to initialize // Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js // The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect') .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('reload', 'reload') .declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod('setSetting', 'setSetting') .declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod('requireSetting', 'requireSetting')
/* Render the gadget /* Render the gadget
* Parameters: * Parameters:
* - get setting: jio_storage_name, jio_storage_description, user_email * - getSetting: jio_storage_name, jio_storage_description
* Effects: * Effects:
* - update header, page title to 'Configure WebDAV Storage' * - updateHeader: "Configure WebDAV Storage"
* - hide document_configurator gadget based on jio_storage_name * - hide document_configurator gadget based on jio_storage_name
* - pre-fill input field if jio_storage_description already defined * - pre-fill input field if jio_storage_description already defined
* - redirect if user not logged in
*/ */
.declareMethod('render', function () {
const gadget = this; .declareMethod("render", function () {
return new RSVP.Queue() var gadget = this;
return gadget.updateHeader({
page_title: "Configure WebDAV Storage",
back_url: "#!display?n.page=jio_configurator"
})
.push(function () { .push(function () {
return gadget.getSetting('connect_page', 'none'); return gadget.getSetting("jio_storage_name");
}) })
.push(function (connect_page) { .push(function (storage_name) {
return gadget.requireSetting( if (storage_name === "dav") {
'user_email', return gadget.getSetting("jio_storage_description")
connect_page, .push(function (configuration) {
new RSVP.Queue() gadget.element.querySelector("input[name='dav_url']")
.push(function () { .value = configuration.remote_sub_storage
return gadget.updateHeader({ .sub_storage.sub_storage.url;
page_title: 'Configure WebDAV Storage', });
back_url: '#!display?n.page=jio_configurator', }
}); gadget.element.querySelector("div[data-gadget-scope="
}) + "document_configurator").style.display = "none";
.push(function () { });
return gadget.getSetting('jio_storage_name', 'none'); })
})
.push(function (storage_name) {
if (storage_name === 'dav') { /* Generate a generic jIO configuration for WebDAV storage.
return new RSVP.Queue() * Parameters:
.push(function () { * - dav_url: the WebDAV URL from the configuration form,
return gadget.getSetting('jio_storage_description'); * example: https://softinst75722.host.vifib.net/share
}) * - dav_user: the WebDAV username, example: eyqs
.push(function (configuration) { * - dav_pass: the WebDAV password, example: correct horse battery staple
gadget.element.querySelector('input[name="dav_url"]') * - getSetting: jio_query, indexeddb_database_name
.value = configuration.remote_sub_storage * Effects:
.sub_storage.sub_storage.url; * - setSetting:
return; * jio_storage_name, jio_storage_description, redirect_after_reload
}); * - reload, then redirect to sync
} else { */
gadget.element.querySelector('div[data-gadget-scope='
+ 'document_configurator').style.display = 'none'; .declareMethod("setDavConfiguration", function (event) {
var gadget = this;
return gadget.setSetting("jio_storage_name", "dav")
.push(function () {
return RSVP.all([
gadget.getSetting("jio_query", ""),
gadget.getSetting("indexeddb_database_name", "officejs")
]);
})
.push(function (setting_list) {
var dav_url = event.target.dav_url.value,
dav_user = event.target.dav_user.value,
dav_pass = event.target.dav_pass.value,
configuration = {
type: "replicate",
query: {
query: setting_list[0],
limit: [0, 16777215]
},
use_remote_post: true,
conflict_handling: 2,
check_local_deletion: false,
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: setting_list[1]
}
} }
return; },
}) remote_sub_storage: {
); type: "query",
sub_storage: {
type: "drivetojiomapping",
sub_storage: {
type: "dav",
url: dav_url,
basic_login: btoa(dav_user + ":" + dav_pass),
with_credentials: true
}
}
}
};
return gadget.setSetting("jio_storage_description", configuration);
})
.push(function () {
return gadget.setSetting("redirect_after_reload", {
command: "display",
options: {page: "sync"}
});
})
.push(function () {
return gadget.reload();
}); });
}) })
// Call setDavConfiguration when the form is submitted // Call setDavConfiguration when the form is submitted
.onEvent('submit', function (event) {
const gadget = this; .onEvent("submit", function (event) {
return setDavConfiguration(gadget, event); var gadget = this;
return gadget.setDavConfiguration(event);
}); });
}(window, RSVP, rJS, btoa)); }(window, RSVP, rJS, btoa));
\ No newline at end of file
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41431.40897.24064</string> </value> <value> <string>958.41793.3712.46284</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1491999885.02</float> <float>1492013640.63</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/* global window, RSVP, rJS */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/* jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */ /*global window, RSVP, rJS */
(function (window, RSVP, rJS) { (function (window, RSVP, rJS) {
'use strict'; "use strict";
/* Settings required: /* Settings used:
* - either erp5_jio_query or jio_general_query * - jio_query, default: ""
* - user_email, or be redirected * - indexeddb_database_name, default: "officejs"
* Settings used:
* - connect_page, default: ''
* - indexeddb_database_name, default: 'jio'
* Settings modified: * Settings modified:
* - jio_storage_name, to: 'erp5' * - jio_storage_name, to: "erp5"
* - jio_storage_description * - jio_storage_description
* - redirect_after_reload, to: {command: 'display', options: {page: 'sync'}} * - redirect_after_reload, to: {command: "display", options: {page: "sync"}}
*/ */
/* Generate a generic jIO configuration for ERP5 storage
* Parameters:
* - erp5_url: the ERP5 URL from the configuration form,
* example: https://softinst75770.host.vifib.net/web_page_module/
* - get setting: jio_erp5_query, jio_general_query, indexeddb_database_name
* Effects:
* - set setting:
* jio_storage_name, jio_storage_description, redirect_after_reload
* - reload, then redirect to sync
*/
function setErp5Configuration(gadget, event) {
return new RSVP.Queue()
.push(function () {
return gadget.setSetting('jio_storage_name', 'erp5');
})
.push(function () {
return gadget.getSetting('jio_general_query', 'none');
})
.push(function (general_query) {
if (general_query === 'none') {
general_query = null;
}
return RSVP.all([
gadget.getSetting('jio_erp5_query', general_query),
gadget.getSetting('indexeddb_database_name', 'jio'),
]);
})
.push(function (setting_list) {
const erp5_url = event.target.erp5_url.value;
const configuration = {
type: 'replicate',
query: {
query: setting_list[0],
limit: [0, 16777215],
},
use_remote_post: true,
conflict_handling: 2,
check_local_deletion: false,
local_sub_storage: {
type: 'query',
sub_storage: {
type: 'uuid',
sub_storage: {
type: 'indexeddb',
database: setting_list[1],
},
},
},
remote_sub_storage: {
type: 'erp5',
url: erp5_url,
default_view_reference: 'jio_view',
},
};
return gadget.setSetting('jio_storage_description', configuration);
})
.push(function () {
return gadget.setSetting('redirect_after_reload', {
command: 'display',
options: {page: 'sync'},
});
})
.push(function () {
return gadget.reload();
})
}
rJS(window) rJS(window)
// Neither state to set nor ready to initialize // Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js // The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect') .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('reload', 'reload') .declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod('setSetting', 'setSetting') .declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod('getSetting', 'getSetting') .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod('requireSetting', 'requireSetting')
/* Render the gadget /* Render the gadget.
* Parameters: * Parameters:
* - get setting: jio_storage_name, jio_storage_description, user_email * - getSetting: jio_storage_name, jio_storage_description
* Effects: * Effects:
* - update header, page title to 'Configure ERP5 Storage' * - updateHeader: "Configure ERP5 Storage"
* - hide document_configurator gadget based on jio_storage_name * - hide document_configurator gadget based on jio_storage_name
* - pre-fill input field if jio_storage_description already defined * - pre-fill input field if jio_storage_description already defined
* - redirect if user not logged in
*/ */
.declareMethod('render', function () {
const gadget = this; .declareMethod("render", function () {
return new RSVP.Queue() var gadget = this;
return gadget.updateHeader({
page_title: "Configure ERP5 Storage",
back_url: "#!display?n.page=jio_configurator"
})
.push(function () { .push(function () {
return gadget.getSetting('connect_page', 'none'); return gadget.getSetting("jio_storage_name");
}) })
.push(function (connect_page) { .push(function (storage_name) {
return gadget.requireSetting( if (storage_name === "erp5") {
'user_email', return gadget.getSetting("jio_storage_description")
connect_page, .push(function (configuration) {
new RSVP.Queue() gadget.element.querySelector("input[name='erp5_url']")
.push(function () { .value = configuration.remote_sub_storage.url;
return gadget.updateHeader({ });
page_title: 'Configure ERP5 Storage', }
back_url: '#!display?n.page=jio_configurator', gadget.element.querySelector("div[data-gadget-scope="
}); + "document_configurator").style.display = "none";
}) });
.push(function () { })
return gadget.getSetting('jio_storage_name', 'none');
})
.push(function (storage_name) { /* Generate a generic jIO configuration for ERP5 storage.
if (storage_name === 'erp5') { * Parameters:
return new RSVP.Queue() * - erp5_url: the ERP5 URL from the configuration form,
.push(function () { * example: https://softinst75770.host.vifib.net/web_page_module/
return gadget.getSetting('jio_storage_description'); * - getSetting: jio_query, indexeddb_database_name
}) * Effects:
.push(function (configuration) { * - setSetting:
gadget.element.querySelector('input[name="erp5_url"]') * jio_storage_name, jio_storage_description, redirect_after_reload
.value = configuration.remote_sub_storage.url; * - reload, then redirect to sync
return; */
});
} else { .declareMethod("setErp5Configuration", function (event) {
gadget.element.querySelector('div[data-gadget-scope=' var gadget = this;
+ 'document_configurator').style.display = 'none'; return gadget.setSetting("jio_storage_name", "erp5")
.push(function () {
return RSVP.all([
gadget.getSetting("jio_query", ""),
gadget.getSetting("indexeddb_database_name", "officejs")
]);
})
.push(function (setting_list) {
var erp5_url = event.target.erp5_url.value,
configuration = {
type: "replicate",
query: {
query: setting_list[0],
limit: [0, 16777215]
},
use_remote_post: true,
conflict_handling: 2,
check_local_deletion: false,
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: setting_list[1]
}
} }
return; },
}) remote_sub_storage: {
); type: "erp5",
url: erp5_url,
default_view_reference: "jio_view"
}
};
return gadget.setSetting("jio_storage_description", configuration);
})
.push(function () {
return gadget.setSetting("redirect_after_reload", {
command: "display",
options: {page: "sync"}
});
})
.push(function () {
return gadget.reload();
}); });
}) })
// Call setErp5Configuration when the form is submitted // Call setErp5Configuration when the form is submitted
.onEvent('submit', function (event) {
const gadget = this; .onEvent("submit", function (event) {
return setErp5Configuration(gadget, event); var gadget = this;
return gadget.setErp5Configuration(event);
}); });
}(window, RSVP, rJS)); }(window, RSVP, rJS));
\ No newline at end of file
...@@ -232,7 +232,7 @@ ...@@ -232,7 +232,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41431.39363.46114</string> </value> <value> <string>958.41792.65211.10615</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1491999921.03</float> <float>1492013653.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/* global window, RSVP, rJS */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/* jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */ /*global window, rJS */
(function (window, RSVP, rJS) { (function (window, rJS) {
'use strict'; "use strict";
/* Settings required:
* - jio_storage_description, or be redirected
*/
/* Synchronize between the local and remote storages in replicate storage
* Parameters: nothing
* Returns: nothing
* Effects:
* - repair replicate storage
* - redirect to sync
*/
function launchSynchronization(gadget, event) {
return new RSVP.Queue()
.push(function () {
event.target.elements[0].disabled = true;
return gadget.jio_repair();
})
.push(function (result_dict) {
if (result_dict && result_dict.hasOwnProperty('redirect')) {
return gadget.redirect({
command: 'display',
options: {page: result_dict.redirect},
});
} else {
return gadget.redirect();
}
});
}
rJS(window) rJS(window)
// Neither state to set nor ready to initialize // Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js // The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect') .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod('jio_repair', 'jio_repair') .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod('requireSetting', 'requireSetting') .declareAcquiredMethod("jio_repair", "jio_repair")
/* Render the gadget
// updateHeader: "Synchronize".
.declareMethod("render", function () {
var gadget = this;
return gadget.updateHeader({page_title: "Synchronize"});
})
/* Synchronize between the local and remote storages in replicate storage.
* Parameters: * Parameters:
* - get setting: jio_storage_description * - event: the event from the form element, caught by the event listener
* Effects: * Effects:
* - update header, page_title to 'Synchronize' * - repair replicate storage
* - redirect if no jIO storage available * - redirect to the front page
*/ */
.declareMethod('render', function () {
const gadget = this; .declareMethod("launchSynchronization", function (event) {
return gadget.requireSetting( var gadget = this;
'jio_storage_description', event.target.elements[0].disabled = true;
'jio_configurator', return gadget.jio_repair()
new RSVP.Queue() .push(function () {
.push(function () { return gadget.redirect({command: "display"});
return gadget.updateHeader({page_title: 'Synchronize'}); });
})
);
}) })
// Call launchSynchronization when the form is submitted // Call launchSynchronization when the form is submitted
.onEvent('submit', function (event) {
const gadget = this; .onEvent("submit", function (event) {
return launchSynchronization(gadget, event); var gadget = this;
return gadget.launchSynchronization(event);
}); });
}(window, RSVP, rJS)); }(window, rJS));
\ No newline at end of file \ No newline at end of file
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41607.62274.10973</string> </value> <value> <string>958.41780.56818.15274</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492001776.17</float> <float>1492013599.99</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!DOCTYPE html> <!DOCTYPE html>
<html><!-- manifest="${manifest_url}"--> <html><!-- manifest="${manifest_url}"-->
<head> <head>
<!-- all ${parameters} are based on the Layout Configuration in Web Site Module, and are set by /erp5/portal_skins/erp5_web_renderjs_ui/WebSection_renderDefaultPageAsGadget -->
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico"> <link rel="shortcut icon" href="favicon.ico">
...@@ -21,6 +20,8 @@ ...@@ -21,6 +20,8 @@
<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="indexeddb_database_name" type="text/x-renderjs-configuration">officejs-chat</script>
<script data-renderjs-configuration="jio_query" type="text/x-renderjs-configuration">portal_type: "Text Post" OR portal_type: "Person"</script>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>958.41669.34238.56968</string> </value> <value> <string>958.41752.36104.19524</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1492005464.73</float> <float>1492010721.49</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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