Commit a0abff34 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: On add erp5 login form, handle errors using JIO API

It relies on using jIO.util.readBlobAsText rather them Blob.text() to recover the result.
parent 390b318a
......@@ -25,6 +25,11 @@
</head>
<body>
<div data-gadget-url="gadget_slapos_annotated_helper.html"
data-gadget-scope="annotated_helper"
data-template-id="add-new-login-header-text"
data-gadget-sandbox="public">
</div>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>982.32516.46874.3959</string> </value>
<value> <string>984.14093.31233.63027</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1584351106.69</float>
<float>1590777644.94</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, jIO) {
"use strict";
rJS(window)
......@@ -65,22 +65,17 @@
"page": "slap_controller"}});
})
.push(undefined, function (error) {
return new RSVP.Queue()
.push(function () {
return RSVP.all([
error.target.response.text(),
gadget.getTranslationList(["Unknown Error, please open a ticket."])
]);
})
.push(function (result) {
var text = result[0],
error_message = result[0][1];
if (error.target.status === 406) {
return gadget.notifySubmitted({message: text,
status: 'error'});
}
return gadget.notifySubmitted({message: error_message,
status: 'error'});
return gadget.getTranslationList(["Unknown Error, please open a ticket."])
.push(function (error_message) {
return jIO.util.readBlobAsText(error.target.response)
.then(function (evt) {
if (error.target.status === 406) {
return gadget.notifySubmitted({message: JSON.parse(evt.target.result),
status: 'error'});
}
return gadget.notifySubmitted({message: error_message[0],
status: 'error'});
});
});
});
});
......@@ -203,4 +198,4 @@
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, jIO));
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>984.12854.52715.32426</string> </value>
<value> <string>984.13871.46211.53043</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1590705868.36</float>
<float>1590759622.51</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