Skip to content

Commit d258407

Browse files
committed
Bare minimum mvp working
clicking the example card now renders the communication data directly.
1 parent 8ffa343 commit d258407

5 files changed

Lines changed: 46 additions & 17 deletions

File tree

app/components/ApplicationsCard/ApplicationsCard.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ type ClickEvent = React.MouseEvent<HTMLElement>;
1313
const ApplicationsCard = (props) => {
1414

1515
const { application, i, setModal, classes } = props
16-
const { deleteApp } = useContext(DashboardContext)
17-
const { setAppIndex, setApp, setServicesData, app } = useContext(ApplicationContext)
16+
const { deleteApp,user,applications } = useContext(DashboardContext)
17+
const { setAppIndex, setApp, setServicesData, app,example,connectToDB,setChart } = useContext(ApplicationContext)
18+
const [ cardName,dbType,dbURI,description,serviceType ] = applications[i]
1819

1920
//dynamic refs
2021
const delRef = useRef<any>([]);
@@ -41,7 +42,16 @@ const ApplicationsCard = (props) => {
4142
setAppIndex(i);
4243
setApp(selectedApp);
4344
navigate(`/aws/:${app}`, { state: { typeOfService: selectedService } });
44-
} else {
45+
}
46+
else if(example) {
47+
setAppIndex(i);
48+
setApp(selectedApp);
49+
setServicesData([]);
50+
setChart('communications')
51+
52+
connectToDB(user, i, app, dbURI, dbType)
53+
}
54+
else {
4555
setAppIndex(i);
4656
setApp(selectedApp);
4757
setServicesData([]);

app/components/Occupied/Occupied.tsx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ import DashboardIcons from '../DashboardIcons/DashboardIcons';
3434
import ApplicationsCard from '../ApplicationsCard/ApplicationsCard';
3535

3636
import { useStylesLight, useStylesDark } from './helpers/muiHelper'
37+
import { Link } from 'react-router-dom';
3738

3839
//v10: Memoized function, without any props. Should theoretically be called only once.
3940
const Occupied = React.memo(() => {
40-
const { setServicesData, app } = useContext(ApplicationContext);
41+
const { setServicesData, app,example } = useContext(ApplicationContext);
4142
const { user, applications, getApplications, mode } = useContext(DashboardContext);
4243
const [ modal,setModal ] = useState({isOpen:false,type:''})
4344
const { appIndex } = useContext(ApplicationContext);
@@ -90,15 +91,23 @@ const Occupied = React.memo(() => {
9091

9192
{applications
9293
.filter((db: any) => db[0].toLowerCase().includes(searchTerm.toLowerCase()))
93-
.map((application: string[], i: any) => (
94-
<ApplicationsCard
95-
key={crypto.randomUUID()}
96-
application={application}
97-
i={i}
98-
setModal={setModal}
99-
classes={classes}
100-
/>
101-
))}
94+
.map((application: string[], i: any) => {
95+
const services = ['auth','client','event-bus','items','inventory','orders']
96+
console.log({app,services})
97+
return (
98+
<Link
99+
to={services.length > 0 ? `/applications/example/${services.join(' ')}` : '#'}
100+
>
101+
<ApplicationsCard
102+
key={crypto.randomUUID()}
103+
application={application}
104+
i={i}
105+
setModal={setModal}
106+
classes={classes}
107+
/>
108+
</Link>
109+
)
110+
})}
102111

103112
<Modal
104113
open={modal.isOpen}

app/containers/GraphsContainer/GraphsContainer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ const GraphsContainer: React.FC = React.memo(() => {
3434

3535
const { app, service } = useParams<keyof Params>() as Params;
3636
const [ live, setLive ] = useState<boolean>(false);
37-
const { intervalID, setIntervalID } = useContext(ApplicationContext);
37+
const { intervalID, setIntervalID,example,chart,setChart } = useContext(ApplicationContext);
3838
const { getSavedMetrics } = useContext(ApplicationContext);
3939
const { fetchHealthData, setHealthData } = useContext(HealthContext);
4040
const { setDockerData, dockerData } = useContext(DockerContext);
4141
const { fetchEventData, setEventData } = useContext(EventContext);
4242
// const { fetchKafkaEventData, setKafkaEventData } = useContext(EventContext);
4343
// const { fetchKubernetesEventData, setKubernetesEventData } = useContext(EventContext);
4444
const { fetchCommsData } = useContext(CommsContext);
45-
const [chart, setChart] = useState<string>('all');
45+
// const [chart, setChart] = useState<string>('all');
4646
const { mode } = useContext(DashboardContext.DashboardContext);
4747
let [inspect, setInspect] = useState<boolean>(false);
4848

app/containers/SidebarContainer.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DashboardContext } from '../context/DashboardContext';
1414
const SidebarContainer = React.memo(() => {
1515

1616
// Extract invervalID from ApplicationContext. Initival value: intervalID = null
17-
const { intervalID } = useContext(ApplicationContext);
17+
const { intervalID,setExample } = useContext(ApplicationContext);
1818
// Extract isLoading and setLoading state from AwsContext. Initial value: isLoading = true
1919
const { isLoading, setLoadingState } = useContext(AwsContext);
2020
// clear interval and set loading state to true when leaving graph containers
@@ -29,6 +29,9 @@ const SidebarContainer = React.memo(() => {
2929
};
3030

3131
const handleExample = () => {
32+
33+
setExample(true)
34+
3235
const fields = {
3336
typeOfService: 'Microservices',
3437
database: 'MongoDB',

app/context/ApplicationContext.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const ApplicationContext = React.createContext<any>(null);
2020

2121
const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props => {
2222
const children = props.children;
23+
const [ example,setExample ] = useState(false)
24+
const [chart, setChart] = useState<string>('all');
25+
2326
const [servicesData, setServicesData] = useState([]);
2427
const [app, setApp] = useState<string>('');
2528
const [savedMetrics, setSavedMetrics] = useState({});
@@ -84,7 +87,7 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
8487
data.forEach(el => {
8588
store[el.metric] = el;
8689
});
87-
console.log({store})
90+
// console.log({store})
8891
// console.log('result from getSavedMetrics is: ', store);
8992
setSavedMetrics(store);
9093
});
@@ -106,6 +109,10 @@ const ApplicationContextProvider: React.FC<AppContextProps> = React.memo(props =
106109
setAppIndex,
107110
intervalID,
108111
setIntervalID,
112+
example,
113+
setExample,
114+
chart,
115+
setChart
109116
}}
110117
>
111118
{children}

0 commit comments

Comments
 (0)