Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backend/frontend]Adjust expectations results reactflow #1594

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Divider, ListItemButton, ListItemIcon, ListItemText, Paper } from '@mui/material';
import { makeStyles } from '@mui/styles';
import { DevicesOtherOutlined, Groups3Outlined } from '@mui/icons-material';
import { DevicesOtherOutlined, Groups3Outlined, PersonOutlined } from '@mui/icons-material';
import { SelectGroup } from 'mdi-material-ui';
import type { InjectTargetWithResult } from '../../../../utils/api-types';
import AtomicTestingResult from './AtomicTestingResult';
Expand Down Expand Up @@ -42,16 +42,19 @@ const TargetListItem: React.FC<Props> = ({ isChild, onClick, target, selected })
// Icon
const getIcon = (type: string | undefined) => {
if (type === 'ASSETS') {
return <DevicesOtherOutlined/>;
return <DevicesOtherOutlined />;
}
if (type === 'ASSETS_GROUPS') {
return <SelectGroup/>;
return <SelectGroup />;
}
if (isChild) {
return <PersonOutlined fontSize="small" />; // Player in a team
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing the icon!

return <Groups3Outlined />;
};
return (
<>
{isChild && <Divider className={classes.dividerL}/>}
{isChild && <Divider className={classes.dividerL} />}
<Paper elevation={1} style={style} key={target?.id}>
<ListItemButton onClick={handleItemClick} style={{ marginBottom: 15 }} selected={selected}>
<ListItemIcon>
Expand All @@ -68,7 +71,7 @@ const TargetListItem: React.FC<Props> = ({ isChild, onClick, target, selected })
{target?.platformType ?? 'Unknown'}
</div>
<div className={classes.bodyTarget} style={{ width: '20%' }}>
<AtomicTestingResult expectations={target?.expectationResultsByTypes}/>
<AtomicTestingResult expectations={target?.expectationResultsByTypes} />
</div>
</div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.openbas.database.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.hypersistence.utils.hibernate.type.json.JsonType;
Expand Down Expand Up @@ -95,11 +96,7 @@ public EXPECTATION_STATUS getResponse() {
return EXPECTATION_STATUS.PENDING;
}
if (team != null) {
return switch (getResults().getFirst().getResult()) {
case "Failed" -> EXPECTATION_STATUS.FAILED;
case "Success" -> EXPECTATION_STATUS.SUCCESS;
default -> EXPECTATION_STATUS.PENDING;
};
return getExpectationStatus();
}

if (this.getScore() >= this.getExpectedScore()) {
Expand All @@ -111,6 +108,18 @@ public EXPECTATION_STATUS getResponse() {
return EXPECTATION_STATUS.PARTIAL;
}

@JsonIgnore
public EXPECTATION_STATUS getExpectationStatus() {
String result = getResults().getFirst().getResult().toUpperCase();
return switch (result) {
case "FAILED" -> EXPECTATION_STATUS.FAILED;
case "SUCCESS" -> EXPECTATION_STATUS.SUCCESS;
case "PARTIAL" -> EXPECTATION_STATUS.PARTIAL;
case "UNKNOWN" -> EXPECTATION_STATUS.UNKNOWN;
default -> EXPECTATION_STATUS.PENDING;
};
}

@Setter
@Column(name = "inject_expectation_expected_score")
@JsonProperty("inject_expectation_expected_score")
Expand Down