Skip to content

Commit 6bbe511

Browse files
Merge pull request #140 from alanconway/better-timerange
NO-JIRA: Improved layout, time duration option.
2 parents a028ffe + 1d278ab commit 6bbe511

15 files changed

Lines changed: 530 additions & 249 deletions
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
{
22
"Correlation result was empty.": "Correlation result was empty.",
3-
"Depth": "Depth",
3+
"Duration": "Duration",
44
"Find related resources.": "Find related resources.",
55
"Focus": "Focus",
6+
"Follow paths to class": "Follow paths to class",
7+
"Follow up to": "Follow up to",
68
"Generate a correlation graph starting from resources in the current view.": "Generate a correlation graph starting from resources in the current view.",
7-
"Goal directed search": "Goal directed search",
9+
"Goal": "Goal",
810
"Korrel8r Error": "Korrel8r Error",
11+
"Last": "Last",
912
"Logging Plugin Disabled": "Logging Plugin Disabled",
10-
"Neighbourhood search": "Neighbourhood search",
13+
"Neighbourhood": "Neighbourhood",
1114
"Netflow Plugin Disabled": "Netflow Plugin Disabled",
1215
"No Correlated Signals Found": "No Correlated Signals Found",
1316
"Open the Troubleshooting Panel": "Open the Troubleshooting Panel",
17+
"Query": "Query",
1418
"Query to select the starting resources for correlation.": "Query to select the starting resources for correlation.",
19+
"Range": "Range",
1520
"Refresh the graph using the current search settings": "Refresh the graph using the current search settings",
1621
"Request Failed": "Request Failed",
17-
"Search for correlated resources up to the specified depth.": "Search for correlated resources up to the specified depth.",
18-
"Search for paths to resources of the specified class.": "Search for paths to resources of the specified class.",
22+
"rules": "rules",
23+
"Search Type": "Search Type",
1924
"The current view does not support correlation.": "The current view does not support correlation.",
25+
"Time Range": "Time Range",
2026
"Troubleshooting": "Troubleshooting",
2127
"Troubleshooting Panel": "Troubleshooting Panel",
22-
"Unable to find Console Link": "Unable to find Console Link",
23-
"Update": "Update"
28+
"Unable to find Console Link": "Unable to find Console Link"
2429
}

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"scripts": {
88
"clean": "rm -rf dist",
9-
"build": "npm run clean && NODE_ENV=production npm run ts-node node_modules/.bin/webpack",
9+
"build": "npm run clean && npm run ts-node node_modules/.bin/webpack",
1010
"build-dev": "npm run clean && npm run ts-node node_modules/.bin/webpack",
1111
"start": "npm run ts-node node_modules/.bin/webpack serve",
1212
"start-console": "../scripts/start-console.sh",

web/src/__tests__/time.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as time from '../time';
2+
3+
describe('Range', () => {
4+
it('constructs', () => {
5+
const [start, end] = [new Date(1969, 3, 21), new Date(1969, 3, 22)];
6+
const range = new time.Range(start, end);
7+
expect(range.startEnd()).toEqual([start, end]);
8+
});
9+
});
10+
11+
describe('Duration', () => {
12+
it('constructs', () => {
13+
const duration = new time.Duration(1000, time.SECOND);
14+
const [start, end] = duration.startEnd();
15+
const now = Date.now();
16+
expect(duration.duration()).toEqual(1000 * time.SECOND.value);
17+
expect(end.getTime() - start.getTime()).toEqual(1000 * time.SECOND.value);
18+
expect(Math.floor(end.getTime() / 100)).toEqual(Math.floor(now / 100));
19+
});
20+
});
21+
22+
describe('Unit', () => {
23+
it('all', () => {
24+
expect(time.Unit.all()).toEqual([time.SECOND, time.MINUTE, time.HOUR, time.DAY, time.WEEK]);
25+
});
26+
it('get', () => {
27+
expect(time.Unit.get('seconds')).toEqual(time.SECOND);
28+
});
29+
});

web/src/components/Chooser.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ToggleGroup, ToggleGroupItem, Tooltip } from '@patternfly/react-core';
2+
import * as React from 'react';
3+
import './korrel8rpanel.css';
4+
5+
export interface ChooserProps {
6+
selectedID: string;
7+
items: { label: string; id: string; tooltip?: string }[];
8+
onChange: (id: string) => void;
9+
}
10+
11+
export const Chooser: React.FC<ChooserProps> = ({ selectedID, items, onChange }) => (
12+
<ToggleGroup>
13+
{items.map(({ label, id, tooltip }) => {
14+
let item = (
15+
<ToggleGroupItem
16+
text={label}
17+
isSelected={selectedID === id}
18+
onChange={(_, on) => on && onChange && onChange(id)}
19+
/>
20+
);
21+
if (tooltip) item = <Tooltip content={tooltip}>{item}</Tooltip>;
22+
return item;
23+
})}
24+
</ToggleGroup>
25+
);
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {
2+
DatePicker,
3+
InputGroup,
4+
InputGroupItem,
5+
InputGroupText,
6+
isValidDate,
7+
TimePicker,
8+
yyyyMMddFormat,
9+
} from '@patternfly/react-core';
10+
import * as React from 'react';
11+
import { copyTime, setTime } from '../time';
12+
13+
/** Combine date and time pickers, return the result as a Date */
14+
export const DateTimePicker: React.FC<{
15+
date: Date;
16+
onChange: (date: Date) => void;
17+
label: string;
18+
}> = ({ date, onChange, label }) => {
19+
if (!isValidDate(date)) date = new Date();
20+
return (
21+
<InputGroup>
22+
<InputGroupText isPlain>{label}</InputGroupText>
23+
<InputGroupItem>
24+
<DatePicker
25+
value={isValidDate(date) ? yyyyMMddFormat(date) : ''}
26+
onChange={(_event, _inputDate, newDate) => onChange(copyTime(newDate, date))}
27+
aria-label={label}
28+
/>
29+
</InputGroupItem>
30+
<InputGroupItem>
31+
<TimePicker
32+
time={date}
33+
onChange={(_event, _time, hour, minute, second, isValid) => {
34+
if (isValid) onChange(setTime(date, hour, minute, second));
35+
}}
36+
is24Hour={true}
37+
width="80px"
38+
/>
39+
</InputGroupItem>
40+
</InputGroup>
41+
);
42+
};

web/src/components/DateTimeRangePicker.tsx

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

0 commit comments

Comments
 (0)