Skip to content

Commit 830d84f

Browse files
authored
Merge pull request #431 from signals-dev/similarShapes
Similar shapes within the sidebar - first draft
2 parents 6242b7f + 58e7d7b commit 830d84f

File tree

12 files changed

+717
-62
lines changed

12 files changed

+717
-62
lines changed

client/src/components/Timeseries/FocusChart/EventDetails/index.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { connect } from 'react-redux';
33
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
44
import { faCheck, faExclamation, faMicrophone } from '@fortawesome/free-solid-svg-icons';
55
import PropTypes from 'prop-types';
6-
import { toggleSimilarShapesModalAction } from 'src/model/actions/similarShapes';
7-
import { getIsSimilarShapesModalOpen } from 'src/model/selectors/similarShapes';
6+
import { toggleSimilarShapesAction } from 'src/model/actions/similarShapes';
7+
import { getIsSimilarShapesActive } from 'src/model/selectors/similarShapes';
88
import {
99
updateEventDetailsAction,
1010
saveEventDetailsAction,
@@ -70,8 +70,8 @@ export class EventDetails extends Component {
7070
isTranscriptSupported,
7171
isSpeechInProgress,
7272
toggleAggregationLevels,
73-
toggleSimilarShapesModal,
74-
isSimilarShapesOpen,
73+
toggleSimilarShapes,
74+
isSimilarShapesActive,
7575
} = this.props;
7676

7777
const currentEventDetails = isAddingNewEvent ? newEventDetails : eventDetails;
@@ -99,7 +99,7 @@ export class EventDetails extends Component {
9999
<button type="button" onClick={() => toggleAggregationLevels(true)} title="Signal Aggregation Levels">
100100
<AggregationIcon />
101101
</button>{' '}
102-
<button type="button" onClick={() => toggleSimilarShapesModal(true)} disabled={isSimilarShapesOpen}>
102+
<button type="button" onClick={() => toggleSimilarShapes(true)} disabled={isSimilarShapesActive}>
103103
<SearchIcon />
104104
</button>
105105
<button type="button" className="close" onClick={closeEventDetails}>
@@ -240,7 +240,7 @@ export default connect(
240240
eventUpdateStatus: getUpdateEventStatus(state),
241241
isTranscriptSupported: getIsTranscriptSupported(state),
242242
isSpeechInProgress: getIsSpeechInProgress(state),
243-
isSimilarShapesOpen: getIsSimilarShapesModalOpen(state),
243+
isSimilarShapesActive: getIsSimilarShapesActive(state),
244244
}),
245245
(dispatch) => ({
246246
closeEventDetails: () => dispatch(closeEventModal()),
@@ -251,6 +251,6 @@ export default connect(
251251
updateNewEventDetails: (details) => dispatch(updateNewEventDetailsAction(details)),
252252
recordComment: () => dispatch(recordCommentAction()),
253253
toggleAggregationLevels: (state) => dispatch(toggleAggregationModal(state)),
254-
toggleSimilarShapesModal: (modalState) => dispatch(toggleSimilarShapesModalAction(modalState)),
254+
toggleSimilarShapes: (modalState) => dispatch(toggleSimilarShapesAction(modalState)),
255255
}),
256256
)(EventDetails);

client/src/components/Timeseries/FocusChart/FocusChart.tsx

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
import React, { Component } from 'react';
22
import { connect } from 'react-redux';
33
import * as d3 from 'd3';
4-
import {
5-
getIsSimilarShapesLoading,
6-
getIsSimilarShapesModalOpen,
7-
getSimilarShapesCoords,
8-
} from 'src/model/selectors/similarShapes';
4+
import { getIsSimilarShapesActive, getSimilarShapesCoords } from 'src/model/selectors/similarShapes';
95
import { RootState } from '../../../model/types';
106
import { FocusChartConstants, colorSchemes } from './Constants';
11-
import EventDetails from './EventDetails';
7+
// import EventDetails from './EventDetails';
128
import AddEvent from './FocusChartEvents/AddEvent';
139
import ShowErrors from './ShowErrors';
1410
import { setTimeseriesPeriod, setActiveEventAction } from '../../../model/actions/datarun';
@@ -373,14 +369,7 @@ export class FocusChart extends Component<Props, State> {
373369

374370
drawChartData() {
375371
const { width, height } = this.state;
376-
const {
377-
dataRun,
378-
isPredictionVisible,
379-
isZoomEnabled,
380-
isSimilarShapesLoading,
381-
isSimilarShapesOpen,
382-
similarShapesCoords,
383-
} = this.props;
372+
const { dataRun, isPredictionVisible, isZoomEnabled, isSimilarShapesActive, similarShapesCoords } = this.props;
384373
const { eventWindows, timeSeries, timeseriesPred } = dataRun;
385374
const focusChartWidth = width - TRANSLATE_LEFT - 2 * CHART_MARGIN;
386375

@@ -405,8 +394,8 @@ export class FocusChart extends Component<Props, State> {
405394
</g>
406395
<rect className="zoom" {...zoomProps} />
407396
{eventWindows.map((currentEvent) => this.renderEvents(currentEvent))}
408-
{isSimilarShapesOpen &&
409-
!isSimilarShapesLoading &&
397+
{isSimilarShapesActive &&
398+
similarShapesCoords !== null &&
410399
similarShapesCoords.map((currentShapeCoords) => this.renderSimilarShapes(currentShapeCoords))}
411400
</g>
412401
<g className="chart-axis">
@@ -425,7 +414,7 @@ export class FocusChart extends Component<Props, State> {
425414
<div className="focus-chart" id="focusChartWrapper">
426415
{isTooltipVisible && this.renderEventTooltip()}
427416
<ShowErrors isOpen={this.props.isPredictionVisible} />
428-
<EventDetails />
417+
{/* <EventDetails /> */}
429418
<svg width={width} height={height} id="focusChart">
430419
{this.drawChartData()}
431420
</svg>
@@ -449,8 +438,7 @@ const mapState = (state: RootState) => ({
449438
isZoomEnabled: getZoomMode(state),
450439
isTimeSyncEnbled: getIsTimeSyncModeEnabled(state),
451440
scrollHistory: getScrollHistory(state),
452-
isSimilarShapesLoading: getIsSimilarShapesLoading(state),
453-
isSimilarShapesOpen: getIsSimilarShapesModalOpen(state),
441+
isSimilarShapesActive: getIsSimilarShapesActive(state),
454442
similarShapesCoords: getSimilarShapesCoords(state),
455443
});
456444

client/src/components/Timeseries/Overview/DrawChart.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import * as d3 from 'd3';
33
import { connect } from 'react-redux';
44
import {
5-
getIsSimilarShapesModalOpen,
5+
getIsSimilarShapesActive,
66
getIsSimilarShapesLoading,
77
getSimilarShapesCoords,
88
} from 'src/model/selectors/similarShapes';
@@ -246,7 +246,13 @@ export class DrawChart extends Component<ChartProps, ChartState> {
246246

247247
drawData() {
248248
const { width, height, offset } = this.state;
249-
const { dataRun, isSimilarShapesLoading, isSimilarShapesOpen, similarShapesCoords, selectedDatarunID } = this.props;
249+
const {
250+
dataRun,
251+
isSimilarShapesLoading,
252+
isSimilarShapesActive,
253+
similarShapesCoords,
254+
selectedDatarunID,
255+
} = this.props;
250256
const { eventWindows, timeSeries } = dataRun;
251257

252258
return (
@@ -255,7 +261,7 @@ export class DrawChart extends Component<ChartProps, ChartState> {
255261
<g className="event-wrapper" transform={`translate(${offset.left}, ${offset.top})`}>
256262
<path className="wave-data" d={this.drawLine(timeSeries)} />
257263
{eventWindows.length > 0 && eventWindows.map((windowEvent) => this.drawEvent(windowEvent))}
258-
{isSimilarShapesOpen &&
264+
{isSimilarShapesActive &&
259265
!isSimilarShapesLoading &&
260266
dataRun.id === selectedDatarunID &&
261267
similarShapesCoords.map((currentShape) => this.renderSimilarShapes(currentShape))}
@@ -342,7 +348,7 @@ const mapState = (state: RootState) => ({
342348
isAddingNewEvent: getIsAddingNewEvents(state),
343349
isPopupOpen: getIsPopupOpen(state),
344350
isSimilarShapesLoading: getIsSimilarShapesLoading(state),
345-
isSimilarShapesOpen: getIsSimilarShapesModalOpen(state),
351+
isSimilarShapesActive: getIsSimilarShapesActive(state),
346352
similarShapesCoords: getSimilarShapesCoords(state),
347353
selectedDatarunID: getSelectedDatarunID(state),
348354
});

client/src/components/Timeseries/Sidebar/SidebarComponents/SignalAnnotationsView/SignalAnnotations.jsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class SignalAnnotations extends Component {
2626

2727
const toggleEventState = (eventID) => (activeEvent === eventID ? setActiveEvent(null) : setActiveEvent(eventID));
2828

29-
return (
30-
events.length &&
29+
return events.length ? (
3130
events.map((currentEvent) => {
3231
const color = currentEvent && currentEvent.tag ? colorSchemes[currentEvent.tag] : colorSchemes.Untagged;
3332
const eventClassName =
@@ -64,6 +63,12 @@ class SignalAnnotations extends Component {
6463
</div>
6564
);
6665
})
66+
) : (
67+
<div className="annotation-wrapper">
68+
<div className="annotation-heading">
69+
<p>No annotations found</p>
70+
</div>
71+
</div>
6772
);
6873
}
6974

0 commit comments

Comments
 (0)