-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathProjectOverviewPage.tsx
More file actions
315 lines (298 loc) · 10.2 KB
/
ProjectOverviewPage.tsx
File metadata and controls
315 lines (298 loc) · 10.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
import React, { useContext } from "react";
import {
EuiPageTemplate,
EuiText,
EuiFlexGroup,
EuiFlexItem,
EuiTitle,
EuiSpacer,
EuiSkeletonText,
EuiEmptyPrompt,
EuiFieldSearch,
EuiPanel,
EuiStat,
EuiCard,
} from "@elastic/eui";
import { useDocumentTitle } from "../hooks/useDocumentTitle";
import ObjectsCountStats from "../components/ObjectsCountStats";
import ExplorePanel from "../components/ExplorePanel";
import useLoadRegistry from "../queries/useLoadRegistry";
import RegistryPathContext from "../contexts/RegistryPathContext";
import RegistryVisualizationTab from "../components/RegistryVisualizationTab";
import RegistrySearch from "../components/RegistrySearch";
import { useParams, useNavigate } from "react-router-dom";
import { useLoadProjectsList } from "../contexts/ProjectListContext";
// Component for "All Projects" view
const AllProjectsDashboard = () => {
const registryUrl = useContext(RegistryPathContext);
const navigate = useNavigate();
const { data: projectsData } = useLoadProjectsList();
const { data: registryData } = useLoadRegistry(registryUrl);
if (!registryData) {
return <EuiSkeletonText lines={10} />;
}
// Calculate total counts across all projects
const totalCounts = {
featureViews: registryData.objects.featureViews?.length || 0,
entities: registryData.objects.entities?.length || 0,
dataSources: registryData.objects.dataSources?.length || 0,
featureServices: registryData.objects.featureServices?.length || 0,
features: registryData.allFeatures?.length || 0,
};
// Get projects from registry and count their objects
const projects = projectsData?.projects.filter((p) => p.id !== "all") || [];
const projectStats = projects.map((project) => {
const projectFVs =
registryData.objects.featureViews?.filter(
(fv: any) => fv?.spec?.project === project.id,
) || [];
const projectEntities =
registryData.objects.entities?.filter(
(e: any) => e?.spec?.project === project.id,
) || [];
const projectFeatures =
registryData.allFeatures?.filter((f: any) => f?.project === project.id) ||
[];
return {
...project,
counts: {
featureViews: projectFVs.length,
entities: projectEntities.length,
features: projectFeatures.length,
},
};
});
return (
<EuiPageTemplate panelled>
<EuiPageTemplate.Section>
<EuiTitle size="l">
<h1>All Projects Overview</h1>
</EuiTitle>
<EuiSpacer />
<EuiText>
<p>
View aggregated statistics and explore data across all your Feast
projects.
</p>
</EuiText>
<EuiSpacer size="l" />
{/* Total Stats */}
<EuiPanel hasBorder>
<EuiTitle size="s">
<h3>Total Across All Projects</h3>
</EuiTitle>
<EuiSpacer size="m" />
<EuiFlexGroup>
<EuiFlexItem>
<EuiStat
title={totalCounts.featureViews.toString()}
description="Feature Views"
titleSize="m"
textAlign="center"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiStat
title={totalCounts.entities.toString()}
description="Entities"
titleSize="m"
textAlign="center"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiStat
title={totalCounts.features.toString()}
description="Features"
titleSize="m"
textAlign="center"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiStat
title={totalCounts.featureServices.toString()}
description="Feature Services"
titleSize="m"
textAlign="center"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiStat
title={totalCounts.dataSources.toString()}
description="Data Sources"
titleSize="m"
textAlign="center"
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
<EuiSpacer size="l" />
{/* Individual Projects */}
<EuiTitle size="s">
<h3>Projects ({projects.length})</h3>
</EuiTitle>
<EuiSpacer size="m" />
<EuiFlexGroup gutterSize="l" wrap>
{projectStats.map((project) => (
<EuiFlexItem
key={project.id}
style={{ minWidth: "300px", maxWidth: "400px" }}
>
<EuiCard
title={project.name}
description={project.description}
onClick={() => navigate(`/p/${project.id}`)}
style={{ cursor: "pointer" }}
>
<EuiSpacer size="s" />
<EuiFlexGroup justifyContent="spaceAround" gutterSize="s">
<EuiFlexItem grow={false}>
<EuiText size="s" textAlign="center">
<strong>{project.counts.featureViews}</strong>
<br />
<span style={{ fontSize: "0.85em", color: "#69707D" }}>
Feature Views
</span>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s" textAlign="center">
<strong>{project.counts.entities}</strong>
<br />
<span style={{ fontSize: "0.85em", color: "#69707D" }}>
Entities
</span>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s" textAlign="center">
<strong>{project.counts.features}</strong>
<br />
<span style={{ fontSize: "0.85em", color: "#69707D" }}>
Features
</span>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
</EuiCard>
</EuiFlexItem>
))}
</EuiFlexGroup>
</EuiPageTemplate.Section>
</EuiPageTemplate>
);
};
const ProjectOverviewPage = () => {
useDocumentTitle("Feast Home");
const registryUrl = useContext(RegistryPathContext);
const { projectName } = useParams<{ projectName: string }>();
const { isLoading, isSuccess, isError, data } = useLoadRegistry(
registryUrl,
projectName,
);
// Show aggregated dashboard for "All Projects" view
if (projectName === "all") {
return <AllProjectsDashboard />;
}
const categories = [
{
name: "Data Sources",
data: data?.objects.dataSources || [],
getLink: (item: any) => `/p/${projectName}/data-source/${item.name}`,
},
{
name: "Entities",
data: data?.objects.entities || [],
getLink: (item: any) => `/p/${projectName}/entity/${item.name}`,
},
{
name: "Features",
data: data?.allFeatures || [],
getLink: (item: any) => {
const featureView = item?.featureView;
return featureView
? `/p/${projectName}/feature-view/${featureView}/feature/${item.name}`
: "#";
},
},
{
name: "Feature Views",
data: data?.mergedFVList || [],
getLink: (item: any) => `/p/${projectName}/feature-view/${item.name}`,
},
{
name: "Feature Services",
data: data?.objects.featureServices || [],
getLink: (item: any) => {
const serviceName = item?.name || item?.spec?.name;
return serviceName
? `/p/${projectName}/feature-service/${serviceName}`
: "#";
},
},
];
return (
<EuiPageTemplate panelled>
<EuiPageTemplate.Section>
<EuiTitle size="l">
<h1>
{isLoading && <EuiSkeletonText lines={1} />}
{isSuccess && data?.project && `Project: ${data.project}`}
</h1>
</EuiTitle>
<EuiSpacer />
<EuiFlexGroup>
<EuiFlexItem grow={2}>
{isLoading && <EuiSkeletonText lines={4} />}
{isError && (
<EuiEmptyPrompt
iconType="alert"
color="danger"
title={<h2>Error Loading Project Configs</h2>}
body={
<p>
There was an error loading the Project Configurations.
Please check that <code>feature_store.yaml</code> file is
available and well-formed.
</p>
}
/>
)}
{isSuccess &&
(data?.description ? (
<EuiText>
<pre>{data.description}</pre>
</EuiText>
) : (
<EuiText>
<p>
Welcome to your new Feast project. In this UI, you can see
Data Sources, Entities, Features, Feature Views, and Feature
Services registered in Feast.
</p>
<p>
It looks like this project already has some objects
registered. If you are new to this project, we suggest
starting by exploring the Feature Services, as they
represent the collection of Feature Views serving a
particular model.
</p>
<p>
<strong>Note</strong>: We encourage you to replace this
welcome message with more suitable content for your team.
You can do so by specifying a{" "}
<code>project_description</code> in your{" "}
<code>feature_store.yaml</code> file.
</p>
</EuiText>
))}
<ObjectsCountStats />
</EuiFlexItem>
<EuiFlexItem grow={1}>
<ExplorePanel />
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageTemplate.Section>
</EuiPageTemplate>
);
};
export default ProjectOverviewPage;