Commit 865d8dea authored by Romain Courteaud's avatar Romain Courteaud

slapos_jio: drop Computer Network scripts

parent fa995bf0
<!doctype html>
<html>
<!--
data-i18n=Title
data-i18n=Portal Type
data-i18n=Parent Relative Url
data-i18n=New Network
data-i18n=New Network created.
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_add_network.js"></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, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, jIO) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.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 RSVP.all([form_gadget.getContent(),
gadget.getSettingList(['me', 'hateoas_url'])]);
})
.push(function (result) {
var doc = result[0],
me = result[1][0],
url = result[1][1];
return gadget.jio_putAttachment(me,
url + me + "/Person_requestNetwork", {title: doc.title});
})
.push(function (attachment) {
return jIO.util.readBlobAsText(attachment.target.response);
})
.push(function (response) {
return JSON.parse(response.target.result);
})
.push(function (result) {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": result.relative_url, "page": "slap_controller"}});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function () {
var gadget = this,
page_title_translation,
translation_list = [
"Title",
"Portal Type",
"Parent Relative Url",
"New Network",
"New Network created."
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
page_title_translation = result[1][3];
gadget.message_translation = result[1][4];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "The name of a document in ERP5",
"title": result[1][0],
"default": "",
"css_class": "",
"required": 0,
"editable": 1,
"key": "title",
"hidden": 0,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"]]
]]
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_network_module"
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'change', options: {page: "slap_network_list"}})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: page_title_translation,
selection_url: url_list[0],
submit_action: true
});
});
});
}(window, rJS, RSVP, jIO));
\ No newline at end of file
<!DOCTYPE html>
<html>
<!--
data-i18n=Title
data-i18n=Reference
data-i18n=State
data-i18n=Tickets
-->
<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_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_all_ticket_list.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function () {
var gadget = this,
lines_limit,
tickets_translation,
translation_list = [
"Title",
"Reference",
"State",
"Tickets"
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getSetting("listbox_lines_limit", 20),
window.getSettingMe(gadget)
]);
})
.push(function (setting) {
lines_limit = setting[0];
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.jio_get(setting[1]),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
var column_list = [
['title', result[2][0]],
['reference', result[2][1]],
['translated_simulation_state_title', result[2][2]]
];
tickets_translation = result[2][3];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_site_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%20%28%22Support%20Request%22%2C%20%22Upgrade%20Decision%22%2C%20%22Regularisation%20Request%22%29%20AND%20destination_decision_reference%3A" + result[1].reference,
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["modification_date", "Descending"]],
"title": tickets_translation,
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return gadget.getSetting('frontpage_gadget');
})
.push(function (frontpage_gadget) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_ticket"}}),
gadget.getUrlFor({command: "change", options: {"page": "slap_rss_ticket"}}),
gadget.getUrlFor({command: "change", options: {"page": frontpage_gadget}}),
gadget.updatePanel({jio_key: "support_request_module"}),
gadget.getUrlFor({command: "change", options: {"page": "slap_ticket_list"}})
]);
})
.push(function (result) {
return gadget.updateHeader({
page_title: tickets_translation,
filter_action: true,
selection_url: result[2],
tab_url: result[4],
add_url: result[0],
rss_url: result[1]
});
});
});
}(window, rJS, RSVP));
<!DOCTYPE html>
<html>
<!--
data-i18n=Data updated.
data-i18n=Title
data-i18n=Reference
data-i18n=Allocation Scope
data-i18n=Status
data-i18n=Monitoring Status
data-i18n=The name of a document in ERP5
data-i18n=Current Project
data-i18n=Current Organisation
data-i18n=Associated Servers
data-i18n=Computer Network:
data-i18n=Computer Network
-->
<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_computer_network_view.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, jIO, Blob */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("getAccessStatus")) {
value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.getAccessStatus;
result.data.rows[i].value.getAccessStatus = {
field_gadget_param : {
css_class: "",
description: "The Status",
hidden: 0,
"default": "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status",
url: "gadget_slapos_status.html",
title: gadget.title_translation,
type: "GadgetField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {};
}
}
return result;
});
})
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
doc: options.doc,
editable: 1
});
})
.onEvent('submit', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (content) {
return gadget.updateDocument(content);
})
.push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.onStateChange(function () {
var gadget = this,
page_title_translation,
translation_list = [
"Data updated.",
"Title",
"Reference",
"Allocation Scope",
"Status",
"Monitoring Status",
"The name of a document in ERP5",
"Current Project",
"Current Organisation",
"Associated Servers",
"Computer Network"
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.getTranslationList(translation_list),
gadget.getSetting("hateoas_url")
]);
})
.push(function (result) {
gadget.title_translation = result[1][4];
gadget.message_translation = result[1][0];
page_title_translation = result[1][10];
var editable = gadget.state.editable,
column_list = [
['title', result[1][1]],
['reference', result[1][2]],
['allocation_scope_translated_title', result[1][3]],
['getAccessStatus', result[1][4]]
];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "",
"title": result[1][1],
"default": gadget.state.doc.title,
"css_class": "",
"required": 0,
"editable": editable,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_reference": {
"description": "",
"title": result[1][2],
"default": gadget.state.doc.reference,
"css_class": "",
"required": 0,
"editable": 0,
"key": "reference",
"hidden": 0,
"type": "StringField"
},
"my_monitoring_status": {
"description": "",
"title": result[1][5],
"default": "",
"renderjs_extra": JSON.stringify({
jio_key: gadget.state.jio_key,
result: gadget.state.doc.news
}),
"css_class": "",
"required": 0,
"editable": 0,
"url": "gadget_slapos_status.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
"type": "GadgetField"
},
"my_source_project": {
"description": result[1][6],
"title": result[1][7],
"default": gadget.state.doc.source_project_title,
"css_class": "",
"required": 0,
"editable": 0,
"key": "",
"hidden": gadget.state.doc.source_project_title ? 0 : 1,
"type": "StringField"
},
"my_source_section": {
"description": result[1][6],
"title": result[1][8],
"default": gadget.state.doc.source_section_title,
"css_class": "",
"required": 0,
"editable": 0,
"key": "",
"hidden": gadget.state.doc.source_section_title ? 0 : 1,
"type": "StringField"
},
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_project_compute_node_listbox",
"lines": 10,
"list_method": "ComputerNetwork_getComputeNodeList",
"list_method_template": result[2] + "ERP5Document_getHateoas?mode=search&" +
"list_method=ComputerNetwork_getComputeNodeList&relative_url=" +
gadget.state.jio_key + "&default_param_json=eyJpZ25vcmVfdW5rbm93bl9jb2x1bW5zIjogdHJ1ZX0={&query,select_list*,limit*,sort_on*,local_roles*}",
"query": "urn:jio:allDocs?query=",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["title", "ascending"]],
"title": result[1][9],
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_reference"]]
], [
"right",
[['my_monitoring_status'], ["my_source_project"], ["my_source_section"]]
], [
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_network_module"
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {editable: true}}),
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: "change", options: {page: "slap_delete_network"}}),
gadget.getUrlFor({command: "change", options: {page: "slap_transfer_computer_network"}})
]);
})
.push(function (url_list) {
var header_dict = {
selection_url: url_list[1],
page_title: page_title_translation + " :" + gadget.state.doc.title,
delete_url: url_list[2],
save_action: true
};
if (gadget.state.doc.is_owner !== undefined) {
header_dict.transfer_url = url_list[3];
}
if (!gadget.state.editable) {
header_dict.edit_content = url_list[0];
}
return gadget.updateHeader(header_dict);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<!doctype html>
<html>
<!--
data-i18n=Network to be removed:
data-i18n=Warning
data-i18n=You cannot delete this object because you have associated Compute Nodes and/or services.
data-i18n=Parent Relative Url
data-i18n=Delete Network:
data-i18n=Network is Deleted.
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Delete Project</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_slap_delete_network.js"></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 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(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("jio_getAttachment", "jio_getAttachment")
.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.getContent();
})
.push(function (doc) {
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/ComputerNetwork_invalidate", {});
});
})
.push(function () {
return gadget.notifySubmitted({message: gadget.message_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_network_list"}});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this,
page_title_translation,
translation_list = [
"Network to be removed:",
"Warning",
"You cannot delete this object because you have associated Compute Nodes and/or services.",
"Parent Relative Url",
"Delete Network:",
"Network is Deleted."
];
return new RSVP.Queue()
.push(function () {
return gadget.getSetting("hateoas_url")
.push(function (url) {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key),
gadget.jio_getAttachment(options.jio_key,
url + options.jio_key + "/ComputerNetwork_hasComputeNode"),
gadget.getTranslationList(translation_list)
]);
});
})
.push(function (result) {
options.doc = result[1];
options.can_delete = result[2] ? 0 : 1;
page_title_translation = result[3][4];
gadget.message_translation = result[3][5];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "",
"title": result[3][0],
"default": options.doc.title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "title_label",
"hidden": 0,
"type": "StringField"
},
"message": {
"description": "",
"title": result[3][1],
"default": result[3][2],
"css_class": "",
"required": 1,
"editable": 0,
"key": "title_label",
"hidden": options.can_delete,
"type": "StringField"
},
"my_relative_url": {
"description": "",
"title": result[3][3],
"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: [[
"left",
[["my_title"], ["my_relative_url"]]
], [
"bottom",
[["message"]]
]]
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_network_module"
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {editable: true}}),
gadget.getUrlFor({command: 'history_previous'})
]);
})
.push(function (result) {
var header_dict = {
selection_url: result[1],
page_title: page_title_translation + " " + options.doc.title
};
if (options.can_delete) {
header_dict.submit_action = true;
}
return gadget.updateHeader(header_dict);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
<!DOCTYPE html>
<html>
<!--
data-i18n=Title
data-i18n=Reference
data-i18n=Status
data-i18n=Networks
-->
<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_network_list.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP, JSON */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP, JSON) {
"use strict";
rJS(window)
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("updatePanel", "updatePanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, value, value_jio_key, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("ComputerNetwork_getNewsDict")) {
value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.ComputerNetwork_getNewsDict;
result.data.rows[i].value.ComputerNetwork_getNewsDict = {
field_gadget_param : {
css_class: "",
description: "The Status",
hidden: 0,
default: "",
renderjs_extra: JSON.stringify({
jio_key: value_jio_key,
result: value
}),
key: "status",
url: "gadget_slapos_status.html",
title: "Status",
type: "GadgetField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function () {
var gadget = this,
lines_limit,
networks_translation,
translation_list = [
"Title",
"Reference",
"Status",
"Networks"
];
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.getSetting("listbox_lines_limit", 20),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
var column_list = [
['title', result[2][0]],
['reference', result[2][1]],
['ComputerNetwork_getNewsDict', result[2][2]]
],
form_list = result[0];
lines_limit = result[1];
networks_translation = result[2][3];
return form_list.render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_network_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
// Filter by My Own networks
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
"Computer Network%22%20AND%20validation_state%3Avalidated",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["reference", "ascending"]],
"title": networks_translation,
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return gadget.getSetting('frontpage_gadget');
})
.push(function (frontpage_gadget) {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "slap_add_network"}}),
gadget.getUrlFor({command: "change", options: {"page": frontpage_gadget}}),
gadget.updatePanel({jio_key: "computer_network_module"})
]);
})
.push(function (result) {
return gadget.updateHeader({
page_title: networks_translation,
filter_action: true,
selection_url: result[1],
add_url: result[0]
});
});
});
}(window, rJS, RSVP, JSON));
\ No newline at end of file
<!doctype html>
<html>
<!--
data-i18n=The name of a document in ERP5
data-i18n=Title
data-i18n=Reference
data-i18n=Current Project
data-i18n=Future Project
data-i18n=Current Organisation
data-i18n=Future Organisation
data-i18n=Parent Relative Url
data-i18n=Transfer Computer Network
data-i18n=Computer Network is transferred.
-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Add Text Document</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_slapos_utils.js" type="text/javascript"></script>
<script src="gadget_erp5_page_slap_transfer_computer_network.js"></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 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(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_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.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.getContent();
})
.push(function (doc) {
return gadget.getSetting("hateoas_url")
.push(function (url) {
return gadget.jio_putAttachment(doc.relative_url,
url + doc.relative_url + "/ComputerNetwork_createMovement", doc);
})
.push(function () {
return gadget.notifySubmitted({message: gadget.message_translation, status: 'success'})
.push(function () {
// Workaround, find a way to open document without break gadget.
return gadget.redirect({"command": "change",
"options": {"jio_key": doc.relative_url,
"page": "slap_controller"}});
});
});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function (options) {
var gadget = this,
translation_list = [
"The name of a document in ERP5",
"Title",
"Reference",
"Project",
"Organisation",
"Parent Relative Url",
"Transfer Computer Network",
"Computer Network will be transferred soon."
];
return new RSVP.Queue()
.push(function () {
return window.getSettingMe(gadget);
})
.push(function (me) {
return gadget.jio_get(me);
})
.push(function (me) {
var i, destination_list = '"NULL",';
for (i in me.assignment_destination_list) {
if (me.assignment_destination_list.hasOwnProperty(i)) {
destination_list += '"' + me.assignment_destination_list[i] + '",';
}
}
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.jio_get(options.jio_key),
gadget.jio_allDocs({
query: 'portal_type:"Project" AND validation_state:"validated"',
sort_on: [['title', 'ascending']],
select_list: ['reference', 'title'],
limit: 1000
}),
gadget.jio_allDocs({
query: 'portal_type:"Organisation" AND role_title: "Client" AND relative_url:(' + destination_list + ')',
sort_on: [['title', 'ascending']],
select_list: ['reference', 'title'],
limit: 1000
}),
gadget.getTranslationList(translation_list)
]);
})
.push(function (result) {
gadget.page_title_translation = result[4][6];
gadget.message_translation = result[4][7];
var doc = result[1],
default_project = "",
default_organisation = "",
organisation_list = [["", ""]],
project_list = [["", ""]],
i,
project_len = result[2].data.total_rows,
organisation_len = result[3].data.total_rows;
for (i = 0; i < project_len; i += 1) {
if (result[2].data.rows[i].value.title === doc.source_project_title) {
default_project = result[2].data.rows[i].id;
}
project_list.push([
result[2].data.rows[i].value.title || result[2].data.rows[i].value.reference,
result[2].data.rows[i].id
]);
}
for (i = 0; i < organisation_len; i += 1) {
if (result[3].data.rows[i].value.title === doc.source_section_title) {
default_organisation = result[3].data.rows[i].id;
}
organisation_list.push([
result[3].data.rows[i].value.title || result[3].data.rows[i].value.reference,
result[3].data.rows[i].id
]);
}
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": result[4][0],
"title": result[4][1],
"default": doc.title,
"css_class": "",
"required": 1,
"editable": 0,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_reference": {
"description": result[4][0],
"title": result[4][2],
"default": doc.reference,
"css_class": "",
"required": 1,
"editable": 0,
"key": "reference",
"hidden": 0,
"type": "StringField"
},
"my_destination_project": {
"description": result[4][0],
"title": result[4][3],
"default": default_project,
"items": project_list,
"css_class": "",
"required": 0,
"editable": 1,
"key": "destination_project",
"hidden": 0,
"type": "ListField"
},
"my_destination_section": {
"description": result[4][0],
"title": result[4][4],
"default": default_organisation,
"items": organisation_list,
"css_class": "",
"required": 0,
"editable": 1,
"key": "destination_section",
"hidden": 0,
"type": "ListField"
},
"my_relative_url": {
"description": "",
"title": result[4][5],
"default": options.jio_key,
"css_class": "",
"required": 0,
"editable": 1,
"key": "relative_url",
"hidden": 1,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_reference"], ["my_source_project"], ["my_source_section"],
["my_destination_project"], ["my_destination_section"], ["my_relative_url"]]
]]
}
});
})
.push(function () {
return gadget.updatePanel({
jio_key: "computer_network_module"
});
})
.push(function () {
return gadget.getUrlFor({command: 'history_previous'});
})
.push(function (selection_url) {
return gadget.updateHeader({
page_title: gadget.page_title_translation,
selection_url: selection_url,
submit_action: true
});
});
});
}(window, rJS, RSVP));
\ No newline at end of file
portal = context.getPortalObject()
return portal.portal_catalog(
portal_type="Compute Node",
validation_state="validated",
subordination__uid=context.getUid(),
default_strict_allocation_scope_uid="!=%s" % portal.portal_categories.allocation_scope.close.forever.getUid()
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerNetwork_getComputeNodeList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import json
return json.dumps(len(context.ComputerNetwork_getComputeNodeList()))
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
<global name="object" module="__builtin__"/>
<none/>
</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>**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ComputerNetwork_hasComputeNode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
This diff is collapsed.
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