Commit dd87a961 authored by Alain Takoudjou's avatar Alain Takoudjou

[erp5_web_monitoring] Drop jquerymobile and use erp5_web_renderjs_ui style

parent 3b3591f7
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.21883.33309.38348</string> </value>
<value> <string>961.21937.16299.41642</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1502445194.86</float>
<float>1507899148.22</float>
<string>UTC</string>
</tuple>
</state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Monitor Page ERP5 Jio Config</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojsm_erp5_configurator.js"></script>
</head>
<body>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your ERP5 Connection parameters
</h3>
</section>
<p>You have to be logged in this ERP5 prior to synchronising</p>
</article>
<br>
<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>
<br>
</body>
</html>
/*global window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS) {
"use strict";
rJS(window)
.setState({
erp5_url: "https://vifib.erp5.net/web_site_module/renderjs_runner"
})
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting")
/////////////////////////////////////////
// Form submit
/////////////////////////////////////////
.onEvent('submit', function () {
var gadget = this,
master_url;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (content) {
master_url = content.erp5_url + "/hateoas/";
return gadget.setSetting("hateoas_url", master_url);
})
.push(function () {
return gadget.redirect({command: "display", options: {
page: "ojsm_import_export",
auto_sync: "erp5",
url: master_url
}});
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
"my_erp5_url": {
"description": "",
"title": "Connection Url",
"default": gadget.state.erp5_url,
"css_class": "",
"required": 1,
"editable": 1,
"key": "erp5_url",
"hidden": 0,
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"top",
[["my_erp5_url"]]
]]
}
});
})
.push(function () {
return gadget.getUrlFor({command: 'display', options: {page: 'ojsm_import_export'}});
})
.push(function (url) {
return gadget.updateHeader({
page_title: "Connect To ERP5 Storage",
back_url: url,
submit_action: true,
panel_action: false
});
});
});
}(window, rJS));
......@@ -4,18 +4,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Monitoring Logs Widget</title>
<title>Monitoring Hosting Subscription List</title>
<link href="gadget_monitoring_custom.css" rel="stylesheet" type="text/css"/>
<link href="gadget_officejs_monitoring_custom.css" rel="stylesheet" type="text/css"/>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_monitoring_log_widget.js"></script>
<script src="gadget_erp5_page_ojsm_hosting_subscription_list.js"></script>
</head>
<body>
<div data-gadget-url="gadget_monitoring_jio.html" data-gadget-scope="jio_gadget" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
......@@ -80,7 +80,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_monitoring_hosting_subscription_list.html</string> </value>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_list.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -90,7 +90,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_monitoring_hosting_subscription_list_html</string> </value>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_list_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.6384.703.48554</string> </value>
<value> <string>962.48791.22929.44424</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -261,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1501862298.92</float>
<float>1507902208.04</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) {
"use strict";
var gadget_klass = rJS(window);
function getHostingData(gadget, filter) {
// optimized way to fetch hosting subscription list
var hosting_dict = {},
instance_dict = {},
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:"global")',
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 === 'global') {
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]);
}
}
return {data: {total_rows: total_rows, rows: row_list}};
});
}
gadget_klass
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
.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;
return getHostingData(gadget, param_list[0])
.push(function (result) {
var i, value, 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 = {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": new Date(result.data.rows[i].value.date).toUTCString(),
key: "date",
required: 0,
timezone_style: 0,
title: "Status Date",
type: "DateTimeField"
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
if (result.data.rows[i].value.hasOwnProperty("status")) {
result.data.rows[i].value.status = {
css_class: "",
description: "The Status",
hidden: 0,
"default": result.data.rows[i].value.status,
key: "status",
url: "gadget_erp5_field_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 (options) {
return this.changeState({
options: options,
latest_reload_time: new Date().getTime()
});
})
.onStateChange(function () {
var gadget = this,
lines_limit;
return new RSVP.Queue()
.push(function () {
return gadget.getSetting("listbox_lines_limit", 100);
})
.push(function (listbox_lines_limit) {
lines_limit = listbox_lines_limit;
return gadget.getDeclaredGadget('form_list');
})
.push(function (form_list) {
var column_list = [
['title', 'Hosting Subscription'],
['amount', 'Instance Amount'],
['date', 'Status Date'],
['synced', 'Synced?'],
['status', 'Status']
];
return form_list.render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 0,
"editable_column_list": [],
"key": "hosting_subscription_listbox",
"lines": lines_limit,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=%28portal_type%3A%22" +
"opml" + "%22%29AND%28active%3A%22" +
"true" + "%22%29",
"portal_type": [],
"search_column_list": [['title', 'Hosting Subscription']],
"sort_column_list": [['title', 'Hosting Subscription']],
"sort": [["title", "ascending"]],
"title": "Hosting Subscriptions",
"command": "index",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function (result) {
return gadget.updateHeader({
page_title: "Hosting Subscriptions Status",
filter_action: true
});
});
})
.onLoop(function () {
var gadget = this;
return gadget.getSetting('latest_sync_time')
.push(function (latest_sync_time) {
if (latest_sync_time > gadget.state.latest_reload_time) {
return gadget.changeState({latest_reload_time: new Date().getTime()});
}
});
}, 30000);
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -80,7 +80,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_monitoring_hosting_subscription_list.js</string> </value>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_list.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -90,7 +90,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_monitoring_hosting_subscription_list_js</string> </value>
<value> <string>gadget_erp5_page_ojsm_hosting_subscription_list_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -108,7 +108,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Monitoring Hosting Subscription list Js</string> </value>
<value> <string>Monitoring Hosting Subscription list JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.36732.50199.26692</string> </value>
<value> <string>963.19077.52757.17169</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1503333754.52</float>
<float>1510052055.87</float>
<string>UTC</string>
</tuple>
</state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Monitoring Hosting Subscription View</title>
<link href="gadget_officejs_monitoring_custom.css" rel="stylesheet" type="text/css"/>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojsm_hosting_subscription_view.js"></script>
</head>
<body>
<br/>
<article class="ui-content ui-body-c">
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-cubes">&nbsp;</span>
<span class="hosting-title"></span>
</h3>
</section>
<section class="ui-body-c ui-content-section">
<p class="text-info">To change monitor password, go to <i>Monitoring Configuration</i>.</p>
<div class="parameters-box">
</div>
</section>
</article>
<div class="bottom">
<div data-gadget-url="gadget_erp5_form.html"
data-gadget-scope="form_list"
data-gadget-sandbox="public">
</div>
</div>
</body>
</html>
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_monitoring_hosting_subscription_view.html</string> </value>
<value> <string>gadget_erp5_page_ojsm_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_monitoring_hosting_subscription_view_html</string> </value>
<value> <string>gadget_erp5_page_ojsm_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>961.40879.58115.22357</string> </value>
<value> <string>962.46060.41528.54152</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1503583096.3</float>
<float>1507901514.08</float>
<string>UTC</string>