-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
task/DSAPP-46, task/WP-611: Tools & Apps Workspace Changes; Notificat…
…ions Enhancements (#1442) * support .log preview * change "Account Profile" to "Manage Account * add workspace links to account dropdown * change /rw/workspace to /workspace; backwards compatible * add "Job Status" label to notification bell * enable docker ngrok * remove notifications link; adjust dropdown header * formatting * sync job notification states * update m1 docker-compose; linting * adjust toast UI to look like secondary button * unify ngrok webhook settings, and move to conf/env_files/ngrok.env * Revert "unify ngrok webhook settings, and move to conf/env_files/ngrok.env" This reverts commit 940be99. * Revert "enable docker ngrok" This reverts commit 793b6d0.
- Loading branch information
1 parent
06a068a
commit 1295c87
Showing
25 changed files
with
176 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
client/modules/workspace/src/Toast/Notifications.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
.root { | ||
cursor: pointer; | ||
background: #f4f4f4; | ||
border: 1px solid #222222; | ||
&:hover { | ||
border-color: #5695c4; | ||
background: #aac7ff; | ||
} | ||
} | ||
|
||
.toast-is-error { | ||
color: #eb6e6e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
designsafe/apps/accounts/templates/designsafe/apps/accounts/profile.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,47 @@ | ||
"""Signal receivers for notifications""" | ||
|
||
import logging | ||
import json | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
from asgiref.sync import async_to_sync | ||
from channels.layers import get_channel_layer | ||
from django.db.models.signals import post_save | ||
from designsafe.apps.api.notifications.models import Notification, Broadcast | ||
import logging | ||
import json | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
WEBSOCKETS_FACILITY = 'websockets' | ||
WEBSOCKETS_FACILITY = "websockets" | ||
|
||
|
||
@receiver(post_save, sender=Notification, dispatch_uid="notification_msg") | ||
def send_notification_ws(instance, created, **kwargs): | ||
"""Send a websocket message to the user when a new notification is created.""" | ||
|
||
@receiver(post_save, sender=Notification, dispatch_uid='notification_msg') | ||
def send_notification_ws(sender, instance, created, **kwargs): | ||
#Only send WS message if it's a new notification not if we're updating. | ||
logger.debug('receiver received something.') | ||
if not created: | ||
return | ||
try: | ||
channel_layer = get_channel_layer() | ||
instance_dict = json.dumps(instance.to_dict()) | ||
logger.debug(instance_dict) | ||
|
||
async_to_sync(channel_layer.group_send)(f"ds_{instance.user}", {"type": "ds.notification", "message": instance_dict}) | ||
channel_layer = get_channel_layer() | ||
instance_dict = json.dumps(instance.to_dict()) | ||
|
||
async_to_sync(channel_layer.group_send)( | ||
f"ds_{instance.user}", {"type": "ds.notification", "message": instance_dict} | ||
) | ||
|
||
# logger.debug('WS socket msg sent: {}'.format(instance_dict)) | ||
except Exception as e: | ||
# logger.debug('Exception sending websocket message', | ||
# exc_info=True, | ||
# extra = instance.to_dict()) | ||
logger.debug('Exception sending websocket message', | ||
exc_info=True) | ||
return | ||
|
||
@receiver(post_save, sender=Broadcast, dispatch_uid='broadcast_msg') | ||
def send_broadcast_ws(sender, instance, created, **kwargs): | ||
|
||
@receiver(post_save, sender=Broadcast, dispatch_uid="broadcast_msg") | ||
def send_broadcast_ws(instance, created, **kwargs): | ||
"""Send a websocket message to all users when a new broadcast is created.""" | ||
|
||
if not created: | ||
return | ||
try: | ||
event_type, user, body = decompose_message(instance) | ||
#rp = RedisPublisher(facility = WEBSOCKETS_FACILITY,broadcast=True) | ||
channel_layer = get_channel_layer() | ||
instance_dict = json.dumps(instance.to_dict()) | ||
|
||
async_to_sync(channel_layer.group_send)("ds_broadcast", {"type": "ds.notification", "message": instance_dict}) | ||
logger.debug('WS socket msg sent: {}'.format(instance_dict)) | ||
except Exception as e: | ||
logger.debug('Exception sending websocket message', | ||
exc_info=True, | ||
extra = instance.to_dict()) | ||
|
||
channel_layer = get_channel_layer() | ||
instance_dict = json.dumps(instance.to_dict()) | ||
|
||
async_to_sync(channel_layer.group_send)( | ||
"ds_broadcast", {"type": "ds.notification", "message": instance_dict} | ||
) | ||
|
||
return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,37 @@ | ||
import json | ||
"""Websocket consumers""" | ||
|
||
from channels.generic.websocket import WebsocketConsumer, AsyncWebsocketConsumer | ||
import json | ||
from channels.generic.websocket import AsyncWebsocketConsumer | ||
from channels.layers import get_channel_layer | ||
|
||
|
||
class DesignsafeWebsocketConsumer(AsyncWebsocketConsumer): | ||
"""Websocket consumer for DesignSafe notifications""" | ||
|
||
async def connect(self): | ||
self.user_channel = f"ds_{self.scope['user']}" | ||
self.broadcast_channel = "ds_broadcast" | ||
await self.channel_layer.group_add( | ||
self.user_channel, self.channel_name | ||
f"ds_{self.scope['user']}", self.channel_name | ||
) | ||
await self.accept() | ||
|
||
async def disconnect(self, close_code): | ||
await self.channel_layer.group_discard( | ||
self.user_channel, self.channel_name | ||
) | ||
async def disconnect(self, code): | ||
await self.channel_layer.group_discard( | ||
self.broadcast_channel, self.channel_name | ||
f"ds_{self.scope['user']}", self.channel_name | ||
) | ||
await self.channel_layer.group_discard("ds_broadcast", self.channel_name) | ||
|
||
async def receive(self, text_data): | ||
pass | ||
async def receive(self, text_data=None, bytes_data=None): | ||
if text_data == "markAllNotificationsAsRead": | ||
channel_layer = get_channel_layer() | ||
await channel_layer.group_send( | ||
f"ds_{self.scope['user']}", | ||
{ | ||
"type": "ds_notification", | ||
"message": json.dumps({"event_type": "markAllNotificationsAsRead"}), | ||
}, | ||
) | ||
|
||
async def ds_notification(self, event): | ||
"""Send notification to user""" | ||
message = event["message"] | ||
await self.send(text_data=message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.