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