Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Mukul
erp5
Commits
f902a75f
Commit
f902a75f
authored
Sep 06, 2017
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[erp5_web_monitoring] don't launch auto-sync when there is no internet access
parent
729d7d28
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
127 additions
and
115 deletions
+127
-115
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_html.html
..._module/gadget_monitoring_settings_configurator_html.html
+31
-18
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_html.xml
...e_module/gadget_monitoring_settings_configurator_html.xml
+2
-2
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_js.js
...page_module/gadget_monitoring_settings_configurator_js.js
+21
-2
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_js.xml
...age_module/gadget_monitoring_settings_configurator_js.xml
+2
-2
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.js
...TemplateItem/web_page_module/gadget_monitoring_sync_js.js
+69
-89
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.xml
...emplateItem/web_page_module/gadget_monitoring_sync_js.xml
+2
-2
No files found.
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_html.html
View file @
f902a75f
...
@@ -138,8 +138,8 @@
...
@@ -138,8 +138,8 @@
</table>
</table>
</div>
</div>
<div
class=
"padding-10 msgtext-box"
></div>
<div
class=
"padding-10 msgtext-box"
></div>
<
div
class=
""
>
<
legend><strong>
With OPML Selection:
</strong></legend
>
<legend><strong>
With OPML Selection:
</strong></legend
>
<div
class=
"padding-lr-10"
>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-state"
><i
class=
"fa fa-check-square-o"
></i>
Enable/disable
</a>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-state"
><i
class=
"fa fa-check-square-o"
></i>
Enable/disable
</a>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-delete"
><i
class=
"fa fa-trash"
></i>
Delete
</a>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-delete"
><i
class=
"fa fa-trash"
></i>
Delete
</a>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-test"
><i
class=
"fa fa-globe"
aria-hidden=
"true"
></i>
Test URL Access
</a>
<a
href=
"#"
class=
"ui-btn ui-corner-all ui-btn-inline opml-test"
><i
class=
"fa fa-globe"
aria-hidden=
"true"
></i>
Test URL Access
</a>
...
@@ -147,23 +147,36 @@
...
@@ -147,23 +147,36 @@
<i
class=
"fa fa-spinner fa-2x fa-spin"
></i>
<i
class=
"fa fa-spinner fa-2x fa-spin"
></i>
</span>
</span>
</div>
</div>
<div
class=
"padding-5"
>
<div>
<fieldset
class=
"sync-interval-controlgroup"
data-role=
"controlgroup"
data-type=
"horizontal"
>
<legend><strong>
Auto Sync Time Interval:
</strong></legend>
<legend><strong>
Auto Sync Interval:
</strong></legend>
<div
class=
"padding-lr-10"
>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-5m"
value=
"300000"
checked=
"checked"
>
<fieldset
class=
"sync-interval-controlgroup"
data-role=
"controlgroup"
data-type=
"horizontal"
>
<label
for=
"sync-data-5m"
>
5 min
</label>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-5m"
value=
"300000"
checked=
"checked"
>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-10m"
value=
"600000"
>
<label
for=
"sync-data-5m"
>
5 mn
</label>
<label
for=
"sync-data-10m"
>
10 min
</label>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-10m"
value=
"600000"
>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-20m"
value=
"1200000"
>
<label
for=
"sync-data-10m"
>
10 mn
</label>
<label
for=
"sync-data-20m"
>
20 min
</label>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-20m"
value=
"1200000"
>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-30m"
value=
"1800000"
>
<label
for=
"sync-data-20m"
>
20 mn
</label>
<label
for=
"sync-data-30m"
>
30 min
</label>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-30m"
value=
"1800000"
>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-1h"
value=
"3600000"
>
<label
for=
"sync-data-30m"
>
30 mn
</label>
<label
for=
"sync-data-1h"
>
1 h
</label>
<input
type=
"radio"
name=
"sync-data-timer"
id=
"sync-data-1h"
value=
"3600000"
>
</fieldset>
<label
for=
"sync-data-1h"
>
1 h
</label>
<p>
Last sync date:
<span
class=
"last-sync"
></span></p>
</fieldset>
<p>
Last sync date:
<span
class=
"last-sync"
></span></p>
</div>
<legend><strong>
Check Online Access Before Sync:
</strong></legend>
<div
class=
"padding-lr-10"
>
<fieldset
data-role=
"controlgroup"
data-type=
"horizontal"
>
<select
name=
"sync-check-offline"
id=
"sync-check-offline"
data-role=
"slider"
data-mini=
"true"
>
<option
value=
"off"
>
Off
</option>
<option
value=
"on"
>
On
</option>
</select>
</fieldset>
</div>
<h2><strong>
Manual Sync:
</strong></h2>
<h2><strong>
Manual Sync:
</strong></h2>
<button
class=
"ui-btn ui-corner-all ui-btn-inline sync-all"
><i
class=
"fa fa-download"
></i>
<span>
Sync Data Now
</span></button>
<div
class=
"padding-lr-10"
>
<button
class=
"ui-btn ui-corner-all ui-btn-inline sync-all"
><i
class=
"fa fa-download"
></i>
<span>
Sync Data Now
</span></button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
...
...
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_html.xml
View file @
f902a75f
...
@@ -239,7 +239,7 @@
...
@@ -239,7 +239,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.
22105.7758.14592
</string>
</value>
<value>
<string>
961.
52563.23676.54306
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -257,7 +257,7 @@
...
@@ -257,7 +257,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
150
3497281.04
</float>
<float>
150
4526479.13
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_js.js
View file @
f902a75f
...
@@ -287,6 +287,7 @@
...
@@ -287,6 +287,7 @@
.
declareService
(
function
()
{
.
declareService
(
function
()
{
var
gadget
=
this
,
var
gadget
=
this
,
sync_checkbox_list
,
sync_checkbox_list
,
online_select_element
,
alert_box
,
alert_box
,
i
;
i
;
...
@@ -370,6 +371,15 @@
...
@@ -370,6 +371,15 @@
.
push
(
function
(
time_interval
)
{
.
push
(
function
(
time_interval
)
{
return
setSelectSyncTime
(
time_interval
);
return
setSelectSyncTime
(
time_interval
);
})
})
.
push
(
function
()
{
return
gadget
.
getSetting
(
"
sync_check_offline
"
,
"
true
"
);
})
.
push
(
function
(
sync_check_offline
)
{
if
(
sync_check_offline
)
{
$
(
gadget
.
element
.
querySelector
(
"
select[name='sync-check-offline']
"
))
.
val
(
'
on
'
).
slider
(
"
refresh
"
);
}
})
.
push
(
function
()
{
.
push
(
function
()
{
var
promise_list
=
[];
var
promise_list
=
[];
...
@@ -419,6 +429,14 @@
...
@@ -419,6 +429,14 @@
}
}
));
));
promise_list
.
push
(
$
(
gadget
.
element
.
querySelector
(
"
select[name='sync-check-offline']
"
)
).
bind
(
"
change
"
,
function
()
{
var
element
=
gadget
.
element
.
querySelector
(
"
select[name='sync-check-offline']
"
);
return
gadget
.
setSetting
(
'
sync_check_offline
'
,
(
$
(
element
).
val
()
===
'
on
'
)
?
"
true
"
:
"
false
"
);
})
);
promise_list
.
push
(
promise_list
.
push
(
$
(
gadget
.
element
.
querySelector
(
$
(
gadget
.
element
.
querySelector
(
"
input[name='configure-newpwd']
"
"
input[name='configure-newpwd']
"
...
@@ -676,8 +694,9 @@
...
@@ -676,8 +694,9 @@
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
var
msg
=
""
;
var
msg
=
""
;
if
(
error
.
currentTarget
.
responseType
===
""
||
if
(
error
.
currentTarget
!==
undefined
&&
error
.
currentTarget
.
responseType
===
"
text
"
)
{
(
error
.
currentTarget
.
responseType
===
""
||
error
.
currentTarget
.
responseType
===
"
text
"
))
{
msg
=
error
.
currentTarget
.
responseText
;
msg
=
error
.
currentTarget
.
responseText
;
}
}
alert_box
.
removeClass
(
'
ui-content-hidden
'
)
alert_box
.
removeClass
(
'
ui-content-hidden
'
)
...
...
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_settings_configurator_js.xml
View file @
f902a75f
...
@@ -239,7 +239,7 @@
...
@@ -239,7 +239,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.
40699.48372.17271
</string>
</value>
<value>
<string>
961.
62212.52900.63880
</string>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -257,7 +257,7 @@
...
@@ -257,7 +257,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
150
3651680.71
</float>
<float>
150
4861845.27
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.js
View file @
f902a75f
/*global window, rJS, RSVP, $, clearTimeout, setTimeout, console */
/*global window, rJS, RSVP, $, clearTimeout, setTimeout, console
, XMLHttpRequest, document
*/
/*jslint nomen: true, indent: 2, maxerr: 3*/
/*jslint nomen: true, indent: 2, maxerr: 3*/
(
function
(
window
,
rJS
,
RSVP
,
$
,
console
,
clearTimeout
,
setTimeout
)
{
(
function
(
window
,
rJS
,
RSVP
,
$
,
console
,
clearTimeout
,
setTimeout
,
XMLHttpRequest
,
document
)
{
"
use strict
"
;
"
use strict
"
;
var
gadget_klass
=
rJS
(
window
);
var
gadget_klass
=
rJS
(
window
);
...
@@ -23,6 +24,32 @@
...
@@ -23,6 +24,32 @@
.
declareMethod
(
"
startSync
"
,
function
(
options
)
{
.
declareMethod
(
"
startSync
"
,
function
(
options
)
{
var
gadget
=
this
;
var
gadget
=
this
;
function
testOnline
(
url
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
xhr
=
new
XMLHttpRequest
();
xhr
.
onload
=
function
(
event
)
{
var
response
=
event
.
target
;
if
(
response
.
status
===
302
||
response
.
status
===
200
)
{
resolve
({
status
:
'
OK
'
});
}
else
{
reject
({
status
:
'
ERROR
'
});
}
};
xhr
.
onerror
=
function
(
e
)
{
reject
({
status
:
'
ERROR
'
});
};
xhr
.
open
(
"
GET
"
,
url
,
true
);
xhr
.
send
(
""
);
});
}
function
formatDate
(
d
)
{
function
formatDate
(
d
)
{
function
addZero
(
n
)
{
function
addZero
(
n
)
{
return
n
<
10
?
"
0
"
+
n
:
n
.
toString
();
return
n
<
10
?
"
0
"
+
n
:
n
.
toString
();
...
@@ -32,79 +59,41 @@
...
@@ -32,79 +59,41 @@
+
"
-
"
+
addZero
(
d
.
getDate
())
+
"
"
+
addZero
(
d
.
getHours
())
+
"
-
"
+
addZero
(
d
.
getDate
())
+
"
"
+
addZero
(
d
.
getHours
())
+
"
:
"
+
addZero
(
d
.
getMinutes
())
+
"
:
"
+
addZero
(
d
.
getSeconds
());
+
"
:
"
+
addZero
(
d
.
getMinutes
())
+
"
:
"
+
addZero
(
d
.
getSeconds
());
}
}
/*
function getErrorLog(error_list) {
// Build error msg from failed sync
var i,
tmp_url,
error_message = "";
for (i = 0; i < error_list.length; i += 1) {
function
syncAllStorageWithCheck
()
{
if (error_list[i].storage_dict.hasOwnProperty('sub_storage')) {
gadget
.
props
.
offline
=
false
;
if (error_list[i].storage_dict.sub_storage.hasOwnProperty('sub_storage')) {
return
gadget
.
getSetting
(
'
sync_check_offline
'
,
'
true
'
)
tmp_url = error_list[i].storage_dict.sub_storage.sub_storage.url;
.
push
(
function
(
check_offline
)
{
} else {
var
parser
;
tmp_url = error_list[i].storage_dict.sub_storage.url;
if
(
check_offline
===
'
true
'
)
{
parser
=
document
.
createElement
(
"
a
"
);
parser
.
href
=
document
.
URL
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
testOnline
(
parser
.
origin
);
})
.
push
(
undefined
,
function
()
{
return
{
status
:
"
ERROR
"
};
})
.
push
(
function
(
online_result
)
{
if
(
online_result
.
status
===
"
OK
"
)
{
return
syncAllStorage
();
}
gadget
.
props
.
offline
=
true
;
return
$
.
notify
(
"
Sync aborted, no internet access...
"
,
{
position
:
"
bottom right
"
,
autoHide
:
true
,
className
:
"
error
"
,
autoHideDelay
:
10000
}
);
});
}
}
} else {
return
syncAllStorage
();
tmp_url = error_list[i].storage_dict.url;
}
error_message += "> " + error_list[i].storage_dict.hosting + " > " +
error_list[i].storage_dict.title + "\n";
error_message += "Cannot download file(s) at " + tmp_url + ".\n\n";
}
return error_message;
}
function updateStatus(gadget, storage_dict, status) {
var promise_list = [],
jio_gadget,
url,
i;
return getJioGadget(gadget, storage_dict)
.push(function (jio_declared_gadget) {
jio_gadget = jio_declared_gadget;
return jio_gadget.allDocs({include_docs: true});
})
.push(undefined, function (error) {
console.log(error);
return {
data: {
total_rows: 0
}
};
})
.push(function (jio_docs) {
var tmp;
for (i = 0; i < jio_docs.data.total_rows; i += 1) {
if (jio_docs.data.rows[i].id.startsWith('_replicate_')) {
continue;
}
tmp = jio_docs.data.rows[i].doc;
if (storage_dict.storage_type === "rss") {
if (tmp.category === "WARNING") {
continue;
}
tmp.category = "WARNING";
} else if (storage_dict.storage_type === "webdav") {
if (tmp.status === "WARNING") {
continue;
}
tmp.status = "WARNING";
}
promise_list.push(jio_gadget.put(
jio_docs.data.rows[i].id,
tmp
));
}
return RSVP.all(promise_list);
})
.push(undefined, function (error) {
console.log("ERROR: update status to WARNING");
console.log(error);
});
});
}
*/
}
function
syncAllStorage
()
{
function
syncAllStorage
()
{
var
error_log
,
var
error_log
,
...
@@ -169,19 +158,6 @@
...
@@ -169,19 +158,6 @@
method: 'Monitoring Sync'
method: 'Monitoring Sync'
})*/
})*/
})
})
/*.push(function () {
var promise_list = [],
i;
// Update all failures monitoring status to Warning
for (i = 0; i < gadget.props.error_list.length; i += 1) {
promise_list.push(updateStatus(
gadget,
gadget.props.error_list[i].storage_dict,
'WARNING'
));
}
return RSVP.all(promise_list);
})*/
.
push
(
function
()
{
.
push
(
function
()
{
gadget
.
props
.
started
=
false
;
gadget
.
props
.
started
=
false
;
return
$
.
notify
(
return
$
.
notify
(
...
@@ -213,7 +189,7 @@
...
@@ -213,7 +189,7 @@
// There was a recent sync don't start a new sync before the time_interval!
// There was a recent sync don't start a new sync before the time_interval!
return
;
return
;
}
}
return
syncAllStorage
();
return
syncAllStorage
WithCheck
();
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
...
@@ -223,7 +199,10 @@
...
@@ -223,7 +199,10 @@
return
gadget
.
getSetting
(
'
sync_data_interval
'
);
return
gadget
.
getSetting
(
'
sync_data_interval
'
);
})
})
.
push
(
function
(
timer_interval
)
{
.
push
(
function
(
timer_interval
)
{
if
(
timer_interval
===
undefined
)
{
if
(
gadget
.
props
.
offline
===
true
)
{
// Offline mode detected, next check will be in 3 minutes
timer_interval
=
180000
;
}
else
if
(
timer_interval
===
undefined
)
{
timer_interval
=
gadget
.
props
.
default_sync_interval
;
timer_interval
=
gadget
.
props
.
default_sync_interval
;
}
}
gadget
.
props
.
timer_interval
=
timer_interval
;
gadget
.
props
.
timer_interval
=
timer_interval
;
...
@@ -248,7 +227,7 @@
...
@@ -248,7 +227,7 @@
// sync is running...
// sync is running...
return
;
return
;
}
}
return
syncAllStorage
();
return
syncAllStorage
WithCheck
();
}
}
// Default sync interval to 5 minutes
// Default sync interval to 5 minutes
gadget
.
props
.
default_sync_interval
=
300000
;
gadget
.
props
.
default_sync_interval
=
300000
;
...
@@ -289,4 +268,5 @@
...
@@ -289,4 +268,5 @@
});
});
});
});
}(
window
,
rJS
,
RSVP
,
$
,
console
,
clearTimeout
,
setTimeout
));
}(
window
,
rJS
,
RSVP
,
$
,
console
,
clearTimeout
,
setTimeout
,
XMLHttpRequest
,
\ No newline at end of file
document
));
\ No newline at end of file
bt5/erp5_web_monitoring/PathTemplateItem/web_page_module/gadget_monitoring_sync_js.xml
View file @
f902a75f
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<key>
<string>
serial
</string>
</key>
<value>
<string>
961.
40574.58268.18875
</string>
</value>
<value>
<string>
961.
62215.16074.40192
</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>
150
3563500.59
</float>
<float>
150
4861961.08
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</state>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment