Commit 4016711c authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Add testing parameter form

   This form allows you test any software release on the parameter form.
parent e4d4b9ba
<!DOCTYPE html>
<html>
<!--
data-i18n=Title
data-i18n=Instance Parameter
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Site List</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_page_slap_test_parameter_form.js" type="text/javascript"></script>
</head>
<body>
<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>
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
/*global window, rJS, RSVP, btoa */
/*jslint nomen: true, indent: 2, maxerr: 3, sub:true */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("getTranslationList", "getTranslationList")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.checkValidity()
.push(function (is_valid) {
if (!is_valid) {
return null;
}
return form_gadget.getContent();
});
})
.push(function (doc) {
if (doc === null) {
return gadget.notifySubmitted({message: "Doc is empty", status: 'error'});
}
return gadget.getSetting("hateoas_url")
.push(function () {
return gadget.notifySubmitted({message: "All is fine, we reseted your form.", status: 'success'})
.push(function () {
return gadget.redirect({"command": "change",
"options": {"url_string": doc.url_string,
"parameter_output": doc.text_content}});
});
}, function (error) {
if (error.target.status === 409) {
return gadget.notifySubmitted({message: "Error 409", status: 'error'});
}
if (error.target.status === 400) {
return gadget.notifySubmitted({message: "Error 400", status: 'error'});
}
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this;
if (options.url_string === undefined) {
options.url_string = "";
}
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view')
]);
})
.push(function (result) {
var parameter_hash,
parameter_dict,
default_url;
if (options.url_string === "") {
default_url = "https://lab.nexedi.com/rafael/testing-slapos-schemas/raw/master/software/simpledemo/software.cfg"
} else {
default_url = options.url_string
}
if (options.parameter_output === undefined) {
parameter_hash = btoa('<?xml version="1.0" encoding="utf-8" ?><instance></instance>');
} else {
parameter_hash = btoa(options.parameter_output);
}
parameter_dict = {
'parameter' : {
'json_url': options.url_string.split('?')[0] + ".json",
'parameter_hash': parameter_hash,
'restricted_softwaretype': false
}
};
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_url_string": {
"description": "Software Release Url",
"title": "Software Release URL",
"default": default_url,
"css_class": "",
"required": 1,
"editable": options.url_string === "",
"key": "url_string",
"hidden": 0,
"type": "StringField"
},
"your_text_content": {
"description": "",
"title": "Parameters",
"default": parameter_dict,
"css_class": "",
"required": 1,
"editable": options.url_string !== "",
"url": "gadget_erp5_page_slap_parameter_form.html",
"sandbox": "",
"key": "text_content",
"hidden": options.url_string === "",
"type": "GadgetField"
},
"your_parameter_output": {
"description": "",
"title": "Parameters Output",
"default": options.parameter_output,
"css_class": "",
"required": 0,
"editable": 0,
"sandbox": "",
"key": "parameter_output",
"hidden": options.parameter_output === undefined,
"type": "TextAreaField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"center",
[["my_url_string"], ["your_parameter_output"], ["your_text_content"]]
]]
}
})
.push(function () {
return gadget.updateHeader({
page_title: "Parameter testing page",
submit_action: true
});
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
...@@ -214,6 +214,8 @@ web_page_module/rjs_slapos_load_meta_schema_xml_in_json_json ...@@ -214,6 +214,8 @@ web_page_module/rjs_slapos_load_meta_schema_xml_in_json_json
web_page_module/rjs_slapos_load_meta_schema_xml_json web_page_module/rjs_slapos_load_meta_schema_xml_json
web_page_module/rjs_slapos_load_software_schema_json web_page_module/rjs_slapos_load_software_schema_json
web_page_module/rjs_gadget_slapos_login_page_css web_page_module/rjs_gadget_slapos_login_page_css
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_html
web_page_module/rjs_tv4_min_js web_page_module/rjs_tv4_min_js
web_page_module/rjs_vkbeautify_js web_page_module/rjs_vkbeautify_js
web_site_module/hostingjs web_site_module/hostingjs
......
...@@ -89,6 +89,8 @@ web_page_module/rjs_gadget_erp5_page_slap_organisation_view_html ...@@ -89,6 +89,8 @@ web_page_module/rjs_gadget_erp5_page_slap_organisation_view_html
web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js web_page_module/rjs_gadget_erp5_page_slap_organisation_view_js
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css web_page_module/rjs_gadget_erp5_page_slap_parameter_form_css
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_html web_page_module/rjs_gadget_erp5_page_slap_parameter_form_html
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_html
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js web_page_module/rjs_gadget_erp5_page_slap_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_parameter_form_zh_html web_page_module/rjs_gadget_erp5_page_slap_parameter_form_zh_html
web_page_module/rjs_gadget_erp5_page_slap_payment_result_html web_page_module/rjs_gadget_erp5_page_slap_payment_result_html
...@@ -140,6 +142,8 @@ web_page_module/rjs_gadget_erp5_page_slap_start_instance_tree_js ...@@ -140,6 +142,8 @@ web_page_module/rjs_gadget_erp5_page_slap_start_instance_tree_js
web_page_module/rjs_gadget_erp5_page_slap_stop_instance_tree_html web_page_module/rjs_gadget_erp5_page_slap_stop_instance_tree_html
web_page_module/rjs_gadget_erp5_page_slap_stop_instance_tree_js web_page_module/rjs_gadget_erp5_page_slap_stop_instance_tree_js
web_page_module/rjs_gadget_erp5_page_slap_support_request_view_html web_page_module/rjs_gadget_erp5_page_slap_support_request_view_html
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_html
web_page_module/rjs_gadget_erp5_page_slap_test_parameter_form_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_html web_page_module/rjs_gadget_erp5_page_slap_ticket_list_html
web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js web_page_module/rjs_gadget_erp5_page_slap_ticket_list_js
web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js web_page_module/rjs_gadget_erp5_page_slap_ticket_view_js
......
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