This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Adding Deployment message details formatting and removing onRowClick #1117
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
20bcd99
Deployment message details formatting and removing onRowClick
isaac-dasan ed1a577
fix for stephen's comments
isaac-dasan 39f48d7
minimize setState calls
isaac-dasan cad8c78
refactoring componentWillReceiveProps
isaac-dasan a807103
semicolon and single line
isaac-dasan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ import { | |
import Flyout from 'components/shared/flyout'; | ||
import { TelemetryChart, chartColorObjects } from 'components/pages/dashboard/panels/telemetry'; | ||
import { transformTelemetryResponse } from 'components/pages/dashboard/panels'; | ||
import { getEdgeAgentStatusCode } from 'utilities'; | ||
|
||
import './deviceDetails.css'; | ||
|
||
|
@@ -50,9 +51,10 @@ export class DeviceDetails extends Component { | |
telemetryIsPending: true, | ||
telemetryError: null, | ||
|
||
showRawMessage: false | ||
showRawMessage: false, | ||
currentModuleStatus: undefined | ||
}; | ||
|
||
this.baseState = this.state; | ||
this.columnDefs = [ | ||
{ | ||
...rulesColumnDefs.ruleName, | ||
|
@@ -65,6 +67,14 @@ export class DeviceDetails extends Component { | |
|
||
this.resetTelemetry$ = new Subject(); | ||
this.telemetryRefresh$ = new Subject(); | ||
if (this.props.moduleStatus) { | ||
this.state = { | ||
...this.state, | ||
currentModuleStatus: this.props.moduleStatus | ||
}; | ||
} else { | ||
this.props.fetchModules(this.props.device.id); | ||
} | ||
} | ||
|
||
componentDidMount() { | ||
|
@@ -119,11 +129,49 @@ export class DeviceDetails extends Component { | |
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
if ((this.props.device || {}).id !== nextProps.device.id) { | ||
const deviceId = (nextProps.device || {}).id; | ||
const { | ||
deviceModuleStatus, | ||
isDeviceModuleStatusPending, | ||
deviceModuleStatusError, | ||
moduleStatus, | ||
resetPendingAndError, | ||
device, | ||
fetchModules | ||
} = nextProps; | ||
let tempState = {}; | ||
/* | ||
deviceModuleStatus is a prop fetched by making fetchModules() API call through deviceDetails.container on demand. | ||
moduleStatus is a prop sent from deploymentDetailsGrid which it already has in rowData. | ||
Both deviceModuleStatus and moduleStatus have the same content, | ||
but come from different sources based on the page that opens this flyout. | ||
Depending on which one is available, currentModuleStatus is set in component state. | ||
*/ | ||
|
||
if ((this.props.device || {}).id !== device.id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. else if |
||
// Reset state if the device changes. | ||
resetPendingAndError(); | ||
tempState = { ...this.baseState }; | ||
|
||
if (moduleStatus) { | ||
// If moduleStatus exist in props, set it in state. | ||
tempState = { | ||
...tempState, | ||
currentModuleStatus: moduleStatus | ||
}; | ||
} else { | ||
// Otherwise make an API call to get deviceModuleStatus. | ||
fetchModules(device.id); | ||
} | ||
|
||
const deviceId = (device || {}).id; | ||
this.resetTelemetry$.next(deviceId); | ||
this.fetchAlerts(deviceId); | ||
} else if (!moduleStatus && !isDeviceModuleStatusPending && !deviceModuleStatusError) { | ||
// set deviceModuleStatus in state, if moduleStatus doesn't exist and devicesReducer successfully received the API response. | ||
tempState = { currentModuleStatus: deviceModuleStatus }; | ||
} | ||
|
||
if (Object.keys(tempState).length) this.setState(tempState); | ||
} | ||
|
||
componentWillUnmount() { | ||
|
@@ -162,8 +210,16 @@ export class DeviceDetails extends Component { | |
} | ||
|
||
render() { | ||
const { t, onClose, device, theme, timeSeriesExplorerUrl } = this.props; | ||
const { telemetry, lastMessage } = this.state; | ||
const { | ||
t, | ||
onClose, | ||
device, | ||
theme, | ||
timeSeriesExplorerUrl, | ||
isDeviceModuleStatusPending, | ||
deviceModuleStatusError | ||
} = this.props; | ||
const { telemetry, lastMessage, currentModuleStatus } = this.state; | ||
const lastMessageTime = (lastMessage || {}).time; | ||
const isPending = this.state.isAlertsPending && this.props.isRulesPending; | ||
const rulesGridProps = { | ||
|
@@ -176,8 +232,12 @@ export class DeviceDetails extends Component { | |
}; | ||
const tags = Object.entries(device.tags || {}); | ||
const properties = Object.entries(device.properties || {}); | ||
|
||
const moduleQuerySuccessful = currentModuleStatus && | ||
currentModuleStatus !== {} && | ||
!isDeviceModuleStatusPending && | ||
!deviceModuleStatusError; | ||
// Add parameters to Time Series Insights Url | ||
|
||
const timeSeriesParamUrl = | ||
timeSeriesExplorerUrl | ||
? timeSeriesExplorerUrl + | ||
|
@@ -391,6 +451,28 @@ export class DeviceDetails extends Component { | |
|
||
</Section.Content> | ||
</Section.Container> | ||
|
||
<Section.Container> | ||
<Section.Header>{t('devices.flyouts.details.modules.title')}</Section.Header> | ||
<Section.Content> | ||
<SectionDesc> | ||
{t("devices.flyouts.details.modules.description")} | ||
</SectionDesc> | ||
<div className="device-details-deployment-contentbox"> | ||
{ | ||
!moduleQuerySuccessful && | ||
t('devices.flyouts.details.modules.noneExist') | ||
} | ||
{ | ||
moduleQuerySuccessful && | ||
<ComponentArray > | ||
<div>{currentModuleStatus.code}: {getEdgeAgentStatusCode(currentModuleStatus.code, t)}</div> | ||
<div>{currentModuleStatus.description}</div> | ||
</ComponentArray > | ||
} | ||
</div> | ||
</Section.Content> | ||
</Section.Container> | ||
</div> | ||
} | ||
<BtnToolbar> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is what you meant
({ id = '' })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done