Commit cf8507a4 authored by Stavros Sachtouris's avatar Stavros Sachtouris Committed by Giorgos Korfiatis
Browse files

Open notification box on critical errors

parent 09b71df9
......@@ -16,10 +16,14 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<html>
<head><title>GUI for Agkyra Pithos+ Syncing Client</title></head>
<head>
<meta charset="UTF-8" />
<title>GUI for Agkyra Pithos+ Syncing Client</title>
</head>
<body>
<script src="protocol.js"></script>
<script src="settings.js"></script>
<script src="notify.js"></script>
<script src="static/js/jquery.js"></script>
<script type="text/javascript">
......@@ -214,7 +218,14 @@ window.setInterval(function() {
var status = globals['status'];
var new_progress = progress_item.label;
var new_pause = pause_item.label;
if (!status.can_sync) {
if (status.notification !== 0) {
new_progress = notifications[status.notification];
new_pause = 'inactive';
if (progress_item.label !== new_progress) {
notify_user(new_progress, 'critical');
}
}
else if (!status.can_sync) {
if (globals.just_opened) new_progress = 'Connecting...'
else new_progress = 'Not able to sync'
new_pause = 'inactive'
......
var gui = require('nw.gui');
var ntf_title = {
'info': 'Notification',
'warning': 'Warning',
'critical': 'Critical Error'
}
var ntf_icon = {
'info': 'static/images/ntf_info.png',
'warning': 'static/images/ntf_warning.png',
'critical': 'static/images/ntf_critical.png',
}
var notify_menu = new gui.MenuItem({
label: 'Notifications',
icon: 'static/images/play_pause.png',
iconIsTemplate: false,
click: function() {
console.log('Notification is clecked');
}
});
function notify_user(msg, level) {
var n = new Notification(ntf_title[level], {
lang: 'utf-8',
body: msg,
icon: ntf_icon[level]
});
setTimeout(n.close.bind(n), 4000);
}
\ No newline at end of file
......@@ -28,6 +28,13 @@ function send_json(socket, msg) {
socket.send(JSON.stringify(msg));
}
var notifications = {
0: 'Syncer is consistent',
1: 'Local directory is not accessible',
2: 'Remote container is not accessible',
100: 'Unknown error'
}
var globals = {
settings: {
token: null,
......@@ -36,7 +43,8 @@ var globals = {
directory: null,
exclude: null
},
status: {synced: 0, unsynced: 0, paused: null, can_sync: false},
status: {
synced: 0, unsynced: 0, paused: null, can_sync: false, notification: 0},
authenticated: false,
just_opened: false,
open_settings: false,
......
......@@ -437,7 +437,7 @@ class WebSocketProtocol(WebSocket):
# LOG.info('Collision for "%s"' % msg.objname)
# elif isinstance(msg, messaging.ConflictStashMessage):
# LOG.info('Conflict for "%s"' % msg.objname)
if isinstance(msg, messaging.LocalfsSyncDisabled):
elif isinstance(msg, messaging.LocalfsSyncDisabled):
# LOG.debug('Local FS is dissabled, noooo!')
self.status['notification'] = 1
self.syncer.stop_all_daemons()
......@@ -485,12 +485,18 @@ class WebSocketProtocol(WebSocket):
# while not msg:
# time.sleep(0.2)
# msg = syncer_.get_next_message()
# This should be activated only on accepting a positive message
self.status['notification'] = 0
self.status['unsynced'] = 0
self.status['synced'] = 0
if msg:
if isinstance(msg, messaging.LocalfsSyncDisabled):
LOG.debug('Local FS is dissabled, noooo!')
LOG.debug('Local FS is disabled')
self.status['notification'] = 1
elif isinstance(msg, messaging.PithosSyncDisabled):
LOG.debug('Pithos sync is disabled, noooooo!')
LOG.debug('Pithos sync is disabled')
self.status['notification'] = 2
else:
LOG.debug("Unexpected message: %s" % msg)
......
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