Commit 324e20ff authored by Sebastian's avatar Sebastian

Finish replicating normal web-app setup (without UI)

parent e16082c8
...@@ -7,9 +7,25 @@ ...@@ -7,9 +7,25 @@
rJS(window) rJS(window)
.ready(function (gadget) { .ready(function (gadget) {
console.log("Jio Contents Gadget yes yes.") console.log("Jio Contents Gadget yes yes.");
return gadget; return gadget;
}); })
.declareMethod('render', function (options) {
console.log("Rendering jio CONTENTS");
this.jio_allDocs({
query: 'portal_type: "Web JSON"',
select_list : ['text_content', 'title', 'reference'], //, 'modification_date'], NOT WORKING
// sort_on: [["modification_date", "descending"]], // NOT WORKING
limit: [0, 5]
})
.push(function(result) {
console.log("Querying Web JSON List");
console.log(result.data.rows);
}, function(err) {
console.log(err);
});
})
.declareAcquiredMethod("jio_allDocs", "jio_allDocs");
}(window, rJS)); }(window, rJS));
...@@ -2,20 +2,6 @@ ...@@ -2,20 +2,6 @@
<html> <html>
<head> <head>
<!--
<script data-renderjs-configuration="application_title" type="text/x-renderjs-configuration">ERP5</script>
<script data-renderjs-configuration="panel_gadget" type="text/x-renderjs-configuration">gadget_erp5_panel.html</script>
<script data-renderjs-configuration="action_view" type="text/x-renderjs-configuration">object_view</script>
<script data-renderjs-configuration="default_view_reference" type="text/x-renderjs-configuration">notebook_jio_view</script>
<script data-renderjs-configuration="hateoas_url" type="text/x-renderjs-configuration">hateoas/</script>
<script data-renderjs-configuration="frontpage_gadget" type="text/x-renderjs-configuration">jupytertest</script>
<script data-renderjs-configuration="jio_document_page_gadget" type="text/x-renderjs-configuration">form</script>
<script data-renderjs-configuration="language_map" type="text/x-renderjs-configuration">{"en": "English"}</script>
<script data-renderjs-configuration="default_selected_language" type="text/x-renderjs-configuration">en</script>
<script data-renderjs-configuration="website_url_set" type="text/x-renderjs-configuration">{"en": "http://softinst86155.host.vifib.net/erp5/web_site_module/renderjs_runner/"}</script>
<script data-renderjs-configuration="service_worker_url" type="text/x-renderjs-configuration"></script>
-->
<script src="rsvp.js"></script> <script src="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
<script src="gadget_jupyter_page.js"></script> <script src="gadget_jupyter_page.js"></script>
...@@ -23,10 +9,22 @@ ...@@ -23,10 +9,22 @@
</head> </head>
<body> <body>
<script data-renderjs-configuration="application_title" type="text/x-renderjs-configuration">ERP5</script>
<script data-renderjs-configuration="action_view" type="text/x-renderjs-configuration">object_view</script>
<script data-renderjs-configuration="default_view_reference" type="text/x-renderjs-configuration">notebook_jio_view</script>
<script data-renderjs-configuration="hateoas_url" type="text/x-renderjs-configuration">hateoas/</script>
<div data-gadget-url="gadget_jio.html"
data-gadget-scope="setting_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_erp5_jio.html" <div data-gadget-url="gadget_erp5_jio.html"
data-gadget-scope="jio_gadget" data-gadget-scope="jio_gadget"
data-gadget-sandbox="public"></div> data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_jiocontents.html"
data-gadget-scope="jiocontents_gadget"
data-gadget-sandbox="public"></div>
<div>Hello renderJS + Jupyter</div> <div>Hello renderJS + Jupyter</div>
......
...@@ -5,10 +5,166 @@ ...@@ -5,10 +5,166 @@
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
// SNIP // SNIP
function callJioGadget(gadget, method, param_list) {
var called = false;
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget[method].apply(jio_gadget, param_list);
});
}
gadget_klass gadget_klass
.ready(function() { .ready(function() {
console.log("Hello ready!"); console.log("Hello ready!");
var gadget = this,
setting_gadget,
setting;
this.props = {
};
// Configure setting storage
return gadget.getDeclaredGadget("setting_gadget")
.push(function (result) {
setting_gadget = result;
return setting_gadget.createJio({
type: "indexeddb",
database: "setting"
});
})
.push(function () {
return setting_gadget.get("setting")
.push(undefined, function (error) {
if (error.status_code === 404) {
return {};
}
throw error;
});
})
.push(function (result) {
setting = result;
// Extract configuration parameters stored in HTML
// XXX Will work only if top gadget...
var gadget_cont = document.querySelector(".gadget-jupyter-page-container");
var element_list =
gadget_cont
.querySelectorAll("script[data-renderjs-configuration]"),
len = element_list.length,
key,
value,
i;
for (i = 0; i < len; i += 1) {
key = element_list[i].getAttribute('data-renderjs-configuration');
value = element_list[i].textContent;
gadget.props[key] = value;
setting[key] = value;
}
// Calculate erp5 hateoas url
setting.hateoas_url = (new URI(gadget.props.hateoas_url))
.absoluteTo(location.href)
.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);
})
.push(function () {
// Configure jIO storage
return gadget.getDeclaredGadget("jio_gadget");
})
.push(function (jio_gadget) {
return jio_gadget.createJio(setting.jio_storage_description);
})
.push(function() {
return gadget.getDeclaredGadget("jiocontents_gadget");
})
.push(function(jiocontents_gadget) {
jiocontents_gadget.render({});
});
})
.allowPublicAcquisition("getSetting", function (argument_list) {
var gadget = this,
key = argument_list[0],
default_value = argument_list[1];
return gadget.getDeclaredGadget("setting_gadget")
.push(function (jio_gadget) {
return jio_gadget.get("setting");
})
.push(function (doc) {
return doc[key] || default_value;
}, function (error) {
if (error.status_code === 404) {
return default_value;
}
throw error;
});
})
.allowPublicAcquisition("setSetting", function (argument_list) {
var jio_gadget,
gadget = this,
key = argument_list[0],
value = argument_list[1];
return gadget.getDeclaredGadget("setting_gadget")
.push(function (result) {
jio_gadget = result;
return jio_gadget.get("setting");
})
.push(undefined, function (error) {
if (error.status_code === 404) {
return {};
}
throw error;
})
.push(function (doc) {
doc[key] = value;
return jio_gadget.put('setting', doc);
});
})
.allowPublicAcquisition("jio_allDocs", function (param_list) {
return callJioGadget(this, "allDocs", param_list);
})
.allowPublicAcquisition("jio_remove", function (param_list) {
return callJioGadget(this, "remove", param_list);
})
.allowPublicAcquisition("jio_post", function (param_list) {
return callJioGadget(this, "post", param_list);
})
.allowPublicAcquisition("jio_put", function (param_list) {
return callJioGadget(this, "put", param_list);
})
.allowPublicAcquisition("jio_get", function (param_list) {
return callJioGadget(this, "get", param_list);
})
.allowPublicAcquisition("jio_allAttachments", function (param_list) {
return callJioGadget(this, "allAttachments", param_list);
})
.allowPublicAcquisition("jio_getAttachment", function (param_list) {
return callJioGadget(this, "getAttachment", param_list);
})
.allowPublicAcquisition("jio_putAttachment", function (param_list) {
return callJioGadget(this, "putAttachment", param_list);
})
.allowPublicAcquisition("jio_removeAttachment", function (param_list) {
return callJioGadget(this, "removeAttachment", param_list);
})
.allowPublicAcquisition("jio_repair", function (param_list) {
return callJioGadget(this, "repair", param_list);
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP));
\ No newline at end of file
...@@ -12,6 +12,7 @@ define(function(require) { ...@@ -12,6 +12,7 @@ define(function(require) {
var gadget_div = document.createElement("div"); var gadget_div = document.createElement("div");
gadget_div.setAttribute("data-gadget-url", baseUrl + "/gadget_jupyter_page.html"); gadget_div.setAttribute("data-gadget-url", baseUrl + "/gadget_jupyter_page.html");
gadget_div.setAttribute("class", "gadget-jupyter-page-container");
document.body.append(gadget_div); document.body.append(gadget_div);
var s1 = document.createElement("script"); s1.type = "text/javascript"; var s1 = document.createElement("script"); s1.type = "text/javascript";
...@@ -27,45 +28,7 @@ define(function(require) { ...@@ -27,45 +28,7 @@ define(function(require) {
}; };
s1.src = baseUrl + "/rsvp.js"; s1.src = baseUrl + "/rsvp.js";
document.head.append(s1); document.head.append(s1);
/*
var gadget_div = document.createElement("div");
gadget_div.setAttribute("data-gadget-url", "/nbextensions/jiocontents/gadget_jiocontents.html");
document.body.append(gadget_div);
var baseUrl = "https://softinst86155.host.vifib.net/erp5/web_site_module/renderjs_runner";
var s1 = document.createElement("script"); s1.type = "text/javascript";
s1.onload = function() {
console.log("loaded rsvp");
var s2 = document.createElement("script"); s2.type = "text/javascript";
s2.onload = function() {
console.log("loaded renderjs");
rJS.manualBootstrap();
}
s2.src = baseUrl + "/renderjs.js";
document.head.append(s2);
};
s1.src = baseUrl + "/rsvp.js";
document.head.append(s1);
*/
/*
$.getScript(baseUrl + "/rsvp.js", function() {
console.log("~~~ rsvp loaded");
$.getScript(baseUrl + "/renderjs.js", function() {
console.log("~~~ renderjs loaded");
rJS.manualBootstrap();
});
});
$.getScript("/nbextensions/jiocontents/rsvp-2.0.4.min.js", function() {
console.log("~~ loading_gadget: rsvp.js loaded");
$.getScript("/nbextensions/jiocontents/renderjs-latest.js", function() {
console.log("~~ loading_gadget: renderjs.js loaded");
rJS.manualBootstrap();
});
});
*/
var Contents = function(options) { var Contents = function(options) {
/** /**
......
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