Commit 6f7596ed authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Alain Takoudjou

[erp5_web_monitoring] use Hosting Subscription software_type

Intead of using opml software type, Hosting Subscription has now his own software type which simplify management.
parent 306e95c0
......@@ -5,103 +5,6 @@
var gadget_klass = rJS(window);
function getHostingData(gadget, filter, status_sort) {
// optimized way to fetch hosting subscription list
var hosting_dict = {},
instance_dict = {},
compare_function,
total_rows = 0;
return gadget.jio_allDocs(filter)
.push(function (result) {
var i;
total_rows = result.data.total_rows;
for (i = 0; i < result.data.total_rows; i += 1) {
hosting_dict[result.data.rows[i].id] = {
id: result.data.rows[i].id,
value: {
url: result.data.rows[i].value.url,
status: "WARNING",
date: 'Not Synchronized',
title: result.data.rows[i].value.title,
amount: 0
}
};
}
return gadget.jio_allDocs({
query: '(portal_type:"opml-outline") OR (portal_type:"Software Instance")',
select_list: [
"parent_url",
"status",
"parent_id",
"date",
"portal_type"
]
});
})
.push(function (result) {
var i,
key,
item,
row_list = [];
for (i = 0; i < result.data.total_rows; i += 1) {
if (result.data.rows[i].value.portal_type === 'opml-outline') {
if (hosting_dict.hasOwnProperty(result.data.rows[i].value.parent_url)) {
instance_dict[result.data.rows[i].id] = {
parent_id: result.data.rows[i].value.parent_url
};
}
}
}
for (i = 0; i < result.data.total_rows; i += 1) {
if (result.data.rows[i].value.portal_type === 'Software Instance') {
if (instance_dict.hasOwnProperty(result.data.rows[i].value.parent_id)) {
instance_dict[result.data.rows[i].value.parent_id].date =
result.data.rows[i].value.date;
instance_dict[result.data.rows[i].value.parent_id].status =
result.data.rows[i].value.status;
}
}
}
//calculate hosting subscription status
for (key in instance_dict) {
if (instance_dict.hasOwnProperty(key)) {
item = hosting_dict[instance_dict[key].parent_id].value;
item.amount += 1;
if (item.status !== "ERROR") {
item.status = instance_dict[key].status || "WARNING";
}
item.date = instance_dict[key].date || 'Not Synchronized';
item.synced = item.status !== "WARNING" ? "YES" : "NO";
}
}
for (key in hosting_dict) {
if (hosting_dict.hasOwnProperty(key)) {
row_list.push(hosting_dict[key]);
}
}
if (status_sort !== undefined) {
compare_function = function (first, second) {
first = first.toUpperCase();
second = second.toUpperCase();
if (first > second) {
return 1;
}
if (first < second) {
return -1;
}
return 0;
};
row_list.sort(function (a, b) {
if (status_sort === "ascending") {
return compare_function(b.value.status, a.value.status);
}
return compare_function(a.value.status, b.value.status);
});
}
return {data: {total_rows: total_rows, rows: row_list}};
});
}
gadget_klass
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
......@@ -111,31 +14,16 @@
.declareAcquiredMethod("renderApplication", "renderApplication")
.declareAcquiredMethod('jio_allDocs', 'jio_allDocs')
.allowPublicAcquisition("getUrlFor", function (param_list) {
if (param_list[0].options.jio_key !== undefined &&
param_list[0].options.query.indexOf('portal_type:"opml"') !== -1) {
param_list[0].options.page = "ojsm_hosting_subscription_view";
param_list[0].options.opml_key = param_list[0].options.jio_key;
}
return this.getUrlFor(param_list[0]);
})
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this,
status_sort,
j;
for (j = 0; j < param_list[0].sort_on.length; j += 1) {
if (param_list[0].sort_on[j][0] === 'status') {
status_sort = param_list[0].sort_on[j][1];
}
}
return getHostingData(gadget, param_list[0], status_sort)
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i,
len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("date")) {
result.data.rows[i].value.date = {
if (result.data.rows[i].value.hasOwnProperty("status_date")) {
result.data.rows[i].value.status_date = {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
......@@ -144,7 +32,7 @@
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": new Date(result.data.rows[i].value.date).toUTCString(),
"default": new Date(result.data.rows[i].value.status_date).toUTCString(),
key: "date",
required: 0,
timezone_style: 0,
......@@ -209,9 +97,8 @@
var column_list = [
['status', 'Status'],
['title', 'Hosting Subscription'],
['amount', 'Instance Amount'],
['date', 'Status Date'],
['synced', 'Synced?']
['instance_amount', 'Instance Amount'],
['status_date', 'Status Date']
];
return form_list.render({
erp5_document: {
......@@ -226,13 +113,11 @@
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=%28portal_type%3A%22" +
"opml" + "%22%29AND%28active%3A%22" +
"true" + "%22%29AND%28url%3A%22" +
"https://%25%22%29",
"Hosting Subscription" + "%22%29",
"portal_type": [],
"search_column_list": [['status', 'Status'], ['title', 'Hosting Subscription']],
"sort_column_list": [['title', 'Hosting Subscription']],
"sort": [['title', 'ascending']],
"sort_column_list": [['status', 'Status'], ['title', 'Hosting Subscription'], ['instance_amount', 'Instance Amount']],
"sort": [['status', 'ascending'], ['title', 'ascending']],
"title": "Hosting Subscriptions",
"command": "index",
"type": "ListBox"
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42290.3299.27938</string> </value>
<value> <string>971.13420.64097.35857</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1519222382.45</float>
<float>1540569088.19</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -264,9 +264,9 @@
if (uri_param.has('url') && uri_param.has('password') &&
uri_param.has('username') && uri_param.get('url').startsWith('http')) {
return {
opml_url: uri_param.get('url'),
username: uri_param.get('username'),
password: uri_param.get('password')
opml_url: uri_param.get('url').trim(),
username: uri_param.get('username').trim(),
password: uri_param.get('password').trim()
};
}
}
......@@ -277,9 +277,9 @@
connection_dict["monitor-user"] &&
connection_dict["monitor-password"]) {
return {
opml_url: connection_dict["monitor-url"],
username: connection_dict["monitor-user"],
password: connection_dict["monitor-password"]
opml_url: connection_dict["monitor-url"].trim(),
username: connection_dict["monitor-user"].trim(),
password: connection_dict["monitor-password"].trim()
};
}
}
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.60726.55816.57890</string> </value>
<value> <string>967.60730.33169.16435</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1527847350.32</float>
<float>1530700819.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -10,7 +10,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojsm_hosting_subscription_view.js"></script>
<script src="gadget_officejs_jio_hosting_subscription_view.js"></script>
</head>
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_view.html</string> </value>
<value> <string>gadget_officejs_jio_hosting_subscription_view.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -93,7 +93,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_view_html</string> </value>
<value> <string>gadget_officejs_jio_hosting_subscription_view_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.46060.41528.54152</string> </value>
<value> <string>971.13402.51340.4454</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1507901514.08</float>
<float>1540563538.46</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, document, RSVP, Rusha, escape */
/*global window, rJS, document, RSVP, escape */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, document, RSVP, Rusha, escape) {
(function (window, rJS, document, RSVP, escape) {
"use strict";
var gadget_klass = rJS(window),
rusha = new Rusha();
function generateHash(str) {
return rusha.digestFromString(str);
}
var gadget_klass = rJS(window);
gadget_klass
.setState({
ouline_list: "",
opml: ""
hosting_subscription: ""
})
.ready(function (g) {
g.props = {};
......@@ -95,15 +90,21 @@
title: 'Hosting Subscriptions View'
})
.push(function () {
return gadget.jio_get(options.opml_key);
return gadget.jio_get(options.jio_key);
})
.push(function (hosting_doc) {
return gadget.changeState({hosting_subscription: hosting_doc});
})
.push(function () {
return gadget.jio_get(gadget.state.hosting_subscription.opml_url);
})
.push(function (opml_doc) {
return gadget.changeState({opml: opml_doc});
})
.push(function () {
return gadget.jio_allDocs({
query: '(portal_type:"opml-outline") AND (parent_id:"' +
generateHash(options.opml_key) + '")'
query: '(portal_type:"Opml Outline") AND (parent_id:"' +
options.jio_key + '")'
});
})
.push(function (ouline_list) {
......@@ -280,27 +281,27 @@
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'store_and_change', options: {
page: "ojsm_jump",
jio_key: gadget.state.opml.url,
title: gadget.state.opml.title,
jio_key: gadget.state.hosting_subscription.opml_url,
title: gadget.state.hosting_subscription.title,
view_title: "Related OPML",
search_page: "ojsm_status_list"
}})
]);
})
.push(function (url_list) {
if (gadget.state.ouline_list.length === 0) {
if (gadget.state.hosting_subscription.instance_amount === 0) {
gadget.element.querySelector('.hosting-title').textContent =
gadget.state.opml.title + " - Not synchronized!";
gadget.state.hosting_subscription.title + " - Not synchronized!";
return gadget.updateHeader({
page_title: "Hosting Subscription: " + gadget.state.opml.title,
page_title: "Hosting Subscription: " + gadget.state.hosting_subscription.title,
selection_url: url_list[0],
jump_url: url_list[1]
});
}
gadget.element.querySelector('.hosting-title').textContent =
gadget.state.opml.title;
gadget.state.hosting_subscription.title;
return gadget.updateHeader({
page_title: "Hosting Subscription: " + gadget.state.opml.title,
page_title: "Hosting Subscription: " + gadget.state.hosting_subscription.title,
selection_url: url_list[0],
jump_url: url_list[1],
save_action: true
......@@ -308,4 +309,4 @@
});
});
}(window, rJS, document, RSVP, Rusha, escape));
\ No newline at end of file
}(window, rJS, document, RSVP, escape));
\ No newline at end of file
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_view.js</string> </value>
<value> <string>gadget_officejs_jio_hosting_subscription_view.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -93,7 +93,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_view_js</string> </value>
<value> <string>gadget_officejs_jio_hosting_subscription_view_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.33706.12675.27699</string> </value>
<value> <string>971.13401.64783.28074</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1510929502.78</float>
<float>1540563489.91</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, Rusha) {
"use strict";
var rusha = new Rusha();
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -208,17 +210,16 @@
.push(function () {
return new RSVP.Queue()
.push(function () {
var hosting_key = rusha.digestFromString(gadget.state.opml_key);
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({command: 'push_history', options: {
page: "ojsm_jump",
jio_key: gadget.state.opml_key,
jio_key: hosting_key,
title: gadget.state.opml_title,
jump_page: "ojsm_hosting_subscription_view",
view_title: "Related Hosting Subscription",
opml_key: gadget.state.opml_key
view_title: "Related Hosting Subscription"
}}),
gadget.getUrlFor({command: 'change', options: {
page: 'ojsm_opml_delete',
......@@ -240,4 +241,4 @@
});
});
});
}(window, rJS, RSVP));
}(window, rJS, RSVP, Rusha));
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42338.34743.44339</string> </value>
<value> <string>971.13427.58478.56115</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1519225208.75</float>
<float>1540565190.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -134,14 +134,13 @@
})
.push(function (outline_doc) {
// get opml
return gadget.jio_get(outline_doc.parent_url);
return RSVP.all([outline_doc.parent_id,
gadget.jio_get(outline_doc.parent_url)]);
})
.push(function (opml_document) {
opml_doc = opml_document;
.push(function (document_list) {
opml_doc = document_list[1];
return gadget.getUrlFor({command: 'push_history', options: {
jio_key: options.doc.reference,
page: 'ojsm_hosting_subscription_view',
opml_key: opml_document.url
jio_key: document_list[0]
}});
})
.push(function (hosting_url) {
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.22632.27070.1706</string> </value>
<value> <string>971.13514.36384.35805</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1523626142.93</float>
<float>1540570354.65</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -108,7 +108,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# generated on Fri, 20 May 2018 17:47:45 +0000\n
# generated on Fri, 16 Jul 2018 17:48:21 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -205,7 +205,7 @@ gadget_erp5_page_ojsm_hosting_subscription_list.html\n
gadget_officejs_monitoring_parameter_view.html\n
gadget_erp5_page_settings_configurator.html\n
gadget_erp5_page_ojsm_processes_view.html\n
gadget_erp5_page_ojsm_hosting_subscription_view.html\n
gadget_officejs_jio_hosting_subscription_view.html\n
gadget_officejs_monitoring_sync.html\n
gadget_officejs_jio_software_instance_view.html\n
gadget_erp5_page_ojsm_software_instance_list.html\n
......@@ -233,7 +233,7 @@ gadget_officejs_monitoring_parameter_view.js\n
gadget_erp5_page_settings_configurator.js\n
gadget_erp5_page_ojsm_processes_view.js\n
gadget_officejs_monitoring_custom.css\n
gadget_erp5_page_ojsm_hosting_subscription_view.js\n
gadget_officejs_jio_hosting_subscription_view.js\n
gadget_erp5_global.js\n
gadget_officejs_monitoring_sync.js\n
gadget_erp5_page_ojsm_software_instance_list.js\n
......@@ -387,7 +387,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>966.64659.26947.45004</string> </value>
<value> <string>971.13516.48622.23296</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -405,7 +405,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1527847381.11</float>
<float>1540570672.89</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.40778.47295.35669</string> </value>
<value> <string>965.42058.36320.56678</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1519208313.2</float>
<float>1540559911.98</float>
<string>UTC</string>
</tuple>
</state>
......
web_page_module/gadget_officejs_jio_hosting_subscription_view_html
web_page_module/gadget_officejs_jio_hosting_subscription_view_js
web_page_module/gadget_erp5_field_status_*
web_page_module/gadget_erp5_page_ojsm_*
web_page_module/gadget_ojsm_*
web_page_module/gadget_erp5_page_settings_configurator_*
web_page_module/gadget_officejs_jio_software_instance_view_html
web_page_module/gadget_officejs_jio_software_instance_view_js
web_page_module/gadget_officejs_jio_opml_view_html
web_page_module/gadget_officejs_jio_opml_view_js
web_page_module/gadget_officejs_jio_promise_view_html
web_page_module/gadget_officejs_jio_promise_view_js
web_page_module/gadget_officejs_jio_software_instance_view_html
web_page_module/gadget_officejs_jio_software_instance_view_js
web_page_module/gadget_officejs_monitoring_*
web_page_module/gadget_ojsm_*
web_page_module/jsen_json_validator_js
web_page_module/monitoring_jio_storage_js
web_page_module/monitoring_jio_web_storage_js
......
web_page_module/gadget_officejs_jio_hosting_subscription_view_html
web_page_module/gadget_officejs_jio_hosting_subscription_view_js
web_page_module/gadget_erp5_field_status_*
web_page_module/gadget_erp5_page_ojsm_*
web_page_module/gadget_ojsm_*
web_page_module/gadget_erp5_page_settings_configurator_*
web_page_module/gadget_officejs_jio_software_instance_view_html
web_page_module/gadget_officejs_jio_software_instance_view_js
web_page_module/gadget_officejs_jio_opml_view_html
web_page_module/gadget_officejs_jio_opml_view_js
web_page_module/gadget_officejs_jio_promise_view_html
web_page_module/gadget_officejs_jio_promise_view_js
web_page_module/gadget_officejs_jio_software_instance_view_html
web_page_module/gadget_officejs_jio_software_instance_view_js
web_page_module/gadget_officejs_monitoring_*
web_page_module/gadget_ojsm_*
web_page_module/jsen_json_validator_js
web_page_module/monitoring_jio_storage_js
web_page_module/monitoring_jio_web_storage_js
......
web_page_module/gadget_erp5_field_status_*
web_page_module/gadget_erp5_page_ojsm_*
web_page_module/gadget_erp5_page_settings_configurator_*
web_page_module/gadget_officejs_jio_hosting_subscription_view_html
web_page_module/gadget_officejs_jio_hosting_subscription_view_js
web_page_module/gadget_officejs_jio_opml_view_html
web_page_module/gadget_officejs_jio_opml_view_js
web_page_module/gadget_officejs_jio_promise_view_html
......
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