Commit 05871c0d authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Rafael Monnerat

[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 ea96edde
......@@ -13,6 +13,7 @@
</head>
<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>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.27666.8050.30907</string> </value>
<value> <string>963.29479.31715.56712</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1510675648.98</float>
<float>1542210800.49</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,6 +5,7 @@
rJS(window)
.setState({auto_sync: true})
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
......@@ -56,6 +57,19 @@
})
.push(function (result_list) {
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({
"command": "display",
"options": {"page": "settings_configurator"}
......@@ -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 () {
var new_options;
......@@ -194,6 +214,14 @@
save_action: true,
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));
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.29486.6222.37785</string> </value>
<value> <string>971.40858.48738.62941</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1510676454.74</float>
<float>1542298099.06</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>963.27666.8050.30907</string> </value>
<value> <string>971.40832.39714.27067</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1515055044.86</float>
<float>1542210787.16</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -169,6 +169,10 @@
return gadget.setSetting('sync_check_offline',
doc.check_online_access === "on" ? 'true' : 'false');
})
.push(function () {
return gadget.setSetting('opml_add_auto_sync',
doc.opml_add_auto_sync || "off");
})
.push(function () {
return gadget.setSetting('sync_data_interval',
parseInt(doc.auto_sync_interval, 10));
......@@ -197,7 +201,8 @@
sync_data_interval,
check_online_access,
listbox_lines_limit,
opml_import_limit;
opml_import_limit,
opml_add_auto_sync;
if (options.url) {
// backward compatibility redirect to add opml
......@@ -223,6 +228,10 @@
})
.push(function (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");
})
.push(function (sync_check_offline) {
......@@ -295,6 +304,16 @@
"hidden": 0,
"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": {
"description": "Maximum number of OPML to import",
"title": "OPML Import Limit",
......@@ -336,7 +355,7 @@
"left",
[["your_last_sync_date"], ["my_auto_sync_interval"],
["my_listbox_lines_limit"], ["my_opml_import_limit"],
["my_check_online_access"]]
["my_check_online_access"], ["my_opml_add_auto_sync"]]
],
[
"right",
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.37880.29513.12492</string> </value>
<value> <string>971.42397.40766.62515</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1542032249.32</float>
<float>1542303383.28</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -225,9 +225,7 @@
.push(function (status_history) {
var i,
len,
start,
//lines,
message;
start;
if (status_history && status_history.hasOwnProperty('data')) {
// the status history list is reversed ([old, ...., newest])
......@@ -241,10 +239,6 @@
// lines = len - start;
//}
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.rows.push({
value: {
......@@ -302,7 +296,7 @@
type: "DateTimeField"
}
},
message: message,
message: status_history.data[i].message,
"listbox_uid:list": {
key: "listbox_uid:list",
value: 2713
......@@ -524,7 +518,7 @@
"sort": [],
"hide_sort": true,
"command": "reload",
"title": "Promise Status History",
"title": "Promise Status list (On live)",
"type": "ListBox"
}
}},
......
......@@ -250,7 +250,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.37851.10663.58692</string> </value>
<value> <string>971.40824.2567.53640</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1542030756.81</float>
<float>1542294280.54</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -177,10 +177,12 @@
})
.push(undefined, function (error) {
var message_text,
code;
code = 0;
if (error instanceof jIO.util.jIOError) {
message_text = error.message;
code = error.status_code;
} else if (error instanceof TypeError || error.message) {
message_text = error.message;
} else {
code = error.target.status;
message_text = error.target.responseType === "text" ?
......
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>965.42333.60944.62105</string> </value>
<value> <string>971.37897.12342.12851</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1542033191.29</float>
<float>1542281232.26</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