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
Labels
Merge Requests
139
Merge Requests
139
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
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
Pipeline
#12840
failed with stage
in 0 seconds
Changes
4
Pipelines
2
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 */
/*jslint indent: 2, maxerr: 3, nomen: true */
(
function
(
window
,
rJS
,
RSVP
,
jIO
,
document
,
loopEventListener
)
{
(
function
(
window
,
rJS
,
RSVP
,
jIO
,
Notification
,
document
,
loopEventListener
)
{
"
use strict
"
;
"
use strict
"
;
var
CONNECTION_GADGET_SCOPE
=
"
connection
"
,
var
CONNECTION_GADGET_SCOPE
=
"
connection
"
,
CONNECTION_GADGET_URL
=
"
connection/
"
,
CONNECTION_GADGET_URL
=
"
connection/
"
,
JIO_GADGET_URL
=
"
gadget_jio.html
"
;
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
"
);
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
)
{
function
wrapJioCall
(
gadget
,
method_name
,
argument_list
)
{
...
@@ -272,7 +279,8 @@
...
@@ -272,7 +279,8 @@
document
.
querySelector
(
"
link[rel='shortcut icon']
"
).
setAttribute
(
"
href
"
,
"
gadget_jabberclient_notification_warning.ico
"
);
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
)
return
addLog
(
this
,
argument_list
[
0
],
argument_list
[
2
],
true
)
.
push
(
function
()
{
.
push
(
function
()
{
return
initializeContact
(
gadget
,
argument_list
[
0
]);
return
initializeContact
(
gadget
,
argument_list
[
0
]);
...
@@ -281,6 +289,17 @@
...
@@ -281,6 +289,17 @@
doc
.
notification
=
true
;
doc
.
notification
=
true
;
return
gadget
.
state_parameter_dict
.
volatile_jio
.
put
(
argument_list
[
0
],
doc
);
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
()
{
.
push
(
function
()
{
return
gadget
.
refresh
();
return
gadget
.
refresh
();
});
});
...
@@ -361,9 +380,10 @@
...
@@ -361,9 +380,10 @@
connected
:
false
,
connected
:
false
,
server
:
'
https://mail.nexedi.net/chat/http-bind/
'
,
server
:
'
https://mail.nexedi.net/chat/http-bind/
'
,
jio
:
''
,
jio
:
''
,
passwd
:
''
passwd
:
''
,
notification_per_contact
:
{}
};
};
dropNotification
();
dropNotification
(
gadget
);
})
})
.
ready
(
function
(
gadget
)
{
.
ready
(
function
(
gadget
)
{
return
gadget
.
getDeclaredGadget
(
'
persistent_jio
'
)
return
gadget
.
getDeclaredGadget
(
'
persistent_jio
'
)
...
@@ -485,12 +505,16 @@
...
@@ -485,12 +505,16 @@
})
})
.
declareService
(
function
()
{
.
declareService
(
function
()
{
var
gadget
=
this
;
function
_dropNotification
()
{
return
dropNotification
(
gadget
);
}
return
loopEventListener
(
return
loopEventListener
(
window
,
window
,
'
focus
'
,
'
focus
'
,
false
,
false
,
dropNotification
_
dropNotification
);
);
});
});
}(
window
,
rJS
,
RSVP
,
jIO
,
document
,
loopEventListener
));
}(
window
,
rJS
,
RSVP
,
jIO
,
Notification
,
document
,
loopEventListener
));
\ No newline at end of file
\ 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 @@
...
@@ -236,7 +236,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<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>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -254,7 +254,7 @@
...
@@ -254,7 +254,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
526979580.7
</float>
<float>
1
606985968.14
</float>
<string>
UTC
</string>
<string>
UTC
</string>
</tuple>
</tuple>
</state>
</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 */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(
function
(
window
,
rJS
)
{
(
function
(
window
,
rJS
,
Notification
)
{
"
use strict
"
;
"
use strict
"
;
rJS
(
window
)
rJS
(
window
)
...
@@ -102,7 +102,16 @@
...
@@ -102,7 +102,16 @@
]]
]]
}
}
});
});
})
.
push
(
function
()
{
return
gadget
.
requestNotificationPermission
();
});
});
})
.
declareJob
(
"
requestNotificationPermission
"
,
function
()
{
if
(
Notification
!==
undefined
&&
Notification
.
permission
!==
"
denied
"
)
{
return
Notification
.
requestPermission
();
}
});
});
}(
window
,
rJS
));
}(
window
,
rJS
,
Notification
));
\ No newline at end of file
\ 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 @@
...
@@ -236,7 +236,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
serial
</string>
</key>
<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>
<item>
<item>
<key>
<string>
state
</string>
</key>
<key>
<string>
state
</string>
</key>
...
@@ -254,7 +254,7 @@
...
@@ -254,7 +254,7 @@
</tuple>
</tuple>
<state>
<state>
<tuple>
<tuple>
<float>
1
528383833.9
1
</float>
<float>
1
607665366.1
1
</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