Commit 76dd6229 authored by Sven Franck's avatar Sven Franck

implemeneted software installation and destroy on server

parent fd215c7d
......@@ -40,9 +40,7 @@
"property_dict": {
"direction": "horizontal"
},
"children": [
{"type": "input", "direct": {"value": "Reset", "className": "translate"}, "attributes": {"type": "reset", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.cancel"}},
{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add_server", "data-icon":"save", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.submit", "data-theme": "slapos-black"}}
"children": [{"type": "input", "direct": {"value": "Submit", "className": "action translate"}, "attributes": {"type": "submit", "data-action":"add_server", "data-icon":"save", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.submit", "data-theme": "slapos-black"}}
]
}]
}
......
......@@ -52,6 +52,13 @@
"title": "Server Configuration",
"title_i18n": "portal_type_dict.computer_dict.text_dict.instance_configuration",
"view_dict": {
"default": [
{
"generate": "gadget",
"type": "fieldlist",
"href": "software_installation_status"
}
],
"config": [
{
"generate": "gadget",
......
......@@ -163,6 +163,47 @@
}
}
},
"url_string": {
"type": "StringField",
"widget": {
"id": "url_string",
"title": "Software URL",
"title_i18n": "portal_type_dict.software_dict.field_dict.url_string.title",
"description": "The software URL of this installation.",
"description_i18n": "portal_type_dict.software_dict.field_dict.url_string.description",
"alternate_name": "url_string",
"default_value": null,
"css_class": null,
"hidden": false,
"display_width": 30,
"maximum_input": null,
"extra": {"data-clear-btn":"true"}
},
"properties": {
"enabled": true,
"editable": true,
"external_validator": null,
"required": null,
"preserve_whitespace": null,
"unicode": null,
"maximum_length": null,
"truncate": null
},
"messages": {
"external_validator_failed": {
"message": "The input failed the external validator.",
"i18n": "validation_dict.external"
},
"required_not_found": {
"message": "Input is required but no input given.",
"i18n": "validation_dict.required"
},
"too_long": {
"message":"Too much input given.",
"i18n": "validation_dict.too_much_input"
}
}
},
"image_url": {
"type":"ImageField",
"widget": {
......
{
"portal_type_source": "Service",
"portal_type_title": "service",
"portal_type_fields": "service_fieldlist",
"initial_query": {"include_docs": true, "limit":[0,1]},
"form": true,
"view": "web_view",
"property_dict": {
"always_render": true,
"initial_query_url_identifier": "_id",
"dynamic_children": [0],
"requires_authentication": true,
"depends_on": "login_state",
"submit_to": "#servers/__id__"
},
"scheme": [
{
"position": "center",
"fieldlist": [
{"field": "url_string", "overrides": {"properties":{"editable":false, "required": false}}}
]
},
{
"position": "left",
"fieldlist": [
{
"custom": true,
"action_list": [
{"setters": ["data-method", "href"], "setValues":[["_actions", "destroy", "method"], ["_actions", "destroy", "href"]], "class_list": "action error status translate", "iconpos": "left", "action": "destroy_installation", "icon":"trash", "text": "Destroy", "text_i18n":"portal_type_dict.service_dict.text_dict.destroy"}
]
}
]
}
],
"children": [{
"generate": "widget",
"type": "form",
"class_list": "responsive",
"property_dict": {
"editable": true,
"secure": "default",
"secret_hash": "foo",
"public_key": "6Ldpb-oSAAAAAGwriKpk4ol1n4yjN_as6M4xv0zA"
},
"children": []
}]
}
......@@ -2,15 +2,16 @@
"portal_type_source": "Service",
"portal_type_title": "service",
"portal_type_fields": "service_fieldlist",
"initial_query": {"include_docs": true, "limit":[0,1]},
"portal_type_mapper": "installed_services",
"initial_query": {"include_docs": true, "limit":[0,8]},
"form": true,
"view": "web_view",
"property_dict": {
"initial_query_url_identifier": "reference_computer",
"dynamic_children": [0],
"wrap_gadget": 2,
"linkable": true,
"link_identifier": "id",
"link": true,
"link_identifier": "_id",
"caption": {
"slot": 1,
"text": "Installed Services",
......@@ -24,18 +25,6 @@
{"value": "32", "text": "32", "text_i18n":"portal_type_dict.invoice_dict.text_dict.32"},
{"value": "64", "text": "64", "text_i18n":"portal_type_dict.invoice_dict.text_dict.64"}
]
},
"no_items": {
"message":"No Software installed.",
"message_i18n":"portal_type_dict.software_dict.text_dict.no_software",
"children": [
{
"href": "#services/add",
"text": "Add Software",
"text_i18n": "portal_type_dict.software_dict.text_dict.add_software",
"class_list": "translate ui-btn-slapos-black"
}
]
}
},
"scheme":[
......@@ -71,15 +60,7 @@
"top_grid": 1,
"bottom_grid": 1
},
"children": [{
"generate": "widget",
"type": "controlgroup",
"class_list": "center inline",
"property_dict": {},
"children": [
{"type": "a", "direct": {"href": "#software/add", "className": "ui-btn-slapos-black"}, "attributes": {"data-i18n":"portal_type_dict.software_dict.text_dict.add_software"}, "logic": {"text":"Install Software"}}
]
}]
}
"children": []
}, {"type": "a", "direct": {"href": "#services/add", "className": "ui-btn-slapos-black ui-btn ui-shadow ui-btn-inline ui-corner-all"}, "attributes": {"data-i18n":"portal_type_dict.software_dict.text_dict.add_software"}, "logic": {"text":"Install New Software"}}
]
}
......@@ -36,7 +36,7 @@
"fieldlist": [
{"field": "user", "show": true, "priority": 4},
{"field": "date", "show": true, "priority": 1},
{"field": "text_content", "show": "true", "priority": 2}
{"field": "text_content", "show": "true", "priority": 1}
]
},
{
......@@ -44,7 +44,7 @@
"fieldlist": [
{"field": "user", "show": true, "priority": 4},
{"field": "date", "show": true, "priority": 1},
{"field": "text_content", "show": "true", "priority": 2}
{"field": "text_content", "show": "true", "priority": 1}
]
}
],
......
......@@ -529,6 +529,47 @@
// TODO: remove!
map.handlers = {
/**
* @method release_list
* @param {object} reply Object received from previous chain element
* @param {object} response Object object passed on to next element
**/
"installed_services": function (reply) {
var config, property, query, fetch, href, pass = reply.pass;
if (storage) {
// access storage
fetch = reply.pass.value || reply.pass.state.query.force;
return storage.items.get({"_id": fetch})
.then(function(answer) {
query = util.parse(answer).data._links.slapos_jump._query;
if (pass.config.initial_query === undefined) {
pass.config.initial_query = {};
}
pass.config.initial_query.query = query;
pass.config.initial_query.skip_type = true;
pass.preserve_lookup = reply.pass.value;
// set a flag to now run allDocs
pass.force_allDocs = true;
// pass hacked query back into chain
if (reply.response) {
return {
"response": util.parse(reply.response),
"pass": pass
};
}
return {
"pass": pass
}
}).fail(util.error);
}
return (reply);
},
/**
* @method release_list
* @param {object} reply Object received from previous chain element
......@@ -1009,6 +1050,34 @@
**/
map.actions = {
/**
* Start a software instance
* @method start_instance
* @param {object} obj Action Object
**/
"destroy_installation": function (obj) {
var element = obj.element,
id = obj.state.fragment_list[1],
decode = /^[^\/]*%2[^\/]*$/.test(id);
util.loader("", "status_dict.destroying", "trash");
jIO.util.ajax({
"url": element.href,
"type": element.getAttribute("data-method")
})
.then(function (answer) {
util.loader("", "status_dict.success", "check");
$.mobile.changePage("#servers");
})
.fail(function(error) {
util.loader("", "status_dict.success", "check");
util.error(error);
if (util.parse(error.target).responseText === "" && id && obj.state.callback) {
$.mobile.changePage(obj.state.callback.replace("__id__", decode ? id : window.encodeURIComponent(id)));
}
});
},
/**
* Start a software instance
* @method start_instance
......@@ -2876,6 +2945,7 @@
}
target = document.createDocumentFragment();
spec.set_id = "form_" + util.uuid();
if ((answer.data === undefined && answer.request_new === undefined)) {
target.appendChild(no_content(spec.property_dict.no_items));
......@@ -2900,6 +2970,9 @@
for (i = 0; i < spec.children.length; i += 1) {
element = spec.children[i];
// set flag for referencing gadget
element.reference = spec.set_id;
// dynamic form
if (element.type === "form") {
element.data = data;
......@@ -3809,7 +3882,7 @@
safety_box, fragment, wrap, item_id, input_config, setter, setter_list,
button;
spec.set_id = "form_" + util.uuid();
spec.set_id = spec.reference;
fragment = factory.util.wrapInForm(spec);
secure = spec.property_dict.secure;
item_id = spec.data ? (spec.data._id || undefined) : undefined;
......@@ -3997,6 +4070,13 @@
// widget
if (input_config.generate) {
if (spec.set_id) {
if (input_config.attributes !== undefined) {
input_config.attributes["data-reference"] = spec.set_id;
} else {
input_config.reference = spec.set_id;
}
}
container.appendChild(app.setContent(input_config));
// html element
......
......@@ -831,10 +831,12 @@
}
},
"text_dict": {
"installation_parameters": "Installation Parameters",
"software": "Software",
"destroy": "Destroy",
"release": "Release",
"installed_services": "Installed Services",
"add_software": "Install software",
"add_software": "Install New Software",
"status": "Status",
"search": "Search available software",
"8":"8",
......@@ -845,6 +847,10 @@
"no_software": "No services installed"
},
"field_dict": {
"url_string": {
"title": "Software URL",
"description": "The URL to this software installation."
},
"id": {
"title": "ID",
"description": "The id the software service was registered with."
......
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