Commit 02d8b9a5 authored by Roque's avatar Roque

erp5_web_monitoring: fixes (configuration and jio storage)

parent 7fafd79a
......@@ -62,18 +62,30 @@
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('updateConfiguration', function (appcache_storage, migration_version, current_version) {
.declareMethod('updateConfiguration', function (appcache_storage, migration_version, current_version, jio_storage) {
var gadget = this;
if (!appcache_storage) { return; }
return RSVP.Queue()
.push(function () {
return appcache_storage.repair(current_version);
})
.push(function () {
return jio_storage.repair();
})
.push(function () {
return gadget.setSetting("migration_version", current_version);
});
})
.declareMethod('createStorage', function (options, monitoring_jio) {
var gadget = this;
if (options !== undefined) {
gadget.props.jio_storage = jIO.createJIO(options);
} else {
gadget.props.jio_storage = jIO.createJIO(monitoring_jio);
}
})
.declareMethod('createJio', function (options) {
var gadget = this, current_version, index, appcache_storage,
monitoring_jio, appcache_jio, migration_version, manifest,
......@@ -83,70 +95,95 @@
.push(function (result_list) {
//TODO fix missing router setting (it's set but get returns undefined)
migration_version = result_list[1];
current_version = window.location.href.replace(window.location.hash, "");
index = current_version.indexOf(window.location.host) + window.location.host.length;
current_version = current_version.substr(index);
manifest = "gadget_officejs_monitoring.configuration";
if (options !== undefined) {
gadget.props.jio_storage = jIO.createJIO(options);
} else {
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"
}
}
}
};
appcache_jio = {
type: "replicate",
parallel_operation_attachment_amount: 10,
parallel_operation_amount: 1,
conflict_handling: 2, //keep remote
signature_hash_key: 'hash',
check_remote_attachment_modification: true,
check_remote_attachment_creation: true,
check_remote_attachment_deletion: true,
check_remote_deletion: true,
check_local_creation: false,
check_local_deletion: false,
check_local_modification: false,
signature_sub_storage: {
type: "query",
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-configuration-hash"
database: "monitoring_local.db"
}
},
local_sub_storage: JSON.parse(JSON.stringify(monitoring_jio)),
remote_sub_storage: {
type: "saferepair",
}
}
};
appcache_jio = {
type: "replicate",
parallel_operation_attachment_amount: 10,
parallel_operation_amount: 1,
conflict_handling: 2, //keep remote
signature_hash_key: 'hash',
check_remote_attachment_modification: true,
check_remote_attachment_creation: true,
check_remote_attachment_deletion: true,
check_remote_deletion: true,
check_local_creation: false,
check_local_deletion: false,
check_local_modification: false,
signature_sub_storage: {
type: "query",
sub_storage: {
type: "indexeddb",
database: "monitoring-configuration-hash"
}
},
local_sub_storage: JSON.parse(JSON.stringify(monitoring_jio)),
remote_sub_storage: {
type: "saferepair",
sub_storage: {
type: "configuration",
origin_url: origin_url,
hateoas_appcache: "hateoas_appcache",
manifest: manifest,
sub_storage: {
type: "configuration",
type: "appcache",
origin_url: origin_url,
hateoas_appcache: "hateoas_appcache",
manifest: manifest,
sub_storage: {
type: "appcache",
origin_url: origin_url,
manifest: manifest
}
manifest: manifest
}
}
};
gadget.props.jio_storage = jIO.createJIO(monitoring_jio);
}
};
return gadget.createStorage(options, monitoring_jio);
})
.push(function () {
if (migration_version !== current_version) {
if (gadget.props.jio_storage) {
return gadget.props.jio_storage.allDocs();
}
}
current_version = window.location.href.replace(window.location.hash, "");
index = current_version.indexOf(window.location.host) + window.location.host.length;
current_version = current_version.substr(index);
})
.push(function (all_docs) {
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);
}
return RSVP.all([
remove_queue,
gadget.createStorage(options, monitoring_jio),
gadget.setSetting("latest_import_date", undefined)
]);
}
})
.push(function () {
if (migration_version !== current_version) {
appcache_storage = jIO.createJIO(appcache_jio);
return gadget.updateConfiguration(appcache_storage, migration_version, current_version);
return gadget.updateConfiguration(appcache_storage, migration_version, current_version, gadget.props.jio_storage);
}
})
.push(function () {
......
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1015.22775.37961.58163</string> </value>
<value> <string>1015.32779.62576.10939</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -269,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1710945940.66</float>
<float>1711544405.46</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -155,10 +155,10 @@
return storage.get(id)
.push(function (doc) {
if (doc.portal_type !== 'opml') {
throw new TypeError("Object with portal_type" + doc.portal_type +
"is frozen, cannot remove it.");
return storage.remove(id);
}
function removeOPMLTree(url) {
console.log("portal_type 'opml'! complex opml remove");
var remove_id_list = [],
remove_signature_id_list = [];
......
......@@ -249,7 +249,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1014.13769.50435.48776</string> </value>
<value> <string>1015.31816.24445.1945</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -269,7 +269,7 @@
</tuple>
<state>
<tuple>
<float>1706644494.36</float>
<float>1711544040.72</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -12,7 +12,6 @@
<list>
<string>all_columns</string>
<string>columns</string>
<string>default_params</string>
<string>domain_root_list</string>
<string>domain_tree</string>
<string>editable_columns</string>
......@@ -85,10 +84,6 @@
<key> <string>portal_types</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>search_columns</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>selection_name</string> </key>
<value>
......@@ -134,63 +129,20 @@
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>source_reference</string>
<string>Software Type</string>
</tuple>
<tuple>
<string>aggregate_parent_subordination_title</string>
<string>Computer Network</string>
</tuple>
<tuple>
<string>aggregate_parent_title</string>
<string>Compute Node</string>
</tuple>
<tuple>
<string>aggregate_parent_reference</string>
<string>Compute Node Reference</string>
</tuple>
<tuple>
<string>aggregate_title</string>
<string>Compute Partition</string>
</tuple>
<tuple>
<string>SoftwareInstance_getComputePartitionIPv6</string>
<string>IPv6</string>
<string>status</string>
<string>Status</string>
</tuple>
<tuple>
<string>is_slave</string>
<string>Slave</string>
<string>start_date</string>
<string>Report Date</string>
</tuple>
<tuple>
<string>translated_validation_state_title</string>
<string>Validation State</string>
<string>change_date</string>
<string>Status Date</string>
</tuple>
<tuple>
<string>slap_state_title</string>
<string>Request State</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>default_params</string> </key>
<value>
<list>
<tuple>
<string>channel</string>
<string>channel</string>
</tuple>
<tuple>
<string>channel_item</string>
<string>channel_item</string>
</tuple>
<tuple>
<string>title</string>
<string>title</string>
<string>message</string>
<string>Promise Output</string>
</tuple>
</list>
</value>
......@@ -254,7 +206,7 @@
<value>
<list>
<tuple>
<string>title</string>
<string>change_date</string>
<string>descending</string>
</tuple>
</list>
......@@ -265,8 +217,8 @@
<value>
<list>
<tuple>
<string>title</string>
<string>Title</string>
<string>change_date</string>
<string>Status Date</string>
</tuple>
</list>
</value>
......
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