Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
S
stable-diffusion-webui
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
stable-diffusion-webui
Commits
d7f36dac
Commit
d7f36dac
authored
Sep 19, 2022
by
Dave Sescleifer
Committed by
AUTOMATIC1111
Sep 20, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send a browser notification when the images are ready
parent
a8a75ec4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
0 deletions
+42
-0
notification.js
javascript/notification.js
+34
-0
ui.py
modules/ui.py
+8
-0
No files found.
javascript/notification.js
0 → 100644
View file @
d7f36dac
// Monitors the gallery and sends a browser notification when the leading image is new.
let
lastHeadImg
=
null
;
onUiUpdate
(
function
(){
const
galleryPreviews
=
gradioApp
().
querySelectorAll
(
'img.h-full.w-full.overflow-hidden'
);
if
(
galleryPreviews
==
null
)
return
;
const
headImg
=
galleryPreviews
[
0
]?.
src
;
if
(
headImg
==
null
||
headImg
==
lastHeadImg
)
return
;
lastHeadImg
=
headImg
;
if
(
document
.
hasFocus
())
return
;
// Multiple copies of the images are in the DOM when one is selected. Dedup with a Set to get the real number generated.
const
imgs
=
new
Set
(
Array
.
from
(
galleryPreviews
).
map
(
img
=>
img
.
src
));
const
notification
=
new
Notification
(
'Stable Diffusion'
,
{
body
:
`Generated
${
imgs
.
size
>
1
?
imgs
.
size
-
1
:
1
}
image
${
imgs
.
size
>
1
?
's'
:
''
}
`
,
icon
:
headImg
,
image
:
headImg
,
}
);
notification
.
onclick
=
function
(
_
){
parent
.
focus
();
this
.
close
();
};
});
modules/ui.py
View file @
d7f36dac
...
@@ -875,6 +875,14 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
...
@@ -875,6 +875,14 @@ def create_ui(txt2img, img2img, run_extras, run_pnginfo):
outputs
=
[
result
]
outputs
=
[
result
]
)
)
request_notifications
=
gr
.
Button
(
value
=
'Request browser notifications'
)
request_notifications
.
click
(
fn
=
lambda
:
None
,
inputs
=
[],
outputs
=
[],
_js
=
'() => Notification.requestPermission()'
)
interfaces
=
[
interfaces
=
[
(
txt2img_interface
,
"txt2img"
,
"txt2img"
),
(
txt2img_interface
,
"txt2img"
,
"txt2img"
),
(
img2img_interface
,
"img2img"
,
"img2img"
),
(
img2img_interface
,
"img2img"
,
"img2img"
),
...
...
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