|
@@ -33,6 +33,7 @@ const REFRESH_TIME = 15000;
|
|
|
const EventsTab: React.FunctionComponent<Props> = (props) => {
|
|
const EventsTab: React.FunctionComponent<Props> = (props) => {
|
|
|
const { currentCluster, currentProject } = useContext(Context);
|
|
const { currentCluster, currentProject } = useContext(Context);
|
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
|
+ const [isError, setIsError] = useState(false);
|
|
|
const [shouldRequest, setShouldRequest] = useState(true);
|
|
const [shouldRequest, setShouldRequest] = useState(true);
|
|
|
const [eventData, setEventData] = useState<EventContainer[]>([]); // most recent event is last
|
|
const [eventData, setEventData] = useState<EventContainer[]>([]); // most recent event is last
|
|
|
const [selectedEvent, setSelectedEvent] = useState<number | null>(null);
|
|
const [selectedEvent, setSelectedEvent] = useState<number | null>(null);
|
|
@@ -83,36 +84,50 @@ const EventsTab: React.FunctionComponent<Props> = (props) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- const id = window.setInterval(() => {
|
|
|
|
|
|
|
+ const getData = () => {
|
|
|
if (!shouldRequest) return;
|
|
if (!shouldRequest) return;
|
|
|
setShouldRequest(false);
|
|
setShouldRequest(false);
|
|
|
api
|
|
api
|
|
|
- .getReleaseSteps(
|
|
|
|
|
- "<token>",
|
|
|
|
|
- {
|
|
|
|
|
- cluster_id: currentCluster.id,
|
|
|
|
|
- namespace: props.currentChart.namespace,
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- id: currentProject.id,
|
|
|
|
|
- name: props.currentChart.name,
|
|
|
|
|
- }
|
|
|
|
|
- )
|
|
|
|
|
- .then((data) => {
|
|
|
|
|
- setIsLoading(false);
|
|
|
|
|
- filterData(data.data);
|
|
|
|
|
- })
|
|
|
|
|
- .catch((err) => {})
|
|
|
|
|
- .finally(() => {
|
|
|
|
|
- setShouldRequest(true);
|
|
|
|
|
- });
|
|
|
|
|
- }, REFRESH_TIME);
|
|
|
|
|
|
|
+ .getReleaseSteps(
|
|
|
|
|
+ "<token>",
|
|
|
|
|
+ {
|
|
|
|
|
+ cluster_id: currentCluster.id,
|
|
|
|
|
+ namespace: props.currentChart.namespace,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ id: currentProject.id,
|
|
|
|
|
+ name: props.currentChart.name,
|
|
|
|
|
+ }
|
|
|
|
|
+ )
|
|
|
|
|
+ .then((data) => {
|
|
|
|
|
+ setIsLoading(false);
|
|
|
|
|
+ filterData(data.data);
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ setIsError(true);
|
|
|
|
|
+ })
|
|
|
|
|
+ .finally(() => {
|
|
|
|
|
+ setShouldRequest(true);
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ getData();
|
|
|
|
|
+ const id = window.setInterval(getData, REFRESH_TIME);
|
|
|
|
|
+
|
|
|
return () => {
|
|
return () => {
|
|
|
setIsLoading(true);
|
|
setIsLoading(true);
|
|
|
window.clearInterval(id);
|
|
window.clearInterval(id);
|
|
|
};
|
|
};
|
|
|
}, [currentProject, currentCluster, props.currentChart]);
|
|
}, [currentProject, currentCluster, props.currentChart]);
|
|
|
|
|
|
|
|
|
|
+ if (isError) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Placeholder>
|
|
|
|
|
+ Error loading events.
|
|
|
|
|
+ </Placeholder>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (isLoading) {
|
|
if (isLoading) {
|
|
|
return (
|
|
return (
|
|
|
<Placeholder>
|
|
<Placeholder>
|