Commit 413b2f38 authored by Sven Franck's avatar Sven Franck

custom handlers: add overview/new for computer and networks

parent 2ee97fbb
......@@ -3,7 +3,7 @@
"portal_type_title": "computer",
"portal_type_fields": "computer_fieldlist",
"form": true,
"view": "FOO",
"view": "web_view",
"property_dict": {
"dynamic_children": [0],
"requires_authentication": true,
......@@ -15,15 +15,12 @@
{
"position": "left",
"fieldlist": [
{"field": "title"},
{"field": "reference_network"}
]
}, {
"position": "center",
"fieldlist": [
{"field": "description"},
{"field": "reference", "overrides": {"widget":{"hidden": true}}}
{"type": "input", "direct": {"name": "computer_title", "id": "computer_title", "className": "required"}, "attributes": {"data-enhanced": true, "type": "text"}, "logic": {"clear": true, "label": "Computer Title", "setValue": "computer_", "label_i18n": "portal_type_dict.computer_dict.text_dict.title", "skip": false}}
]
},
{
"position": "right",
"fieldlist": []
}
],
"children": [{
......@@ -45,7 +42,7 @@
},
"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", "data-icon":"save", "data-i18n":"[value]portal_type_dict.computer_dict.text_dict.submit", "data-theme": "slapos-black"}}
{"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"}}
]
}]
}
......
......@@ -2,7 +2,7 @@
"portal_type_source": "Computer",
"portal_type_title": "computer",
"portal_type_fields": "computer_fieldlist",
"portal_type_mapper": "subscriptions",
"portal_type_mapper": "servers",
"initial_query": {"include_docs": true, "limit":[0,8]},
"form": true,
"view": "web_view",
......
......@@ -15,7 +15,7 @@
{
"position": "left",
"fieldlist": [
{"field": "title"}
{"type": "input", "direct": {"name": "network_title", "id": "network_title", "className": "required"}, "attributes": {"data-enhanced": true, "type": "text"}, "logic": {"clear": true, "label": "Computer Title", "setValue": "network_", "label_i18n": "portal_type_dict.network_dict.text_dict.title", "skip": false}}
]
},
{
......
......@@ -2,6 +2,7 @@
"portal_type_source": "Computer Network",
"portal_type_title": "network",
"portal_type_fields": "network_fieldlist",
"portal_type_mapper": "networks",
"initial_query": {"include_docs": true, "limit":[0,8]},
"form": true,
"view": "FOO",
......
......@@ -25,7 +25,7 @@
"fieldlist": [
{"type": "input", "direct": {"id":"software_release_show", "className": "required"}, "attributes": {"data-enhanced": "true", "type": "text", "readonly": "readonly"}, "logic": {"setValue": "_relative_url", "label": "Software Release", "label_i18n": "portal_type_dict.release_dict.text_dict.software_release", "skip":false}},
{"type": "input", "direct": {"name": "software_release", "id":"software_release", "className": "required"}, "attributes": {"data-enhanced": "true", "type": "hidden"}, "logic": {"setValue": "_relative_url", "skip":false}},
{"type": "input", "direct": {"name": "software_title", "id": "software_title", "className": "required"}, "attributes": {"data-enhanced": true, "type": "text"}, "logic": {"label": "Instance Title", "setValue": "instance_", "label_i18n": "portal_type_dict.release_dict.text_dict.instance_title", "skip": false}}
{"type": "input", "direct": {"name": "software_title", "id": "software_title", "className": "required"}, "attributes": {"data-enhanced": true, "type": "text"}, "logic": {"clear": true, "label": "Instance Title", "setValue": "instance_", "label_i18n": "portal_type_dict.release_dict.text_dict.instance_title", "skip": false}}
]
},
{
......
......@@ -4,7 +4,7 @@
"portal_type_fields": "service_fieldlist",
"initial_query": {"include_docs": true, "limit":[0,1]},
"form": true,
"view": "FOO",
"view": "web_view",
"property_dict": {
"initial_query_url_identifier": "reference_computer",
"dynamic_children": [0],
......
......@@ -153,6 +153,106 @@
return (reply);
},
/**
* @method subscriptions
* @param {object} reply Object received from previous chain element
* @param {object} response Object object passed on to next element
**/
"servers": function (reply) {
var config, property, query, href, i, reply, pass = reply.pass;
if (storage) {
config = {
"url": storage.items.dict.url,
"type": "GET",
"data": JSON.stringify({"_id":""})
};
// access storage
return jIO.util.ajax(config)
.then(function(response) {
return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href
});
}).then(function (answer) {
reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_computer") {
query = reply[i]._query;
}
}
if (query === undefined) {
query = reply.href;
}
if (pass.config.initial_query === undefined) {
pass.config.initial_query = {};
}
pass.config.initial_query.query = query;
// 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 subscriptions
* @param {object} reply Object received from previous chain element
* @param {object} response Object object passed on to next element
**/
"networks": function (reply) {
var config, property, query, href, i, reply, pass = reply.pass;
if (storage) {
config = {
"url": storage.items.dict.url,
"type": "GET",
"data": JSON.stringify({"_id":""})
};
// access storage
return jIO.util.ajax(config)
.then(function(response) {
return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href
});
}).then(function (answer) {
reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_network") {
query = reply[i]._query;
}
}
if (query === undefined) {
query = reply.href;
}
if (pass.config.initial_query === undefined) {
pass.config.initial_query = {};
}
pass.config.initial_query.query = query;
// 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 subscriptions
* @param {object} reply Object received from previous chain element
......@@ -160,7 +260,7 @@
**/
// TODO: should be renamed to overview
"subscriptions": function (reply) {
var config, property, query, href, pass = reply.pass;
var config, property, query, href, i, reply, pass = reply.pass;
if (storage) {
config = {
......@@ -172,14 +272,19 @@
// access storage
return jIO.util.ajax(config)
.then(function(response) {
console.log(util.parse(response.target.responseText))
return jIO.util.ajax({
"url": util.parse(response.target.responseText)._links.me.href
});
}).then(function (answer) {
console.log(util.parse(answer.target.responseText))
query = util.parse(answer.target.responseText)._links.slapos_jump._query;
reply = util.parse(answer.target.responseText)._links.slapos_jump;
for (i = 0; i < reply.length; i += 1) {
if (reply[i].name === "current_hosting_subscription") {
query = reply[i]._query;
}
}
if (query === undefined) {
query = reply.href;
}
if (pass.config.initial_query === undefined) {
pass.config.initial_query = {};
}
......@@ -576,17 +681,6 @@
.fail(util.error);
},
/**
* Instantiate a software instance
* @method install
* @param {object} obj Action Object
**/
"instantiate": function (obj) {
obj.gadget.state.create_new = true;
obj.gadget.state.force_formdata = true;
storage.add(obj);
},
/**
* Create an installation = new service object
* @method install
......@@ -596,7 +690,6 @@
// force new portal type and POST (create new record)
obj.gadget.state.force_type = "Service";
obj.gadget.state.create_new = true;
storage.add(obj);
},
......@@ -617,7 +710,44 @@
"add": function (obj) {
storage.add(obj);
},
/**
* Add a user to the storage
* @method submit
* @param {object} obj Action Object
**/
"add_server": function (obj) {
obj.gadget.state.create_new = true;
obj.gadget.state.force_formdata = true;
obj.gadget.state.url_pointer = "request_computer";
storage.add(obj);
},
/**
* Instantiate a software instance
* @method install
* @param {object} obj Action Object
**/
"instantiate": function (obj) {
obj.gadget.state.create_new = true;
obj.gadget.state.force_formdata = true;
obj.gadget.state.url_pointer = "request";
storage.add(obj);
},
/**
* Instantiate a software instance
* @method install
* @param {object} obj Action Object
**/
"add_network": function (obj) {
obj.gadget.state.create_new = true;
obj.gadget.state.force_formdata = true;
obj.gadget.state.url_pointer = "request_network";
storage.add(obj);
},
/**
* Show jumps popup
* @method jump
......@@ -4784,12 +4914,13 @@
app.store({
"response": [obj],
"pass": {
"form_data": formData,
"type": config.gadget.state.type,
"reply": true,
"validate_type": validate_portal_type_fields,
// hacked view
"view": config.gadget.state.view
"view": config.gadget.state.view,
"form_data": formData,
"fetch": config.gadget.state.url_pointer
}
})
.then(function (answer) {
......@@ -6358,14 +6489,13 @@
})
.then(function (answer) {
return jIO.util.ajax({
"url": util.parse(answer.target.responseText)._actions.request.href,
"url": util.parse(answer.target.responseText)._actions[pass.fetch].href,
"type": "POST",
"data": pass.form_data
});
})
.then(function (erp5_response) {
header = erp5_response.target.getResponseHeader("Location");
console.log(header)
return RSVP.resolve({
"status": 200,
"foo": "bar",
......
......@@ -87,6 +87,7 @@
"portal_type_dict": {
"network_dict": {
"text_dict": {
"title": "Network Title",
"status": "Status",
"networks": "Networks",
"network_instance": "Network Instance",
......@@ -238,7 +239,8 @@
"delete": "Delete",
"server_instance": "Server Instance",
"instance_configuration": "Instance Configuration",
"installed_services": "Installed Services"
"installed_services": "Installed Services",
"title": "Computer Title"
},
"field_dict": {
"network": {
......
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