Commit 842587d7 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Alain Takoudjou

[erp5_web_monitoring] option to add OPML, immediately synchronize then go to status list

When adding opml from SlapOS interface, sync then show promise status.
parent 91122e12
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
</head> </head>
<body> <body>
<div data-gadget-url="gadget_officejs_monitoring_sync.html" data-gadget-scope="sync_gadget" data-gadget-sandbox="public"></div>
<form class="save_form ui-body-c" novalidate> <form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline <button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button> ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
......
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.27666.8050.30907</string> </value> <value> <string>963.29479.31715.56712</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1510675648.98</float> <float>1542210800.49</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
rJS(window) rJS(window)
.setState({auto_sync: true})
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Acquired methods // Acquired methods
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -56,6 +57,19 @@ ...@@ -56,6 +57,19 @@
}) })
.push(function (result_list) { .push(function (result_list) {
if (result_list[1]) { if (result_list[1]) {
if (gadget.state.auto_sync) {
return gadget.getDeclaredGadget('sync_gadget')
.push(function (sync_gadget) {
// start synchronization now
return sync_gadget.register({now: true});
})
.push(function () {
return gadget.redirect({
"command": "display",
"options": {"page": "ojsm_status_list"}
});
});
}
return gadget.redirect({ return gadget.redirect({
"command": "display", "command": "display",
"options": {"page": "settings_configurator"} "options": {"page": "settings_configurator"}
...@@ -178,6 +192,12 @@ ...@@ -178,6 +192,12 @@
} }
}); });
}) })
.push(function () {
return gadget.getSetting("opml_add_auto_sync", "on");
})
.push(function (auto_sync) {
return gadget.changeState({auto_sync: auto_sync === "on"});
})
.push(function () { .push(function () {
var new_options; var new_options;
...@@ -194,6 +214,14 @@ ...@@ -194,6 +214,14 @@
save_action: true, save_action: true,
change_password: chg_pwd_url change_password: chg_pwd_url
}); });
})
.push(function () {
return gadget.checkSynchronize();
}); });
})
.declareJob("checkSynchronize", function () {
if (this.state.auto_sync) {
return this.element.querySelector('button[type="submit"]').click();
}
}); });
}(window, rJS, RSVP)); }(window, rJS, RSVP));
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.29486.6222.37785</string> </value> <value> <string>971.40858.48738.62941</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1510676454.74</float> <float>1542298099.06</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>963.27666.8050.30907</string> </value> <value> <string>971.40832.39714.27067</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1515055044.86</float> <float>1542210787.16</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -169,6 +169,10 @@ ...@@ -169,6 +169,10 @@
return gadget.setSetting('sync_check_offline', return gadget.setSetting('sync_check_offline',
doc.check_online_access === "on" ? 'true' : 'false'); doc.check_online_access === "on" ? 'true' : 'false');
}) })
.push(function () {
return gadget.setSetting('opml_add_auto_sync',
doc.opml_add_auto_sync || "off");
})
.push(function () { .push(function () {
return gadget.setSetting('sync_data_interval', return gadget.setSetting('sync_data_interval',
parseInt(doc.auto_sync_interval, 10)); parseInt(doc.auto_sync_interval, 10));
...@@ -197,7 +201,8 @@ ...@@ -197,7 +201,8 @@
sync_data_interval, sync_data_interval,
check_online_access, check_online_access,
listbox_lines_limit, listbox_lines_limit,
opml_import_limit; opml_import_limit,
opml_add_auto_sync;
if (options.url) { if (options.url) {
// backward compatibility redirect to add opml // backward compatibility redirect to add opml
...@@ -223,6 +228,10 @@ ...@@ -223,6 +228,10 @@
}) })
.push(function (latest_sync_time) { .push(function (latest_sync_time) {
last_sync_time = latest_sync_time; last_sync_time = latest_sync_time;
return gadget.getSetting("opml_add_auto_sync", "on");
})
.push(function (auto_sync) {
opml_add_auto_sync = auto_sync;
return gadget.getSetting("sync_check_offline", "true"); return gadget.getSetting("sync_check_offline", "true");
}) })
.push(function (sync_check_offline) { .push(function (sync_check_offline) {
...@@ -295,6 +304,16 @@ ...@@ -295,6 +304,16 @@
"hidden": 0, "hidden": 0,
"type": "CheckBoxField" "type": "CheckBoxField"
}, },
"my_opml_add_auto_sync": {
"description": "When Add OPML, start sync automatically",
"title": "Auto Sync Added OPML",
"default": opml_add_auto_sync,
"css_class": "",
"editable": 1,
"key": "opml_add_auto_sync",
"hidden": 0,
"type": "CheckBoxField"
},
"my_opml_import_limit": { "my_opml_import_limit": {
"description": "Maximum number of OPML to import", "description": "Maximum number of OPML to import",
"title": "OPML Import Limit", "title": "OPML Import Limit",
...@@ -336,7 +355,7 @@ ...@@ -336,7 +355,7 @@
"left", "left",
[["your_last_sync_date"], ["my_auto_sync_interval"], [["your_last_sync_date"], ["my_auto_sync_interval"],
["my_listbox_lines_limit"], ["my_opml_import_limit"], ["my_listbox_lines_limit"], ["my_opml_import_limit"],
["my_check_online_access"]] ["my_check_online_access"], ["my_opml_add_auto_sync"]]
], ],
[ [
"right", "right",
......
...@@ -238,7 +238,7 @@ ...@@ -238,7 +238,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.37880.29513.12492</string> </value> <value> <string>971.42397.40766.62515</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -256,7 +256,7 @@ ...@@ -256,7 +256,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542032249.32</float> <float>1542303383.28</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -225,9 +225,7 @@ ...@@ -225,9 +225,7 @@
.push(function (status_history) { .push(function (status_history) {
var i, var i,
len, len,
start, start;
//lines,
message;
if (status_history && status_history.hasOwnProperty('data')) { if (status_history && status_history.hasOwnProperty('data')) {
// the status history list is reversed ([old, ...., newest]) // the status history list is reversed ([old, ...., newest])
...@@ -241,10 +239,6 @@ ...@@ -241,10 +239,6 @@
// lines = len - start; // lines = len - start;
//} //}
for (i = start; i >= 0; i -= 1) { for (i = start; i >= 0; i -= 1) {
message = status_history.data[i].message.slice(0, 80);
if (message.length >= 80) {
message += "...";
}
result.data.total_rows += 1; result.data.total_rows += 1;
result.data.rows.push({ result.data.rows.push({
value: { value: {
...@@ -302,7 +296,7 @@ ...@@ -302,7 +296,7 @@
type: "DateTimeField" type: "DateTimeField"
} }
}, },
message: message, message: status_history.data[i].message,
"listbox_uid:list": { "listbox_uid:list": {
key: "listbox_uid:list", key: "listbox_uid:list",
value: 2713 value: 2713
...@@ -524,7 +518,7 @@ ...@@ -524,7 +518,7 @@
"sort": [], "sort": [],
"hide_sort": true, "hide_sort": true,
"command": "reload", "command": "reload",
"title": "Promise Status History", "title": "Promise Status list (On live)",
"type": "ListBox" "type": "ListBox"
} }
}}, }},
......
...@@ -250,7 +250,7 @@ ...@@ -250,7 +250,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>971.37851.10663.58692</string> </value> <value> <string>971.40824.2567.53640</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542030756.81</float> <float>1542294280.54</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -177,10 +177,12 @@ ...@@ -177,10 +177,12 @@
}) })
.push(undefined, function (error) { .push(undefined, function (error) {
var message_text, var message_text,
code; code = 0;
if (error instanceof jIO.util.jIOError) { if (error instanceof jIO.util.jIOError) {
message_text = error.message; message_text = error.message;
code = error.status_code; code = error.status_code;
} else if (error instanceof TypeError || error.message) {
message_text = error.message;
} else { } else {
code = error.target.status; code = error.target.status;
message_text = error.target.responseType === "text" ? message_text = error.target.responseType === "text" ?
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>965.42333.60944.62105</string> </value> <value> <string>971.37897.12342.12851</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1542033191.29</float> <float>1542281232.26</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </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