Commit 295154cb authored by Rafael Monnerat's avatar Rafael Monnerat

Fixup redirection after request an instance

See merge request nexedi/slapos.core!529
parents 94999b09 53ee9096
/*global window, rJS, RSVP, btoa */ /*global window, rJS, RSVP, btoa, jIO, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */ /*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, btoa, jIO, JSON) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -50,12 +50,22 @@ ...@@ -50,12 +50,22 @@
return gadget.jio_putAttachment(doc.relative_url, return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/SoftwareRelease_requestInstanceTree", doc); 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 () { .push(function () {
// Workaround, find a way to open document without break gadget. return jIO.util.readBlobAsText(attachment.target.response);
return gadget.redirect({"command": "change", })
"options": {"jio_key": "/", "page": "slap_service_list"}}); .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) { }, function (error) {
if (error.target.status === 409) { if (error.target.status === 409) {
...@@ -224,4 +234,4 @@ ...@@ -224,4 +234,4 @@
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, btoa, jIO, JSON));
\ No newline at end of file \ No newline at end of file
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1000.31175.43828.12919</string> </value> <value> <string>1008.22803.51783.61098</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1669310140.13</float> <float>1683853456.43</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
/*global window, rJS, RSVP */ /*global window, rJS, RSVP, JSON , jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */ /*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) { (function (window, rJS, RSVP, JSON, jIO) {
"use strict"; "use strict";
rJS(window) rJS(window)
...@@ -42,7 +42,8 @@ ...@@ -42,7 +42,8 @@
"New service created.", "New service created.",
"Intent not supported", "Intent not supported",
"Requesting a service…", "Requesting a service…",
"Instance" "Instance",
]; ];
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
...@@ -135,33 +136,28 @@ ...@@ -135,33 +136,28 @@
} }
return gadget.notifySubmitting() return gadget.notifySubmitting()
.push(function () { .push(function () {
var query = []; return gadget.getSetting("hateoas_url")
query.push("title=" + encodeURIComponent(doc.title)); .push(function (url) {
return gadget.jio_putAttachment(doc.relative_url,
if (doc.software_type) { url + doc.relative_url + "/SoftwareRelease_requestInstanceTree", doc);
query.push("software_type=" + encodeURIComponent(doc.software_type)); })
}
if (doc.shared) { .push(function (attachment) {
query.push("shared:int=" + encodeURIComponent(doc.shared)); return jIO.util.readBlobAsText(attachment.target.response);
} })
if (doc.text_content) { .push(function (response) {
query.push("text_content=" + encodeURIComponent(doc.text_content)); return JSON.parse(response.target.result);
} })
if (doc.sla_xml) { .push(function (relative_url) {
query.push("sla_xml=" + encodeURIComponent(doc.sla_xml)); return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
} .push(function () {
return gadget.jio_getAttachment(doc.relative_url, // Workaround, find a way to open document without break gadget.
url + doc.relative_url + "/SoftwareRelease_requestInstanceTree?" + query.join("&")); return gadget.redirect({"command": "change",
}) "options": {"jio_key": relative_url, "page": "slap_controller"}});
.push(function (key) { });
return gadget.notifySubmitted({message: gadget.message_tranlation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": key, "page": "slap_controller"}});
}); });
}); });
}); });
}); });
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP, JSON , jIO));
...@@ -283,7 +283,7 @@ ...@@ -283,7 +283,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1008.12332.26729.18090</string> </value> <value> <string>1008.22835.52422.8345</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1683224657.13</float> <float>1683854663.4</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -126,7 +126,16 @@ ...@@ -126,7 +126,16 @@
'text': 'New service created.'}"> 'text': 'New service created.'}">
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/wait_for_notification" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/wait_for_notification" />
</tal:block> </tal:block>
<tr tal:define="dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SERVICE-FRONTEND 0'})">
<td>waitForElementPresent</td>
<td tal:content="python: '//a[@data-i18n= \'%s\']' % (here.Base_translateString('Instance Tree: ${title}', mapping=context.REQUEST.get('mapping', {}), lang=lang))"></td>
<td></td>
</tr>
<tr tal:define="dummy python: context.REQUEST.set('mapping', {'title': 'TEST-SLAPOSJS-SERVICE-FRONTEND 0'})">
<td>assertElementPresent</td>
<td tal:content="python: '//a[@data-i18n= \'%s\']' % (here.Base_translateString('Instance Tree: ${title}', mapping=context.REQUEST.get('mapping', {}), lang=lang))"></td>
<td></td>
</tr>
<tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_wait_for_activities_and_front_page" /> <tal:block metal:use-macro="here/Zuite_SlapOSCommonTemplate/macros/slapos_wait_for_activities_and_front_page" />
<tal:block define="menu_item python: 'Services'; header menu_item"> <tal:block define="menu_item python: 'Services'; header menu_item">
......
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