From a9db2f224ddbaa6d9bca171bce4953def627c141 Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Fri, 14 Feb 2025 14:46:14 +0100 Subject: [PATCH] ui: event page --- frontend/app/PrivateRoutes.tsx | 9 ++ .../DataManagement/Activity/data/Event.ts | 2 + .../DataManagement/UsersEvents/EventPage.tsx | 133 ++++++++++++++++++ .../DataManagement/UsersEvents/ListPage.tsx | 15 +- frontend/app/routes.ts | 2 + 5 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 frontend/app/components/DataManagement/UsersEvents/EventPage.tsx diff --git a/frontend/app/PrivateRoutes.tsx b/frontend/app/PrivateRoutes.tsx index 6ed5c201d..d5aed7776 100644 --- a/frontend/app/PrivateRoutes.tsx +++ b/frontend/app/PrivateRoutes.tsx @@ -40,6 +40,7 @@ const components: any = { ActivityPure: lazy(() => import('Components/DataManagement/Activity/Page')), UserPage: lazy(() => import('Components/DataManagement/UsersEvents/UserPage')), UsersEventsPage: lazy(() => import('Components/DataManagement/UsersEvents/ListPage')), + EventPage: lazy(() => import('Components/DataManagement/UsersEvents/EventPage')), }; const enhancedComponents: any = { @@ -66,6 +67,7 @@ const enhancedComponents: any = { Activity: components.ActivityPure, UserPage: components.UserPage, UsersEventsPage: components.UsersEventsPage, + EventPage: components.EventPage, }; const withSiteId = routes.withSiteId; @@ -119,6 +121,7 @@ const DATA_MANAGEMENT = { ACTIVITY: routes.dataManagement.activity(), USER_PAGE: routes.dataManagement.userPage(), USERS_EVENTS: routes.dataManagement.usersEvents(), + EVENT_PAGE: routes.dataManagement.eventPage(), } function PrivateRoutes() { @@ -320,6 +323,12 @@ function PrivateRoutes() { path={withSiteId(DATA_MANAGEMENT.USERS_EVENTS, siteIdList)} component={enhancedComponents.UsersEventsPage} /> + {Object.entries(routes.redirects).map(([fr, to]) => ( ))} diff --git a/frontend/app/components/DataManagement/Activity/data/Event.ts b/frontend/app/components/DataManagement/Activity/data/Event.ts index 5ee3d3810..fe57c3fa1 100644 --- a/frontend/app/components/DataManagement/Activity/data/Event.ts +++ b/frontend/app/components/DataManagement/Activity/data/Event.ts @@ -14,6 +14,7 @@ export interface EventData { export default class Event { name: string; + eventId: string; displayName: string; description: string; monthVolume: number; @@ -54,6 +55,7 @@ export default class Event { monthQuery: number; }) { this.name = name; + this.eventId = 'asdasd'; this.time = time; this.defaultFields = defaultFields; this.customFields = customFields; diff --git a/frontend/app/components/DataManagement/UsersEvents/EventPage.tsx b/frontend/app/components/DataManagement/UsersEvents/EventPage.tsx new file mode 100644 index 000000000..cfa255d70 --- /dev/null +++ b/frontend/app/components/DataManagement/UsersEvents/EventPage.tsx @@ -0,0 +1,133 @@ +import React from 'react'; +import { Button, Input, Segmented, Table } from 'antd'; +import Breadcrumb from 'Shared/Breadcrumb'; +import Event from 'Components/DataManagement/Activity/data/Event'; +import { Triangle } from '../Activity/EventDetailsModal'; +import cn from 'classnames'; +import { EditOutlined } from '@ant-design/icons'; + +const testAutoEv = new Event({ + name: 'auto test ev', + time: Date.now(), + defaultFields: { + userId: '123', + userLocation: 'NY', + userEnvironment: 'Mac OS', + }, + customFields: {}, + isAutoCapture: true, + sessionId: '123123', + displayName: 'Test Auto Event', + description: 'This is A test Auto Event', + monthQuery: 100, + monthVolume: 1000, +}); + +function EventPage() { + const [tab, setTab] = React.useState('all'); + const tabs = [ + { + label: 'All Properties', + value: 'all', + }, + { + label: 'Custom Properties', + value: 'custom', + }, + { + label: 'Default Properties', + value: 'default', + } + ] + return ( +
+ +
+
+
+ {testAutoEv.name} +
+
+ Play Sessions + +
+
+ null} fieldName={'Display Name'} value={testAutoEv.displayName} /> + null} fieldName={'Description'} value={testAutoEv.description} /> + null} fieldName={'30 Day Volume'} value={testAutoEv.monthVolume} /> +
+ +
+
+
Event Properties
+ setTab(v)} /> +
+
+
+ ); +} + +function EditableField({ + onSave, + fieldName, + value, +}: { + onSave: (value: string) => void + fieldName: string + value: string +}) { + const [isEdit, setIsEdit] = React.useState(false); + return ( +
+
+ {fieldName} +
+
+ {isEdit ? ( +
+ +
+ + +
+ ) : ( +
+ {value} +
setIsEdit(true)}> + +
+
+ )} +
+
+ ); +} + +export default EventPage \ No newline at end of file diff --git a/frontend/app/components/DataManagement/UsersEvents/ListPage.tsx b/frontend/app/components/DataManagement/UsersEvents/ListPage.tsx index 40ed25eb3..a18f1e1c3 100644 --- a/frontend/app/components/DataManagement/UsersEvents/ListPage.tsx +++ b/frontend/app/components/DataManagement/UsersEvents/ListPage.tsx @@ -20,6 +20,8 @@ function ListPage() { const history = useHistory(); const toUser = (id: string) => history.push(withSiteId(dataManagement.userPage(id), siteId)); + const toEvent = (id: string) => + history.push(withSiteId(dataManagement.eventPage(id), siteId)); const [view, setView] = React.useState('users'); const views = [ @@ -50,12 +52,12 @@ function ListPage() {
- {view === 'users' ? : } + {view === 'users' ? : } ); } -function EventsList() { +function EventsList({ toEvent }: { toEvent: (id: string) => void }) { const columns = [ { title: 'Event Name', @@ -99,7 +101,14 @@ function EventsList() { const limit = 10; return (
- +
({ + onClick: () => toEvent(record.eventId), + })} + /> '/data-management/activity', userPage: (id = ':userId', hash?: string | number) => hashed(`/data-management/user/${id}`, hash), usersEvents: () => '/data-management/users-and-events', + eventPage: (id = ':eventId', hash?: string | number) => hashed(`/data-management/event/${id}`, hash), } const REQUIRED_SITE_ID_ROUTES = [ @@ -201,6 +202,7 @@ const REQUIRED_SITE_ID_ROUTES = [ dataManagement.activity(), dataManagement.userPage(''), dataManagement.usersEvents(), + dataManagement.eventPage(''), ]; const routeNeedsSiteId = (path: string): boolean => REQUIRED_SITE_ID_ROUTES.some(r => path.startsWith(r)); const siteIdToUrl = (siteId = ':siteId'): string => {