Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cf9e0077
authored
8 years ago
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: send a notification when an activity has finished and the window not in focus
Issue: #444
parent
cb2d9cff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
circle/dashboard/static/dashboard/activity.js
+37
-0
No files found.
circle/dashboard/static/dashboard/activity.js
View file @
cf9e0077
...
...
@@ -169,6 +169,9 @@ $(function() {
);
}
else
{
in_progress
=
false
;
if
(
windowHasFocus
===
false
){
sendNotification
(
generateMessageFromLastActivity
());
}
if
(
reload_vm_detail
)
location
.
reload
();
if
(
runs
>
1
)
addConnectText
();
}
...
...
@@ -181,6 +184,40 @@ $(function() {
}
});
// Notification init
$
(
function
(){
Notification
.
requestPermission
();
});
// Detect window has focus
windowHasFocus
=
true
;
$
(
window
).
blur
(
function
(){
windowHasFocus
=
false
;
});
$
(
window
).
focus
(
function
(){
windowHasFocus
=
true
;
});
function
generateMessageFromLastActivity
(){
var
ac
=
$
(
'div.activity'
).
first
();
if
(
ac
.
length
===
0
)
return
""
;
var
error
=
$
(
ac
[
0
]).
children
(
".timeline-icon-failed"
).
length
;
var
sign
=
(
error
===
1
)
?
"❌ "
:
"✓ "
;
return
sign
+
ac
[
0
].
innerText
.
split
(
","
)[
0
];
}
function
sendNotification
(
message
)
{
if
(
Notification
.
permission
===
"granted"
)
{
var
notification
=
new
Notification
(
message
);
}
else
if
(
Notification
.
permission
!==
'denied'
)
{
Notification
.
requestPermission
(
function
(
permission
)
{
if
(
permission
===
"granted"
)
{
var
notification
=
new
Notification
(
message
);
}
});
}
}
function
addConnectText
()
{
var
activities
=
$
(
".timeline .activity"
);
...
...
This diff is collapsed.
Click to expand it.
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