Skip to content

Commit

Permalink
Updated API, renamed event to pushAlert, filter before
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Jul 9, 2024
1 parent 2e78fde commit 6494c01
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 14 deletions.
244 changes: 240 additions & 4 deletions packages/api-client/lib/openapi/api.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/api-client/lib/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { version as rmfModelVer } from 'rmf-models';

export const version = {
rmfModels: rmfModelVer,
rmfServer: '06e5475f096ec8f2eae05aae7c939a612aaa11e6',
rmfServer: '2e78fded62245f24a712e0c34127cc28d0b36aad',
openapiGenerator: '6.2.1',
};
69 changes: 68 additions & 1 deletion packages/api-client/schema/index.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions packages/api-server/api_server/repositories/alerts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional
from typing import List

from api_server.exceptions import AlreadyExistsError, InvalidInputError, NotFoundError
from api_server.models import AlertRequest, AlertResponse, Pagination
Expand Down Expand Up @@ -80,7 +80,7 @@ async def get_alerts_of_task(
return alert_models

async def get_unresponded_alerts(
self, pagination: Optional[Pagination]
self, pagination: Pagination | None
) -> List[AlertRequest]:
query = ttm.AlertRequest.filter(alert_response=None, response_expected=True)
if pagination:
Expand Down
17 changes: 13 additions & 4 deletions packages/dashboard/src/components/alert-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,18 @@ export const AlertManager = React.memo(() => {
const subs: Subscription[] = [];

subs.push(
rmf.alertRequestsObsStore.subscribe((alertRequest) =>
AppEvents.alertListOpenedAlert.next(alertRequest),
),
rmf.alertRequestsObsStore.subscribe((alertRequest) => {
if (!alertRequest.display) {
setOpenAlerts((prev) => {
const filteredAlerts = Object.fromEntries(
Object.entries(prev).filter(([key]) => key !== alertRequest.id),
);
return filteredAlerts;
});
return;
}
AppEvents.pushAlert.next(alertRequest);
}),
);

subs.push(
Expand All @@ -319,7 +328,7 @@ export const AlertManager = React.memo(() => {
);

subs.push(
AppEvents.alertListOpenedAlert.subscribe(async (alertRequest) => {
AppEvents.pushAlert.subscribe(async (alertRequest) => {
if (!alertRequest) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/app-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const AppEvents = {
refreshTaskApp: new Subject<void>(),
refreshFavoriteTasks: new Subject<void>(),
refreshTaskSchedule: new Subject<void>(),
alertListOpenedAlert: new Subject<AlertRequest | null>(),
pushAlert: new Subject<AlertRequest | null>(),
disabledLayers: new ReplaySubject<Record<string, boolean>>(),
zoom: new BehaviorSubject<number | null>(null),
cameraPosition: new BehaviorSubject<Vector3 | null>(null),
Expand Down
2 changes: 1 addition & 1 deletion packages/dashboard/src/components/appbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ export const AppBar = React.memo(({ extraToolbarItems }: AppBarProps): React.Rea
};

const openAlertDialog = (alert: AlertRequest) => {
AppEvents.alertListOpenedAlert.next(alert);
AppEvents.pushAlert.next(alert);
};

const timeDistance = (time: number) => {
Expand Down

0 comments on commit 6494c01

Please sign in to comment.