|
@@ -1,7 +1,9 @@
|
|
|
-import EventCard from "components/EventCard";
|
|
|
|
|
-import EventLogs from "components/EventLogs";
|
|
|
|
|
import React, { useEffect, useState } from "react";
|
|
import React, { useEffect, useState } from "react";
|
|
|
import styled from "styled-components";
|
|
import styled from "styled-components";
|
|
|
|
|
+import backArrow from "assets/back_arrow.png";
|
|
|
|
|
+import Dropdown from "components/Dropdown";
|
|
|
|
|
+import EventCard from "components/EventCard";
|
|
|
|
|
+import EventLogs from "components/EventLogs";
|
|
|
|
|
|
|
|
const mockData = [
|
|
const mockData = [
|
|
|
{
|
|
{
|
|
@@ -110,12 +112,17 @@ type EventsTabProps = {};
|
|
|
const EventsTab: React.FunctionComponent<EventsTabProps> = () => {
|
|
const EventsTab: React.FunctionComponent<EventsTabProps> = () => {
|
|
|
const [eventList, setEventList] = useState<Event[]>([]);
|
|
const [eventList, setEventList] = useState<Event[]>([]);
|
|
|
const [selectedEvent, setSelectedEvent] = useState<Event>(null);
|
|
const [selectedEvent, setSelectedEvent] = useState<Event>(null);
|
|
|
|
|
+ const [currentFilter, setCurrentFilter] = useState<string>("all");
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
|
- setEventList(mockData as Event[]);
|
|
|
|
|
|
|
+ setEventList(
|
|
|
|
|
+ (mockData as Event[]).filter(
|
|
|
|
|
+ (e) => currentFilter === "all" || e.resource_type === currentFilter
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
}, 500);
|
|
}, 500);
|
|
|
- }, []);
|
|
|
|
|
|
|
+ }, [currentFilter]);
|
|
|
|
|
|
|
|
const selectEvent = (id: number) => {
|
|
const selectEvent = (id: number) => {
|
|
|
const event = eventList.find((e) => e.id === id);
|
|
const event = eventList.find((e) => e.id === id);
|
|
@@ -126,29 +133,54 @@ const EventsTab: React.FunctionComponent<EventsTabProps> = () => {
|
|
|
setSelectedEvent(null);
|
|
setSelectedEvent(null);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const handleEventTypeSelection = (option: {
|
|
|
|
|
+ label: string;
|
|
|
|
|
+ value: string;
|
|
|
|
|
+ }) => {
|
|
|
|
|
+ console.log(option);
|
|
|
|
|
+ setCurrentFilter(option.value);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<NamespaceListWrapper>
|
|
<NamespaceListWrapper>
|
|
|
- <ControlRow>
|
|
|
|
|
- <button>
|
|
|
|
|
- <i className="material-icons">add</i> Add namespace
|
|
|
|
|
- </button>
|
|
|
|
|
- </ControlRow>
|
|
|
|
|
-
|
|
|
|
|
{!selectedEvent && (
|
|
{!selectedEvent && (
|
|
|
- <EventsGrid>
|
|
|
|
|
- {eventList.map((event) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <EventCard
|
|
|
|
|
- key={event.id}
|
|
|
|
|
- event={event}
|
|
|
|
|
- selectEvent={selectEvent}
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <ControlRow>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <Dropdown
|
|
|
|
|
+ options={[
|
|
|
|
|
+ { label: "All", value: "all" },
|
|
|
|
|
+ { label: "Pods", value: "pod" },
|
|
|
|
|
+ { label: "HPA", value: "HPA" },
|
|
|
|
|
+ ]}
|
|
|
|
|
+ onSelect={handleEventTypeSelection}
|
|
|
/>
|
|
/>
|
|
|
- );
|
|
|
|
|
- })}
|
|
|
|
|
- </EventsGrid>
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </ControlRow>
|
|
|
|
|
+ <EventsGrid>
|
|
|
|
|
+ {eventList.map((event) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <EventCard
|
|
|
|
|
+ key={event.id}
|
|
|
|
|
+ event={event}
|
|
|
|
|
+ selectEvent={selectEvent}
|
|
|
|
|
+ />
|
|
|
|
|
+ );
|
|
|
|
|
+ })}
|
|
|
|
|
+ </EventsGrid>
|
|
|
|
|
+ </>
|
|
|
)}
|
|
)}
|
|
|
{selectedEvent && (
|
|
{selectedEvent && (
|
|
|
- <EventLogs event={selectedEvent} goBack={clearSelectedEvent} />
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ <ControlRow>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <BackButton onClick={clearSelectedEvent}>
|
|
|
|
|
+ <BackButtonImg src={backArrow} />
|
|
|
|
|
+ </BackButton>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </ControlRow>
|
|
|
|
|
+ <EventLogs event={selectedEvent} />
|
|
|
|
|
+ </>
|
|
|
)}
|
|
)}
|
|
|
</NamespaceListWrapper>
|
|
</NamespaceListWrapper>
|
|
|
);
|
|
);
|
|
@@ -174,3 +206,27 @@ const EventsGrid = styled.div`
|
|
|
grid-row-gap: 15px;
|
|
grid-row-gap: 15px;
|
|
|
grid-template-columns: 1;
|
|
grid-template-columns: 1;
|
|
|
`;
|
|
`;
|
|
|
|
|
+
|
|
|
|
|
+const BackButton = styled.div`
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ width: 36px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ height: 36px;
|
|
|
|
|
+ align-items: center;
|
|
|
|
|
+ justify-content: center;
|
|
|
|
|
+ border: 1px solid #ffffff55;
|
|
|
|
|
+ border-radius: 100px;
|
|
|
|
|
+ background: #ffffff11;
|
|
|
|
|
+
|
|
|
|
|
+ :hover {
|
|
|
|
|
+ background: #ffffff22;
|
|
|
|
|
+ > img {
|
|
|
|
|
+ opacity: 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+`;
|
|
|
|
|
+
|
|
|
|
|
+const BackButtonImg = styled.img`
|
|
|
|
|
+ width: 16px;
|
|
|
|
|
+ opacity: 0.75;
|
|
|
|
|
+`;
|