Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
cf8507a4
Commit
cf8507a4
authored
Jun 17, 2015
by
Stavros Sachtouris
Committed by
Giorgos Korfiatis
Oct 19, 2015
Browse files
Open notification box on critical errors
parent
09b71df9
Changes
7
Hide whitespace changes
Inline
Side-by-side
agkyra/nwgui/menu.html
View file @
cf8507a4
...
...
@@ -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
'
...
...
agkyra/nwgui/notify.js
0 → 100644
View file @
cf8507a4
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
agkyra/nwgui/protocol.js
View file @
cf8507a4
...
...
@@ -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
,
...
...
agkyra/nwgui/static/images/ntf_critical.png
0 → 100644
View file @
cf8507a4
4.22 KB
agkyra/nwgui/static/images/ntf_info.png
0 → 100644
View file @
cf8507a4
4.43 KB
agkyra/nwgui/static/images/ntf_warning.png
0 → 100644
View file @
cf8507a4
3.88 KB
agkyra/protocol.py
View file @
cf8507a4
...
...
@@ -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
):
el
if
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 dis
s
abled
, 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
)
...
...
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