Commit 4908fe22 authored by Vincent Bechu's avatar Vincent Bechu

erp5_officjs: add redirect in router for dropbox and fix bookmark

/reviewed-on nexedi/erp5!302
parent 66cfe1e0
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<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">
<title>OfficeJS jIO Dropbox Configurator Page</title> <title>OfficeJS jIO Dropbox Configurator Page</title>
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="gadget_officejs_page_jio_dropbox_configurator.js"></script> <script src="gadget_officejs_page_jio_dropbox_configurator.js"></script>
</head> </head>
<body>
<body> </body>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your Dropbox Connection parameters
</h3>
</section>
<section class="ui-content-header-plain">
<p>Connecting to Dropbox</p>
</section>
</article>
<article class="ui-content ui-body-c document-access">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-file-text-o">&nbsp;</span>
Your Documents
</h3>
</section>
<section class="ui-body-c ui-content-section">
<p style="color: red">Continue by <b>synchronizing</b> with your remote storage or <b>accessing</b> your documents</p>
<div class="ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-a ui-responsive">
<div class="ui-block-a">
<a class="ui-btn" href="#page=sync" data-i18n="Synchronize">Synchronize</a>
</div>
<div class="ui-block-b">
<a class="ui-btn" href="#page=document_list" data-i18n="Go to document List">Access document List</a>
</div>
</div>
</div>
</section>
</article>
<div class="global_setting_gadget" style="display: none;"></div>
</body>
</html> </html>
\ 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>956.64672.3552.2918</string> </value> <value> <string>958.24259.25538.21094</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>1485780527.48</float> <float>1498039956.08</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP, URI, location, /*global window, rJS, RSVP, URI, location,
loopEventListener, btoa */ loopEventListener, btoa */
/*jslint nomen: true, indent: 2, maxerr: 3*/ /*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, console) {
"use strict"; "use strict";
function setDropboxConfiguration(gadget) { function setDropboxConfiguration(gadget) {
return gadget.getSetting("portal_type") return gadget.getSetting("portal_type")
.push(function (portal_type) { .push(function (portal_type) {
var old_date = new Date(), var old_date = new Date(),
configuration = {}; configuration = {};
// We are looking for documents modified in the past 3 month // We are looking for documents modified in the past 3 month
old_date = new Date(old_date.getFullYear(), old_date.getMonth() - 3); old_date = new Date(old_date.getFullYear(), old_date.getMonth() - 3);
configuration = { configuration = {
type: "replicate", type: "replicate",
// XXX This drop the signature lists... // XXX This drop the signature lists...
query: { query: {
query: 'portal_type:"' + portal_type + '" ', query: 'portal_type:"' + portal_type + '" ',
// XX Synchonizing the whole module is too much, here is a way to start quietly // XX Synchonizing the whole module is too much, here is a way to start quietly
// Supsended until modification_date is handled for synchronization // Supsended until modification_date is handled for synchronization
limit: [0, 1234567890] limit: [0, 1234567890]
}, },
use_remote_post: false, use_remote_post: false,
conflict_handling: 2, conflict_handling: 2,
check_local_modification: true, check_local_modification: true,
check_local_creation: true, check_local_creation: true,
check_local_deletion: false, check_local_deletion: false,
check_remote_modification: true, check_remote_modification: true,
check_remote_creation: true, check_remote_creation: true,
check_remote_deletion: true, check_remote_deletion: true,
local_sub_storage: { local_sub_storage: {
type: "mapping", type: "mapping",
attachment: { attachment: {
'data': { 'data': {
get: {uri_template: 'enclosure'}, get: {uri_template: 'enclosure'},
put: {uri_template: 'enclosure'} put: {uri_template: 'enclosure'}
} }
}, },
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
type: "uuid", type: "uuid",
sub_storage: { sub_storage: {
type: "indexeddb", type: "indexeddb",
database: "officejs-dropbox" database: "officejs-dropbox"
} }
} }
} }
}, },
remote_sub_storage: { remote_sub_storage: {
type: "mapping", type: "mapping",
attachment: { attachment: {
'data': { 'data': {
get: {uri_template: 'enclosure'}, get: {uri_template: 'enclosure'},
put: {uri_template: 'enclosure'} put: {uri_template: 'enclosure'}
} }
}, },
mapping_dict: { mapping_dict: {
"portal_type": ["equalSubProperty", "type"] "portal_type": ["equalSubProperty", "type"]
}, },
sub_storage: { sub_storage: {
type: "query", type: "query",
sub_storage: { sub_storage: {
type: "drivetojiomapping", type: "drivetojiomapping",
sub_storage: { sub_storage: {
type: "dropbox", type: "dropbox",
access_token: gadget.props.access_token, access_token: gadget.props.access_token,
root: "sandbox" root: "sandbox"
} }
} }
} }
} }
}; };
return gadget.setSetting('jio_storage_description', configuration); return gadget.setSetting('jio_storage_description', configuration);
}) })
.push(function () { .push(function () {
return gadget.setSetting('jio_storage_name', "DROPBOX"); return gadget.setSetting('jio_storage_name', "DROPBOX");
}) })
.push(function () { .push(function () {
return gadget.setSetting('sync_reload', true); return gadget.setSetting('sync_reload', true);
}) })
.push(function () { .push(function () {
return gadget.redirect({page: 'sync', auto_repair: 'true'}); return gadget.redirect({page: 'sync', auto_repair: 'true'});
}); });
} }
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
gadget_klass gadget_klass
.ready(function (g) { .ready(function (g) {
g.props = {}; g.props = {};
return g.getElement() return g.getElement()
.push(function (element) { .push(function (element) {
g.props.element = element; g.props.element = element;
g.props.deferred = RSVP.defer(); g.props.deferred = RSVP.defer();
}); });
}) })
.declareAcquiredMethod("updateHeader", "updateHeader") .declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect") .declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload") .declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting") .declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting") .declareAcquiredMethod("setSetting", "setSetting")
.declareMethod("getGlobalSetting", function (key) { .declareMethod("render", function (options) {
var gadget = this; var gadget = this;
return gadget.getDeclaredGadget("global_setting_gadget") return gadget.updateHeader({
.push(function (global_setting_gadget) { title: "Connect To Drobox Storage",
return global_setting_gadget.getSetting(key); back_url: "#page=jio_configurator",
}); panel_action: false
}) })
.declareMethod("setGlobalSetting", function (key, value) { .push(function () {
var gadget = this; gadget.props.access_token = options.token;
return gadget.getDeclaredGadget("global_setting_gadget") return gadget.props.deferred.resolve();
.push(function (global_setting_gadget) { });
return global_setting_gadget.setSetting(key, value); })
}); .declareService(function () {
}) var gadget = this;
.declareMethod("render", function (options) { return setDropboxConfiguration(gadget);
var gadget = this; });
return gadget.updateHeader({
title: "Connect To Drobox Storage", }(window, rJS, RSVP, console));
back_url: "#page=jio_configurator", \ No newline at end of file
panel_action: false
})
.push(function (options) {
return gadget.getSetting('jio_storage_name');
})
.push(function (jio_storage_name) {
if (!jio_storage_name) {
gadget.props.element.querySelector(".document-access").setAttribute("style", "display: none;");
}
})
.push(function () {
gadget.props.access_token = options.token;
return setDropboxConfiguration(gadget);
});
});
}(window, rJS, RSVP));
\ 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>956.64671.54901.45909</string> </value> <value> <string>960.12610.20791.23552</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>1485780514.28</float> <float>1498039829.6</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -94,6 +94,19 @@ ...@@ -94,6 +94,19 @@
var gadget = this, var gadget = this,
args = options.args; args = options.args;
gadget.options = options; gadget.options = options;
if (args.access_token) {
if (args.state === "gdrive") {
args.page = "jio_gdrive_configurator";
} else {
args.page = "jio_dropbox_configurator";
}
return this.getCommandUrlFor({"page": args.page,
"token": args.access_token})
.push(function (hash) {
window.location.replace(hash);
return RSVP.timeout(REDIRECT_TIMEOUT);
});
}
if (args.jio_key === undefined || args.jio_key === '') { if (args.jio_key === undefined || args.jio_key === '') {
if (args.page === undefined || args.page === '' || args.page === "document_list") { if (args.page === undefined || args.page === '' || args.page === "document_list") {
args.page = DEFAULT_PAGE; args.page = DEFAULT_PAGE;
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>957.15167.59077.43741</string> </value> <value> <string>960.12474.59711.2781</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>1486742528.7</float> <float>1498033186.77</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