diff options
author | Aijana Schumann <aijana.schumann@highstreet-technologies.com> | 2020-08-12 12:28:06 +0200 |
---|---|---|
committer | Aijana Schumann <aijana.schumann@highstreet-technologies.com> | 2020-08-12 12:29:48 +0200 |
commit | 3d02271058d2e59a71e49afdd866462f7b6ab1c6 (patch) | |
tree | bb42b3428055136a4a8f5def9c63e412390d40ef /sdnr/wt/odlux/apps/faultApp/src | |
parent | cd29d2dd98b7c40bd4efb6a8705787ca35e99fe9 (diff) |
Switch odlux from Biermann-RestConf to RFC8040 interface
Switched rest-calls in odlux to use RFC8040 interface
Issue-ID: CCSDK-2565
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Change-Id: Ia59dd02bc6456bad648083146c0256f204e134d1
Diffstat (limited to 'sdnr/wt/odlux/apps/faultApp/src')
5 files changed, 30 insertions, 34 deletions
diff --git a/sdnr/wt/odlux/apps/faultApp/src/actions/clearStuckAlarmsAction.ts b/sdnr/wt/odlux/apps/faultApp/src/actions/clearStuckAlarmsAction.ts index ba1a24822..fea500dd3 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/actions/clearStuckAlarmsAction.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/actions/clearStuckAlarmsAction.ts @@ -28,9 +28,9 @@ export class AreStuckAlarmsCleared extends FaultApplicationBaseAction { } -export const clearStuckAlarmAsyncAction = (dispatcher: Dispatch) => async (nodeNames: string[]) => { - dispatcher(new AreStuckAlarmsCleared(true)) +export const clearStuckAlarmAsyncAction = (dispatch: Dispatch) => async (nodeNames: string[]) => { + dispatch(new AreStuckAlarmsCleared(true)) const result = await clearStuckAlarms(nodeNames).catch(error => { console.error(error); return undefined }); - dispatcher(new AreStuckAlarmsCleared(false)) + dispatch(new AreStuckAlarmsCleared(false)) return result; }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/src/components/clearStuckAlarmsDialog.tsx b/sdnr/wt/odlux/apps/faultApp/src/components/clearStuckAlarmsDialog.tsx index 3b8b9b684..e131fa619 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/components/clearStuckAlarmsDialog.tsx +++ b/sdnr/wt/odlux/apps/faultApp/src/components/clearStuckAlarmsDialog.tsx @@ -30,25 +30,29 @@ export enum ClearStuckAlarmsDialogMode { const mapDispatch = (dispatcher: IDispatcher) => ({ clearStuckAlarmsAsync: clearStuckAlarmAsyncAction(dispatcher.dispatch), reloadCurrentProblemsAction: () => dispatcher.dispatch(currentProblemsReloadAction) -}) +}); type clearStuckAlarmsProps = Connect<typeof undefined, typeof mapDispatch> & { - numberDevices: Number, - mode: ClearStuckAlarmsDialogMode, - stuckAlarms: string[] - onClose: () => void + numberDevices: Number; + mode: ClearStuckAlarmsDialogMode; + stuckAlarms: string[]; + onClose: () => void; } type ClearStuckAlarmsState = { - clearAlarmsSuccessful: boolean, - errormessage: string, - unclearedAlarms: string[] + clearAlarmsSuccessful: boolean; + errormessage: string; + unclearedAlarms: string[]; } class ClearStuckAlarmsDialogComponent extends React.Component<clearStuckAlarmsProps, ClearStuckAlarmsState>{ constructor(props: clearStuckAlarmsProps) { super(props); - this.state = { clearAlarmsSuccessful: true, errormessage: '', unclearedAlarms: [] } + this.state = { + clearAlarmsSuccessful: true, + errormessage: '', + unclearedAlarms: [] + }; } onClose = (event: React.MouseEvent) => { @@ -62,19 +66,14 @@ class ClearStuckAlarmsDialogComponent extends React.Component<clearStuckAlarmsPr event.preventDefault(); const result = await this.props.clearStuckAlarmsAsync(this.props.stuckAlarms); - if (result) { - if (result.output.nodenames) { - if (result.output.nodenames.length !== this.props.stuckAlarms.length) { //show errormessage if not all devices were cleared - const undeletedAlarm = this.props.stuckAlarms.filter(item => !result.output.nodenames.includes(item)) - const error = "The alarms of the following devices couldn't be refreshed: "; - this.setState({ clearAlarmsSuccessful: false, errormessage: error, unclearedAlarms: undeletedAlarm }) - return; - } - } - } - else { //show errormessage if no devices were cleared - this.setState({ clearAlarmsSuccessful: false, errormessage: "Alarms couldn't be refreshed.", unclearedAlarms: [] }) + if (result && result["data-provider:output"].nodenames && result["data-provider:output"].nodenames.length !== this.props.stuckAlarms.length) { //show errormessage if not all devices were cleared + const undeletedAlarm = this.props.stuckAlarms.filter(item => !result["data-provider:output"].nodenames.includes(item)); + const error = "The alarms of the following devices couldn't be refreshed: "; + this.setState({ clearAlarmsSuccessful: false, errormessage: error, unclearedAlarms: undeletedAlarm }); return; + + } else { //show errormessage if no devices were cleared + this.setState({ clearAlarmsSuccessful: false, errormessage: "Alarms couldn't be refreshed.", unclearedAlarms: [] }); } this.props.reloadCurrentProblemsAction(); @@ -132,5 +131,5 @@ class ClearStuckAlarmsDialogComponent extends React.Component<clearStuckAlarmsPr } } -const ClearStuckAlarmsDialog = connect(undefined, mapDispatch)(ClearStuckAlarmsDialogComponent) +const ClearStuckAlarmsDialog = connect(undefined, mapDispatch)(ClearStuckAlarmsDialogComponent); export default ClearStuckAlarmsDialog; diff --git a/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts b/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts index e03d2b560..5b51a100c 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/handlers/faultAppRootHandler.ts @@ -67,7 +67,6 @@ const actionHandlers = { alarmLogEntries: alarmLogEntriesActionHandler, currentOpenPanel: currentOpenPanelHandler, faultStatus: faultStatusHandler, - stuckAlarms: stuckAlarmHandler, listenForPartialUpdates: arePartialUpdatesActiveHandler }; diff --git a/sdnr/wt/odlux/apps/faultApp/src/models/fault.ts b/sdnr/wt/odlux/apps/faultApp/src/models/fault.ts index c65734437..e4e43f19c 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/models/fault.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/models/fault.ts @@ -61,7 +61,5 @@ export type Faults = { }; export type DeletedStuckAlarms = { - output: { nodenames: string[] - } }
\ No newline at end of file diff --git a/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts b/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts index d3409e095..d1236d2e7 100644 --- a/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts +++ b/sdnr/wt/odlux/apps/faultApp/src/services/faultStatusService.ts @@ -16,12 +16,12 @@ * ============LICENSE_END========================================================================== */ import { requestRest } from "../../../../framework/src/services/restService"; -import { Result, PostResponse } from "../../../../framework/src/models/elasticSearch"; +import { Result, SingeResult } from "../../../../framework/src/models/elasticSearch"; import { FaultType, Faults, DeletedStuckAlarms } from "../models/fault"; export const getFaultStateFromDatabase = async (): Promise<FaultType | null> => { - const path = 'restconf/operations/data-provider:read-status'; + const path = 'rests/operations/data-provider:read-status'; const result = await requestRest<Result<Faults>>(path, { method: "POST" }); let faultType: FaultType = { @@ -32,8 +32,8 @@ export const getFaultStateFromDatabase = async (): Promise<FaultType | null> => } let faults: Faults[] | null = null; - if (result && result.output && result.output.data) { - faults = result.output.data; + if (result && result["data-provider:output"] && result["data-provider:output"].data) { + faults = result["data-provider:output"].data; faultType = { Critical: faults[0].faults.criticals, Major: faults[0].faults.majors, @@ -46,8 +46,8 @@ export const getFaultStateFromDatabase = async (): Promise<FaultType | null> => } export const clearStuckAlarms = async (nodeNames: string[]) => { - const path = 'restconf/operations/devicemanager:clear-current-fault-by-nodename' - const result = await requestRest<DeletedStuckAlarms>(path, { method: 'Post', body: JSON.stringify({ input: { nodenames: nodeNames } }) }) + const path = 'rests/operations/devicemanager:clear-current-fault-by-nodename' + const result = await requestRest<SingeResult<DeletedStuckAlarms>>(path, { method: 'Post', body: JSON.stringify({ input: { nodenames: nodeNames } }) }) return result; }
\ No newline at end of file |