Commit 10166bb4 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Redirect to the instance after request

    Use response from putAttachment to get the relative URL
parent 94999b09
/*global window, rJS, RSVP, btoa */
/*global window, rJS, RSVP, btoa, jIO, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, btoa, jIO, JSON) {
"use strict";
rJS(window)
......@@ -50,12 +50,22 @@
return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/SoftwareRelease_requestInstanceTree", doc);
})
.push(function () {
return gadget.notifySubmitted({message: gadget.message2_translation, status: 'success'})
.push(function (attachment) {
return new RSVP.Queue()
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": "/", "page": "slap_service_list"}});
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
})
.push(function (relative_url) {
return gadget.notifySubmitted({message: gadget.message2_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": relative_url, "page": "slap_controller"}});
});
});
}, function (error) {
if (error.target.status === 409) {
......@@ -224,4 +234,4 @@
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, btoa, jIO, JSON));
\ No newline at end of file
......@@ -283,7 +283,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1000.31175.43828.12919</string> </value>
<value> <string>1008.22803.51783.61098</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -303,7 +303,7 @@
</tuple>
<state>
<tuple>
<float>1669310140.13</float>
<float>1683853456.43</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