-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aded an event bus for admin-caused report changes. updated the dashbo…
…ard widgets to listen for those changes, and to refresh accordingly.
- Loading branch information
Showing
7 changed files
with
142 additions
and
17 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
7 changes: 6 additions & 1 deletion
7
admin-frontend/src/components/reports/ReportAdminActionHistoryPanel.vue
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { TinyEmitter } from 'tiny-emitter'; | ||
import { AdminPortalEvent } from '../types/events'; | ||
|
||
const reportChangedEvents = new TinyEmitter(); | ||
|
||
export type ReportChangedEventCallback = ( | ||
payload: ReportChangedEventPayload, | ||
) => void; | ||
|
||
export type ReportChangedEventPayload = { reportId: string }; | ||
|
||
/** | ||
* This service is an event bus for events related to data changes made by | ||
* admin users to Reports. It is intented to be used by | ||
* components which trigger admin-related report changes (e.g. lock/unlock) | ||
* to alert other components about those changes. | ||
*/ | ||
export const ReportChangeService = { | ||
/** | ||
* Pushes a report change event onto the event bus for the given reportId | ||
* @param reportId | ||
*/ | ||
reportChanged(reportId: string) { | ||
const payload: ReportChangedEventPayload = { reportId: reportId }; | ||
reportChangedEvents.emit(AdminPortalEvent.REPORT_CHANGED, payload); | ||
}, | ||
|
||
/** | ||
* Register a callback function which will called whenever | ||
* a report change event occurs | ||
* @param eventType the type of event that occurred | ||
* @param callback a function that will be called | ||
*/ | ||
listen(callback: ReportChangedEventCallback): void { | ||
reportChangedEvents.on(AdminPortalEvent.REPORT_CHANGED, callback); | ||
}, | ||
|
||
/** | ||
* Un-register a callback function so that it will no longer be called | ||
* when report change events occur | ||
* @param callback a function that will be de-registered | ||
*/ | ||
unlisten(callback: ReportChangedEventCallback): void { | ||
reportChangedEvents.off(AdminPortalEvent.REPORT_CHANGED, callback); | ||
}, | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export enum AdminPortalEvent { | ||
REPORT_CHANGED = 'report_changed', | ||
} |
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