Skip to content
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

✨ User Notifications (⚠️ devops) 🚨 #3937

Merged
merged 91 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
244ff28
notifications api
odeimaiz Mar 2, 2023
2b93120
NotificationIn and NotificationOut
odeimaiz Mar 2, 2023
c7cabdd
added to the openapi
odeimaiz Mar 2, 2023
4d35a37
table to redis
odeimaiz Mar 2, 2023
cbbf1a1
moved to /me
odeimaiz Mar 2, 2023
e50d9ae
renamings
odeimaiz Mar 2, 2023
4a56b23
more renaming
odeimaiz Mar 2, 2023
58156e9
move handlers
odeimaiz Mar 2, 2023
8371f49
NavBar fetches notifications
odeimaiz Mar 2, 2023
1386c8f
make openapi-specs
odeimaiz Mar 2, 2023
c2cd292
Merge branch 'master' into feature/push-notifications
odeimaiz Mar 3, 2023
fa3cfd2
dummy notifications
odeimaiz Mar 3, 2023
fa3ec86
renaming
odeimaiz Mar 3, 2023
6eb9f04
dummy notifications to backend
odeimaiz Mar 3, 2023
9b9b094
Merge branch 'feature/push-notifications' of github.com:odeimaiz/ospa…
odeimaiz Mar 3, 2023
ee3e6a1
NotificationUI extended
odeimaiz Mar 3, 2023
0b58eea
Maintenance only on ribbon
odeimaiz Mar 3, 2023
cda13ac
renaming classes
odeimaiz Mar 3, 2023
83e08d7
refactoring
odeimaiz Mar 3, 2023
a643347
working
odeimaiz Mar 3, 2023
478b012
Notifications UI
odeimaiz Mar 3, 2023
81f444c
more samples
odeimaiz Mar 3, 2023
db63eca
actionablePath
odeimaiz Mar 3, 2023
a823e87
sorted
odeimaiz Mar 3, 2023
54db0aa
openOrganizations
odeimaiz Mar 3, 2023
fe1c00e
update_user_notification
odeimaiz Mar 6, 2023
210fbb6
number in circle
odeimaiz Mar 6, 2023
79371e5
_resourceType
odeimaiz Mar 6, 2023
8f780d9
NotificationUpdate schema
odeimaiz Mar 6, 2023
bcbe655
notificationTapped
odeimaiz Mar 6, 2023
cee8708
minor
odeimaiz Mar 6, 2023
282637d
notifications patch
odeimaiz Mar 6, 2023
1a15146
renaming
odeimaiz Mar 6, 2023
e36d451
minor
odeimaiz Mar 6, 2023
e8144d0
minor
odeimaiz Mar 6, 2023
2fd4611
get_user_notifications
odeimaiz Mar 6, 2023
d0c3362
JSON.parse
odeimaiz Mar 6, 2023
4e9e536
/me/notifications/{nid}
odeimaiz Mar 6, 2023
a00600f
push 'new_organization' notification
odeimaiz Mar 6, 2023
9b6e3c5
add redis entry
odeimaiz Mar 6, 2023
07d7562
post_user_notification
odeimaiz Mar 6, 2023
d027c64
post_user_notification working
odeimaiz Mar 6, 2023
a8c10f8
minor
odeimaiz Mar 6, 2023
8a5fead
minor
odeimaiz Mar 6, 2023
dfafeb0
refactoring
odeimaiz Mar 6, 2023
6e12f63
more progress
odeimaiz Mar 6, 2023
8d9e989
larger Privacy Policy
odeimaiz Mar 7, 2023
6cb7f6a
_get_user_notifications
odeimaiz Mar 7, 2023
0ad660a
minor
odeimaiz Mar 7, 2023
7428050
update_user_notification
odeimaiz Mar 7, 2023
6ada761
minor
odeimaiz Mar 7, 2023
630a28e
update_user_notification
odeimaiz Mar 7, 2023
f551bda
update_user_notification working
odeimaiz Mar 7, 2023
4a4bfd5
number fix
odeimaiz Mar 7, 2023
819a328
osparc.component.notification.Notification
odeimaiz Mar 7, 2023
10e2e1e
minors
odeimaiz Mar 7, 2023
93f4f20
improve button ux
odeimaiz Mar 7, 2023
67d4424
minor
odeimaiz Mar 7, 2023
d647e14
aesthetics
odeimaiz Mar 7, 2023
e5a2b73
notificationsContainer in Scroll
odeimaiz Mar 7, 2023
bca8f2c
openOrganizationDetails
odeimaiz Mar 7, 2023
8e58f9d
open Study/Template info
odeimaiz Mar 7, 2023
415efd4
Merge branch 'master' into feature/push-notifications
odeimaiz Mar 7, 2023
baf106e
cleanup
odeimaiz Mar 7, 2023
7d6d013
Merge branch 'feature/push-notifications' of github.com:odeimaiz/ospa…
odeimaiz Mar 7, 2023
49a4b31
minors
odeimaiz Mar 7, 2023
11065d3
postNewStudy
odeimaiz Mar 7, 2023
eddc028
postNewStudy & postNewTemplate
odeimaiz Mar 7, 2023
b8afd8a
cleanup
odeimaiz Mar 7, 2023
af7f79b
minor
odeimaiz Mar 7, 2023
1650d07
comment
odeimaiz Mar 7, 2023
4cee306
minor fix
odeimaiz Mar 7, 2023
04a3c35
potentialCollaborators
odeimaiz Mar 7, 2023
abbff75
descriptions updated
odeimaiz Mar 7, 2023
c817cf8
Update services/web/server/src/simcore_service_webserver/users_handle…
odeimaiz Mar 7, 2023
3e9010c
Update services/web/server/src/simcore_service_webserver/users_handle…
odeimaiz Mar 8, 2023
61024d2
Update services/web/server/src/simcore_service_webserver/users_handle…
odeimaiz Mar 8, 2023
9e49ed2
not needed
odeimaiz Mar 8, 2023
f22210a
Update services/web/server/src/simcore_service_webserver/users_handle…
odeimaiz Mar 8, 2023
06b849b
notification id is a uuid
odeimaiz Mar 8, 2023
68622cf
read is boolean
odeimaiz Mar 8, 2023
c8d8d5b
fixes
odeimaiz Mar 8, 2023
84a4feb
Merge branch 'master' into feature/push-notifications
odeimaiz Mar 10, 2023
75b8605
openOrganizationDetails
odeimaiz Mar 10, 2023
ac713d6
post_user_notification
odeimaiz Mar 10, 2023
a25d3cc
get_user_notifications
odeimaiz Mar 10, 2023
a07942f
update_user_notification
odeimaiz Mar 10, 2023
5462e69
minor
odeimaiz Mar 10, 2023
7043f62
minor
odeimaiz Mar 10, 2023
bbfc80a
make sure list is created
odeimaiz Mar 10, 2023
7ce8a29
remove old notifications
odeimaiz Mar 10, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 147 additions & 0 deletions api/specs/webserver/openapi-user.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,154 @@ paths:
"204":
description: token has been successfully deleted

/me/notifications:
odeimaiz marked this conversation as resolved.
Show resolved Hide resolved
get:
tags:
- user
summary: List of Notifications for the specific user
operationId: get_user_notifications
responses:
"200":
description: List of Notifications
content:
application/json:
schema:
$ref: "#/components/schemas/NotificationsOutListEnveloped"
default:
$ref: "#/components/responses/DefaultErrorResponse"
post:
tags:
- user
summary: Submit a new Notification
operationId: post_user_notification
requestBody:
required: true
description: the group to create
content:
application/json:
schema:
$ref: "#/components/schemas/NotificationIn"
responses:
"204":
description: Notification registered
default:
$ref: "#/components/responses/DefaultErrorResponse"

/me/notifications/{nid}:
parameters:
- name: nid
in: path
required: true
schema:
type: integer
patch:
tags:
- user
summary: Update a Notification
operationId: update_user_notification
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/NotificationUpdate'
responses:
"200":
description: Returns modified service
default:
$ref: "./openapi.yaml#/components/responses/DefaultErrorResponse"

components:
schemas:
NotificationIn:
type: object
required:
- user_id
- category
- actionable_path
- title
- text
- date
properties:
user_id:
type: string
description: >-
the user that will receive the notification
example: "123"
category:
type: string
enum:
- new_organization
- study_shared
- template_shared
description: >-
notification type, the frontend will use this to decorate the notification
example: new_organization
actionable_path:
type: string
description: >-
the frontend will use this information to trigger an action when the user click on it
example:
organization/123
title:
type: string
description: >-
the notification title to show in the frontend
example:
New Organization
text:
type: string
description: >-
the notification text to show in the frontend
example:
You are now part of Dummy Organization!
date:
type: string
format: date-time
description: >-
when it was created

NotificationOut:
# extend NotificationIn
allOf:
- $ref: "#/components/schemas/NotificationIn"
- type: "object"
- required:
- id
- read
properties:
id:
type: string
description: >-
notification id
example: "123456789"
read:
type: boolean
description: >-
wether the notification has been read

NotificationsOutListEnveloped:
type: object
required:
- data
properties:
data:
type: array
items:
$ref: "#/components/schemas/NotificationOut"
error:
nullable: true
default: null

NotificationUpdate:
type: object
required:
- read
properties:
read:
type: boolean
description: >-
notification has been read

responses:
DefaultErrorResponse:
$ref: "./openapi.yaml#/components/responses/DefaultErrorResponse"
6 changes: 6 additions & 0 deletions api/specs/webserver/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ paths:
/me/tokens/{service}:
$ref: "./openapi-user.yaml#/paths/~1me~1tokens~1{service}"

/me/notifications:
$ref: "./openapi-user.yaml#/paths/~1me~1notifications"

/me/notifications/{nid}:
$ref: "./openapi-user.yaml#/paths/~1me~1notifications~1{nid}"

# GROUP SETTINGS ------------------------------------------------------------------

/groups:
Expand Down
7 changes: 7 additions & 0 deletions packages/settings-library/src/settings_library/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class RedisSettings(BaseCustomSettings):
REDIS_SCHEDULED_MAINTENANCE_DB: int = Field(
default=3, description="This redis table is used for handling scheduled maintenance"
)
REDIS_USER_NOTIFICATIONS_DB: int = Field(
default=4, description="This redis table is used for handling the notifications that have to be sent to the user"
)

def _build_redis_dsn(self, db_index: int):
return RedisDsn.build(
Expand Down Expand Up @@ -60,3 +63,7 @@ def dsn_validation_codes(self) -> str:
@cached_property
def dsn_scheduled_maintenance(self) -> str:
return self._build_redis_dsn(self.REDIS_SCHEDULED_MAINTENANCE_DB)

@cached_property
def dsn_user_notifications(self) -> str:
return self._build_redis_dsn(self.REDIS_USER_NOTIFICATIONS_DB)
2 changes: 1 addition & 1 deletion services/docker-compose-ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ services:
image: rediscommander/redis-commander:latest
init: true
environment:
- REDIS_HOSTS=resources:${REDIS_HOST}:${REDIS_PORT}:0,locks:${REDIS_HOST}:${REDIS_PORT}:1,validation_codes:${REDIS_HOST}:${REDIS_PORT}:2,scheduled_maintenance:${REDIS_HOST}:${REDIS_PORT}:3
- REDIS_HOSTS=resources:${REDIS_HOST}:${REDIS_PORT}:0,locks:${REDIS_HOST}:${REDIS_PORT}:1,validation_codes:${REDIS_HOST}:${REDIS_PORT}:2,scheduled_maintenance:${REDIS_HOST}:${REDIS_PORT}:3,user_notifications:${REDIS_HOST}:${REDIS_PORT}:4
odeimaiz marked this conversation as resolved.
Show resolved Hide resolved
# If you add/remove a db, do not forget to update the --databases entry in the docker-compose.yml
ports:
- "18081:8081"
Expand Down
2 changes: 1 addition & 1 deletion services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ services:
"--loglevel",
"verbose",
"--databases",
"4",
"5",
"--appendonly",
"yes"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ qx.Class.define("osparc.Application", {
if (!osparc.CookiePolicy.areCookiesAccepted()) {
const cookiePolicy = new osparc.CookiePolicy();
let title = this.tr("Privacy Policy");
let height = 155;
let height = 160;
if (osparc.product.Utils.showLicenseExtra()) {
// "tis" and "s4llite" include the license terms
title = this.tr("Privacy Policy and License Terms");
height = 200;
height = 210;
}
const win = osparc.ui.window.Window.popUpInWindow(cookiePolicy, title, 400, height).set({
clickAwayClose: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ qx.Class.define("osparc.MaintenanceTracker", {

members: {
__checkInternval: null,
__lastNotification: null,
__lastRibbonMessage: null,
__logoutTimer: null,

Expand Down Expand Up @@ -119,32 +118,14 @@ qx.Class.define("osparc.MaintenanceTracker", {

__scheduleStart: function() {
if (this.getStart() === null) {
this.__removeNotification();
this.__removeRibbonMessage();
this.__removeScheduledLogout();
} else {
this.__addNotification();
this.__scheduleRibbonMessage();
this.__scheduleLogout();
}
},

__addNotification: function() {
this.__removeNotification();

const text = this.__getText();
const notification = new osparc.component.notification.Notification(text);
const notificationUI = this.__lastNotification = new osparc.component.notification.NotificationUI(notification.getFullText(true));
osparc.component.notification.Notifications.getInstance().addNotification(notificationUI);
},

__removeNotification: function() {
if (this.__lastNotification) {
osparc.component.notification.Notifications.getInstance().removeNotification(this.__lastNotification);
this.__lastNotification = null;
}
},

__scheduleRibbonMessage: function() {
this.__removeRibbonMessage();

Expand All @@ -155,8 +136,8 @@ qx.Class.define("osparc.MaintenanceTracker", {
const messageToRibbon = closable => {
this.__removeRibbonMessage();
const text = this.__getText();
const notification = new osparc.component.notification.Notification(text, "maintenance", closable);
osparc.component.notification.NotificationsRibbon.getInstance().addNotification(notification);
const notification = new osparc.component.notification.RibbonNotification(text, "maintenance", closable);
osparc.component.notification.RibbonNotifications.getInstance().addNotification(notification);
this.__lastRibbonMessage = notification;
};
if (diffClosable < 0) {
Expand All @@ -173,7 +154,7 @@ qx.Class.define("osparc.MaintenanceTracker", {

__removeRibbonMessage: function() {
if (this.__lastRibbonMessage) {
osparc.component.notification.NotificationsRibbon.getInstance().removeNotification(this.__lastRibbonMessage);
osparc.component.notification.RibbonNotifications.getInstance().removeNotification(this.__lastRibbonMessage);
this.__lastRibbonMessage = null;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ qx.Class.define("osparc.WindowSizeTracker", {

let notification = null;
if (tooSmall === "shortText") {
notification = new osparc.component.notification.Notification(null, "smallWindow", true);
notification = new osparc.component.notification.RibbonNotification(null, "smallWindow", true);
} else if (tooSmall === "longText") {
const text = this.__getLongText(true);
notification = new osparc.component.notification.Notification(text, "smallWindow", true);
notification = new osparc.component.notification.RibbonNotification(text, "smallWindow", true);
}
osparc.component.notification.NotificationsRibbon.getInstance().addNotification(notification);
osparc.component.notification.RibbonNotifications.getInstance().addNotification(notification);
this.__lastRibbonMessage = notification;
},

Expand All @@ -108,7 +108,7 @@ qx.Class.define("osparc.WindowSizeTracker", {

__removeRibbonMessage: function() {
if (this.__lastRibbonMessage) {
osparc.component.notification.NotificationsRibbon.getInstance().removeNotification(this.__lastRibbonMessage);
osparc.component.notification.RibbonNotifications.getInstance().removeNotification(this.__lastRibbonMessage);
this.__lastRibbonMessage = null;
}
}
Expand Down
Loading