Commit db9466f8 authored by Roque's avatar Roque

erp5_web_monitoring: refactor how app handles data

- app does not manipulate data structure anymore (jio does)
- use union storage for multiple masters
- remote slapos masters fetch is done in replicateopml storage repair method
- sync repair method recreates the storage on new master urls, and updates the stored objects accordingly
- add erp5monitor layer in monitoring jio storage
parent b3c075f1
......@@ -55,7 +55,7 @@
"url": options.url,
"username": options.username,
"password": options.password,
"slapos_master_url": options.slapos_master_url || "not-provided",
"slapos_master_url": options.slapos_master_url || "",
"page": "ojsm_opml_add"
}
});
......@@ -74,7 +74,7 @@
"url": options.url,
"username": options.username,
"password": options.password,
"slapos_master_url": options.slapos_master_url || "not-provided",
"slapos_master_url": options.slapos_master_url || "",
"page": "ojsm_opml_add"
}
});
......@@ -98,6 +98,8 @@
// default front page (list of promises)
return gadget.redirect({command: 'display',
options: {page: "ojs_local_controller",
notify_msg: options.notify_msg,
notify_type: options.notify_type,
portal_type: "Promise Module"}
});
});
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.31995.2932.55961</string> </value>
<value> <string>1018.11987.13059.19063</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1719275229.13</float>
<float>1721920651.07</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,7 +5,7 @@
rJS(window)
.setState({
erp5_url_list: "https://panel.rapid.space/hateoas/"
erp5_url_list: ["https://panel.rapid.space/hateoas/"]
})
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -13,7 +13,8 @@
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSettingList", "setSettingList")
/////////////////////////////////////////
// Form submit
......@@ -30,6 +31,10 @@
for (i = 0; i < master_url_list.length; i += 1) {
master_url_list[i] = master_url_list[i].trim();
}
return gadget.setSettingList({'master_url_list': master_url_list,
'master_url_list_updated': true});
})
.push(function () {
return gadget.redirect({command: "display", options: {
page: "ojsm_import_export",
auto_sync: "erp5",
......@@ -44,8 +49,13 @@
.declareMethod("render", function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
return gadget.getSetting('master_url_list')
.push(function (master_url_list) {
if (master_url_list) {
gadget.state.erp5_url_list = master_url_list;
}
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
//TODO replace textarea by N stringfield inputs
return form_gadget.render({
......@@ -54,7 +64,7 @@
"my_erp5_url_list": {
"description": "",
"title": "Connection Url List",
"default": gadget.state.erp5_url_list,
"default": gadget.state.erp5_url_list.join('\r\n'),
"css_class": "",
"required": 1,
"editable": 1,
......
......@@ -260,7 +260,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.60960.54632.28569</string> </value>
<value> <string>1018.39277.14666.4573</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -280,7 +280,7 @@
</tuple>
<state>
<tuple>
<float>1718127515.73</float>
<float>1723557962.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -600,91 +600,7 @@
.push(function () {
var has_failed = false, i;
if (gadget.state.sync === "erp5" && gadget.state.storage_url_list) {
var storage_definition_list = [];
// start import from erp5 now
return gadget.notifySubmitting()
.push(function () {
gadget.getSetting('default_view_reference');
})
.push(function (default_view_reference) {
for (i = 0; i < gadget.state.storage_url_list.length; i += 1) {
storage_definition_list.push({
type: "erp5",
url: gadget.state.storage_url_list[i],
default_view_reference: default_view_reference
});
}
//TODO fix. union doesn't bring all elements (limit issue?)
/*return gadget.state.jio_gadget.createJio(
{
"type": "union",
"storage_list": storage_definition_list
}
);*/
return gadget.state.jio_gadget.createJio({
type: "erp5",
url: gadget.state.storage_url_list[0],
default_view_reference: default_view_reference
});
})
.push(function () {
return gadget.getSetting('opml_import_limit', 300);
})
.push(function (select_limit) {
return getInstanceOPMLListFromMaster(gadget, select_limit);
})
.push(undefined, function () {
gadget.state.message
.innerHTML = notify_msg_template({
status: 'error',
message: 'Error: Failed to get Monitor Configuration from URL: ' +
gadget.state.storage_url_list[0]
});
has_failed = true;
return [];
})
.push(function (opml_list) {
var i, push_queue = new RSVP.Queue();
function pushOPML(opml_dict) {
push_queue
.push(function () {
return gadget.jio_put(opml_dict.url, opml_dict);
})
.push(undefined, function (error) {
throw error;
});
}
for (i = 0; i < opml_list.length; i += 1) {
pushOPML(opml_list[i]);
}
return push_queue;
})
.push(undefined, function () {
gadget.state.message
.innerHTML = notify_msg_template({
status: 'error',
message: 'An error occurred while saving Configuration from URL: ' +
gadget.state.storage_url_list[0]
});
has_failed = true;
})
.push(function () {
if (has_failed) {
return gadget.notifySubmitted({
message: "Failed to import Configurations",
status: "error"
});
}
return RSVP.all([
gadget.setSetting("latest_import_date", new Date().getTime()),
gadget.notifySubmitted({
message: "Configuration Saved!",
status: "success"
})
]);
})
return gadget.setSetting("latest_import_date", new Date().getTime())
.push(function () {
if (!has_failed) {
return gadget.redirect({
......
......@@ -260,7 +260,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.35724.42699.60194</string> </value>
<value> <string>1019.25789.13503.57429</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -280,7 +280,7 @@
</tuple>
<state>
<tuple>
<float>1719499012.07</float>
<float>1726682048.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -160,7 +160,7 @@
"my_slapos_master_url": {
"description": "Slapos master URL",
"title": "Slapos master URL",
"default": options.slapos_master_url || "not-provided",
"default": options.slapos_master_url || "",
"css_class": "",
"required": 1,
"editable": 1,
......
......@@ -260,7 +260,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.7024.38172.32733</string> </value>
<value> <string>1018.38079.38037.25019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -280,7 +280,7 @@
</tuple>
<state>
<tuple>
<float>1717777119.89</float>
<float>1723486191.89</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -13,7 +13,7 @@
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod("render", function (options) {
var gadget = this;
var gadget = this, notify = {}, redirect_options;
return this.updateHeader({
page_title: "Monitoring Synchronization"
})
......@@ -24,8 +24,10 @@
return sync_gadget.register({now: true});
});
})
.push(function () {
var redirect_options = {"page": "ojsm_dispatch"};
.push(function (result) {
redirect_options = {"page": "ojsm_dispatch", "notify_msg": result.msg, "notify_type": result.type};
notify.msg = result.msg;
notify.type = result.type;
if (options.reset === "1") {
// reset redirections
return gadget.setSetting("sync_redirect_options", undefined)
......@@ -38,7 +40,9 @@
}
return gadget.getSetting('sync_redirect_options')
.push(function (redirect_dict) {
if (redirect_options) {
if (redirect_dict) {
redirect_dict.msg = notify.msg;
redirect_dict.type = notify.type;
redirect_options = redirect_dict;
return gadget.setSetting("sync_redirect_options", undefined);
}
......@@ -51,4 +55,4 @@
});
});
});
}(window, rJS));
}(window, rJS));
\ No newline at end of file
......@@ -260,7 +260,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.6962.52907.14592</string> </value>
<value> <string>1019.25789.13503.57429</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -280,7 +280,7 @@
</tuple>
<state>
<tuple>
<float>1717773952.0</float>
<float>1726682152.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.1125.9926.47069</string> </value>
<value> <string>1017.42953.62497.13994</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1717423120.28</float>
<float>1721847085.79</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -87,7 +87,7 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CONFIGURATION MANIFEST\n
# generated on Mon Jun 3 13:55:24 2024\n
# generated on Thu Sep 26 17:05:54 2024\n
CACHE:\n
\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1NvZnR3YXJlIEluc3RhbmNl\n
......
......@@ -370,4 +370,9 @@ margin-top: 5px;
padding: 20px 10px;
margin: 30px 25px 10px 0;
border-top: 1px solid #dedede;
}
div[data-gadget-scope$="output_message"] p {
margin: 0;
}
\ No newline at end of file
......@@ -247,7 +247,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.24509.15236.10769</string> </value>
<value> <string>1019.25707.33677.14080</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -267,7 +267,7 @@
</tuple>
<state>
<tuple>
<float>1711048261.14</float>
<float>1727276878.74</float>
<string>UTC</string>
</tuple>
</state>
......
div[data-gadget-scope$="output_message"] p {
margin: 0;
}
\ No newline at end of file
......@@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Jio All Docs</title>
<link rel="stylesheet" href="gadget_officejs_monitoring_jio_alldocs.css">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
......
......@@ -248,7 +248,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.43169.7471.64085</string> </value>
<value> <string>1019.35831.119.51780</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1712168022.61</float>
<float>1727283353.81</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -18,6 +18,7 @@
})
.push(function (result) {
jio_gadget = result;
// TODO check url response before creating jio? sometimes public feeds url is broken
return jio_gadget.createJio({
type: "webhttp",
// XXX fix of url
......@@ -30,6 +31,7 @@
gadget.state.doc.source + ".history"
)
.push(undefined, function (error) {
//check if json error
if (error.name === "cancel") {
return undefined;
}
......@@ -133,7 +135,7 @@
description: "The promise output message",
editable: 0,
hidden: 0,
"default": status_history.data[i].message,
"default": status_history.data[i].message.replaceAll("\n", "").replaceAll("\\n", ""),
key: "message",
required: 0,
title: "Promise Output",
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.40876.2382.12151</string> </value>
<value> <string>1019.35732.58009.30941</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -270,7 +270,7 @@
</tuple>
<state>
<tuple>
<float>1715958907.55</float>
<float>1727278390.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,6 +12,7 @@
<script src="jiodev.js" type="text/javascript"></script>
<script src="monitoring_jio_storage.js" type="text/javascript"></script>
<script src="monitoring_jio_web_storage.js" type="text/javascript"></script>
<script src="monitoring_jio_erp5monitor_storage.js" type="text/javascript"></script>
<script src="jio_ojs_storage.js" type="text/javascript"></script>
<script src="jio_appcachestorage.js"></script>
<script src="jio_configuration_storage.js"></script>
......
......@@ -245,7 +245,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.2117.47678.65518</string> </value>
<value> <string>1017.35894.43518.51251</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -265,7 +265,7 @@
</tuple>
<state>
<tuple>
<float>1706206800.08</float>
<float>1723154487.39</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,7 +3,7 @@
(function (window, rJS, jIO) {
"use strict";
var LOCK_NAME = "sync_lock";
var LOCK_NAME = "sync_lock", LIMIT = 300;
function promiseLock(name, options, callback) {
var callback_promise = null,
......@@ -52,6 +52,63 @@
return new RSVP.Promise(resolver, canceller);
}
function getUpdatedMonitoringStorageSpec(gadget, checking_update_on_repair) {
var storage_definition_list = [], i, master_url_list,
update_settings, monitoring_jio;
return gadget.getSettingList(['master_url_list',
'master_url_list_updated',
'default_view_reference'])
.push(function (result_list) {
if (result_list[0]) {
master_url_list = result_list[0];
if (result_list[1]) {
update_settings = true;
} else {
if (checking_update_on_repair) {
return;
}
}
for (i = 0; i < master_url_list.length; i += 1) {
storage_definition_list.push({
type: "erp5monitor",
limit: LIMIT,
sub_storage: {
type: "erp5",
url: master_url_list[i],
default_view_reference: result_list[2]
}
});
}
}
monitoring_jio = {
type: "replicatedopml",
remote_storage_unreachable_status: "WARNING",
remote_opml_check_time_interval: 86400000,
request_timeout: 25000, // timeout is to 25 second
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoring_local.db"
}
}
},
remote_sub_storage: {
type: "union",
storage_list: storage_definition_list
}
};
if (update_settings) {
return gadget.setSetting('master_url_list_updated', false);
}
})
.push(function () {
return monitoring_jio;
});
}
rJS(window)
.ready(function (gadget) {
......@@ -60,9 +117,10 @@
})
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("setSettingList", "setSettingList")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('updateConfiguration', function (appcache_storage, migration_version, current_version, jio_storage) {
.declareMethod('updateConfiguration', function (appcache_storage, current_version, jio_storage) {
var gadget = this;
if (!appcache_storage) { return; }
return RSVP.Queue()
......@@ -73,7 +131,9 @@
return jio_storage.repair();
})
.push(function () {
return gadget.setSetting("migration_version", current_version);
return gadget.setSettingList({'migration_version': current_version,
'master_url_list': undefined,
'master_url_list_updated': false});
});
})
......@@ -88,7 +148,7 @@
.declareMethod('createJio', function (options) {
var gadget = this, current_version, index, appcache_storage,
monitoring_jio, appcache_jio, migration_version, manifest,
appcache_jio, migration_version, manifest, monitoring_jio,
origin_url = window.location.href;
return gadget.getSettingList(['configuration_manifest',
'migration_version'])
......@@ -99,22 +159,16 @@
index = current_version.indexOf(window.location.host) + window.location.host.length;
current_version = current_version.substr(index);
manifest = "gadget_officejs_monitoring.configuration";
monitoring_jio = {
type: "replicatedopml",
remote_storage_unreachable_status: "WARNING",
remote_opml_check_time_interval: 86400000,
request_timeout: 25000, // timeout is to 25 second
local_sub_storage: {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoring_local.db"
}
}
}
};
if (migration_version !== current_version) {
return gadget.setSettingList({'master_url_list': undefined,
'master_url_list_updated': false});
}
})
.push(function () {
return getUpdatedMonitoringStorageSpec(gadget);
})
.push(function (spec) {
monitoring_jio = spec;
appcache_jio = {
type: "replicate",
parallel_operation_attachment_amount: 10,
......@@ -161,15 +215,15 @@
}
})
.push(function (all_docs) {
var remove_queue = new RSVP.Queue(), i;
function remove_doc(id) {
remove_queue
.push(function () {
return gadget.props.jio_storage.remove(id);
});
}
if (all_docs && all_docs.data.total_rows) {
//iterate all docs, jio_remove, and recreate
var remove_queue = new RSVP.Queue(), i;
function remove_doc(id) {
remove_queue
.push(function () {
return gadget.props.jio_storage.remove(id);
});
}
for (i = 0; i < all_docs.data.total_rows; i += 1) {
remove_doc(all_docs.data.rows[i].id);
}
......@@ -183,7 +237,7 @@
.push(function () {
if (migration_version !== current_version) {
appcache_storage = jIO.createJIO(appcache_jio);
return gadget.updateConfiguration(appcache_storage, migration_version, current_version, gadget.props.jio_storage);
return gadget.updateConfiguration(appcache_storage, current_version, gadget.props.jio_storage);
}
})
.push(function () {
......@@ -228,10 +282,16 @@
});
})
.declareMethod('repair', function () {
var storage = this.props.jio_storage,
argument_list = arguments;
var gadget = this, argument_list = arguments;
return promiseLock(LOCK_NAME, {}, function () {
return storage.repair.apply(storage, argument_list);
return getUpdatedMonitoringStorageSpec(gadget, true)
.push(function (monitoring_jio) {
if (monitoring_jio) {
gadget.createStorage(undefined, monitoring_jio);
}
var storage = gadget.props.jio_storage;
return storage.repair.apply(storage, argument_list);
});
});
});
......
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.59484.28533.58572</string> </value>
<value> <string>1019.25813.42370.5614</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -269,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1717176711.0</float>
<float>1726682335.1</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -63,10 +63,14 @@
.push(function () {
return {status: 'OK'};
}, function (error) {
//console.error(error);
console.log(error);
var code = error.status;
if (!code && error.target) {
code = error.target.status;
}
return {
status: 'ERROR',
code: error.status || error.target.status,
code: code,
url: base_url,
title: title
};
......@@ -149,13 +153,14 @@
password: doc.password,
active: (doc.active === "on") ? true : false,
has_monitor: true,
state: doc.state || (doc.active === "on" ? "Started" : "Stopped")
state: doc.state || (doc.active === "on" ? "Started" : "Stopped"),
slapos_master_url: doc.slapos_master_url,
manually_added: true
},
update_password_list = [],
allow_force = false,
return_dict;
if (doc.slapos_master_url && doc.slapos_master_url !== undefined &&
doc.slapos_master_url !== "") {
if (doc.slapos_master_url !== undefined) {
opml_dict.slapos_master_url = doc.slapos_master_url;
}
gadget.state.message.textContent = "";
......
......@@ -252,7 +252,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.62588.18488.24661</string> </value>
<value> <string>1019.37418.47754.9113</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -272,7 +272,7 @@
</tuple>
<state>
<tuple>
<float>1717178789.09</float>
<float>1727388970.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -13,5 +13,10 @@
<script src="gadget_officejs_monitoring_submit.js"></script>
</head>
<body></body>
<body>
<form>
<div data-gadget-url="gadget_officejs_monitoring_opml_edit.html"
data-gadget-scope="opml_gadget" data-gadget-sandbox="public"></div>
</form>
</body>
</html>
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.14835.20658.8448</string> </value>
<value> <string>1019.25707.33677.14080</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1714399889.98</float>
<float>1727375273.45</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -8,19 +8,19 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("handle_submit", function (argument_list, options) {
.declareMethod("handle_submit", function (argument_list, options, content) {
switch (options.options.portal_type) {
case "Instance Tree":
//TODO do the old parameter gadget save here and fix it
return this.redirect({command: 'reload'});
case "Opml":
console.log("opml submit argument_list, options:", argument_list, options);
//TODO fix submit
var gadget = this,
doc,
opml_gadget;
......@@ -30,18 +30,12 @@
})
.push(function (g) {
opml_gadget = g;
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return form_gadget.getContent();
})
.push(function (form_doc) {
doc = form_doc;
if (doc.password !== gadget.state.password) {
doc = content;
if (doc.password !== options.doc.password) {
// password was modified, update on backend
doc.new_password = doc.password;
doc.confirm_new_password = doc.new_password;
doc.password = gadget.state.password;
doc.password = options.doc.password;
doc.verify_password = 1;
} else {
doc.verify_password = (doc.verify_password === "on") ? 1 : 0;
......@@ -54,10 +48,10 @@
.push(function () {
var verify_opml = doc.title === "" || doc.title === undefined ||
doc.verify_password === 1;
if (gadget.state.active === false && doc.active === "on") {
if (options.doc.active === false && doc.active === "on") {
verify_opml = true;
}
doc.title = gadget.state.opml_title;
doc.title = options.doc.title;
return opml_gadget.saveOPML(doc, verify_opml);
})
.push(function (state) {
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.1223.8753.47035</string> </value>
<value> <string>1019.37597.6963.8738</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1717428914.0</float>
<float>1727389294.71</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, console, XMLHttpRequest, document */
/*global window, rJS, RSVP, XMLHttpRequest, document */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP, console, XMLHttpRequest, document) {
(function (window, rJS, RSVP, XMLHttpRequest, document) {
"use strict";
var gadget_klass = rJS(window);
......@@ -47,7 +47,9 @@
function syncAllStorage() {
var has_error = false,
last_sync_time;
last_sync_time,
classname = "success",
message = "Synchronisation finished.";
gadget.props.started = true;
return new RSVP.Queue()
.push(function () {
......@@ -68,8 +70,7 @@
})
.push(undefined, function (error) {
// should include error message in error
has_error = true;
console.error(error);
has_error = error;
// return false so it will trigger the next run
return false;
})
......@@ -77,34 +78,17 @@
last_sync_time = new Date().getTime();
return RSVP.all([
gadget.setSetting('latest_sync_time', last_sync_time),
gadget.notifySubmitting()
gadget.notifySubmitted()
]);
})
.push(function () {
var classname = "success",
message = "Synchronisation finished.";
if (has_error) {
classname = "error";
message = "Synchronisation finished with error(s).";
message += " \nYou can retry with manual sync.";
message += " \n" + has_error;
}
return gadget.notifySubmitted({
message: message,
status: classname
});
})
.push(function () {
gadget.props.started = false;
/*return $.notify(
"Last Sync: " + formatDate(new Date(last_sync_time)),
{
position: "bottom right",
autoHide: true,
className: "success",
autoHideDelay: 30000
}
);*/
return {msg: message, type: classname};
});
}
......@@ -223,4 +207,4 @@
});
});
}(window, rJS, RSVP, console, XMLHttpRequest, document));
\ No newline at end of file
}(window, rJS, RSVP, XMLHttpRequest, document));
\ No newline at end of file
......@@ -252,7 +252,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.7721.36434.2560</string> </value>
<value> <string>1018.39204.41098.43246</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -272,7 +272,7 @@
</tuple>
<state>
<tuple>
<float>1706281549.43</float>
<float>1723554584.83</float>
<string>UTC</string>
</tuple>
</state>
......
/*
* Copyright 2016, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/*jslint nomen: true*/
/*global jIO, RSVP */
(function (jIO, RSVP) {
"use strict";
var LIMIT = 100; //default
/**
* Monitor erp5 layer to wrap erp5 storages for monitor app
*
* @class ERP5Monitor
* @constructor
*/
function ERP5Monitor(spec) {
if (!spec.sub_storage || spec.sub_storage.type !== 'erp5') {
throw new TypeError("ERP5Monitor subtorage must be erp5 type");
}
if (spec.limit) {
LIMIT = spec.limit;
}
this._storage_definition = spec.sub_storage;
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
ERP5Monitor.prototype.get = function (id) {
return this._sub_storage.get.apply(this._sub_storage, arguments);
};
ERP5Monitor.prototype.post = function () {
return this._sub_storage.post.apply(this._sub_storage, arguments);
};
ERP5Monitor.prototype.put = function () {
return this._sub_storage.put.apply(this._sub_storage, arguments);
};
ERP5Monitor.prototype.remove = function () {
return this._sub_storage.remove.apply(this._sub_storage, arguments);
};
ERP5Monitor.prototype.hasCapacity = function (capacity) {
return (capacity === "list") || (capacity === "limit") || (capacity === "include") || (capacity === "query") || (capacity === "select");
};
ERP5Monitor.prototype.buildQuery = function () {
var sub_storage = this._sub_storage, args = arguments, master_url = this._storage_definition.url, i;
if (!arguments[0].limit) {
arguments[0].limit = [0, LIMIT];
}
return sub_storage.allDocs.apply(sub_storage, args)
.push(function (result) {
for (i = 0; i < result.data.rows.length; i += 1) {
result.data.rows[i].master_url = master_url;
}
return result.data.rows;
});
};
jIO.addStorage('erp5monitor', ERP5Monitor);
}(jIO, RSVP));
\ No newline at end of file
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1017.22812.19597.42137</string> </value>
<value> <string>1019.38541.57829.32512</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -269,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1718724260.35</float>
<float>1727445979.03</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, RSVP, Handlebars, atob */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
(function (window, rJS, RSVP, Handlebars, atob) {
"use strict";
var gadget_klass = rJS(window),
......@@ -72,7 +72,7 @@
return gadget.changeState(state_dict);
});
case "software_instance":
if (software_instance.reference) {
if (software_instance && software_instance.reference) {
return new RSVP.Queue()
.push(function () {
return gadget.getUrlFor({command: 'push_history', options: {
......@@ -94,21 +94,54 @@
return gadget.changeState(state_dict);
}
case "computer":
state_dict.content = software_instance.aggregate_reference;
if (software_instance) {
state_dict.content = software_instance.aggregate_reference;
}
return gadget.changeState(state_dict);
case "partition":
state_dict.content = software_instance.partition_id;
if (software_instance) {
state_dict.content = software_instance.partition_id;
}
return gadget.changeState(state_dict);
case "partition_ipv6":
state_dict.content = software_instance.ipv6;
if (software_instance) {
state_dict.content = software_instance.ipv6;
}
return gadget.changeState(state_dict);
case "software_release":
if (software_instance) {
state_dict.content = link_template({
url: software_instance.software_release,
title: "Access Software release",
target: "_blank"
});
}
return gadget.changeState(state_dict);
case "public_url":
state_dict.content = link_template({
url: software_instance.software_release,
title: "Access Software release",
url: options.link.replace('private', 'public'),
title: "Access Public files",
target: "_blank"
});
return gadget.changeState(state_dict);
case "private_url":
return gadget.jio_get(options.parent_id)
.push(function (outline_doc) {
return RSVP.all([outline_doc.parent_id,
gadget.jio_get(outline_doc.parent_url)]);
})
.push(function (doc_list) {
if (software_instance && software_instance._links) {
var pass_url = "https://" + atob(doc_list[1].basic_login) +
"@" + software_instance._links.private_url.href.split("//")[1];
state_dict.content = link_template({
url: pass_url,
title: "Access Private files",
target: "_blank"
});
}
return gadget.changeState(state_dict);
});
default:
state_dict.content = "";
return gadget.changeState(state_dict);
......@@ -120,4 +153,4 @@
this.element.innerHTML = modification_dict.content;
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, RSVP, Handlebars, atob));
\ No newline at end of file
......@@ -244,7 +244,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1016.27890.23432.33160</string> </value>
<value> <string>1019.38589.15925.60637</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -264,7 +264,7 @@
</tuple>
<state>
<tuple>
<float>1715096834.79</float>
<float>1727448911.56</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -104,7 +104,7 @@
<dictionary>
<item>
<key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_hookname</string> </key>
......@@ -544,7 +544,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.32811.46439.54528</string> </value>
<value> <string>1019.25707.33677.14080</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -564,7 +564,7 @@
</tuple>
<state>
<tuple>
<float>1716562039.61</float>
<float>1727370343.76</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -104,7 +104,7 @@
<dictionary>
<item>
<key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_hookname</string> </key>
......@@ -579,7 +579,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.45944.11619.35208</string> </value>
<value> <string>1019.25707.33677.14080</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -599,7 +599,7 @@ WebSection_getMonitorPrecacheManifestList</string> </value>
</tuple>
<state>
<tuple>
<float>1716562039.61</float>
<float>1727370348.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -69,7 +69,7 @@
<dictionary>
<item>
<key> <string>_defined_in_class</string> </key>
<value> <bool>True</bool> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>_hookname</string> </key>
......@@ -339,7 +339,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.3364.27014.64238</string> </value>
<value> <string>1019.25707.33677.14080</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -359,7 +359,7 @@
</tuple>
<state>
<tuple>
<float>1716562039.61</float>
<float>1727370343.75</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -91,7 +91,7 @@
<key> <string>center</string> </key>
<value>
<list>
<string>my_description</string>
<string>my_output_message</string>
</list>
</value>
</item>
......@@ -109,8 +109,8 @@
<string>my_category</string>
<string>my_pubDate</string>
<string>my_lastBuildDate</string>
<string>my_public_url</string>
<string>my_private_url</string>
<string>my_parent_public_url</string>
<string>my_parent_private_url</string>
</list>
</value>
</item>
......
......@@ -2,28 +2,45 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="HyperLinkField" module="Products.ERP5Form.HyperLinkField"/>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_private_url</string> </value>
<value> <string>my_parent_private_url</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>no_validator</string> </key>
<value> <string>Does not support this operation.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -40,22 +57,42 @@
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>href</string> </key>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -63,10 +100,18 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -83,22 +128,42 @@
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>href</string> </key>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -106,13 +171,21 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Access Private files</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -126,26 +199,49 @@
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string encoding="cdata"><![CDATA[
if (context_document && context_document.link) { result.href = context_document.link; }
]]></string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>gadget_erp5_field_parent.html</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>href</string> </key>
<value> <string>*</string> </value>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<list>
<tuple>
<string>{"field": "private_url"}</string>
<string>{"field": "private_url"}</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Private Logs Url</string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......
......@@ -2,28 +2,45 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="HyperLinkField" module="Products.ERP5Form.HyperLinkField"/>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_public_url</string> </value>
<value> <string>my_parent_public_url</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary/>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>no_validator</string> </key>
<value> <string>Does not support this operation.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -40,22 +57,42 @@
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>href</string> </key>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -63,10 +100,18 @@
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
......@@ -83,22 +128,42 @@
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>href</string> </key>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -106,13 +171,21 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string>Access Public files</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -126,26 +199,49 @@
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string encoding="cdata"><![CDATA[
if (context_document && context_document.link) { result.href = context_document.link.replace(\'private\', \'public\'); }
]]></string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>gadget_erp5_field_parent.html</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>href</string> </key>
<value> <string>*</string> </value>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<list>
<tuple>
<string>{"field": "public_url"}</string>
<string>{"field": "public_url"}</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Public Logs Url</string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......
......@@ -16,6 +16,7 @@ url_list = [
"erp5_launcher_nojqm.js",
"monitoring_jio_storage.js",
"monitoring_jio_web_storage.js",
"monitoring_jio_erp5monitor_storage.js",
"jio_ojs_storage.js",
"jio_configuration_storage.js",
"jio_appcachestorage.js",
......@@ -125,6 +126,7 @@ url_list = [
"gadget_erp5_editor_panel.js",
"gadget_officejs_monitoring_jio_alldocs.html",
"gadget_officejs_monitoring_jio_alldocs.js",
"gadget_officejs_monitoring_jio_alldocs.css",
"gadget_erp5_page_ojsm_parameters_view.html",
"gadget_erp5_page_ojsm_parameters_view.js",
"gadget_officejs_monitoring_options_header.html",
......
......@@ -15,6 +15,7 @@ web_page_module/gadget_officejs_monitoring.configuration
web_page_module/gadget_officejs_monitoring_*
web_page_module/gadget_ojsm_*
web_page_module/jsen_json_validator_js
web_page_module/monitoring_jio_erp5monitor_storage_js
web_page_module/monitoring_jio_storage_js
web_page_module/monitoring_jio_web_storage_js
web_page_module/ojsm_gadget_erp5_parent*
......
......@@ -15,6 +15,7 @@ web_page_module/gadget_officejs_monitoring.configuration
web_page_module/gadget_officejs_monitoring_*
web_page_module/gadget_ojsm_*
web_page_module/jsen_json_validator_js
web_page_module/monitoring_jio_erp5monitor_storage_js
web_page_module/monitoring_jio_storage_js
web_page_module/monitoring_jio_web_storage_js
web_page_module/ojsm_gadget_erp5_parent*
......
......@@ -15,6 +15,7 @@ web_page_module/gadget_officejs_monitoring.configuration
web_page_module/gadget_officejs_monitoring_*
web_page_module/gadget_ojsm_*
web_page_module/jsen_json_validator_js
web_page_module/monitoring_jio_erp5monitor_storage_js
web_page_module/monitoring_jio_storage_js
web_page_module/monitoring_jio_web_storage_js
web_page_module/ojsm_gadget_erp5_parent*
......
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