Commit de7272f8 authored by Vincent Bechu's avatar Vincent Bechu

[erp5_officejs] Update bootloader to show all errors

Test Pass:

https://nexedijs.erp5.net/#/test_result_module/20170905-1D7D2697?page=form&view=view

/reviewed-on !373
parent 8e84d1da
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
<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">
<link rel="stylesheet" href="gadget_erp5_nojqm.css">
<title> OfficeJS Install </title> <title> OfficeJS Install </title>
<script src="${latest_version}/rsvp.js"></script> <script src="${latest_version}/rsvp.js"></script>
......
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.282.28573.14114</string> </value> <value> <string>961.50636.39446.44697</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1501754635.21</float> <float>1504537605.24</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -45,6 +45,7 @@ var repair = false; ...@@ -45,6 +45,7 @@ var repair = false;
} }
rJS(window) rJS(window)
.setState({error_amount: 0})
.ready(function (gadget) { .ready(function (gadget) {
var i, var i,
state = {}, state = {},
...@@ -73,6 +74,7 @@ var repair = false; ...@@ -73,6 +74,7 @@ var repair = false;
return true; return true;
}) })
.declareAcquiredMethod('isChildren', 'isChildren') .declareAcquiredMethod('isChildren', 'isChildren')
.declareAcquiredMethod('renderError', 'renderError')
.declareService(function () { .declareService(function () {
var gadget = this; var gadget = this;
...@@ -85,7 +87,7 @@ var repair = false; ...@@ -85,7 +87,7 @@ var repair = false;
return RSVP.delay(600); return RSVP.delay(600);
}) })
.push(function () { .push(function () {
return gadget.changeState({retry: 0}); return gadget.changeState({main: true});
}), }),
gadget.install() gadget.install()
.push(function () { .push(function () {
...@@ -97,31 +99,49 @@ var repair = false; ...@@ -97,31 +99,49 @@ var repair = false;
}); });
}) })
.onStateChange(function () { .allowPublicAcquisition('renderError', function (param_list) {
var gadget = this, element; param_list[0].error_amount = this.state.error_amount + 1;
if (gadget.state.retry !== undefined) { return this.changeState(param_list[0]);
return new RSVP.Queue() })
.push(function () {
if (gadget.state.retry === 0) { .declareMethod('render', function (options) {
return this.getDeclaredGadget('view_gadget')
.push(function (view_gadget) {
return view_gadget.render(options);
});
})
.onStateChange(function (modification_dict) {
var gadget = this, element, options;
if (modification_dict.main) {
element = document.createElement("div"); element = document.createElement("div");
element.className = "presentation"; element.className = "presentation";
gadget.element.insertBefore(element, gadget.element.firstChild); gadget.element.insertBefore(element, gadget.element.firstChild);
return gadget.declareGadget( return gadget.declareGadget(
"gadget_officejs_bootloader_presentation.html", "gadget_officejs_bootloader_presentation.html",
{"scope": "view_gadget", "element": element} {"scope": "view_gadget", "element": element}
); )
}
return gadget.getDeclaredGadget('view_gadget');
})
.push(function (view_gadget) { .push(function (view_gadget) {
return view_gadget.render({ return view_gadget.render({
app_name: gadget.state.app_name, app_name: gadget.state.app_name,
retry: gadget.state.retry,
error: gadget.state.error,
redirect_url: gadget.state.redirect_url redirect_url: gadget.state.redirect_url
}); });
}); });
} }
if (modification_dict.error) {
options = {
error: gadget.state.error,
error_amount: gadget.state.error_amount
};
if (modification_dict.error_source) {
options.error_source = gadget.state.error_source;
}
if (gadget.state.main) {
return gadget.render(options);
}
options.error_source = gadget.state.app_name;
return gadget.renderError(options);
}
}) })
.declareMethod('declareAndInstall', function (url) { .declareMethod('declareAndInstall', function (url) {
...@@ -146,8 +166,7 @@ var repair = false; ...@@ -146,8 +166,7 @@ var repair = false;
return storage.repair() return storage.repair()
.push(undefined, function (error) { .push(undefined, function (error) {
return gadget.changeState({ return gadget.changeState({
retry: gadget.state.retry !== undefined ? error_amount: gadget.state.error_amount + 1,
gadget.state.retry + 1 : 0,
error: error error: error
}) })
.push(function () { .push(function () {
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.30792.56927.40004</string> </value> <value> <string>961.57945.44138.39099</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>1504078631.47</float> <float>1504605705.8</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -22,3 +22,6 @@ header{ ...@@ -22,3 +22,6 @@ header{
color: #f8fff3; color: #f8fff3;
padding: 0.6em; padding: 0.6em;
} }
.main {
padding-top: 19%;
}
\ No newline at end of file
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.64508.21399.59801</string> </value> <value> <string>961.57798.64228.15018</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485770670.74</float> <float>1504603901.9</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, user-scalable=no" /> <meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Presentation Install</title> <title>OfficeJS Presentation Install</title>
<link rel="stylesheet" href="gadget_erp5_nojqm.css">
<link rel="stylesheet" href="gadget_officejs_bootloader_presentation.css"> <link rel="stylesheet" href="gadget_officejs_bootloader_presentation.css">
<!-- renderjs --> <!-- renderjs -->
...@@ -16,6 +17,16 @@ ...@@ -16,6 +17,16 @@
</head> </head>
<body> <body>
<center> <center>
<header> OfficeJS Bootloader </header>
<div class="main">
<img src="officejs_logo.png">
<div class="app-name"> Preparing</div>
<div class="loader"></div>
<a class="skip-link" href="#">Skip</a>
<div class="error-message"></div>
<div class="error-source"></div>
<div class="error-amount"></div>
</div>
</center> </center>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>961.16133.53728.41011</string> </value> <value> <string>961.59243.21205.33843</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1502097067.26</float> <float>1504683723.57</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, document*/ /*global window, rJS*/
/*jslint nomen: true, maxlen:80, indent:2*/ /*jslint nomen: true, maxlen:80, indent:2*/
(function (window, rJS, document) { (function (window, rJS) {
"use strict"; "use strict";
rJS(window) rJS(window)
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var element = this.element.querySelector("center"), return this.changeState(options);
img, div, i, header, p, loader, error, skip; })
.onStateChange(function (modification_dict) {
var skip_link, error_div, app_name_div, message,
gadget = this;
header = document.createElement('header'); if (modification_dict.app_name) {
header.textContent = "OfficeJS Installer"; app_name_div = gadget.element.querySelector(".app-name");
element.appendChild(header); app_name_div.textContent = gadget.state.app_name +
" is being prepared for 100 % offline mode";
for (i = 0; i < 7; i += 1) {
element.appendChild(document.createElement('br'));
} }
if (modification_dict.error_source) {
img = document.createElement('img'); app_name_div = gadget.element.querySelector(".error-source");
img.setAttribute('width', '100'); app_name_div.textContent = "Source: " + gadget.state.error_source;
img.setAttribute('height', '100'); }
img.setAttribute('src', 'officejs_logo.png'); if (modification_dict.error_amount) {
element.appendChild(img); app_name_div = gadget.element.querySelector(".error-amount");
element.appendChild(document.createElement('br')); app_name_div.textContent = "Retry: " + gadget.state.error_amount;
}
div = document.createElement('div'); if (modification_dict.error) {
p = document.createElement('p'); error_div = gadget.element.querySelector(".error-message");
p.textContent = "Preparing " + options.app_name; message = "Last Error: ";
div.appendChild(p); if (gadget.state.error.message) {
div.appendChild(document.createElement('br')); message += gadget.state.error.message;
p = document.createElement('p'); } else {
p.textContent = message += JSON.stringify(gadget.state.error);
"Your application is being prepared for a 100 % offline mode"; }
div.appendChild(p); error_div.textContent = message;
loader = document.createElement('div'); }
loader.setAttribute('class', 'loader'); if (modification_dict.redirect_url) {
element.appendChild(div); skip_link = gadget.element.querySelector(".skip-link");
div.appendChild(document.createElement('br')); skip_link.setAttribute('href', gadget.state.redirect_url);
element.appendChild(loader);
if (options.retry > 0) {
element.appendChild(document.createElement('br'));
error = document.createElement('div');
p = document.createElement('p');
p.textContent = "Last Error: " +
options.error.message || 'Unknow Error';
element.appendChild(p);
element.appendChild(document.createElement('br'));
p = document.createElement('p');
p.textContent = "Retry n° " + options.retry;
element.appendChild(p);
} }
div = document.createElement('div');
skip = document.createElement('a');
skip.textContent = 'Skip';
skip.setAttribute('href', options.redirect_url);
div.appendChild(skip);
element.appendChild(document.createElement('br'));
element.appendChild(skip);
return;
}); });
}(window, rJS, document)); }(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>961.40574.60793.40960</string> </value> <value> <string>961.59243.59705.49169</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>1503563479.26</float> <float>1504683865.92</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