Commit 4361f52a authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio: drop slap_add_instance_tree page

parent 9956351e
<!DOCTYPE html>
<html>
<!--
data-i18n=Please review the form.
data-i18n=New service created.
data-i18n=The name of a document in ERP5
data-i18n=Software Release URL
data-i18n=Title
data-i18n=Instance Parameter
data-i18n=Compute Node
data-i18n=SLA
data-i18n=Parent Relative Url
data-i18n=3/3 Request Service:
-->
<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_add_instance_tree.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: gadget.message1_translation, status: 'error'});
}
return gadget.getSetting("hateoas_url")
.push(function (url) {
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 () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": "/", "page": "slap_service_list"}});
});
}, function (error) {
if (error.target.status === 409) {
return gadget.notifySubmitted({message: gadget.message3_translation, status: 'error'});
}
if (error.target.status === 400) {
return gadget.notifySubmitted({message: gadget.message4_translation, status: 'error'});
}
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this,
page_title_translation,
translation_list = [
"Please review the form.",
"New service created.",
"The name of a document in ERP5",
"Software Release URL",
"Title",
"Instance Parameter",
"Compute Node",
"SLA",
"Parent Relative Url",
"3/3 Request Service:",
"A service with this title already exists.",
"Service Title is mandatory."
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
gadget.message1_translation = result[2][0];
gadget.message2_translation = result[2][1];
gadget.message3_translation = result[2][10];
gadget.message4_translation = result[2][11];
page_title_translation = result[2][9];
var doc = result[1],
parameter_dict = {
'parameter' : {
'json_url': doc.url_string.split('?')[0] + ".json",
'parameter_hash': btoa('<?xml version="1.0" encoding="utf-8" ?><instance/>')
}
};
if (options.software_type) {
parameter_dict["parameter"]['softwaretype'] = options.software_type;
}
if (options.shared) {
parameter_dict["parameter"]['shared'] = true;
}
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_url_string": {
"description": result[2][2],
"title": result[2][3],
"default": doc.url_string,
"css_class": "",
"required": 1,
"editable": 0,
"key": "url_string",
"hidden": 0,
"type": "StringField"
},
"your_title": {
"description": result[2][2],
"title": result[2][4],
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"your_text_content": {
"description": "",
"title": result[2][5],
"default": parameter_dict,
"css_class": "",
"required": 1,
"editable": 1,
"url": "gadget_erp5_page_slap_parameter_form.html",
"sandbox": "",
"key": "text_content",
"hidden": 0,
"type": "GadgetField"
},
"your_computer_guid": {
"description": result[2][2],
"title": result[2][6],
"default": "",
"items": doc.computer_guid,
"css_class": "",
"required": 0,
"editable": 1,
"key": "computer_guid",
"hidden": options.sla_xml !== undefined ? 1 : 0,
"type": "ListField"
},
"your_sla_xml": {
"description": result[2][2],
"title": result[2][7],
"default": options.sla_xml,
"css_class": "",
"required": 0,
"editable": 0,
"key": "sla_xml",
"hidden": options.sla_xml !== undefined ? 0 : 1,
"type": "StringField"
},
"my_relative_url": {
"description": "",
"title": result[2][8],
"default": options.jio_key,
"css_class": "",
"required": 1,
"editable": 1,
"key": "relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"center",
[["my_url_string"], ["your_title"], ["your_text_content"],
["your_computer_guid"], ["your_sla_xml"], ["my_portal_type"], ["my_relative_url"]]
]]
}
})
.push(function () {
return gadget.updatePanel({
jio_key: "software_release_module"
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'cancel_dialog_with_history'})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: page_title_translation + " " + doc.title,
cancel_url: url_list[0],
submit_action: true
});
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
from zExceptions import Unauthorized
if REQUEST is None:
raise Unauthorized
import json
portal = context.getPortalObject()
response = REQUEST.RESPONSE
if shared in ["true", "1", 1]:
shared = True
if shared in ["false", "", 0, "0", None]:
shared = False
if not title:
response.setStatus(400)
return "Service Title is mandatory!"
if "{uid}" in title:
uid_ = portal.portal_ids.generateNewId(id_group=("vifib", "kvm"), default=1)
title = title.replace("{uid}", str(uid_))
instance_tree = portal.portal_catalog.getResultValue(
portal_type='Instance Tree',
validation_state="validated",
title={'query': title, 'key': 'ExactMatch'}
)
if instance_tree is not None:
response.setStatus(409)
return "Instance with this name already exists"
# The URL should come from the URL Probably
url = context.getUrlString()
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
if person is None:
raise Unauthorized("You cannot request without been logged in as a user.")
if software_type in [None, ""]:
software_type = "RootSoftwareInstance"
if text_content in ["", None]:
text_content = """<?xml version='1.0' encoding='utf-8' ?>
<instance>
</instance>"""
request_kw = {}
request_kw.update(
software_release=url,
software_title=title,
software_type=software_type,
instance_xml=text_content,
sla_xml="",
shared=shared,
state="started",
)
for sla_category_id, sla_category in [
('computer_guid', computer_guid),
]:
if sla_category:
sla_xml += '<parameter id="%s">%s</parameter>' % (sla_category_id, sla_category)
if sla_xml:
request_kw['sla_xml'] = """<?xml version='1.0' encoding='utf-8'?>
<instance>
%s
</instance>""" % sla_xml
person.requestSoftwareInstance(**request_kw)
return json.dumps(context.REQUEST.get('request_instance_tree').getRelativeUrl())
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>title, text_content="", software_type=None, shared=False, computer_guid=None, sla_xml="", REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SoftwareRelease_requestInstanceTree</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -19,8 +19,6 @@ web_page_module/rjs_gadget_erp5_page_map_html ...@@ -19,8 +19,6 @@ web_page_module/rjs_gadget_erp5_page_map_html
web_page_module/rjs_gadget_erp5_page_map_js web_page_module/rjs_gadget_erp5_page_map_js
web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html
web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js
web_page_module/rjs_gadget_erp5_page_slap_add_instance_tree_html
web_page_module/rjs_gadget_erp5_page_slap_add_instance_tree_js
web_page_module/rjs_gadget_erp5_page_slap_add_network_html web_page_module/rjs_gadget_erp5_page_slap_add_network_html
web_page_module/rjs_gadget_erp5_page_slap_add_network_js web_page_module/rjs_gadget_erp5_page_slap_add_network_js
web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html
......
...@@ -16,8 +16,6 @@ web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html ...@@ -16,8 +16,6 @@ web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_html
web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js web_page_module/rjs_gadget_erp5_page_slap_accept_upgrade_decision_js
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_html web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_html
web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_js web_page_module/rjs_gadget_erp5_page_slap_access_denied_view_js
web_page_module/rjs_gadget_erp5_page_slap_add_instance_tree_html
web_page_module/rjs_gadget_erp5_page_slap_add_instance_tree_js
web_page_module/rjs_gadget_erp5_page_slap_add_network_html web_page_module/rjs_gadget_erp5_page_slap_add_network_html
web_page_module/rjs_gadget_erp5_page_slap_add_network_js web_page_module/rjs_gadget_erp5_page_slap_add_network_js
web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html web_page_module/rjs_gadget_erp5_page_slap_add_organisation_html
......
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