Skip to content

Commit 1d3171d

Browse files
committed
feat: link status and control
1 parent 5951828 commit 1d3171d

File tree

5 files changed

+98
-14
lines changed

5 files changed

+98
-14
lines changed

nerdlets/entity-mode/components/map/map-utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export const rightClick = (
104104
sourceEntityType &&
105105
targetEntityType &&
106106
!sourceEntityType.includes('INFRA') &&
107-
!targetEntityType.includes('INFRA')
107+
!targetEntityType.includes('INFRA') &&
108+
!sourceEntityType.includes('WORKLOAD') &&
109+
!targetEntityType.includes('WORKLOAD')
108110
) {
109111
// add node
110112
let selectedEntity = null;

nerdlets/observability-maps-nerdlet/components/map/map-utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export const rightClick = (
104104
sourceEntityType &&
105105
targetEntityType &&
106106
!sourceEntityType.includes('INFRA') &&
107-
!targetEntityType.includes('INFRA')
107+
!targetEntityType.includes('INFRA') &&
108+
!sourceEntityType.includes('WORKLOAD') &&
109+
!targetEntityType.includes('WORKLOAD')
108110
) {
109111
// add node
110112
let selectedEntity = null;

nerdlets/observability-maps-nerdlet/components/map/settings.js

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { Modal, Button, Form } from 'semantic-ui-react';
3-
import { writeUserDocument } from '../../lib/utils';
3+
import { writeUserDocument, writeAccountDocument } from '../../lib/utils';
44
import { DataConsumer } from '../../context/data';
55

66
export default class MapSettings extends React.PureComponent {
@@ -12,7 +12,8 @@ export default class MapSettings extends React.PureComponent {
1212
backgroundImage: null,
1313
backgroundPosition: null,
1414
backgroundRepeat: null,
15-
backgroundSize: null
15+
backgroundSize: null,
16+
linkType: null
1617
};
1718
}
1819

@@ -21,13 +22,20 @@ export default class MapSettings extends React.PureComponent {
2122
handleChange = (e, { value }, formType) =>
2223
this.setState({ [formType]: value });
2324

24-
handleSave = async (tempState, dataFetcher, mapConfig, selectedMap) => {
25+
handleSave = async (
26+
tempState,
27+
dataFetcher,
28+
mapConfig,
29+
selectedMap,
30+
storageLocation
31+
) => {
2532
const {
2633
backgroundColor,
2734
backgroundImage,
2835
backgroundPosition,
2936
backgroundRepeat,
30-
backgroundSize
37+
backgroundSize,
38+
linkType
3139
} = tempState;
3240

3341
if (!mapConfig.settings) {
@@ -54,9 +62,24 @@ export default class MapSettings extends React.PureComponent {
5462
this.state.backgroundRepeat || backgroundRepeat;
5563
mapConfig.settings.backgroundSize =
5664
this.state.backgroundSize || backgroundSize;
65+
mapConfig.settings.linkType = this.state.linkType || linkType;
5766

58-
await writeUserDocument('ObservabilityMaps', selectedMap.value, mapConfig);
59-
await dataFetcher(['userMaps']);
67+
if (storageLocation.type === 'user') {
68+
await writeUserDocument(
69+
'ObservabilityMaps',
70+
selectedMap.value,
71+
mapConfig
72+
);
73+
} else if (storageLocation.type === 'account') {
74+
await writeAccountDocument(
75+
storageLocation.value,
76+
'ObservabilityMaps',
77+
selectedMap.value,
78+
mapConfig
79+
);
80+
}
81+
82+
await dataFetcher(['userMaps', 'accountMaps']);
6083
};
6184

6285
onUnmount = updateDataContextState => {
@@ -66,7 +89,8 @@ export default class MapSettings extends React.PureComponent {
6689
backgroundImage: null,
6790
backgroundPosition: null,
6891
backgroundRepeat: null,
69-
backgroundSize: null
92+
backgroundSize: null,
93+
linkType: null
7094
});
7195
};
7296

@@ -75,13 +99,20 @@ export default class MapSettings extends React.PureComponent {
7599

76100
return (
77101
<DataConsumer>
78-
{({ updateDataContextState, dataFetcher, mapConfig, selectedMap }) => {
102+
{({
103+
updateDataContextState,
104+
dataFetcher,
105+
mapConfig,
106+
selectedMap,
107+
storageLocation
108+
}) => {
79109
const tempState = {
80110
backgroundColor: '',
81111
backgroundImage: '',
82112
backgroundPosition: '',
83113
backgroundRepeat: '',
84-
backgroundSize: ''
114+
backgroundSize: '',
115+
linkType: ''
85116
};
86117

87118
if (mapConfig.settings) {
@@ -91,6 +122,7 @@ export default class MapSettings extends React.PureComponent {
91122
mapConfig.settings.backgroundPosition;
92123
tempState.backgroundRepeat = mapConfig.settings.backgroundRepeat;
93124
tempState.backgroundSize = mapConfig.settings.backgroundSize;
125+
tempState.linkType = mapConfig.settings.linkType;
94126
}
95127

96128
const value = name =>
@@ -181,6 +213,22 @@ export default class MapSettings extends React.PureComponent {
181213
label="Background Size"
182214
placeholder="auto"
183215
/>
216+
<Form.Select
217+
fluid
218+
label="Link Type"
219+
width="8"
220+
value={value('linkType')}
221+
options={[
222+
{ key: 's', text: 'STRAIGHT', value: 'STRAIGHT' },
223+
{
224+
key: 'cs',
225+
text: 'CURVE_SMOOTH',
226+
value: 'CURVE_SMOOTH'
227+
},
228+
{ key: 'cf', text: 'CURVE_FULL', value: 'CURVE_FULL' }
229+
]}
230+
onChange={(e, d) => this.handleChange(e, d, 'linkType')}
231+
/>
184232
</Form.Group>
185233
</Form>
186234
<br />
@@ -194,7 +242,8 @@ export default class MapSettings extends React.PureComponent {
194242
tempState,
195243
dataFetcher,
196244
mapConfig,
197-
selectedMap
245+
selectedMap,
246+
storageLocation
198247
)
199248
}
200249
/>

nerdlets/observability-maps-nerdlet/components/observability-maps.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ export default class ObservabilityMaps extends React.Component {
7474
}) => {
7575
const errors = [];
7676

77+
d3MapConfig.link.type =
78+
mapConfig?.settings?.linkType || 'CURVE_SMOOTH';
79+
7780
if (isWidget) {
7881
if (!vizMapStorage) {
7982
errors.push('Map storage not selected');

nerdlets/observability-maps-nerdlet/context/data.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,15 @@ export class DataProvider extends Component {
187187
}
188188

189189
// eslint-disable-next-line
190-
this.setState({ storageLocation, vizMapName: mapName, vizMapStorage: mapStorage, vizAccountId: accountId, vizHideMenu: hideMenu }, async () => {
190+
this.setState(
191+
{
192+
storageLocation,
193+
vizMapName: mapName,
194+
vizMapStorage: mapStorage,
195+
vizAccountId: accountId,
196+
vizHideMenu: hideMenu
197+
},
198+
async () => {
191199
if (storageLocation.type === 'account') {
192200
const maps = await this.dataFetcher(['accountMaps']);
193201
const accountMaps = maps.accountMaps || [];
@@ -743,10 +751,30 @@ export class DataProvider extends Component {
743751

744752
// reconstruct link data for graph
745753
const mapLinks = Object.keys((mapData || {}).linkData || {}).map(link => {
746-
return {
754+
const configuredLink = {
747755
source: mapData.linkData[link].source,
748756
target: mapData.linkData[link].target
749757
};
758+
759+
const sourceNodeData =
760+
mapData.nodeData?.[mapData.linkData[link].source];
761+
762+
// link alert severity handling
763+
if (sourceNodeData.alertSeverity === 'CRITICAL') {
764+
configuredLink.strokeWidth = 2.5;
765+
configuredLink.color = 'red';
766+
} else if (sourceNodeData.alertSeverity === 'WARNING') {
767+
configuredLink.strokeWidth = 2.5;
768+
configuredLink.color = 'orange';
769+
} else if (sourceNodeData.alertSeverity === 'WARNING') {
770+
configuredLink.strokeWidth = 2.5;
771+
configuredLink.color = 'orange';
772+
} else if (sourceNodeData.alertSeverity === 'NOT_ALERTING') {
773+
configuredLink.strokeWidth = 2.5;
774+
configuredLink.color = 'green';
775+
}
776+
777+
return configuredLink;
750778
});
751779

752780
links = [...links, ...mapLinks];

0 commit comments

Comments
 (0)