mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Add a check to see if the Notification API is available prior to trying
to configure or send them.
This commit is contained in:
@@ -177,16 +177,20 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
toggleNotifications() {
|
||||
Notification.requestPermission().then(function (permission) {
|
||||
//If the user accepts, let's create a notification
|
||||
if (permission === "granted") {
|
||||
new Notification("Notifications enabled", {
|
||||
icon: "static/favicon.ico",
|
||||
});
|
||||
} else {
|
||||
alert("Notifications disabled, please re-enable through browser settings.");
|
||||
}
|
||||
});
|
||||
if (window.Notification) {
|
||||
Notification.requestPermission().then(function (permission) {
|
||||
//If the user accepts, let's create a notification
|
||||
if (permission === "granted") {
|
||||
new Notification("Notifications enabled", {
|
||||
icon: "static/favicon.ico",
|
||||
});
|
||||
} else {
|
||||
alert("Notifications disabled, please re-enable through browser settings.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert("Notifications are not supported by this browser.");
|
||||
}
|
||||
},
|
||||
openManageCustomBuilds() {
|
||||
const Galaxy = getGalaxyInstance();
|
||||
|
||||
@@ -103,19 +103,25 @@ var DatasetAssociation = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend(
|
||||
this.trigger("state:ready", currModel, newState, this.previous("state"));
|
||||
if (newState != "discarded") {
|
||||
if (newState === "ok") {
|
||||
new Notification(`Job complete: ${this.get("name")}`, {
|
||||
icon: "static/favicon.ico",
|
||||
});
|
||||
// If Notifications are supported, send one.
|
||||
if (window.Notification) {
|
||||
new Notification(`Job complete: ${this.get("name")}`, {
|
||||
icon: "static/favicon.ico",
|
||||
});
|
||||
}
|
||||
if (TAB_UPDATES.is_hidden()) {
|
||||
TAB_UPDATES.hidden_count(hiddenupdates);
|
||||
hiddenupdates++;
|
||||
}
|
||||
} else if (newState == "error") {
|
||||
new Notification(`Job failure: ${this.get("name")}`, {
|
||||
icon: "static/erricon.ico",
|
||||
});
|
||||
if (TAB_UPDATES.is_hidden() && Notification.permission == "granted") {
|
||||
TAB_UPDATES.change_favicon("static/erricon.ico");
|
||||
// If Notifications are supported, send one.
|
||||
if (window.Notification) {
|
||||
new Notification(`Job failure: ${this.get("name")}`, {
|
||||
icon: "static/erricon.ico",
|
||||
});
|
||||
if (TAB_UPDATES.is_hidden() && Notification.permission == "granted") {
|
||||
TAB_UPDATES.change_favicon("static/erricon.ico");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user