Commit 83ea6ba0 authored by Sven Franck's avatar Sven Franck

custom handler: destroy service added

parent 971be979
......@@ -41,6 +41,7 @@
{
"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_instance", "icon":"trash", "text": "Destroy", "text_i18n":"portal_type_dict.service_dict.text_dict.destroy"},
{"setters": ["data-method", "href"], "setValues":[["_actions", "stop", "method"], ["_actions", "stop", "href"]], "class_list": "action error status translate", "iconpos": "left", "action": "stop_instance", "icon":"ban-circle", "text": "Stop", "text_i18n":"portal_type_dict.service_dict.text_dict.stop"},
{"setters": ["data-method", "href"], "setValues":[["_actions", "start", "method"], ["_actions", "start", "href"]], "class_list": "action ui-btn-slapos-black translate", "iconpos": "left", "action": "start_instance", "icon":"cogs", "text": "Start", "text_i18n":"portal_type_dict.service_dict.text_dict.start"}
]
......
......@@ -8,7 +8,7 @@
"view": "web_view",
"property_dict": {
"initial_query_url_identifier": "_id",
"dynamic_children": [0],
"dynamic_children": [0,1],
"link": true,
"link_identifier": "_id",
"wrap_gadget": 2,
......@@ -60,11 +60,6 @@
"bottom_grid": 1
},
"children": []
}, {
"type": "a",
"direct": {"href": "#", "className": "action translate right error status ui-btn ui-btn-inline ui-shadow ui-corner-all ui-btn-icon-left ui-icon-trash"},
"attributes": {"data-i18n":"portal_type_dict.service_dict.text_dict.destroy", "data-action": "destroy"},
"logic": {"text":"Destroy"}
}
]
}
......@@ -158,6 +158,7 @@
* @param {object} reply Object received from previous chain element
* @param {object} response Object object passed on to next element
**/
// TODO: should be renamed to overview
"subscriptions": function (reply) {
var config, property, query, href, pass = reply.pass;
......@@ -171,10 +172,12 @@
// 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;
if (pass.config.initial_query === undefined) {
......@@ -254,6 +257,26 @@
**/
map.actions = {
/**
* Start a software instance
* @method start_instance
* @param {object} obj Action Object
**/
"destroy_instance": function (obj) {
var element = obj.element;
util.loader("", "status_dict.destroying", "trash");
jIO.util.ajax({
"url": element.href,
"type": element.getAttribute("data-method")
})
.then(function (response) {
util.loader("", "status_dict.success", "check");
$.mobile.changePage("#services");
})
.fail(util.error);
},
/**
* Start a software instance
* @method start_instance
......@@ -4770,7 +4793,7 @@
}
})
.then(function (answer) {
if (answer.response.result === "success") {
if (answer.response && answer.response.result === "success") {
pass_id = answer.response.id;
switch (config.gadget.getAttribute("data-reset")) {
case "login_state":
......@@ -4780,10 +4803,17 @@
util.loader("", "status_dict.saved", "check");
return pass_id;
}
// install new instance
if (answer.response && answer.response.location) {
return jIO.util.ajax({"url": answer.response.location})
.then(function (instance_location) {
return util.parse(instance_location.target.responseText)._relative_url;
}).fail(util.error);
}
})
.then(function (id) {
if (id && config.state.callback) {
$.mobile.changePage(config.state.callback.replace("__id__", id));
$.mobile.changePage(config.state.callback.replace("__id__", window.encodeURIComponent(id)));
}
})
.fail(util.error);
......@@ -6218,7 +6248,7 @@
// TODO: storages should not call this, this should call storage!
app.store = function (reply) {
var i, obj, key, promises, record, items, store, pass, send_status,
method, validate, hacked_view;
method, validate, hacked_view, header;
pass = reply.pass;
......@@ -6316,7 +6346,7 @@
}
} else {
// do it again, Sam...
promises[i] = jIO.util.ajax({
promises[0] = jIO.util.ajax({
"url": storage.items.dict.url,
"type": "GET",
"data": JSON.stringify({"_id":""})
......@@ -6333,15 +6363,20 @@
"data": pass.form_data
});
})
.then(function (foo) {
return foo;
.then(function (erp5_response) {
header = erp5_response.target.getResponseHeader("Location");
console.log(header)
return RSVP.resolve({
"status": 200,
"foo": "bar",
"location": header
});
})
.fail(util.error);
}
return RSVP.all(promises)
.then(function (response) {
// for single item actions, allow to return a status message
if (response.length === 1 && reply.pass.reply) {
send_status = response[0];
......
......@@ -60,7 +60,9 @@
"removing": "Removing",
"starting": "Starting...",
"stopping": "Shutting Down...",
"success": "Ok"
"success": "Ok",
"created": "Created",
"destroying": "Destroying"
},
"validation_dict": {
"general": "Please correct the highlighted fields.",
......
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