Ordered list according to technique type

This commit is contained in:
VakarisZ 2019-12-03 13:41:44 +02:00
parent 064a0b17e6
commit a52c47f5a5
2 changed files with 27 additions and 6 deletions

View File

@ -109,7 +109,8 @@ class AttackReport extends React.Component {
techniques={this.state.techniques} techniques={this.state.techniques}
selected={this.state.selectedTechnique}/> selected={this.state.selectedTechnique}/>
<TechniqueDropdowns techniques={this.state.techniques} <TechniqueDropdowns techniques={this.state.techniques}
techComponents={techComponents}/> techComponents={techComponents}
schema={this.state.schema}/>
<br/> <br/>
</div> </div>
) )

View File

@ -15,6 +15,7 @@ class TechniqueDropdowns extends React.Component{
this.state = { this.state = {
techniques: this.props.techniques, techniques: this.props.techniques,
techComponents: this.props.techComponents, techComponents: this.props.techComponents,
schema: this.props.schema,
collapseOpen: '', collapseOpen: '',
techniquesHidden: true techniquesHidden: true
}; };
@ -72,15 +73,34 @@ class TechniqueDropdowns extends React.Component{
this.setState({techniquesHidden: (! this.state.techniquesHidden)}) this.setState({techniquesHidden: (! this.state.techniquesHidden)})
} }
render(){ getOrderedTechniqueList(){
let listClass = '';
let content = []; let content = [];
for(const type_key in this.state.schema.properties){
if (! this.state.schema.properties.hasOwnProperty(type_key)){
continue;
}
let tech_type = this.state.schema.properties[type_key];
content.push(<h2>{tech_type.title}</h2>);
for(const tech_id in this.state.techniques){
if (! this.state.techniques.hasOwnProperty(tech_id)){
continue;
}
let technique = this.state.techniques[tech_id];
if(technique.type === tech_type.title){
content.push(this.getTechniqueCollapse(tech_id))
}
}
}
return content
}
render(){
let content = [];
let listClass = '';
if (this.state.techniquesHidden){ if (this.state.techniquesHidden){
listClass = 'hidden-list' listClass = 'hidden-list'
} else { } else {
Object.keys(this.state.techniques).forEach((tech_id) => { content = this.getOrderedTechniqueList()
content.push(this.getTechniqueCollapse(tech_id))
});
} }
return ( return (
<div className='attack-technique-list-component'> <div className='attack-technique-list-component'>