|
@@ -1,15 +1,18 @@
|
|
|
import * as api from 'redux/api';
|
|
|
-import * as actions from './actions';
|
|
|
-import { ConsumerGroupID } from '../interfaces/consumerGroup';
|
|
|
import {
|
|
|
PromiseThunk,
|
|
|
Cluster,
|
|
|
ClusterName,
|
|
|
TopicFormData,
|
|
|
- TopicName, Topic,
|
|
|
+ TopicName,
|
|
|
+ Topic,
|
|
|
} from 'redux/interfaces';
|
|
|
+import * as actions from './actions';
|
|
|
+import { ConsumerGroupID } from '../interfaces/consumerGroup';
|
|
|
|
|
|
-export const fetchBrokers = (clusterName: ClusterName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchBrokers = (
|
|
|
+ clusterName: ClusterName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchBrokersAction.request());
|
|
|
try {
|
|
|
const payload = await api.getBrokers(clusterName);
|
|
@@ -19,7 +22,9 @@ export const fetchBrokers = (clusterName: ClusterName): PromiseThunk<void> => as
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchBrokerMetrics = (clusterName: ClusterName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchBrokerMetrics = (
|
|
|
+ clusterName: ClusterName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchBrokerMetricsAction.request());
|
|
|
try {
|
|
|
const payload = await api.getBrokerMetrics(clusterName);
|
|
@@ -39,7 +44,9 @@ export const fetchClustersList = (): PromiseThunk<void> => async (dispatch) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchTopicList = (clusterName: ClusterName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchTopicList = (
|
|
|
+ clusterName: ClusterName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchTopicListAction.request());
|
|
|
try {
|
|
|
const topics = await api.getTopics(clusterName);
|
|
@@ -49,17 +56,41 @@ export const fetchTopicList = (clusterName: ClusterName): PromiseThunk<void> =>
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchTopicDetails = (clusterName: ClusterName, topicName: TopicName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchTopicMessages = (
|
|
|
+ clusterName: ClusterName,
|
|
|
+ topicName: TopicName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
+ dispatch(actions.fetchTopicMessagesAction.request());
|
|
|
+ try {
|
|
|
+ const messages = await api.getTopicMessages(clusterName, topicName);
|
|
|
+ dispatch(actions.fetchTopicMessagesAction.success(messages));
|
|
|
+ } catch (e) {
|
|
|
+ dispatch(actions.fetchTopicMessagesAction.failure());
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+export const fetchTopicDetails = (
|
|
|
+ clusterName: ClusterName,
|
|
|
+ topicName: TopicName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchTopicDetailsAction.request());
|
|
|
try {
|
|
|
const topicDetails = await api.getTopicDetails(clusterName, topicName);
|
|
|
- dispatch(actions.fetchTopicDetailsAction.success({ topicName, details: topicDetails }));
|
|
|
+ dispatch(
|
|
|
+ actions.fetchTopicDetailsAction.success({
|
|
|
+ topicName,
|
|
|
+ details: topicDetails,
|
|
|
+ })
|
|
|
+ );
|
|
|
} catch (e) {
|
|
|
dispatch(actions.fetchTopicDetailsAction.failure());
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchTopicConfig = (clusterName: ClusterName, topicName: TopicName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchTopicConfig = (
|
|
|
+ clusterName: ClusterName,
|
|
|
+ topicName: TopicName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchTopicConfigAction.request());
|
|
|
try {
|
|
|
const config = await api.getTopicConfig(clusterName, topicName);
|
|
@@ -69,7 +100,10 @@ export const fetchTopicConfig = (clusterName: ClusterName, topicName: TopicName)
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const createTopic = (clusterName: ClusterName, form: TopicFormData): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const createTopic = (
|
|
|
+ clusterName: ClusterName,
|
|
|
+ form: TopicFormData
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.createTopicAction.request());
|
|
|
try {
|
|
|
const topic: Topic = await api.postTopic(clusterName, form);
|
|
@@ -79,7 +113,9 @@ export const createTopic = (clusterName: ClusterName, form: TopicFormData): Prom
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchConsumerGroupsList = (clusterName: ClusterName): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchConsumerGroupsList = (
|
|
|
+ clusterName: ClusterName
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchConsumerGroupsAction.request());
|
|
|
try {
|
|
|
const consumerGroups = await api.getConsumerGroups(clusterName);
|
|
@@ -89,11 +125,22 @@ export const fetchConsumerGroupsList = (clusterName: ClusterName): PromiseThunk<
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-export const fetchConsumerGroupDetails = (clusterName: ClusterName, consumerGroupID: ConsumerGroupID): PromiseThunk<void> => async (dispatch) => {
|
|
|
+export const fetchConsumerGroupDetails = (
|
|
|
+ clusterName: ClusterName,
|
|
|
+ consumerGroupID: ConsumerGroupID
|
|
|
+): PromiseThunk<void> => async (dispatch) => {
|
|
|
dispatch(actions.fetchConsumerGroupDetailsAction.request());
|
|
|
try {
|
|
|
- const consumerGroupDetails = await api.getConsumerGroupDetails(clusterName, consumerGroupID);
|
|
|
- dispatch(actions.fetchConsumerGroupDetailsAction.success({ consumerGroupID, details: consumerGroupDetails }));
|
|
|
+ const consumerGroupDetails = await api.getConsumerGroupDetails(
|
|
|
+ clusterName,
|
|
|
+ consumerGroupID
|
|
|
+ );
|
|
|
+ dispatch(
|
|
|
+ actions.fetchConsumerGroupDetailsAction.success({
|
|
|
+ consumerGroupID,
|
|
|
+ details: consumerGroupDetails,
|
|
|
+ })
|
|
|
+ );
|
|
|
} catch (e) {
|
|
|
dispatch(actions.fetchConsumerGroupDetailsAction.failure());
|
|
|
}
|