-
Notifications
You must be signed in to change notification settings - Fork 237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Notification system #1766
Changes from 250 commits
87da0d7
3e740d3
77752d8
5de1e35
e732f04
8381877
ab71c85
9229214
f76639b
06cc9f4
daee7a8
71815ae
cf38f78
88dd2be
ebf452a
9f2cce3
883fe97
6013ce1
090bb1e
dde8bd3
42585f9
608fe31
ecad4db
da546c8
a78ecdf
16f7d92
45c62ec
135d58d
9ac7861
32ae2dd
b9da0be
71cdf22
2fc1010
a997f5a
b616cce
0e0e734
a992739
d24735f
b914f29
da35a16
df9f84c
870cb1e
1485057
800dfc6
765d621
9a9ae30
0385380
4007287
90cd49b
2a0e48c
d471be3
80d2ff9
d71d674
ef14ff2
5150e5e
be6a3b4
b6f9ac0
aeb2e8d
806ce67
f14f618
cd8aa1d
9b400b4
363bd19
1e504e9
b5f1005
c9850fb
276f89a
e824434
982d146
9c5c9db
afc00d3
272aec6
26dc848
4beace3
d655105
d6f4d0d
bcc03d5
eb0addb
05d8cae
57fe201
5f50da6
2626f39
4af5e53
88d3319
d0ee5e2
df996de
8cc0134
007e9fa
114653d
1513060
262a91c
99bdbcd
487a604
f6ee846
3ce4936
d3aa53d
f78f544
c66dac0
48fb2b2
4b9d085
486a528
e7e469a
7a39a36
c3b4b39
a8c8f44
c970e5f
9a40294
5eb1f53
cac9351
57b55b7
fc831bd
950cc4f
7b829a0
df7d9ee
bb15384
2449e80
1364cbc
c204691
fde650b
71e02b7
f71f0d5
1856bf6
3fdbfac
0e9631e
930bb11
cdc0edd
19530fd
09e4ee0
a78a516
38fd496
b98b120
46fd940
fcf7326
f15dc42
6c53bb2
b49c098
f362ace
b482fd5
a598f6b
6150d23
87e28dc
61172d7
3f1e79f
68aea9e
54dc449
681358b
d945862
7f683f3
24747f1
9c1f016
5570487
e5b1530
c388e9f
9547f89
892e954
747b8ab
9804aae
5d7b69a
e1dcaac
1c4ca08
7ac33b8
51acbbc
d2ca3ae
29329be
2083ce0
8666666
aff8b58
20686ad
d329b82
41f0125
5058fa7
0fa1fa8
d2a2493
7ea2762
4242331
d7a64ee
5032353
5c7a7e9
bc72ab9
27b0539
80075c9
6f1f8cf
7c5d0bc
5930358
acba2fa
bae090d
9125fbe
2eb3b35
22fd26e
ecf5da0
e8ec387
514401b
2de3e1e
3fb7b86
b968828
7046d75
7b16578
9ffaa84
7c43706
e01b9ed
7b0ef55
04cca9c
6dbd0f1
4e051d7
1985baf
370e1d5
3f2dd38
c7cd147
7aa4882
ccee38f
361eb04
07f3aaa
10773d7
ab2ad8e
3c64660
18ec3d8
95528f8
640b727
cf1ccca
be37033
e2de832
8d319a9
9df5e4e
314c282
e53eeb9
df3b90b
e63d9a4
e4ff87f
8148de7
1a4bd46
0806418
5555ed9
569dfb7
9df15d9
08231bd
b2009da
ef8dc7d
6958242
0fa5db4
7f3bd1f
bf03c32
0d69ae8
bac4422
e7dff40
7040326
4cec1f4
1f05655
a75d44f
d77efed
5aa0008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
from flask import flash as flask_flash | ||
from flask import current_app as app | ||
from ..services import callbacks | ||
|
||
|
||
def flash(*args, **kwargs): | ||
"""An indirection in order to potentially handle a flash differently | ||
This function could be placed in util but as it might | ||
use the service_manager, we place it here for now. | ||
""" | ||
flask_flash(*args, **kwargs) | ||
|
||
return_values = app.specter.service_manager.execute_ext_callbacks( | ||
callbacks.flash, *args, **kwargs | ||
) | ||
|
||
# if no extension handled the callback | ||
if not return_values: | ||
flask_flash(*args, **kwargs) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ | |
) | ||
from .managers.service_manager import ServiceManager | ||
from .services.service import devstatus_alpha, devstatus_beta, devstatus_prod | ||
from .services import callbacks | ||
from .specter_error import ExtProcTimeoutException, SpecterError | ||
from .tor_daemon import TorDaemonController | ||
from .user import User | ||
|
@@ -192,6 +193,15 @@ def initialize(self): | |
signal.signal(signal.SIGINT, self.cleanup_on_exit) | ||
# This is for kill $pid --> SIGTERM | ||
signal.signal(signal.SIGTERM, self.cleanup_on_exit) | ||
# a list of functions that are called at cleanup_on_exit taking in each signum, frame | ||
self.call_functions_at_cleanup_on_exit = [] | ||
|
||
def service_manager_cleanup_on_exit(signum, frame): | ||
return self.service_manager.execute_ext_callbacks( | ||
callbacks.cleanup_on_exit, signum, frame | ||
) | ||
|
||
self.call_functions_at_cleanup_on_exit.append(service_manager_cleanup_on_exit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is IMHO problematic as it's making the specter-object more aware of the
Is this currently the case? I can't reproduce it but i know that this was, at some point, necessary for Stepan and maybe even @moneymanolis on Mac? Can we fix that somehow? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't recall from the top of my head. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed. Done in bac4422 |
||
|
||
def cleanup_on_exit(self, signum=0, frame=0): | ||
if self._tor_daemon: | ||
|
@@ -202,6 +212,9 @@ def cleanup_on_exit(self, signum=0, frame=0): | |
if not node.external_node: | ||
node.stop() | ||
|
||
for f in self.call_functions_at_cleanup_on_exit: | ||
f(signum, frame) | ||
|
||
logger.info("Closing Specter after cleanup") | ||
# For some reason we need to explicitely exit here. Otherwise it will hang | ||
exit(0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,6 +172,7 @@ | |
{% endif %} | ||
</script> | ||
{% endif %} | ||
<!-- This scripts block will be overwritten in /device --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure i understand the comment. The blocks are there to be overwritten. Sure, some of them indeed are. But why do we comment that here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was a reminder for me, that |
||
{% block scripts %} | ||
<script> | ||
{% include "includes/language/language_js.jinja" %} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,4 +76,29 @@ | |
|
||
|
||
|
||
|
||
|
||
async function sendRequest(url, method_str, formData) { | ||
if (!formData) { | ||
formData = new FormData(); | ||
} | ||
formData.append("csrf_token", "{{ csrf_token() }}") | ||
d = { | ||
method: method_str, | ||
} | ||
if (method_str == 'POST') { | ||
d['body'] = formData; | ||
} | ||
|
||
const response = await fetch(url, d); | ||
if(response.status != 200){ | ||
showError(await response.text()); | ||
console.log(`Error while calling ${url} with ${method_str} ${formData}`) | ||
return | ||
} | ||
return await response.json(); | ||
} | ||
|
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is, in the meantime, already implemented in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 0d69ae8 |
||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we move that to the config of the extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need the
app.config["HOST"]
in the notification extension. Adding it to the global BaseConfig, does make it consistent withPORT
. And if anotherHOST
value if given for the server then the config value is updated here https://github.com/relativisticelectron/specter-desktop/blob/bf03c3236958c49405b7d56c71e0b6ab67c9f5e4/src/cryptoadvance/specter/cli/cli_server.py#L127I don't really see how to move this to the service.