Skip to content

Commit bc81849

Browse files
Integrate kanri directly into ddf-ui
- Integrates kanri directly into ddf-ui, incorporating the branding that was previously an extension point. - Removes code around mocks for now
1 parent a0fa61a commit bc81849

File tree

102 files changed

+13261
-1936
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+13261
-1936
lines changed

ui-frontend/packages/admin/package.json

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,59 @@
1313
"node": "20.x.x"
1414
},
1515
"devDependencies": {
16+
"@connexta/ace": "git+https://github.com/connexta/ace.git#20166c642d60c5c67626f89108c6b72d1451e62f",
17+
"@types/dropzone": "5.0.6",
18+
"@types/lodash": "4.17.16",
1619
"@types/react": "16.9.34",
1720
"@types/react-dom": "16.9.7",
18-
"@types/styled-components": "5.1.0",
19-
"@connexta/ace": "git+https://github.com/connexta/ace.git#20166c642d60c5c67626f89108c6b72d1451e62f",
21+
"@types/react-redux": "5.0.28",
22+
"@types/react-router-dom": "5.1.5",
23+
"@types/react-select": "3.0.12",
24+
"@types/redux-immutable": "3.0.43",
25+
"@types/styled-components": "4.0.3",
26+
"@types/traverse": "0.6.37",
27+
"@types/validator": "13.12.2",
2028
"npm": "10.9.2"
2129
},
2230
"dependencies": {
23-
"@connexta/kanri": "0.0.18",
2431
"@material-ui/core": "4.9.12",
2532
"@material-ui/icons": "4.9.1",
2633
"@material-ui/lab": "4.0.0-alpha.51",
2734
"@material-ui/pickers": "3.2.10",
35+
"ace-builds": "1.39.0",
36+
"autoprefixer": "10.4.20",
37+
"clsx": "1.2.1",
38+
"dropzone": "5.5.1",
39+
"formik": "2.3.3",
40+
"fuse.js": "3.4.5",
41+
"golden-layout": "1.5.9",
42+
"immutable": "3.8.2",
43+
"lodash": "4.17.21",
44+
"moment": "2.29.4",
2845
"notistack": "0.9.11",
46+
"ohash": "2.0.11",
47+
"postcss-focus-visible": "8.0.2",
48+
"prop-types": "15.7.2",
49+
"querystring": "0.2.0",
2950
"react": "16.13.1",
51+
"react-ace": "14.0.1",
3052
"react-dom": "16.13.1",
31-
"react-select": "3.1.0",
53+
"react-redux": "5.1.1",
3254
"react-router-dom": "5.1.2",
33-
"styled-components": "5.1.0"
55+
"react-select": "3.1.0",
56+
"react-visibility-sensor": "5.0.2",
57+
"redux": "3.7.2",
58+
"redux-immutable": "3.1.0",
59+
"redux-thunk": "2.4.2",
60+
"scroll-into-view-if-needed": "2.2.20",
61+
"styled-components": "5.1.0",
62+
"tailwindcss": "3.4.17",
63+
"traverse": "0.6.11",
64+
"type-fest": "4.37.0",
65+
"typescript": "5.8.2",
66+
"url": "0.11.0",
67+
"validator": "13.12.0",
68+
"yup": "1.4.0"
3469
},
3570
"scripts": {
3671
"start": "ace start",
@@ -43,6 +78,6 @@
4378
"target/webapp",
4479
"src/main/resources"
4580
],
46-
"main": "src/components/entry/entry",
81+
"main": "src/main/webapp/components/entry/default-entry.tsx",
4782
"context-path": "/admin"
4883
}
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
const upstreamConfig = require('@connexta/kanri/postcss.config.js')
2-
module.exports = upstreamConfig
1+
const tailwindcss = require('tailwindcss')
2+
const postcssFocusVisible = require('postcss-focus-visible')
3+
module.exports = {
4+
plugins: [
5+
tailwindcss('./tailwind.config.js'),
6+
postcssFocusVisible(),
7+
require('autoprefixer'),
8+
],
9+
}

ui-frontend/packages/admin/src/components/entry/entry.tsx

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
import * as React from 'react'
2+
import { COMMANDS } from '../fetch/fetch'
3+
import Paper from '@material-ui/core/Paper'
4+
import Grid from '@material-ui/core/Grid'
5+
import Typography from '@material-ui/core/Typography'
6+
import { useAppRootContext } from '../app-root/app-root.pure'
7+
import Button from '@material-ui/core/Button'
8+
import CloseIcon from '@material-ui/icons/Close'
9+
10+
const ALERTS_DISMISS_URL =
11+
'/admin/jolokia/exec/org.codice.ddf.ui.admin.api:type=AdminAlertMBean/dismissAlert'
12+
13+
const createPayload = (alertId: string) => {
14+
return {
15+
type: 'EXEC',
16+
mbean: 'org.codice.ddf.ui.admin.api:type=AdminAlertMBean',
17+
operation: 'dismissAlert',
18+
arguments: [alertId],
19+
}
20+
}
21+
22+
export const Alerts = () => {
23+
const { alerts, fetchAlerts } = useAppRootContext()
24+
const [loading, setLoading] = React.useState(false)
25+
return (
26+
<>
27+
<Typography variant="h4" align="center" style={{ marginBottom: '20px' }}>
28+
Alerts
29+
</Typography>
30+
<Grid
31+
container
32+
direction="column"
33+
wrap="nowrap"
34+
spacing={3}
35+
style={{ width: '100%', height: '100%', overflow: 'auto' }}
36+
>
37+
{alerts.map((alert) => {
38+
return (
39+
<Grid item key={alert.id}>
40+
<Paper style={{ padding: '20px' }}>
41+
<Grid container direction="column" spacing={3}>
42+
<Grid item>
43+
<Grid container justify="space-between" alignItems="center">
44+
<Grid item>
45+
<Typography variant="h6">{alert.title}</Typography>
46+
</Grid>
47+
<Grid item>
48+
{alert.id ? (
49+
<Button
50+
disabled={loading}
51+
color="secondary"
52+
onClick={async () => {
53+
if (alert.id === undefined) {
54+
return
55+
}
56+
setLoading(true)
57+
await COMMANDS.FETCH(ALERTS_DISMISS_URL, {
58+
method: 'POST',
59+
body: JSON.stringify(createPayload(alert.id)),
60+
})
61+
await fetchAlerts()
62+
setLoading(false)
63+
}}
64+
>
65+
<CloseIcon />
66+
</Button>
67+
) : null}
68+
</Grid>
69+
</Grid>
70+
</Grid>
71+
{alert.id ? (
72+
<Grid item>
73+
<Typography>
74+
Dismiss this alert at your own risk. This alert may be
75+
repopulated if the issue persists.
76+
</Typography>
77+
<Typography>
78+
Host: {alert.hostName} : {alert.hostAddress}
79+
</Typography>
80+
</Grid>
81+
) : null}
82+
83+
{alert.details.map((detail, index) => {
84+
return (
85+
<Grid item key={index}>
86+
<Typography>{detail}</Typography>
87+
</Grid>
88+
)
89+
})}
90+
</Grid>
91+
</Paper>
92+
</Grid>
93+
)
94+
})}
95+
</Grid>
96+
</>
97+
)
98+
}
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
import * as React from 'react'
2+
import { RouteChildrenProps } from 'react-router'
3+
import { setType } from '../../typescript/hooks'
4+
5+
export type PlatformConfigType = {
6+
background: string
7+
color: string
8+
favIcon: string
9+
footer: string
10+
header: string
11+
productImage: string
12+
systemUsageMessage?: string
13+
systemUsageOncePerSession?: boolean
14+
systemUsageTitle?: string
15+
timeout: number
16+
title: string
17+
vendorImage: string
18+
version: string
19+
}
20+
21+
export type AdminConfigType = {
22+
branding: string
23+
disabledInstallerApps: string
24+
}
25+
26+
export type AlertType = {
27+
alertAttribute?: string
28+
alertLevel?: string
29+
alertPattern?: string
30+
count?: number
31+
createddate?: string
32+
'event.topics'?: string
33+
details: string[]
34+
hostAddress?: string
35+
hostName?: string
36+
id?: string
37+
'last-updated'?: string
38+
noticeTime?: string
39+
priority?: number
40+
source?: string
41+
status?: string
42+
timestamp?: number
43+
title: string
44+
type?: string
45+
}
46+
47+
export type ModuleType = {
48+
iframeLocation: string
49+
name: string
50+
active: boolean
51+
cssLocation: string
52+
id: string
53+
jsLocation: string
54+
}
55+
56+
export type ApplicationType = {
57+
name: string
58+
description: string
59+
}
60+
61+
export type ApplicationTheme = 'light' | 'dark'
62+
63+
export type MetatypeType = {
64+
value: string[]
65+
cardinality: number
66+
defaultValue: string[]
67+
description: string | null
68+
id: string
69+
name: string
70+
optionLabels: string[]
71+
optionValues: string[]
72+
type: number
73+
touched: boolean
74+
initialTouched: boolean
75+
}
76+
77+
export type ExistingConfigurationType = {
78+
bundle: number
79+
bundle_location: string
80+
bundle_name: string
81+
enabled: boolean
82+
fpid?: string
83+
id: string
84+
name: string
85+
properties: {
86+
[key: string]: string | boolean | number | string[] | boolean[] | number[]
87+
}
88+
operation_actions?: any[] // these appear unique to source configurations
89+
report_actions?: any[] // these appear unique to source configurations
90+
// Let the child access parent info like metatype (we do this in our parsing, it's not a default prop from backend)
91+
service?: ConfigurationType
92+
}
93+
94+
export type ConfigurationType = {
95+
configurations?: ExistingConfigurationType[]
96+
factory: boolean
97+
id: string
98+
fpid?: string
99+
metatype: MetatypeType[]
100+
name: string
101+
}
102+
103+
export type FeatureType = {
104+
name: string
105+
repository: string
106+
status: 'Uninstalled' | 'Installed'
107+
version: string
108+
}
109+
110+
// create context with no upfront defaultValue
111+
// without having to do undefined check all the time
112+
export function createCtx<A>() {
113+
const ctx = React.createContext<A | undefined>(undefined)
114+
function useCtx() {
115+
const c = React.useContext(ctx)
116+
if (!c) throw new Error('useCtx must be inside a Provider with a value')
117+
return c
118+
}
119+
return [useCtx, ctx.Provider] as const // make TypeScript infer a tuple, not an array of union types
120+
}
121+
122+
export type ExtensionType =
123+
| {
124+
links?: {
125+
name: string
126+
shortName: string
127+
url: string
128+
Icon: any
129+
content: (props: any) => JSX.Element
130+
}[]
131+
handleModuleRouting?: (moduleId: string) => JSX.Element | undefined
132+
}
133+
| undefined
134+
135+
export const [useAppRootContext, AppRootContextProvider] = createCtx<{
136+
platformConfig: PlatformConfigType
137+
adminConfig: AdminConfigType
138+
alerts: AlertType[]
139+
fetchAlerts: () => Promise<void>
140+
sourceConfigurations: ConfigurationType[]
141+
fetchSourceConfigurations: () => Promise<void>
142+
loadingSourceConfigurations: boolean
143+
isSourceFactoryId: (fpid?: string) => boolean
144+
sourceFactoryIds: string[]
145+
isSourceConfiguration: (configuration: ExistingConfigurationType) => boolean
146+
modules: ModuleType[]
147+
fetchModules: () => Promise<void>
148+
applications: ApplicationType[]
149+
fetchApplications: () => Promise<void>
150+
theme: ApplicationTheme
151+
setTheme: setType<ApplicationTheme>
152+
extension?: ExtensionType
153+
}>()
154+
155+
export const [useRouteContext, RouteContextProvider] = createCtx<{
156+
routeProps: RouteChildrenProps
157+
}>()

0 commit comments

Comments
 (0)