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 @@
<title>>Chat Room Gadget</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<script src="handlebars.js"></script>
<script src="jio_mappingstorage.js"></script>
<script src="gadget_erp5_chat_room.js"></script>
<script class="connect-form-template" type="text/x-handlebars-template">
<label>
......
......@@ -147,6 +147,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -206,4 +212,63 @@
</tuple>
</pickle>
</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>
......@@ -8,11 +8,12 @@
// 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")
// 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_get", "jio_get")
.declareAcquiredMethod("jio_repair", "jio_repair")
......
......@@ -143,6 +143,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -202,4 +208,63 @@
</tuple>
</pickle>
</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>
......@@ -6,7 +6,6 @@
<title>OfficeJS Chat</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_global.js"></script>
<script src="gadget_erp5_page_chat_box.js"></script>
......
......@@ -147,6 +147,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -206,4 +212,63 @@
</tuple>
</pickle>
</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>
......@@ -237,7 +237,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41680.17002.58555</string> </value>
<value> <string>958.41791.24067.34747</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -255,7 +255,7 @@
</tuple>
<state>
<tuple>
<float>1492006100.28</float>
<float>1492013661.62</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -142,6 +142,12 @@
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -201,4 +207,63 @@
</tuple>
</pickle>
</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>
......@@ -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)
// 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("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting")
/* Render the gadget.
* Effects: update header, page_title to "Connect to Chat"
*/
// Update header, page_title to "Connect to Chat".
.declareMethod("render", function () {
var gadget = this;
......@@ -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,
* so that HTML5 form validation is automatically used.
*/
......@@ -87,7 +86,7 @@
.onEvent("submit", function (event) {
var gadget = this;
return setConnectConfiguration(gadget, event);
return gadget.setConnectConfiguration(event);
});
}(window, RSVP, rJS));
\ No newline at end of file
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41616.27300.46916</string> </value>
<value> <string>958.41780.54327.47889</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1492002551.39</float>
<float>1492012847.47</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41673.52064.42257</string> </value>
<value> <string>958.41805.52664.20462</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1492005762.42</float>
<float>1492013630.58</float>
<string>UTC</string>
</tuple>
</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) {
'use strict';
/* Settings required:
* - jio_general_query
* - user_email, or be redirected
* Settings used:
* - connect_page, default: ''
* - indexeddb_database_name, default: 'jio'
"use strict";
/* Settings used:
* - jio_query, default: ""
* - indexeddb_database_name, default: "officejs"
* Settings modified:
* - jio_storage_name, to: 'dav'
* - jio_storage_name, to: "dav"
* - 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)
// Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('reload', 'reload')
.declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('requireSetting', 'requireSetting')
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getSetting", "getSetting")
/* Render the gadget
* Parameters:
* - get setting: jio_storage_name, jio_storage_description, user_email
* - getSetting: jio_storage_name, jio_storage_description
* Effects:
* - update header, page title to 'Configure WebDAV Storage'
* - updateHeader: "Configure WebDAV Storage"
* - hide document_configurator gadget based on jio_storage_name
* - pre-fill input field if jio_storage_description already defined
* - redirect if user not logged in
*/
.declareMethod('render', function () {
const gadget = this;
return new RSVP.Queue()
.declareMethod("render", function () {
var gadget = this;
return gadget.updateHeader({
page_title: "Configure WebDAV Storage",
back_url: "#!display?n.page=jio_configurator"
})
.push(function () {
return gadget.getSetting('connect_page', 'none');
return gadget.getSetting("jio_storage_name");
})
.push(function (connect_page) {
return gadget.requireSetting(
'user_email',
connect_page,
new RSVP.Queue()
.push(function () {
return gadget.updateHeader({
page_title: 'Configure WebDAV Storage',
back_url: '#!display?n.page=jio_configurator',
});
})
.push(function () {
return gadget.getSetting('jio_storage_name', 'none');
})
.push(function (storage_name) {
if (storage_name === 'dav') {
return new RSVP.Queue()
.push(function () {
return gadget.getSetting('jio_storage_description');
})
.push(function (configuration) {
gadget.element.querySelector('input[name="dav_url"]')
.value = configuration.remote_sub_storage
.sub_storage.sub_storage.url;
return;
});
} else {
gadget.element.querySelector('div[data-gadget-scope='
+ 'document_configurator').style.display = 'none';
.push(function (storage_name) {
if (storage_name === "dav") {
return gadget.getSetting("jio_storage_description")
.push(function (configuration) {
gadget.element.querySelector("input[name='dav_url']")
.value = configuration.remote_sub_storage
.sub_storage.sub_storage.url;
});
}
gadget.element.querySelector("div[data-gadget-scope="
+ "document_configurator").style.display = "none";
});
})
/* 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
* - getSetting: jio_query, indexeddb_database_name
* Effects:
* - setSetting:
* jio_storage_name, jio_storage_description, redirect_after_reload
* - reload, then redirect to sync
*/
.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
.onEvent('submit', function (event) {
const gadget = this;
return setDavConfiguration(gadget, event);
.onEvent("submit", function (event) {
var gadget = this;
return gadget.setDavConfiguration(event);
});
}(window, RSVP, rJS, btoa));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41431.40897.24064</string> </value>
<value> <string>958.41793.3712.46284</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1491999885.02</float>
<float>1492013640.63</float>
<string>UTC</string>
</tuple>
</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) {
'use strict';
/* Settings required:
* - either erp5_jio_query or jio_general_query
* - user_email, or be redirected
* Settings used:
* - connect_page, default: ''
* - indexeddb_database_name, default: 'jio'
"use strict";
/* Settings used:
* - jio_query, default: ""
* - indexeddb_database_name, default: "officejs"
* Settings modified:
* - jio_storage_name, to: 'erp5'
* - jio_storage_name, to: "erp5"
* - 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)
// Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('reload', 'reload')
.declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('requireSetting', 'requireSetting')
/* Render the gadget
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getSetting", "getSetting")
/* Render the gadget.
* Parameters:
* - get setting: jio_storage_name, jio_storage_description, user_email
* - getSetting: jio_storage_name, jio_storage_description
* Effects:
* - update header, page title to 'Configure ERP5 Storage'
* - updateHeader: "Configure ERP5 Storage"
* - hide document_configurator gadget based on jio_storage_name
* - pre-fill input field if jio_storage_description already defined
* - redirect if user not logged in
*/
.declareMethod('render', function () {
const gadget = this;
return new RSVP.Queue()
.declareMethod("render", function () {
var gadget = this;
return gadget.updateHeader({
page_title: "Configure ERP5 Storage",
back_url: "#!display?n.page=jio_configurator"
})
.push(function () {
return gadget.getSetting('connect_page', 'none');
return gadget.getSetting("jio_storage_name");
})
.push(function (connect_page) {
return gadget.requireSetting(
'user_email',
connect_page,
new RSVP.Queue()
.push(function () {
return gadget.updateHeader({
page_title: 'Configure ERP5 Storage',
back_url: '#!display?n.page=jio_configurator',
});
})
.push(function () {
return gadget.getSetting('jio_storage_name', 'none');
})
.push(function (storage_name) {
if (storage_name === 'erp5') {
return new RSVP.Queue()
.push(function () {
return gadget.getSetting('jio_storage_description');
})
.push(function (configuration) {
gadget.element.querySelector('input[name="erp5_url"]')
.value = configuration.remote_sub_storage.url;
return;
});
} else {
gadget.element.querySelector('div[data-gadget-scope='
+ 'document_configurator').style.display = 'none';
.push(function (storage_name) {
if (storage_name === "erp5") {
return gadget.getSetting("jio_storage_description")
.push(function (configuration) {
gadget.element.querySelector("input[name='erp5_url']")
.value = configuration.remote_sub_storage.url;
});
}
gadget.element.querySelector("div[data-gadget-scope="
+ "document_configurator").style.display = "none";
});
})
/* 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/
* - getSetting: jio_query, indexeddb_database_name
* Effects:
* - setSetting:
* jio_storage_name, jio_storage_description, redirect_after_reload
* - reload, then redirect to sync
*/
.declareMethod("setErp5Configuration", function (event) {
var gadget = this;
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
.onEvent('submit', function (event) {
const gadget = this;
return setErp5Configuration(gadget, event);
.onEvent("submit", function (event) {
var gadget = this;
return gadget.setErp5Configuration(event);
});
}(window, RSVP, rJS));
\ No newline at end of file
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41431.39363.46114</string> </value>
<value> <string>958.41792.65211.10615</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1491999921.03</float>
<float>1492013653.71</float>
<string>UTC</string>
</tuple>
</state>
......
/* global window, RSVP, rJS */
/* jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
(function (window, RSVP, rJS) {
'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();
}
});
}
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global window, rJS */
(function (window, rJS) {
"use strict";
rJS(window)
// Neither state to set nor ready to initialize
// The following functions are all acquired from erp5_launcher_nojqm.js
.declareAcquiredMethod('updateHeader', 'updateHeader')
.declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('jio_repair', 'jio_repair')
.declareAcquiredMethod('requireSetting', 'requireSetting')
/* Render the gadget
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_repair", "jio_repair")
// 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:
* - get setting: jio_storage_description
* - event: the event from the form element, caught by the event listener
* Effects:
* - update header, page_title to 'Synchronize'
* - redirect if no jIO storage available
* - repair replicate storage
* - redirect to the front page
*/
.declareMethod('render', function () {
const gadget = this;
return gadget.requireSetting(
'jio_storage_description',
'jio_configurator',
new RSVP.Queue()
.push(function () {
return gadget.updateHeader({page_title: 'Synchronize'});
})
);
.declareMethod("launchSynchronization", function (event) {
var gadget = this;
event.target.elements[0].disabled = true;
return gadget.jio_repair()
.push(function () {
return gadget.redirect({command: "display"});
});
})
// Call launchSynchronization when the form is submitted
.onEvent('submit', function (event) {
const gadget = this;
return launchSynchronization(gadget, event);
.onEvent("submit", function (event) {
var gadget = this;
return gadget.launchSynchronization(event);
});
}(window, RSVP, rJS));
\ No newline at end of file
}(window, rJS));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41607.62274.10973</string> </value>
<value> <string>958.41780.56818.15274</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1492001776.17</float>
<float>1492013599.99</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html><!-- manifest="${manifest_url}"-->
<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 name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico">
......@@ -21,6 +20,8 @@
<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="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="renderjs.js"></script>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.41669.34238.56968</string> </value>
<value> <string>958.41752.36104.19524</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1492005464.73</float>
<float>1492010721.49</float>
<string>UTC</string>
</tuple>
</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