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
1
Merge Requests
1
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
Cédric Le Ninivin
erp5
Commits
4e97f824
Commit
4e97f824
authored
Dec 04, 2020
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_web_jabber_client: implement desktop notifications
parent
027fb6a3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
15 deletions
+48
-15
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jio_js.js
.../PathTemplateItem/web_page_module/jabber_gadget_jio_js.js
+32
-8
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jio_js.xml
...PathTemplateItem/web_page_module/jabber_gadget_jio_js.xml
+2
-2
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_page_contact_js.js
...lateItem/web_page_module/jabber_gadget_page_contact_js.js
+12
-3
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_page_contact_js.xml
...ateItem/web_page_module/jabber_gadget_page_contact_js.xml
+2
-2
No files found.
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jio_js.js
View file @
4e97f824
/*global window, rJS, RSVP, jIO, document, loopEventListener */
/*global window, rJS, RSVP, jIO,
Notification,
document, loopEventListener */
/*jslint indent: 2, maxerr: 3, nomen: true */
(
function
(
window
,
rJS
,
RSVP
,
jIO
,
document
,
loopEventListener
)
{
(
function
(
window
,
rJS
,
RSVP
,
jIO
,
Notification
,
document
,
loopEventListener
)
{
"
use strict
"
;
var
CONNECTION_GADGET_SCOPE
=
"
connection
"
,
CONNECTION_GADGET_URL
=
"
connection/
"
,
JIO_GADGET_URL
=
"
gadget_jio.html
"
;
function
dropNotification
()
{
function
dropNotification
(
gadget
)
{
var
contact
;
document
.
querySelector
(
"
link[rel='shortcut icon']
"
).
setAttribute
(
"
href
"
,
"
gadget_jabberclient_notification_ok.ico
"
);
for
(
contact
in
gadget
.
state_parameter_dict
.
notification_per_contact
)
{
if
(
gadget
.
state_parameter_dict
.
notification_per_contact
.
hasOwnProperty
(
contact
))
{
gadget
.
state_parameter_dict
.
notification_per_contact
[
contact
].
close
();
delete
gadget
.
state_parameter_dict
.
notification_per_contact
[
contact
];
}
}
}
function
wrapJioCall
(
gadget
,
method_name
,
argument_list
)
{
...
...
@@ -272,7 +279,8 @@
document
.
querySelector
(
"
link[rel='shortcut icon']
"
).
setAttribute
(
"
href
"
,
"
gadget_jabberclient_notification_warning.ico
"
);
}
var
gadget
=
this
;
var
gadget
=
this
,
from
=
argument_list
[
0
];
return
addLog
(
this
,
argument_list
[
0
],
argument_list
[
2
],
true
)
.
push
(
function
()
{
return
initializeContact
(
gadget
,
argument_list
[
0
]);
...
...
@@ -281,6 +289,17 @@
doc
.
notification
=
true
;
return
gadget
.
state_parameter_dict
.
volatile_jio
.
put
(
argument_list
[
0
],
doc
);
})
.
push
(
function
()
{
if
(
!
document
.
hasFocus
()
&&
Notification
.
permission
===
"
granted
"
)
{
gadget
.
state_parameter_dict
.
notification_per_contact
[
from
]
=
new
Notification
(
"
New message from
"
+
from
,
{
silent
:
true
,
tag
:
'
jabberclient:
'
+
from
}
);
}
})
.
push
(
function
()
{
return
gadget
.
refresh
();
});
...
...
@@ -361,9 +380,10 @@
connected
:
false
,
server
:
'
https://mail.nexedi.net/chat/http-bind/
'
,
jio
:
''
,
passwd
:
''
passwd
:
''
,
notification_per_contact
:
{}
};
dropNotification
();
dropNotification
(
gadget
);
})
.
ready
(
function
(
gadget
)
{
return
gadget
.
getDeclaredGadget
(
'
persistent_jio
'
)
...
...
@@ -485,12 +505,16 @@
})
.
declareService
(
function
()
{
var
gadget
=
this
;
function
_dropNotification
()
{
return
dropNotification
(
gadget
);
}
return
loopEventListener
(
window
,
'
focus
'
,
false
,
dropNotification
_
dropNotification
);
});
}(
window
,
rJS
,
RSVP
,
jIO
,
document
,
loopEventListener
));
\ No newline at end of file
}(
window
,
rJS
,
RSVP
,
jIO
,
Notification
,
document
,
loopEventListener
));
\ No newline at end of file
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_jio_js.xml
View file @
4e97f824
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
67.46266.46579.39065
</string>
</value>
<value>
<string>
9
88.26490.15321.9130
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>
1
526979580.7
</float>
<float>
1
606985968.14
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_page_contact_js.js
View file @
4e97f824
/*global window, rJS*/
/*global window, rJS
, Notification
*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
)
{
(
function
(
window
,
rJS
,
Notification
)
{
"
use strict
"
;
rJS
(
window
)
...
...
@@ -102,7 +102,16 @@
]]
}
});
})
.
push
(
function
()
{
return
gadget
.
requestNotificationPermission
();
});
})
.
declareJob
(
"
requestNotificationPermission
"
,
function
()
{
if
(
Notification
!==
undefined
&&
Notification
.
permission
!==
"
denied
"
)
{
return
Notification
.
requestPermission
();
}
});
}(
window
,
rJS
));
\ No newline at end of file
}(
window
,
rJS
,
Notification
));
\ No newline at end of file
bt5/erp5_web_jabber_client/PathTemplateItem/web_page_module/jabber_gadget_page_contact_js.xml
View file @
4e97f824
...
...
@@ -236,7 +236,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
9
68.4124.44320.51336
</string>
</value>
<value>
<string>
9
88.37813.29181.47069
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>
1
528383833.9
1
</float>
<float>
1
607665366.1
1
</float>
<string>
UTC
</string>
</tuple>
</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