-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature #54394. Ml data upload functionality has been implemented.
(cherry picked from commit e00e7ab4f9ea6e95d8a339f61b58e7663ad62848) Change-Id: I8f06b6fff29aebbb6188c28ebf2790918dcdd7fc
- Loading branch information
1 parent
e8bac1c
commit 22e1deb
Showing
24 changed files
with
527 additions
and
70 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
FrontEnd/Sailfish-JS-report/resources/icons/ml-message-submitted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
92 changes: 92 additions & 0 deletions
92
FrontEnd/Sailfish-JS-report/src/components/MlUploadButton.tsx
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 |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/****************************************************************************** | ||
* Copyright 2009-2019 Exactpro (Exactpro Systems Limited) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
******************************************************************************/ | ||
|
||
import { h, Component } from 'preact'; | ||
import '../styles/messages.scss'; | ||
import { SubmittedData } from '../models/MlServiceResponse' | ||
import AppState from '../state/models/AppState'; | ||
import { setSubmittedMlData, addSubmittedMlData, removeSubmittedMlData } from "../actions/actionCreators"; | ||
import { connect } from 'preact-redux'; | ||
import { submitEntry, deleteEntry } from '../helpers/machineLearning'; | ||
import Action from "../models/Action"; | ||
|
||
interface MlUploadButtonProps { | ||
messageId: number; | ||
token: string; | ||
submittedData: SubmittedData[]; | ||
selectedActionIds: number[]; | ||
actionMap: Map<number, Action>; | ||
setSubmittedMlData: (data: SubmittedData[]) => any; | ||
addSubmittedMlData: (data: SubmittedData) => any; | ||
removeSubmittedMlData: (data: SubmittedData) => any; | ||
} | ||
|
||
export class MlUploadButtonBase extends Component<MlUploadButtonProps, {}> { | ||
render({ submittedData, messageId, token, selectedActionIds, actionMap }: MlUploadButtonProps) { | ||
|
||
let selectedActionId = selectedActionIds.length === 1 ? selectedActionIds[0] : null | ||
|
||
let isAvailable = token !== null | ||
&& selectedActionId !== null | ||
&& actionMap.get(selectedActionId).status.status === "FAILED"; | ||
|
||
let isSubmitted = isAvailable && submittedData.some((entry) => { | ||
return entry.messageId === messageId | ||
&& entry.actionId === selectedActionId | ||
}); | ||
|
||
// default one (message cannot be submitted or ml servie is unavailable) | ||
let mlButton = <div class="mc-header__submit-icon inactive" />; | ||
|
||
if (isAvailable) { | ||
mlButton = isSubmitted | ||
|
||
? <div class="mc-header__submit-icon submitted" | ||
title="Revoke ML data" | ||
onClick={(e) => { | ||
deleteEntry(token, { messageId: messageId, actionId: selectedActionId }, this.props.removeSubmittedMlData); | ||
e.cancelBubble = true; | ||
}} /> | ||
|
||
: <div class="mc-header__submit-icon active" | ||
title="Submit ML data" | ||
onClick={(e) => { | ||
submitEntry(token, { messageId: messageId, actionId: selectedActionId }, this.props.addSubmittedMlData); | ||
e.cancelBubble = true; | ||
}} /> | ||
} | ||
|
||
return ( | ||
<div class="mc-header__submit" title="Unable to submit ML data"> | ||
{mlButton} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export const MlUploadButton = connect( | ||
(state: AppState) => ({ | ||
token: state.machineLearning.token, | ||
submittedData: state.machineLearning.submittedData, | ||
selectedActionIds: state.selected.actionsId, | ||
actionMap: state.selected.actionsMap | ||
}), | ||
(dispatch) => ({ | ||
setSubmittedMlData: (data: SubmittedData[]) => dispatch(setSubmittedMlData(data)), | ||
addSubmittedMlData: (data: SubmittedData) => dispatch(addSubmittedMlData(data)), | ||
removeSubmittedMlData: (data: SubmittedData) => dispatch(removeSubmittedMlData(data)) | ||
}) | ||
)(MlUploadButtonBase); |
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
Oops, something went wrong.