Skip to content

Commit f19bebe

Browse files
authored
Merge pull request #204 from amosproj/refactor/frontend
refactor frontend
2 parents 951d727 + 2270435 commit f19bebe

37 files changed

+507
-2007
lines changed

frontend/src/App.tsx

Lines changed: 8 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -15,93 +15,20 @@ import NamespaceGroup from './routes/namespace'
1515
import TenantGroup from './routes/tenant'
1616
import TopicGroup from './routes/topic'
1717

18-
const allData: Array<SampleCluster> = []
19-
const allMessages: Array<SampleMessage> = []
20-
18+
/**
19+
* The main application component.
20+
* It sets up the main routes for the application and also renders the main Dashboard and NavBar components.
21+
*
22+
* @component
23+
* @returns The main application component rendered to the DOM.
24+
*/
2125
function App() {
22-
const view = useAppSelector(selectView)
23-
/** Landing Page Logic */
24-
// const showLP = useAppSelector(selectShowLP)
25-
/** End of Landing Page Logic */
26-
27-
/*const allTenants = allData
28-
.map((item) => item.tenants)
29-
.filter((el) => el.length > 0)
30-
.flat()
31-
32-
const allNamespaces = allTenants
33-
.map((tenant) => tenant.namespaces)
34-
.filter((el) => el.length > 0)
35-
.flat()
36-
37-
const allTopics = allNamespaces
38-
.map((namespace) => namespace.topics)
39-
.filter((el) => el.length > 0)
40-
.flat()*/
41-
42-
/*const allMessages = allData
43-
.flatMap((item) => item.namespaces)
44-
.flatMap((namespace) => namespace.topics)
45-
.map((topic) => topic.messages)
46-
.filter((el) => el.length > 0)
47-
.flat()*/
48-
49-
/*let filteredData:
50-
| Array<SampleCluster>
51-
| Array<SampleNamespace>
52-
| Array<SampleTopic> = allData
53-
54-
if (view.selectedNav === 'namespace') {
55-
filteredData = allNamespaces
56-
} else if (view.selectedNav === 'topic') {
57-
filteredData = allTopics
58-
}*/
59-
60-
/*const selectNewElement = (
61-
item: SampleCluster | SampleNamespace | SampleTopic
62-
) => {
63-
const selEl = getNewElementTag(item.tag, item.id)
64-
console.log(selEl)
65-
//dispatch(setNav(selEl[0]))
66-
}*/
67-
68-
//can later on be replaced by the fetchDataThunk
69-
/*const getData = () => {
70-
fetch('dummy/dummyClusters.json', {
71-
headers: {
72-
'Content-Type': 'application/json',
73-
Accept: 'application/json',
74-
},
75-
})
76-
.then(function (response) {
77-
return response.json()
78-
})
79-
.then(function (json) {
80-
allData = json
81-
})
82-
}*/
83-
84-
/*const getMessages = () => {
85-
fetch('dummy/dummyMessages.json', {
86-
headers: {
87-
'Content-Type': 'application/json',
88-
Accept: 'application/json',
89-
},
90-
})
91-
.then(function (response) {
92-
return response.json()
93-
})
94-
.then(function (json) {
95-
allMessages = json
96-
})
97-
}*/
98-
9926
return (
10027
<>
10128
<Router>
10229
<div className="dashboard-container">
10330
<NavBar />
104-
<Dashboard completeMessages={allMessages} view={view.selectedNav}>
31+
<Dashboard>
10532
<Routes>
10633
<Route path="/" element={<ClusterGroup />}></Route>
10734
<Route path="/cluster" element={<ClusterGroup />}></Route>

frontend/src/Helpers.tsx

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -2,94 +2,6 @@
22
// SPDX-FileCopyrightText: 2010-2021 Dirk Riehle <dirk@riehle.org
33
// SPDX-FileCopyrightText: 2019 Georg Schwarz <georg. schwarz@fau.de>
44

5-
export function instanceOfSampleCluster(
6-
object:
7-
| SampleCluster
8-
| SampleTenant
9-
| SampleNamespace
10-
| SampleTopic
11-
| SampleMessage
12-
): object is SampleCluster {
13-
if (object) {
14-
return 'tenants' in object
15-
} else return false
16-
}
17-
18-
export function instanceOfSampleNamespace(
19-
object:
20-
| SampleCluster
21-
| SampleTenant
22-
| SampleNamespace
23-
| SampleTopic
24-
| SampleMessage
25-
): object is SampleNamespace {
26-
if (object) {
27-
return 'topics' in object
28-
} else return false
29-
}
30-
31-
export function instanceOfSampleTopic(
32-
object:
33-
| SampleCluster
34-
| SampleTenant
35-
| SampleNamespace
36-
| SampleTopic
37-
| SampleMessage
38-
): object is SampleTopic {
39-
if (object) {
40-
return 'topicStatsDto' in object
41-
} else return false
42-
}
43-
44-
export function instanceOfSampleTenant(
45-
object:
46-
| SampleCluster
47-
| SampleTenant
48-
| SampleNamespace
49-
| SampleTopic
50-
| SampleMessage
51-
): object is SampleTenant {
52-
if (object) {
53-
return 'tenantInfo' in object
54-
} else return false
55-
}
56-
57-
export function instanceOfSampleMessage(
58-
object:
59-
| SampleCluster
60-
| SampleTenant
61-
| SampleNamespace
62-
| SampleTopic
63-
| SampleMessage
64-
): object is SampleMessage {
65-
if (object) {
66-
return 'payload' in object
67-
} else return false
68-
}
69-
70-
export const flattenClustersToTenants = (myClusters: Array<SampleCluster>) => {
71-
return myClusters
72-
.map((cluster) => cluster.tenants)
73-
.filter((el) => el.length > 0)
74-
.flat()
75-
}
76-
77-
export const flattenTenantsToNamespaces = (myTenants: Array<SampleTenant>) => {
78-
return myTenants
79-
.map((tenant) => tenant.namespaces)
80-
.filter((el) => el.length > 0)
81-
.flat()
82-
}
83-
84-
export const flattenNamespacesToTopics = (
85-
myNamespaces: Array<SampleNamespace>
86-
) => {
87-
return myNamespaces
88-
.map((namespace) => namespace.topics)
89-
.filter((el) => el.length > 0)
90-
.flat()
91-
}
92-
935
/**
946
* Helper function to add comma separator if not the last element.
957
* @param index the index of current element in array.

frontend/src/__tests__/Form.test.tsx

Lines changed: 0 additions & 66 deletions
This file was deleted.

frontend/src/components/Card.tsx

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)