Skip to content

Commit f69f0df

Browse files
committed
wip
1 parent 518e1fd commit f69f0df

36 files changed

+10557
-64
lines changed

web/console-extensions.json

+55
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,60 @@
287287
"$codeRef": "netflowDevTab.default"
288288
}
289289
}
290+
},
291+
{
292+
"type": "console.yaml-template",
293+
"properties": {
294+
"model": {
295+
"version": "v1beta2",
296+
"group": "flows.netobserv.io",
297+
"kind": "FlowCollector"
298+
},
299+
"name": "default",
300+
"template": {
301+
"$codeRef": "yamlTemplates.FlowCollector"
302+
}
303+
}
304+
},
305+
{
306+
"type": "console.page/route",
307+
"properties": {
308+
"path": "/k8s/cluster/flows.netobserv.io~v1beta2~FlowCollector/~new/wizard",
309+
"component": {
310+
"$codeRef": "flowCollectorWizard.default"
311+
}
312+
}
313+
},
314+
{
315+
"type": "console.page/route",
316+
"properties": {
317+
"path": "/k8s/cluster/flows.netobserv.io~v1beta2~FlowCollector/~new/form",
318+
"component": {
319+
"$codeRef": "flowCollectorForm.default"
320+
}
321+
}
322+
},
323+
{
324+
"type": "console.yaml-template",
325+
"properties": {
326+
"model": {
327+
"version": "v1alpha1",
328+
"group": "flows.netobserv.io",
329+
"kind": "FlowMetric"
330+
},
331+
"name": "default",
332+
"template": {
333+
"$codeRef": "yamlTemplates.FlowMetric"
334+
}
335+
}
336+
},
337+
{
338+
"type": "console.page/route",
339+
"properties": {
340+
"path": "/k8s/cluster/flows.netobserv.io~v1alpha1~FlowMetric/~new/form",
341+
"component": {
342+
"$codeRef": "flowMetricForm.default"
343+
}
344+
}
290345
}
291346
]

web/locales/en/plugin__netobserv-plugin.json

+40-2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,46 @@
159159
"M": "M",
160160
"S": "S",
161161
"XS": "XS",
162+
"There is some issue in this form view. Please select \"YAML view\" for full control.": "There is some issue in this form view. Please select \"YAML view\" for full control.",
163+
"Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.": "Note: Some fields may not be represented in this form view. Please select \"YAML view\" for full control.",
164+
"Remove {{singularLabel}}": "Remove {{singularLabel}}",
165+
"Add {{singularLabel}}": "Add {{singularLabel}}",
166+
"Error": "Error",
167+
"Fix the following errors:": "Fix the following errors:",
168+
"Enabled": "Enabled",
169+
"Disabled": "Disabled",
170+
"Select {{title}}": "Select {{title}}",
171+
"Configure via:": "Configure via:",
172+
"Form view": "Form view",
173+
"YAML view": "YAML view",
174+
"This object has been updated.": "This object has been updated.",
175+
"Click reload to see the new version.": "Click reload to see the new version.",
176+
"Update": "Update",
177+
"Create": "Create",
178+
"Reload": "Reload",
179+
"Cancel": "Cancel",
180+
"Network Observability FlowCollector setup": "Network Observability FlowCollector setup",
181+
"Overview": "Overview",
182+
"Network Observability Operator deploys a monitoring pipeline that consists in:\n - an eBPF agent, that generates network flows from captured packets\n - flowlogs-pipeline, a component that collects, enriches and exports these flows\n - a Console plugin for flows visualization with powerful filtering options, a topology representation and more\n\nFlow data is then available in multiple ways, each optional:\n - As Prometheus metrics\n - As raw flow logs stored in Grafana Loki\n - As raw flow logs exported to a collector\n\nThe FlowCollector resource is used to configure the operator and its managed components.\nThis setup will guide you on the common aspects of the FlowCollector configuration.": "Network Observability Operator deploys a monitoring pipeline that consists in:\n - an eBPF agent, that generates network flows from captured packets\n - flowlogs-pipeline, a component that collects, enriches and exports these flows\n - a Console plugin for flows visualization with powerful filtering options, a topology representation and more\n\nFlow data is then available in multiple ways, each optional:\n - As Prometheus metrics\n - As raw flow logs stored in Grafana Loki\n - As raw flow logs exported to a collector\n\nThe FlowCollector resource is used to configure the operator and its managed components.\nThis setup will guide you on the common aspects of the FlowCollector configuration.",
183+
"Operator configuration": "Operator configuration",
184+
"Capture": "Capture",
185+
"Filters": "Filters",
186+
"Options": "Options",
187+
"Pipeline": "Pipeline",
188+
"Storage": "Storage",
189+
"Integration": "Integration",
190+
"Review": "Review",
191+
"Network Observability FlowMetric setup": "Network Observability FlowMetric setup",
192+
"You can create custom metrics out of the flowlogs data using the FlowMetric API. In every flowlogs data that is collected, there are a number of fields labeled per log, such as source name and destination name. These fields can be leveraged as Prometheus labels to enable the customization of cluster information on your dashboard.\nThis setup will guide you on the common aspects of the FlowMetric configuration.": "You can create custom metrics out of the flowlogs data using the FlowMetric API. In every flowlogs data that is collected, there are a number of fields labeled per log, such as source name and destination name. These fields can be leveraged as Prometheus labels to enable the customization of cluster information on your dashboard.\nThis setup will guide you on the common aspects of the FlowMetric configuration.",
193+
"General configuration": "General configuration",
194+
"Metric": "Metric",
195+
"Data": "Data",
196+
"Charts": "Charts",
197+
"Update {{kind}}": "Update {{kind}}",
198+
"Create {{kind}}": "Create {{kind}}",
199+
"Update by completing the form. Current values are from the existing resource.": "Update by completing the form. Current values are from the existing resource.",
200+
"Create by completing the form. Default values are provided as example.": "Create by completing the form. Default values are provided as example.",
201+
"Unable to get {{kind}}": "Unable to get {{kind}}",
162202
"Step {{index}}/{{count}}": "Step {{index}}/{{count}}",
163203
"Step {{index}}/{{count}}_plural": "Step {{index}}/{{count}}",
164204
"Previous tip": "Previous tip",
@@ -231,7 +271,6 @@
231271
"Unselect all": "Unselect all",
232272
"Select all": "Select all",
233273
"Restore default columns": "Restore default columns",
234-
"Cancel": "Cancel",
235274
"At least one column must be selected": "At least one column must be selected",
236275
"Save": "Save",
237276
"Export": "Export",
@@ -351,7 +390,6 @@
351390
"Pin this element": "Pin this element",
352391
"Could not fetch drop information": "Could not fetch drop information",
353392
"Sorry, 3D view is not implemented anymore.": "Sorry, 3D view is not implemented anymore.",
354-
"Overview": "Overview",
355393
"Traffic flows": "Traffic flows",
356394
"Topology": "Topology",
357395
"Hide histogram": "Hide histogram",

web/moduleMapper/dummy.tsx

+76-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
2+
import {
3+
K8sGroupVersionKind,
4+
K8sModel,
5+
K8sResourceKindReference,
6+
ResourceIconProps,
7+
ResourceLinkProps,
8+
ResourceYAMLEditorProps
9+
} from '@openshift-console/dynamic-plugin-sdk';
10+
import { CodeEditor, Language } from '@patternfly/react-code-editor';
111
import * as React from 'react';
2-
import { ResourceIconProps, ResourceLinkProps } from '@openshift-console/dynamic-plugin-sdk';
312
import { useK8sModelsWithColors } from '../src/utils/k8s-models-hook';
13+
import { useTheme } from '../src/utils/theme-hook';
14+
import { safeJSToYAML } from '../src/utils/yaml';
415
import { k8sModels } from './k8s-models';
516

617
// This dummy file is used to resolve @Console imports from @openshift-console for JEST / Standalone
@@ -35,6 +46,46 @@ export function useK8sModels() {
3546
]
3647
}
3748

49+
export function getK8sModel(k8s: any, k8sGroupVersionKind?: K8sResourceKindReference | K8sGroupVersionKind): K8sModel {
50+
const models = Object.keys(k8sModels);
51+
52+
for (let i = 0; i < models.length; i++) {
53+
const model = (k8sModels as any)[models[i]];
54+
if (model.kind === k8s.kind) {
55+
return model;
56+
}
57+
}
58+
59+
return {
60+
abbr: '',
61+
kind: '',
62+
label: '',
63+
labelPlural: '',
64+
plural: '',
65+
apiVersion: ''
66+
};
67+
}
68+
69+
export function k8sGet(k8s: any): Promise<any> {
70+
console.log("k8sGet", k8s);
71+
return Promise.resolve(k8s);
72+
}
73+
74+
export function k8sCreate(k8s: any): Promise<any> {
75+
console.log("k8sCreate", k8s);
76+
return Promise.resolve(k8s);
77+
}
78+
79+
export function k8sUpdate(k8s: any): Promise<any> {
80+
console.log("k8sUpdate", k8s);
81+
return Promise.resolve(k8s);
82+
}
83+
84+
export function useK8sWatchResource(req: any) {
85+
console.log("useK8sWatchResource", req);
86+
return [null, true, null];
87+
}
88+
3889
export const ResourceIcon: React.FC<ResourceIconProps> = ({
3990
className,
4091
kind,
@@ -80,4 +131,27 @@ export const ResourceLink: React.FC<ResourceLinkProps> = ({
80131
{children}
81132
</span>
82133
);
83-
};
134+
};
135+
136+
export const ResourceYAMLEditor: React.FC<ResourceYAMLEditorProps> = ({
137+
initialResource,
138+
header,
139+
onSave,
140+
}) => {
141+
const isDarkTheme = useTheme();
142+
const containerHeight = document.getElementById("editor-content-container")?.clientHeight || 800;
143+
const footerHeight = document.getElementById("editor-toggle-footer")?.clientHeight || 0;
144+
return (<>
145+
<CodeEditor
146+
isDarkTheme={isDarkTheme}
147+
isLineNumbersVisible={true}
148+
isReadOnly={false}
149+
isMinimapVisible={true}
150+
isLanguageLabelVisible
151+
code={safeJSToYAML(initialResource)}
152+
language={Language.yaml}
153+
height={`${containerHeight - footerHeight}px`}
154+
onChange={(value) => onSave && onSave(value)}
155+
/>
156+
</>);
157+
};

0 commit comments

Comments
 (0)