mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-08-24 14:48:42 +08:00
Fetch DailyStats in Dashboard view
This commit is contained in:
45
ui/src/actions/queueStatsActions.ts
Normal file
45
ui/src/actions/queueStatsActions.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { Dispatch } from "redux";
|
||||
import { listQueueStats, ListQueueStatsResponse } from "../api";
|
||||
|
||||
export const LIST_QUEUE_STATS_BEGIN = "LIST_QUEUE_STATS_BEGIN";
|
||||
export const LIST_QUEUE_STATS_SUCCESS = "LIST_QUEUE_STATS_SUCCESS";
|
||||
export const LIST_QUEUE_STATS_ERROR = "LIST_QUEUE_STATS_ERROR";
|
||||
|
||||
interface ListQueueStatsBeginAction {
|
||||
type: typeof LIST_QUEUE_STATS_BEGIN;
|
||||
}
|
||||
|
||||
interface ListQueueStatsSuccessAction {
|
||||
type: typeof LIST_QUEUE_STATS_SUCCESS;
|
||||
payload: ListQueueStatsResponse;
|
||||
}
|
||||
|
||||
interface ListQueueStatsErrorAction {
|
||||
type: typeof LIST_QUEUE_STATS_ERROR;
|
||||
error: string;
|
||||
}
|
||||
|
||||
// Union of all queue stats related action types.
|
||||
export type QueueStatsActionTypes =
|
||||
| ListQueueStatsBeginAction
|
||||
| ListQueueStatsSuccessAction
|
||||
| ListQueueStatsErrorAction;
|
||||
|
||||
export function listQueueStatsAsync() {
|
||||
return async (dispatch: Dispatch<QueueStatsActionTypes>) => {
|
||||
dispatch({ type: LIST_QUEUE_STATS_BEGIN });
|
||||
try {
|
||||
const response = await listQueueStats();
|
||||
dispatch({
|
||||
type: LIST_QUEUE_STATS_SUCCESS,
|
||||
payload: response,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("listQueueStatsAsync: ", error);
|
||||
dispatch({
|
||||
type: LIST_QUEUE_STATS_ERROR,
|
||||
error: "Could not fetch queue stats",
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user