Commit 5bd4fe83 authored by Alain Takoudjou's avatar Alain Takoudjou

slapos_monitoring: allow to sync data in local indexdb, add offline mode support

parent a6119296
......@@ -107,7 +107,7 @@
<value> <string encoding="cdata"><![CDATA[
CACHE MANIFEST\n
# generated on Fri, 11 Mai 2016 15:47:33 +0000\n
# generated on Fri, 20 Mai 2016 15:47:33 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
CACHE:\n
......@@ -158,6 +158,7 @@ gadget_monitoring_router.html\n
gadget_monitoring_settings_configurator.html\n
gadget_monitoring_status_grid.html\n
gadget_monitoring_status_list.html\n
gadget_monitoring_sync.html\n
gadget_monitoring_widget_listbox.html\n
gadget_monitoring_widget_listview.html\n
gadget_monitoring_widget_overview.html\n
......@@ -181,6 +182,7 @@ gadget_monitoring_router.js\n
gadget_monitoring_static.js\n
gadget_monitoring_status_grid.js\n
gadget_monitoring_status_list.js\n
gadget_monitoring_sync.js\n
gadget_monitoring_tooltipster.min.js\n
gadget_monitoring_widget_listbox.js\n
gadget_monitoring_widget_listview.js\n
......@@ -327,7 +329,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.6586.44195.10240</string> </value>
<value> <string>951.21023.1861.15223</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -345,7 +347,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1462958448.28</float>
<float>1463759960.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -64,7 +64,7 @@
basic_login: cred.hash
}
}
});
}, false);
return gadget.props.jio_gadget.put(gadget.props.options.key, jio_document);
})
.push(function (result) {
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.49438.50290.39714</string> </value>
<value> <string>950.63263.62080.55091</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1458061223.97</float>
<float>1463069373.0</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -31,6 +31,7 @@
<!--div data-role="header" data-theme="a" class="ui-header ui-bar-a" data-position="fixed" data-tap-toggle="false"-->
<div data-role="header" data-position="fixed" data-theme="a" class="ui-header ui-bar-a" data-tap-toggle="false">
<div data-gadget-url="gadget_monitoring_sync.html" data-gadget-scope="sync_gadget" data-gadget-sandbox="public"></div>
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">
<div class="ui-controlgroup-controls">
</div>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.63263.62080.55091</string> </value>
<value> <string>951.17777.16093.25088</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1462896137.92</float>
<float>1463744803.95</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -44,6 +44,13 @@
};
})
.ready(function (g) {
return g.getDeclaredGadget("sync_gadget")
.push(function (sync_gadget) {
g.props.sync_gadget = sync_gadget;
});
})
// Assign the element to a variable
.ready(function (g) {
return g.getElement()
......@@ -266,6 +273,10 @@
gadget.props.title_element.innerHTML = my_translated_html_list[0];
gadget.props.left_link.innerHTML = my_translated_html_list[1];
gadget.props.right_link.innerHTML = my_translated_html_list[2];
})
.push(function () {
// set auto sync timer
return gadget.props.sync_gadget.startSync();
});
})
......
......@@ -235,7 +235,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.6822.36434.34560</string> </value>
<value> <string>951.20773.60158.51182</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -253,7 +253,7 @@
</tuple>
<state>
<tuple>
<float>1462954238.66</float>
<float>1463745210.1</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -118,6 +118,7 @@
</table>
{{/if}}
{{/each}}
<div class="alert alert-info ui-content-hidden">Your Changes can take a few minutes to appear in this screen!</div>
{{else}}
<h2>No parameters.</h2>
{{/if}}
......
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.7634.20557.47701</string> </value>
<value> <string>951.10932.20107.12578</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -261,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1462956704.34</float>
<float>1463154501.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -115,9 +115,8 @@
opml_tmp_key_list = [];
for (key in url_description_dict) {
opml_tmp_key_list.push(key);
promise_list.push(gadget.props.jio_gadget.getMonitorUrlListFromOpml(
url_description_dict[key].href
));
promise_list.push(gadget.props.jio_gadget.getMonitorUrlList(undefined,
url_description_dict[key].title));
}
return RSVP.all(promise_list);
})
......@@ -291,7 +290,9 @@
}
gadget.props.document_list[index].parameters = data;
updateParameterBox(data, gadget.props.document_list[index].title);
return RSVP.push(update_promise);
$(gadget.props.element.querySelector('.alert-info'))
.removeClass('ui-content-hidden');
return RSVP.all(update_promise);
});
});
}
......@@ -308,7 +309,7 @@
);
}
function getSecureDocument(url, auth_login) {
function getMonitorDocument(url, auth_login) {
var jio_options = {
type: "query",
sub_storage: {
......@@ -321,7 +322,9 @@
},
document_id = 'monitor.global';
if (auth_login) {
jio_options.sub_storage.sub_storage.basic_login = auth_login;
}
gadget.props.jio_gadget.createJio(jio_options);
return gadget.props.jio_gadget.get(document_id);
}
......@@ -377,7 +380,7 @@
$(".ui-block-b .signal").removeClass("ui-content-hidden");
return $(element.querySelector('td:first-child > a')).addClass('selected');
})
.push(function () {
/*.push(function () {
var i,
cred_promise_list = [];
for (i = 0; i < gadget.props.hosting_list[index].instance_list.length; i += 1) {
......@@ -388,14 +391,14 @@
));
}
return RSVP.all(cred_promise_list);
})
.push(function (cred_list) {
})*/
.push(function () {
var i,
promise_list = [];
for (i = 0; i < gadget.props.hosting_list[index].instance_list.length; i += 1) {
promise_list.push(getSecureDocument(
gadget.props.hosting_list[index].instance_list[i].url,
cred_list[i].hash
promise_list.push(getMonitorDocument(
gadget.props.hosting_list[index].instance_list[i].url
//cred_list[i].hash
));
}
return RSVP.all(promise_list);
......@@ -430,7 +433,7 @@
}
}
if (gadget.props.opml_dict[gadget.props.opml_key_list[index]] !== undefined) {
status_url = "#page=status_list&opml_url=" + gadget.props.opml_dict[gadget.props.opml_key_list[index]].href;
status_url = "#page=status_list&search=" + gadget.props.opml_dict[gadget.props.opml_key_list[index]].title;
}
parameter_content = parameters_widget_template({parameter_list: parameter_list});
instance_content = instance_widget_template({
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.7620.46241.55705</string> </value>
<value> <string>951.17698.39476.46574</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1462957229.65</float>
<float>1463560631.34</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -15,6 +15,7 @@
<body>
<div data-gadget-url="gadget_monitoring_jio.html" data-gadget-scope="jio_gadget" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_monitoring_login_widget.html" data-gadget-scope="login_gadget" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_monitoring_sync.html" data-gadget-scope="sync_gadget" data-gadget-sandbox="public"></div>
<div data-role="tabs" class="config-tabs">
<div data-role="navbar">
......@@ -50,13 +51,12 @@
<textarea name="settings-data-input" class="text-data"></textarea>
</div>
</div>
<div class="ui-text-right padding-5">
<span class="ui-text-error"></span>
</div>
<div class="alert alert-error ui-content-hidden"></div>
<div class="select-storage ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b">
<div class="ui-block-b padding-lr-10">
<button data-i18n="Continue" class="ui-btn-btn-right btn-continue ui-content-hidden">Continue</button>
</div>
<div class="ui-block-c">
<button data-i18n="Reload Settings" class="ui-btn-btn-right btn-save">Import Settings</button>
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.11579.61166.10564</string> </value>
<value> <string>951.20886.9345.28125</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1459353714.18</float>
<float>1463752338.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -117,6 +117,12 @@
g.props.login_gadget = login_gadget;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("sync_gadget")
.push(function (sync_gadget) {
gadget.props.sync_gadget = sync_gadget;
});
})
.ready(function (g) {
return g.getDeclaredGadget("jio_gadget")
.push(function (jio_gadget) {
......@@ -124,7 +130,7 @@
return jio_gadget.createJio({
type: "indexeddb",
database: "setting"
});
}, false);
});
})
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -170,6 +176,18 @@
}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector('.btn-continue'),
'click',
true,
function () {
return gadget.redirect({
page: 'settings_configurator',
tab: 'manage'
});
}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector('.btn-save'),
'click',
......@@ -179,16 +197,15 @@
configuration_dict,
monitor_url_dict = {},
monitor_opml_url_dict = {},
error_msg = '',
i;
gadget.props.element.querySelector('.ui-text-error')
.innerHTML = "";
try {
configuration_dict = JSON.parse(json_string);
} catch (e) {
gadget.props.element.querySelector('.ui-text-error')
.innerHTML = 'Error: Invalid json content!';
return;
return $(gadget.props.element.querySelector('.alert-error'))
.removeClass('ui-content-hidden')
.html('Error: Invalid json content!');
}
return validateJsonConfiguration(configuration_dict)
......@@ -204,19 +221,49 @@
hashCode(configuration_dict.monitor_url[i].url)
] = configuration_dict.monitor_url[i];
}
$(gadget.props.element.querySelector('.btn-continue'))
.addClass('ui-content-hidden');
gadget.props.element.querySelector('.btn-save')
.innerHTML = "Please wait...";
return gadget.props.login_gadget.setUrlDict(monitor_url_dict)
.push(function () {
return gadget.setSetting('monitor_url_description', monitor_opml_url_dict);
})
.push(function () {
return gadget.props.jio_gadget.syncMonitoringOpmlData();
})
.push(function (result_list) {
var i;
for (i = 0; i < result_list.length; i += 1) {
if (result_list[i].error) {
error_msg += 'Failed to sync data at "' + result_list[i].url + '" <br/>';
}
}
gadget.props.element.querySelector('.btn-save')
.innerHTML = "Sync Data...";
return gadget.props.sync_gadget.startSync({now: true});
})
.push(function (){
if (error_msg) {
$(gadget.props.element.querySelector('.alert-error'))
.removeClass('ui-content-hidden')
.html(error_msg);
$(gadget.props.element.querySelector('.btn-continue'))
.removeClass('ui-content-hidden');
gadget.props.element.querySelector('.btn-save')
.innerHTML = "Retry Import";
} else {
return gadget.redirect({
page: 'settings_configurator',
tab: 'manage'
});
}
});
} else {
gadget.props.element.querySelector('.ui-text-error')
.innerHTML = 'Error: Content is not a valid Monitoring Json configuration!';
$(gadget.props.element.querySelector('.alert-error'))
.removeClass('ui-content-hidden')
.html('Error: Content is not a valid Monitoring Json configuration!');
}
});
}
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.6586.6078.25975</string> </value>
<value> <string>951.20891.29228.48298</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1462894491.67</float>
<float>1463752927.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,57 +3,164 @@
(function (window, rJS, jIO) {
"use strict";
function getOPMLUrlList(url, query) {
function createReplicatedJio(gadget, storage_dict, query) {
var storage_url,
the_storage,
configuration,
hashCode = function (s) {
return s.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
};
the_storage = JSON.parse(JSON.stringify(storage_dict));
while (the_storage.hasOwnProperty('sub_storage')) {
the_storage = the_storage.sub_storage;
}
/*if (! the_storage.hawOwnProperty('url')) {
throw new Error('Jio configuration must contain url!');
} else {
storage_url = the_storage.url;
}*/
storage_url = the_storage.url;
configuration = {
type: "replicate",
query: query,
use_remote_post: false,
conflict_handling: 2,
check_local_modification: false,
check_local_creation: false,
check_local_deletion: false,
check_remote_modification: true,
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "uuid",
sub_storage: {
type: "query",
sub_storage: {
type: "indexeddb",
database: "monitoringdb_" + hashCode(storage_url)
}
}
},
remote_sub_storage: storage_dict
};
return jIO.createJIO(configuration);
}
function createOPMLReplicatedJio(url) {
var jio_options = {
type: "replicate",
query: {},
use_remote_post: false,
conflict_handling: 2,
check_local_modification: false,
check_local_creation: false,
check_local_deletion: false,
check_remote_modification: true,
check_remote_creation: true,
check_remote_deletion: true,
local_sub_storage: {
type: "uuid",
sub_storage: {
type: "query",
sub_storage: {
type: "indexeddb",
database: "monitoringdb"
}
}
},
remote_sub_storage: {
type: "query",
sub_storage: {
type: "feed",
feed_type: 'opml',
url: url
}
}
},
jio_storage = jIO.createJIO(jio_options);
return jio_storage;
}
function syncMonitoringOpmlData(url) {
var jio_storage = createOPMLReplicatedJio(url);
console.log("Sync of " + url);
return jio_storage.repair()
.push(function () {
return {error: false, url: url};
}, function(error) {
console.log(error);
return {error: true, url: url};
});
}
function getFeedUrlList(query) {
var jio_options = {
type: "query",
sub_storage: {
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoringdb"
}
}
},
jio_storage = jIO.createJIO(jio_options);
if (query === undefined) {
query = {};
query = {
include_docs: true
};
}
return jio_storage.allDocs(query)
.push(function (url_list) {
var i,
feed_url = [];
feed_url_list = [];
for (i = 0; i < url_list.data.total_rows; i += 1) {
if (url_list.data.rows[i].value.htmlurl) { // || url_list.data.rows[i].value.xmlUrl
feed_url.push(url_list.data.rows[i].value.htmlurl); // || url_list.data.rows[i].value.xmlUrl
if (url_list.data.rows[i].doc.htmlurl) { // || url_list.data.rows[i].doc.xmlUrl
feed_url_list.push(url_list.data.rows[i].doc.htmlurl); // || url_list.data.rows[i].doc.xmlUrl
}
}
return feed_url;
return feed_url_list;
}, function(error) {
console.log(error);
});
}
function getMonitorUrlList(url, query) {
function getMonitorUrlList(query, opml_title) {
var jio_options = {
type: "query",
sub_storage: {
type: "feed",
feed_type: 'opml',
url: url
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoringdb"
}
}
},
jio_storage = jIO.createJIO(jio_options);
if (query === undefined) {
query = {};
query = {
include_docs: true
};
}
return jio_storage.allDocs(query)
.push(function (url_list) {
var i,
monitor_url = [];
monitor_url_list = [];
for (i = 0; i < url_list.data.total_rows; i += 1) {
if (url_list.data.rows[i].value.url) {
monitor_url.push(url_list.data.rows[i].value.url);
if (url_list.data.rows[i].doc.url) {
if ((opml_title && url_list.data.rows[i].doc.opml_title === opml_title)
|| (opml_title === undefined)) {
monitor_url_list.push(url_list.data.rows[i].doc.url);
}
}
return monitor_url;
}
return monitor_url_list;
}, function(error) {
console.log(error);
});
......@@ -79,8 +186,16 @@
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod('createJio', function (jio_options) {
var gadget = this;
.declareMethod('createJio', function (jio_options, replicated, query) {
var gadget = this,
storage;
if ((replicated === undefined || replicated === true) && jio_options) {
if (query === undefined) {
query = {};
}
this.state_parameter_dict.jio_storage = createReplicatedJio(
gadget, jio_options, query);
} else {
if (jio_options === undefined) {
jio_options = {
type: "query",
......@@ -94,95 +209,70 @@
};
}
this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options);
return this.getSetting("jio_storage_name")
.push(function (jio_storage_name) {
gadget.state_parameter_dict.jio_storage_name = jio_storage_name;
});
}
return this.state_parameter_dict.jio_storage;
})
.declareMethod('createJioFromRssFeed', function (feed_url, basic_login) {
var gadget = this,
jio_options = {
type: "query",
sub_storage: {
type: "feed",
feed_type: 'rss',
url: opml_url
.declareMethod('syncMonitoringOpmlData', function (url) {
if (url !== undefined) {
return syncMonitoringOpmlData(url);
}
};
if (basic_login !== undefined) {
jio_options.sub_storage.basic_login = basic_login;
return this.getSetting('monitor_url_description')
.push(function (url_description_dict) {
var promise_list = [],
key;
for (key in url_description_dict) {
promise_list.push(syncMonitoringOpmlData(url_description_dict[key].href));
}
this.state_parameter_dict.jio_storage = jIO.createJIO(jio_options);
return jio_options;
return RSVP.all(promise_list);
});
})
.declareMethod('getUrlListFromOPML', function (opml_url, query) {
return getOPMLUrlList(opml_url, query);
.declareMethod('getFeedUrlList', function (query) {
return getFeedUrlList(query);
})
.declareMethod('getUrlDescriptionFromOPML', function (opml_url, query) {
.declareMethod('getUrlFeedDescription', function (query) {
var jio_options = {
type: "query",
sub_storage: {
type: "feed",
feed_type: 'opml',
url: opml_url
type: "uuid",
sub_storage: {
type: "indexeddb",
database: "monitoringdb"
}
}
},
jio_storage = jIO.createJIO(jio_options);
if (query === undefined) {
query = {};
query = {
include_docs: true
};
}
return jio_storage.allDocs(query)
.push(function (url_list) {
var i,
feed_url;
feed_url_list = [];
for (i = 0; i < url_list.data.total_rows; i += 1) {
if (url_list.data.rows[i].value.htmlurl || url_list.data.rows[i].value.xmlUrl) {
feed_url.push({
htmlurl: url_list.data.rows[i].value.htmlurl,
xmlUrl: url_list.data.rows[i].value.xmlUrl,
title: url_list.data.rows[i].value.title,
opml_title: url_list.data.rows[i].value.opml_title,
type: url_list.data.rows[i].value.type,
create_date: url_list.data.rows[i].value.create_date,
modified_date: url_list.data.rows[i].value.modified_date,
version: url_list.data.rows[i].value.version,
text: url_list.data.rows[i].value.text,
});
}
}
return feed_url;
if (url_list.data.rows[i].doc.htmlurl || url_list.data.rows[i].doc.xmlurl) {
feed_url_list.push({
htmlurl: url_list.data.rows[i].doc.htmlurl,
xmlUrl: url_list.data.rows[i].doc.xmlurl,
url: url_list.data.rows[i].doc.url,
title: url_list.data.rows[i].doc.title,
opml_title: url_list.data.rows[i].doc.opml_title,
type: url_list.data.rows[i].doc.type,
create_date: url_list.data.rows[i].doc.create_date,
modified_date: url_list.data.rows[i].doc.modified_date,
version: url_list.data.rows[i].doc.version,
text: url_list.data.rows[i].doc.text,
});
})
.declareMethod('getUrlListFromFullOPML', function (query) {
return this.getSetting('monitor_url_description')
.push(function (url_description_dict) {
var promise_list = [],
key;
for (key in url_description_dict) {
promise_list.push(getOPMLUrlList(url_description_dict[key].href, query));
}
return RSVP.all(promise_list);
})
.push(function(url_list) {
return concatArrayOfArray(url_list);
});
})
.declareMethod('getMonitorUrlList', function (query) {
return this.getSetting('monitor_url_description')
.push(function (url_description_dict) {
var promise_list = [],
key;
for (key in url_description_dict) {
promise_list.push(getMonitorUrlList(url_description_dict[key].href, query));
}
return RSVP.all(promise_list);
})
.push(function(url_list) {
return concatArrayOfArray(url_list);
return feed_url_list;
});
})
.declareMethod('getMonitorUrlListFromOpml', function (url, query) {
return getMonitorUrlList(url, query);
.declareMethod('getMonitorUrlList', function (query, opml_title) {
return getMonitorUrlList(query, opml_title);
})
.declareMethod('allDocs', function () {
var storage = this.state_parameter_dict.jio_storage;
......@@ -232,15 +322,6 @@
storage = gadget.state_parameter_dict.jio_storage;
return storage.repair.apply(storage, arguments)
.push(undefined, function (error) {
if (error instanceof XMLHttpRequestProgressEvent &&
error.currentTarget.status === 401 &&
gadget.state_parameter_dict.jio_storage_name === "ERP5") {
return {
redirect: {
page: "login"
}
};
}
throw error;
});
});
......
......@@ -235,7 +235,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.59884.43592.12680</string> </value>
<value> <string>951.20849.6596.3413</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -253,7 +253,7 @@
</tuple>
<state>
<tuple>
<float>1458313807.96</float>
<float>1463759566.63</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -94,6 +94,24 @@
});
}
function getUrlDict(gadget) {
var jio_gadget;
return gadget.getDeclaredGadget("jio_gadget")
.push(function (result) {
jio_gadget = result;
return jio_gadget.get("urls");
})
.push(undefined, function (error) {
if (error.status_code === 404) {
return {};
}
throw error;
})
.push(function (doc) {
return doc;
});
}
function clearSettingFromParentUrl (gadget, parent_url) {
var jio_gadget;
return gadget.getDeclaredGadget("jio_gadget")
......@@ -206,6 +224,10 @@
var gadget = this;
return setUrlDict(gadget, url_dict);
})
.declareMethod('getUrlDict', function () {
var gadget = this;
return getUrlDict(gadget);
})
.declareMethod('clearSettingFromParentUrl', function (parent_url) {
var gadget = this;
return clearSettingFromParentUrl(gadget, parent_url);
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superalain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.54785.50611.22596</string> </value>
<value> <string>950.63263.62080.55091</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461942642.99</float>
<float>1462973707.48</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -243,7 +243,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>948.31845.65187.32494</string> </value>
<value> <string>951.17777.16093.25088</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -261,7 +261,7 @@
</tuple>
<state>
<tuple>
<float>1452874621.91</float>
<float>1463744746.17</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -7,7 +7,7 @@
gadget_klass
.ready(function (g) {
return false;
g.props = {};
})
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
......@@ -38,6 +38,12 @@
page: 'status_' + current_display
});
});
})
.declareService(function () {
var gadget = this;
});
}(window, rJS));
\ No newline at end of file
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.56645.25063.6451</string> </value>
<value> <string>951.20773.46331.52377</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1458320618.57</float>
<float>1463745785.66</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -41,7 +41,7 @@
],
query: {
select_list: ['title', 'status', 'date', '_links', 'state', 'hosting-title'],
query: '_id:"monitor.global"',
//query: '_id:"monitor.global"',
sort_on: [["status", "ascending"]]
}
};
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.28768.11607.28996</string> </value>
<value> <string>951.9443.43477.54732</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1460450670.49</float>
<float>1463065265.96</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -53,7 +53,7 @@
return gadget.property_dict.login_gadget.loginRedirect(options.jio_for, options, options.title, options.root)
.push(function (cred) {
jio_options.sub_storage.sub_storage.basic_login = cred.hash;
gadget.property_dict.jio_gadget.createJio(jio_options);
gadget.property_dict.jio_gadget.createJio(jio_options, false);
return gadget.updateHeader({
title: options.title + ' [' + options.root + '] Processes status'
});
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.59799.36045.13670</string> </value>
<value> <string>950.63263.62080.55091</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1458308638.96</float>
<float>1463148214.4</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -109,15 +109,15 @@
promise_list = [];
return new RSVP.Queue()
.push(function () {
/*.push(function () {
return gadget.property_dict.login_gadget.loginRedirect(
element._links.monitor.href,
options,
element.instance,
element.hosting_subscription
);
})
.push(function (cred) {
})*/
.push(function () {
status = (element.status.toLowerCase() === 'error') ?
'red' : (element.status.toLowerCase() === 'warning') ? 'warning' : 'ok';
element.state = status;
......@@ -139,7 +139,7 @@
sub_storage: {
type: "dav",
url: element._links.monitor.href,
basic_login: cred.hash
//basic_login: cred.hash
}
}
};
......@@ -200,7 +200,7 @@
var title = options.jio_key.slice(0, -7),
jio_options,
history_content,
jio_url = options.jio_for + '/.jio_documents/history/' + title; // XXX hardcoded URL
jio_url = options.jio_for;
jio_options = {
type: "query",
......@@ -212,9 +212,10 @@
}
}
};
gadget.property_dict.jio_gadget.createJio(jio_options);
gadget.property_dict.jio_gadget.createJio(jio_options, false);
return gadget.property_dict.jio_gadget.allDocs({
select_list: ['title', 'message', 'start-date', 'status'],
query: '_id: "%.history.status"',
limit: [0, 30],
sort_on: [["start-date", "descending"]]
})
......@@ -254,7 +255,7 @@
}
}
};
gadget.property_dict.jio_gadget.createJio(jio_options);
gadget.property_dict.jio_gadget.createJio(jio_options, false);
return gadget.property_dict.jio_gadget.get(jio_key);
})
.push(function (monitor_state) {
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.56728.21843.28501</string> </value>
<value> <string>951.10830.35453.12458</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1458901454.83</float>
<float>1463152445.63</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -93,7 +93,7 @@
}
}
};
gadget.property_dict.jio_gadget.createJio(jio_options);
gadget.property_dict.jio_gadget.createJio(jio_options, false);
return gadget.property_dict.jio_gadget.get(gadget.property_dict.ressource_dict[key])
.push(function (jio_element) {
if (!jio_element.hasOwnProperty('data')) {
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>949.64188.296.22835</string> </value>
<value> <string>950.63263.62080.55091</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1458571980.17</float>
<float>1463147612.98</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -31,6 +31,7 @@
<body>
<div data-gadget-url="gadget_monitoring_jio.html" data-gadget-scope="jio_gadget" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_monitoring_login_widget.html" data-gadget-scope="login_gadget" data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_monitoring_sync.html" data-gadget-scope="sync_gadget" data-gadget-sandbox="public"></div>
<div data-role="tabs" class="config-tabs">
<div data-role="navbar">
<ul>
......@@ -129,7 +130,7 @@
<div class="overview-header">
<div class='content-title ui-instance-title'>
<div class="overview-title">
<i class="fa fa-link"></i><span>Monitoring OPML URL</span>
<i class="fa fa-link"></i><span>Monitoring Instances list</span>
</div>
<div class="commands">
</div>
......@@ -161,6 +162,23 @@
</span>
</div>
<div class="padding-5">
<fieldset class="sync-interval-controlgroup" data-role="controlgroup" data-type="horizontal">
<legend><strong>Auto Sync Interval:</strong></legend>
<input type="radio" name="sync-data-timer" id="sync-data-5m" value="300000" checked="checked">
<label for="sync-data-5m">5 min</label>
<input type="radio" name="sync-data-timer" id="sync-data-10m" value="600000">
<label for="sync-data-10m">10 min</label>
<input type="radio" name="sync-data-timer" id="sync-data-20m" value="1200000">
<label for="sync-data-20m">20 min</label>
<input type="radio" name="sync-data-timer" id="sync-data-30m" value="1800000">
<label for="sync-data-30m">30 min</label>
<input type="radio" name="sync-data-timer" id="sync-data-1h" value="3600000">
<label for="sync-data-1h">1 h</label>
</fieldset>
<button class="ui-btn ui-corner-all ui-btn-inline sync-all"><i class="fa fa-download"></i> Sync Data Now</button>
</div>
<div class="padding-5">
<h2><strong>Access links:</strong></h2>
<a href="#page=hosting_overview">Access Applications</a>
<a href="#page=import_export">Export Settings</a>
</div>
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superalain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.54736.61765.9915</string> </value>
<value> <string>951.21014.7809.37444</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461937944.7</float>
<float>1463759407.22</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -113,7 +113,8 @@
query: {
select_list: ['title', 'opml_title', 'htmlurl', 'type', 'url'],
sort_on: [["opml_title", "ascending"]]
}
},
replicate: false
},
jio_options = {
type: "query",
......@@ -269,7 +270,7 @@
url: url
}
};
gadget.props.jio_gadget.createJio(jio_options);
gadget.props.jio_gadget.createJio(jio_options, false);
return gadget.props.jio_gadget.allDocs({})
.push(function (doc) {
if (!doc) {
......@@ -313,6 +314,12 @@
gadget.props.jio_gadget = jio_gadget;
});
})
.ready(function (gadget) {
return gadget.getDeclaredGadget("sync_gadget")
.push(function (sync_gadget) {
gadget.props.sync_gadget = sync_gadget;
});
})
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
......@@ -365,7 +372,41 @@
// Form submit
/////////////////////////////////////////
.declareService(function () {
var gadget = this;
var gadget = this,
sync_checkbox_list,
i;
function setSyncTimerInterval(element) {
var timer;
if ($(element).prop('checked')) {
timer = parseInt($(element).val(), 10);
console.log(timer);
if (timer && !isNaN(timer)) {
return new RSVP.Queue()
.push(function () {
return gadget.setSetting('sync_data_interval', timer);
});
}
}
}
function setSelectSyncTime(time_interval) {
var element_id = "#sync-data-";
if (time_interval === 300000) {
element_id += "5m";
} else if (time_interval === 600000) {
element_id += "10m";
} else if (time_interval === 1200000) {
element_id += "20m";
} else if (time_interval === 1800000) {
element_id += "30m";
} else if (time_interval === 3600000) {
element_id += "1h";
}
$(element_id).prop('checked', true);
return $(gadget.props.element.querySelector(".sync-interval-controlgroup"))
.controlgroup().controlgroup("refresh");
}
return new RSVP.Queue()
.push(function () {
......@@ -374,6 +415,12 @@
.push(function () {
return $(gadget.props.element.querySelector("a[href='#config-" + gadget.props.selected + "']")).trigger('click');
})
.push(function () {
return gadget.getSetting('sync_data_interval');
})
.push(function (time_interval) {
return setSelectSyncTime(time_interval);
})
.push(function () {
var text = "Give username and password that you have.<br/>For each Monitor, " +
"credentials will be saved only if Login/password are valid.<br/> <br>" +
......@@ -412,6 +459,29 @@
}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector('.sync-all'),
'click',
true,
function () {
var title = gadget.props.element.querySelector('.sync-all').innerHTML;
return new RSVP.Queue()
.push(function () {
gadget.props.element.querySelector('.sync-all')
.innerHTML = '<i class="fa fa-download"></i> Please wait...';
gadget.props.element.querySelector('.sync-all')
.disabled = true;
return gadget.props.sync_gadget.startSync({now: true});
})
.push(function () {
gadget.props.element.querySelector('.sync-all')
.innerHTML = title;
gadget.props.element.querySelector('.sync-all')
.disabled = false;
});
}
));
promise_list.push(loopEventListener(
gadget.props.element.querySelector("table th input[name='opml-all']"),
'change',
......@@ -439,6 +509,7 @@
}
}
));*/
promise_list.push(
$(gadget.props.element.querySelector("input[name='configure-auth']")).bind( "change", function(event, ui) {
var input_login = gadget.props.element.querySelector(".configure input[name='username']"),
......@@ -679,6 +750,10 @@
config_promise_list.push(
setUrlConfiguration(gadget, gadget.props.opml_url, root_name)
);
// sync this opml feed
config_promise_list.push(
gadget.props.jio_gadget.syncMonitoringOpmlData(gadget.props.opml_url)
);
return RSVP.all(config_promise_list);
})
.push(function (result) {
......@@ -744,6 +819,15 @@
}
));
sync_checkbox_list = gadget.props.element.querySelectorAll("input[name='sync-data-timer']");
for (i = 0; i < sync_checkbox_list.length; i += 1) {
promise_list.push(
$(sync_checkbox_list[i])
.bind("change",
setSyncTimerInterval.bind(gadget, sync_checkbox_list[i]))
);
}
return RSVP.all(promise_list);
});
});
......
......@@ -225,7 +225,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superalain</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.54797.54715.48554</string> </value>
<value> <string>951.21015.25528.41881</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1461942058.71</float>
<float>1463759548.44</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -66,18 +66,21 @@
query: {
select_list: ['title', 'siteTitle', 'reference', 'category',
'date', 'message', 'link', 'source'],
//query: '_id:(NOT "monitor.hal") AND _id:(NOT "monitor.global")',
query: '_id: (NOT "_replicate_%")',
sort_on: [["category", "ascending"]]
}
};
return gadget.updateHeader(header)
.push(function () {
if (options.opml_url) {
return gadget.property_dict.jio_gadget.getUrlListFromOPML(options.opml_url);
if (options.root_title) {
return gadget.property_dict.jio_gadget.getFeedUrlList({
query: 'opml_title: "' + options.root_title + '"',
include_docs: true
});
}
else {
return gadget.property_dict.jio_gadget.getUrlListFromFullOPML();
return gadget.property_dict.jio_gadget.getFeedUrlList();
}
})
.push(function (url_list) {
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.28768.11607.28996</string> </value>
<value> <string>951.16713.3981.39628</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1460450783.19</float>
<float>1463501364.68</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 Sync Data</title>
<link href="gadget_monitoring_custom.css" rel="stylesheet" type="text/css"/>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_monitoring_sync.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_monitoring_login_widget.html" data-gadget-scope="login_gadget" data-gadget-sandbox="public"></div>
</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>
<string>Owner</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>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>classification/collaborative/public</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_monitoring_sync.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_monitoring_sync_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</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>Monitoring Sync Data</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463424662.99</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.15435.34499.18483</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463424729.85</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463424597.78</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
/*global window, rJS */
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS) {
"use strict";
var gadget_klass = rJS(window),
rusha = new Rusha();
gadget_klass
.ready(function (g) {
g.props = {};
return g.getDeclaredGadget('jio_gadget')
.push(function (jio_gadget) {
g.props.jio_gadget = jio_gadget;
});
})
.ready(function (g) {
return g.getDeclaredGadget('login_gadget')
.push(function (login_gadget) {
g.props.login_gadget = login_gadget;
});
})
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("setSetting", "setSetting")
.declareMethod("startSync", function (options) {
var gadget = this,
monitor_cred_dict = {},
sync_lock = false;
function syncStorage(gadget, storage_dict, query) {
gadget.props.jio_gadget.createJio(storage_dict, true, query);
return gadget.props.jio_gadget.repair()
.push(undefined, function (error) {
console.log(error);
});
}
function getMonitoringStorageList (feed_url_list) {
var base_url,
base_url_hash,
key,
i,
j,
feed_config,
dav_config,
monitor_storage_list = [],
storage_type_list = [],
dav_storage = {
type: "query",
sub_storage: {
type: "drivetojiomapping",
sub_storage: {
type: "dav"
}
}
},
feed_storage = {
type: "query",
sub_storage: {
type: "feed",
feed_type: 'rss'
}
};
storage_type_list = [
{path: 'jio_public/', query: {}},
{path: 'jio_private/', query: {}, private_access: true},
/*{path: 'jio_private/data/', query: {
//query: '_id: "%.data" AND _id: "%.status"' // Skip history
}},
/*{path: 'jio_private/report/', query: {
query: '_id:"%.report"' // Skip history
}}*/
];
for (i = 0; i < feed_url_list.length; i += 1) {
feed_config = JSON.parse(JSON.stringify(feed_storage));
feed_config.sub_storage.url = feed_url_list[i].htmlurl;
monitor_storage_list.push({
storage: feed_config,
query: {}
});
base_url = feed_url_list[i].url.replace('jio_public/', ''); // Hard coded!!
base_url_hash = rusha.digestFromString(base_url + 'jio_private/'); // hard coded!!
for (j = 0; j < storage_type_list.length; j += 1) {
dav_config = JSON.parse(JSON.stringify(dav_storage));
dav_config.sub_storage.sub_storage.url = base_url + storage_type_list[j].path;
if (storage_type_list[j].private_access) {
if (monitor_cred_dict.hasOwnProperty(base_url_hash)) {
dav_config.sub_storage.sub_storage.basic_login = monitor_cred_dict[base_url_hash].hash;
} else {
continue;
}
}
monitor_storage_list.push({
storage: dav_config,
query: storage_type_list[j].query
});
}
}
return monitor_storage_list;
}
function syncAllStorage() {
var monitor_storage_list = [];
if (sync_lock === true) {
return [];
}
if (options.now) {
sync_lock = true;
}
return gadget.props.login_gadget.getUrlDict()
.push(function(url_dict) {
monitor_cred_dict = url_dict;
return gadget.props.jio_gadget.getUrlFeedDescription(options.query);
})
.push(function (url_list) {
var i,
promise_list = [];
monitor_storage_list = getMonitoringStorageList(url_list);
for (i = 0; i < monitor_storage_list.length; i += 1) {
promise_list.push(syncStorage(
gadget,
monitor_storage_list[i].storage,
monitor_storage_list[i].query));
}
console.log("Sync monitoring data...");
return RSVP.all(promise_list);
})
.push(function () {
var sync_time = new Date().getTime();
sync_lock = false;
return gadget.setSetting('latest_sync_time', sync_time);
});
}
function syncDataTimer() {
if (gadget.props.timer) {
clearInterval(gadget.props.timer);
}
gadget.props.timer = setTimeout(function(){
return new RSVP.Queue()
.push(function () {
return syncAllStorage();
})
.push(function () {
return gadget.getSetting('sync_data_interval');
})
.push(function (timer_interval) {
if (timer_interval === undefined) {
timer_interval = 300000;
}
gadget.props.timer_interval = timer_interval;
return syncDataTimer();
});
}, gadget.props.timer_interval);
}
if (options === undefined) {
options = {};
}
if (options.query === undefined) {
options.query = {
include_docs: true
};
}
if (options.now) {
return syncAllStorage();
}
return new RSVP.Queue()
.push(function () {
return gadget.getSetting('sync_data_interval');
})
.push(function (timer_interval) {
if (timer_interval === undefined) {
timer_interval = 300000;
}
gadget.props.timer_interval = timer_interval;
return gadget.getSetting('latest_sync_time');
})
.push(function (latest_sync_time) {
var current_time = new Date().getTime(),
time_diff;
if (latest_sync_time !== undefined) {
time_diff = current_time - latest_sync_time;
if ((time_diff - 10000) >= gadget.props.timer_interval) {
// sync in after 5 second
gadget.props.timer_interval = 5000;
} else {
gadget.props.timer_interval = gadget.props.timer_interval - time_diff;
}
}
return syncDataTimer();
});
});
}(window, rJS));
\ 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>
<string>Owner</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>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>classification/collaborative/public</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_monitoring_sync.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_monitoring_sync_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>Monitoring Sync Data Gadget JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463424020.0</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.20979.34222.27938</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463759827.91</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1463423808.77</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -95,7 +95,7 @@
search_list = [],
translated_column_list = [],
all_docs_result_list = [],
all_docs = function (query, storage_list) {
all_docs = function (query, storage_list, replicate) {
var promise_list = [],
i;
if (storage_list === undefined) {
......@@ -103,8 +103,11 @@
} else if (storage_list === []) {
return [];
}
if (replicate === undefined) {
replicate = true;
}
for (i = 0; i < storage_list.length; i += 1) {
gadget.property_dict.jio_gadget.createJio(storage_list[i]);
gadget.property_dict.jio_gadget.createJio(storage_list[i], replicate);
/*promise_list.push(
getJioAllDocument(gadget, 'jio_gadget' + i, storage_list[i], query)
);*/
......@@ -149,7 +152,7 @@
}
}
//return gadget.jio_allDocs(option_dict.query)
return all_docs(option_dict.query, option_dict.storage_list)
return all_docs(option_dict.query, option_dict.storage_list, option_dict.replicate)
.push(function (result_list) {
var promise_list = [],
promise_url_list = [],
......@@ -202,6 +205,9 @@
// build handlebars object
for (k = 0; k < all_docs_result_list.length; k += 1) {
for (j = 0, j_len = all_docs_result_list[k].data.total_rows; j < j_len; j += 1) {
if (Object.keys(all_docs_result_list[k].data.rows[j].value).length === 0) {
continue; // Skip empty value
}
gadget.property_dict.data_result.push(all_docs_result_list[k].data.rows[j].value);
cell_list = [];
for (i = 0, i_len = option_dict.column_list.length; i < i_len; i += 1) {
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>950.12978.57403.22323</string> </value>
<value> <string>951.9258.8411.9847</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1459432097.87</float>
<float>1463055528.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -111,7 +111,11 @@
search_string += ' OR (' + option_dict.search_column_list[k].select +
':"%' + option_dict.search + '%"' + ')';
}
if (option_dict.query.query) {
option_dict.query.query = '(' + search_string + ') AND ' + option_dict.query.query;
} else {
option_dict.query.query = search_string;
}
}
getPartialData = function(dav_url, key) {
......@@ -131,6 +135,9 @@
var i;
if (monitor_dict && monitor_dict.data.total_rows > 0) {
for (i = 0; i < monitor_dict.data.total_rows; i += 1) {
if (monitor_dict.data.rows[i].id !== option_dict.data_id) {
continue;
}
all_document_list.push(monitor_dict.data.rows[i].value);
}
} else {
......@@ -274,7 +281,7 @@
);
})
.push(function (cred) {
jio_options.sub_storage.sub_storage.url = cred.url;
jio_options.sub_storage.sub_storage.url = private_link;
jio_options.sub_storage.sub_storage.basic_login = cred.hash;
gadget.property_dict.jio_gadget.createJio(jio_options);
return gadget.property_dict.jio_gadget.get(
......@@ -295,7 +302,7 @@
promise_list_template = Handlebars.compile(
templater.getElementById("promiselist-widget-template").innerHTML
);
gadget.property_dict.jio_gadget.createJio(jio_options);
gadget.property_dict.jio_gadget.createJio(jio_options, false);
return gadget.property_dict.jio_gadget.get(
current_document.data.state
)
......
......@@ -239,7 +239,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>951.7653.61879.51080</string> </value>
<value> <string>951.10827.14939.1501</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -257,7 +257,7 @@
</tuple>
<state>
<tuple>
<float>1462958298.9</float>
<float>1463501917.46</float>
<string>UTC</string>
</tuple>
</state>
......
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