Commit 70843959 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_jio: Use different view for Organisation depending of it's Role

Differ Organisations used as a User's Company and a location where computers are placed.
parent 807a4ac5
......@@ -63,6 +63,9 @@
child_gadget_url = "gadget_erp5_page_slap_network_list.html";
} else if (result.portal_type === "Project Module") {
child_gadget_url = "gadget_erp5_page_slap_project_list.html";
} else if ((result.portal_type === "Organisation") &&
result.role === "host") {
child_gadget_url = "gadget_erp5_page_slap_site_view.html";
} else if (result.portal_type !== undefined) {
child_gadget_url = 'gadget_erp5_page_slap_' +
result.portal_type.replace(/ /g, '_').toLowerCase() +
......
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.9659.10933.28535</string> </value>
<value> <string>976.9867.41515.40260</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1559571845.53</float>
<float>1561425760.83</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -22,37 +22,6 @@
// 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 (1 || (result.data.rows[i].value.hasOwnProperty("Computer_getNewsDict"))) {
value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.Computer_getNewsDict;
result.data.rows[i].value.Computer_getNewsDict = {
field_gadget_param : {
css_class: "",
description: "The Status",
hidden: 0,
"default": {jio_key: value, result: value},
key: "status",
url: "gadget_slapos_computer_status.html",
title: "Status",
type: "GadgetField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
......@@ -92,12 +61,8 @@
]);
})
.push(function (result) {
var editable = gadget.state.editable;
var column_list = [
['title', 'Title'],
['reference', 'Reference'],
['Computer_getNewsDict', 'Status']
];
var column_list = [],
editable = gadget.state.editable;
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
......@@ -123,65 +88,6 @@
"hidden": 0,
"type": "StringField"
},
"my_default_geographical_location_longitude": {
"description": "",
"title": "Longitude",
"default": gadget.state.doc.default_geographical_location_longitude,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_geographical_location_longitude",
"hidden": 0,
"type": "FloatField"
},
"my_default_geographical_location_latitude": {
"description": "",
"title": "Latitude",
"default": gadget.state.doc.default_geographical_location_latitude,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_geographical_location_latitude",
"hidden": 0,
"type": "FloatField"
},
"my_monitoring_status": {
"description": "",
"title": "Monitoring",
"default": {jio_key: gadget.state.jio_key,
result: gadget.state.doc.news},
"css_class": "",
"required": 1,
"editable": 0,
"url": "gadget_slapos_site_status.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
"type": "GadgetField"
},
"my_organisation_map": {
"description": "",
"title": "Map",
"default": [
{"jio_key": gadget.state.jio_key,
"doc": {"title": gadget.state.doc.title,
"reference": gadget.state.doc.reference,
"result": gadget.state.doc.news,
"latitude": gadget.state.doc.default_geographical_location_latitude,
"longitude": gadget.state.doc.default_geographical_location_longitude}
}
],
"css_class": "",
"required": 1,
"editable": 0,
"url": "gadget_slapos_computer_map.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
"type": "GadgetField"
},
"listbox": {
"column_list": column_list,
"show_anchor": 0,
......@@ -199,7 +105,7 @@
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [["title", "ascending"]],
"title": "Associated Servers",
"title": "Associated Persons",
"type": "ListBox"
}
}},
......
......@@ -216,7 +216,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superrafael</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -230,7 +230,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.51812.23976.40123</string> </value>
<value> <string>976.40660.54394.14284</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -248,7 +248,7 @@
</tuple>
<state>
<tuple>
<float>1554319566.54</float>
<float>1561428006.67</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<!--
data-i18n=Slapos
-->
<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_site_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>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Page" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_slap_site_view.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_page_slap_site_view_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Page</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Organisation Site View</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>003</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, jIO, Blob */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, jIO, Blob) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("updateDocument", "updateDocument")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
/////////////////////////////////////////////////////////////////
// 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 (1 || (result.data.rows[i].value.hasOwnProperty("Computer_getNewsDict"))) {
value_jio_key = result.data.rows[i].id;
value = result.data.rows[i].value.Computer_getNewsDict;
result.data.rows[i].value.Computer_getNewsDict = {
field_gadget_param : {
css_class: "",
description: "The Status",
hidden: 0,
"default": {jio_key: value, result: value},
key: "status",
url: "gadget_slapos_computer_status.html",
title: "Status",
type: "GadgetField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
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: 'Data updated.', status: 'success'});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.onStateChange(function () {
var gadget = this, data;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_view'),
gadget.getSetting("hateoas_url")
]);
})
.push(function (result) {
var editable = gadget.state.editable;
var column_list = [
['title', 'Title'],
['reference', 'Reference'],
['Computer_getNewsDict', 'Status']
];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"my_title": {
"description": "",
"title": "Title",
"default": gadget.state.doc.title,
"css_class": "",
"required": 1,
"editable": editable,
"key": "title",
"hidden": 0,
"type": "StringField"
},
"my_reference": {
"description": "",
"title": "Reference",
"default": gadget.state.doc.reference,
"css_class": "",
"required": 1,
"editable": 0,
"key": "reference",
"hidden": 0,
"type": "StringField"
},
"my_default_geographical_location_longitude": {
"description": "",
"title": "Longitude",
"default": gadget.state.doc.default_geographical_location_longitude,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_geographical_location_longitude",
"hidden": 0,
"type": "FloatField"
},
"my_default_geographical_location_latitude": {
"description": "",
"title": "Latitude",
"default": gadget.state.doc.default_geographical_location_latitude,
"css_class": "",
"required": 1,
"editable": 1,
"key": "default_geographical_location_latitude",
"hidden": 0,
"type": "FloatField"
},
"my_monitoring_status": {
"description": "",
"title": "Monitoring",
"default": {jio_key: gadget.state.jio_key,
result: gadget.state.doc.news},
"css_class": "",
"required": 1,
"editable": 0,
"url": "gadget_slapos_site_status.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
"type": "GadgetField"
},
"my_organisation_map": {
"description": "",
"title": "Map",
"default": [
{"jio_key": gadget.state.jio_key,
"doc": {"title": gadget.state.doc.title,
"reference": gadget.state.doc.reference,
"result": gadget.state.doc.news,
"latitude": gadget.state.doc.default_geographical_location_latitude,
"longitude": gadget.state.doc.default_geographical_location_longitude}
}
],
"css_class": "",
"required": 1,
"editable": 0,
"url": "gadget_slapos_computer_map.html",
"sandbox": "",
"key": "monitoring_status",
"hidden": 0,
"type": "GadgetField"
},
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "slap_organisation_computer_listbox",
"lines": 10,
"list_method": "Organisation_getComputerTrackingList",
"list_method_template": result[1] + "ERP5Document_getHateoas?mode=search&" +
"list_method=Organisation_getComputerTrackingList&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": "Associated Servers",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"left",
[["my_title"], ["my_reference"], ['my_monitoring_status'],
["my_default_geographical_location_longitude"],
["my_default_geographical_location_latitude"]]
], [
"right",
[['my_organisation_map']]
], [
"bottom",
[["listbox"]]
]]
}
});
})
.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_organisation"}})
]);
})
.push(function (url_list) {
var header_dict = {
selection_url: url_list[1],
page_title: "Site : " + gadget.state.doc.title,
delete_url: url_list[2],
save_action: true
};
if (!gadget.state.editable) {
header_dict.edit_content = url_list[0];
}
return gadget.updateHeader(header_dict);
});
});
}(window, rJS, RSVP, jIO, Blob));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_slap_site_view.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>rjs_gadget_erp5_page_slap_site_view_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget SlapOS Organisation site View</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>003</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -108,7 +108,7 @@
<value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n
# generated on Fri, 24 Jun 2019 00:00:00 GMT+0200\n
# generated on Fri, 24 Jun 2019 01:00:00 GMT+0200\n
CACHE:\n
favicon.ico\n
font-awesome/font-awesome-webfont.eot?v=4.6.3\n
......@@ -315,6 +315,8 @@ gadget_erp5_page_slap_network_list.html\n
gadget_erp5_page_slap_network_list.js\n
gadget_erp5_page_slap_organisation_view.html\n
gadget_erp5_page_slap_organisation_view.js\n
gadget_erp5_page_slap_site_view.html\n
gadget_erp5_page_slap_site_view.js\n
gadget_erp5_page_slap_parameter_form.css\n
gadget_erp5_page_slap_parameter_form.html\n
gadget_erp5_page_slap_parameter_form.js\n
......@@ -567,7 +569,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.40547.59496.46250</string> </value>
<value> <string>976.40663.4126.24849</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -585,7 +587,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1561423738.11</float>
<float>1561428124.08</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -111,6 +111,8 @@ web_page_module/rjs_gadget_erp5_page_slap_service_list_html
web_page_module/rjs_gadget_erp5_page_slap_service_list_js
web_page_module/rjs_gadget_erp5_page_slap_site_list_html
web_page_module/rjs_gadget_erp5_page_slap_site_list_js
web_page_module/rjs_gadget_erp5_page_slap_site_view_html
web_page_module/rjs_gadget_erp5_page_slap_site_view_js
web_page_module/rjs_gadget_erp5_page_slap_slave_instance_view_html
web_page_module/rjs_gadget_erp5_page_slap_software_installation_view_html
web_page_module/rjs_gadget_erp5_page_slap_software_installation_view_js
......
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