Commit cec042df authored by Vincent Bechu's avatar Vincent Bechu

[erp5_jabber_client] Handle redirection on desktop notification click

parent ad602133
...@@ -193,12 +193,27 @@ ...@@ -193,12 +193,27 @@
}); });
} }
function createNotification(title, body) { function createNotification(gadget, message) {
if (window.Notification !== undefined) { if (window.Notification !== undefined) {
return window.Notification.requestPermission() return window.Notification.requestPermission()
.then(function (result) { .then(function (result) {
if (result === 'granted') { if (result === 'granted') {
return new window.Notification(title, {body: body}); var notification = new window.Notification(message[0], {body: message[2]});
notification.onclick = function () {
window.focus();
return gadget.getUrlParameter('jio_key')
.push(function (key) {
if (key !== message[0]) {
return gadget.redirect({
'command': 'change',
'options': {
'jio_key': message[0],
'page': 'jabberclient_dialog'
}
});
}
});
};
} }
}); });
} }
...@@ -280,7 +295,7 @@ ...@@ -280,7 +295,7 @@
// It simplifies a lot notification status // It simplifies a lot notification status
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");
createNotification(argument_list[0], argument_list[0][2]); createNotification(this, argument_list);
} }
var gadget = this; var gadget = this;
...@@ -394,6 +409,7 @@ ...@@ -394,6 +409,7 @@
.declareAcquiredMethod('redirect', 'redirect') .declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('getUrlFor', 'getUrlFor') .declareAcquiredMethod('getUrlFor', 'getUrlFor')
.declareAcquiredMethod('refresh', 'refresh') .declareAcquiredMethod('refresh', 'refresh')
.declareAcquiredMethod('getUrlParameter', 'getUrlParameter')
.declareMethod('createJio', function () { .declareMethod('createJio', function () {
return this.state_parameter_dict.persistent_jio.createJio({ return this.state_parameter_dict.persistent_jio.createJio({
......
...@@ -230,7 +230,7 @@ ...@@ -230,7 +230,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>970.45900.44706.11212</string> </value> <value> <string>970.47251.8439.43008</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -248,7 +248,7 @@ ...@@ -248,7 +248,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1538581284.91</float> <float>1538662464.71</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
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