diff --git a/src/common/table.js b/src/common/table.js index d0e974c..6b22c19 100644 --- a/src/common/table.js +++ b/src/common/table.js @@ -58,7 +58,7 @@ class CustomTable extends Component { const modifier = child.props.modifier; if (modifier && content != null) { - content = modifier(content); + content = modifier(content, data); } let cell = []; @@ -71,7 +71,7 @@ class CustomTable extends Component { cell.push({content}); } else if (child.props.clickable) { cell.push(); - } else if (linkKey == 'filebuttons') { + } else if (linkKey === 'filebuttons') { content.forEach(element => { cell.push(Download {element}} > + +
Graph:
+
+ {"Graph +
- {this.props.ic.type === "villas-node" || this.props.ic.type === "villas-relay" ? ( - -
- -
-
Graph:
-
- {"Graph -
- - {this.props.userRole === "Admin" ? ( -
-
Controls:
+ {this.props.userRole === "Admin" ? (
- - -
-
) - : (
)} +
Controls:
+
+ + +
+
) + : (
)} - this.closeConfirmModal(c)}/> - - ): (
)} + this.closeConfirmModal(c)}/> + + ) : (
)} + diff --git a/src/ic/ics.js b/src/ic/ics.js index 1982b51..0056a5c 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -74,9 +74,18 @@ class InfrastructureComponents extends Component { } }); + let externalICs = ics.find(ic => ic.managedexternally === true) + + let numberOfExternalICs = 0 + if (externalICs !== undefined && !Array.isArray(externalICs)) { + externalICs = [externalICs]; + numberOfExternalICs = externalICs.length; + } + return { sessionToken: localStorage.getItem("token"), ics: ics, + numberOfExternalICs, modalIC: {}, deleteModal: false, icModal: false, @@ -305,13 +314,13 @@ class InfrastructureComponents extends Component { return style.join(' ') } - stateUpdateModifier(updatedAt) { + stateUpdateModifier(updatedAt, component) { let dateFormat = 'ddd, DD MMM YYYY HH:mm:ss ZZ'; let dateTime = moment(updatedAt, dateFormat); return dateTime.fromNow() } - modifyManagedExternallyColumn(managedExternally){ + modifyManagedExternallyColumn(managedExternally, component){ if(managedExternally){ return @@ -321,7 +330,7 @@ class InfrastructureComponents extends Component { } - modifyUptimeColumn(uptime){ + modifyUptimeColumn(uptime, component){ if(uptime >= 0){ return {uptime + "s"} } @@ -330,20 +339,13 @@ class InfrastructureComponents extends Component { } } - modifyNameColumn(name){ - let ic = this.state.ics.find(ic => ic.name === name); - - if(ic.type === "villas-node" || ic.type === "villas-relay" || ic.managedexternally){ - return } - else{ - return {name} - } + modifyNameColumn(name, component){ + let index = this.state.ics.indexOf(component); + return } openICStatus(ic){ - let index = this.state.ics.indexOf(ic); - this.setState({ icModal: true, modalIC: ic, modalIndex: index }) } @@ -366,36 +368,70 @@ class InfrastructureComponents extends Component { } render() { + const buttonStyle = { marginLeft: '10px' }; return (
-

Infrastructure Components

- +

Infrastructure Components + {this.state.currentUser.role === "Admin" ? + ( + + + ) + : + ( ) + } +

- this.onICChecked(index, event)} width='30' /> - this.modifyNameColumn(name)}/> - this.stateLabelStyle(state, component)} /> - - - this.modifyManagedExternallyColumn(managedexternally)} width='105' /> - this.modifyUptimeColumn(uptime)}/> - - {/* */} - - - this.stateUpdateModifier(stateUpdateAt)} /> + this.onICChecked(index, event)} + width='30' + /> + this.modifyNameColumn(name, component)} + /> + this.stateLabelStyle(state, component)} + /> + + + this.modifyUptimeColumn(uptime, component)} + /> + this.stateUpdateModifier(stateUpdateAt, component)} + /> + {this.state.currentUser.role === "Admin" ? this.setState({ editModal: true, modalIC: this.state.ics[index], modalIndex: index })} + onEdit={index => this.setState({editModal: true, modalIC: this.state.ics[index], modalIndex: index})} onExport={index => this.exportIC(index)} - onDelete={index => this.setState({ deleteModal: true, modalIC: this.state.ics[index], modalIndex: index })} + onDelete={index => this.setState({deleteModal: true, modalIC: this.state.ics[index], modalIndex: index})} /> : }
- {this.state.currentUser.role === "Admin" ? -
+ + {this.state.currentUser.role === "Admin" && this.state.numberOfExternalICs > 0 ? +
this.runAction(action)} actions={[ - { id: '-1', title: 'Select command', data: { action: 'none' } }, - { id: '0', title: 'Reset', data: { action: 'reset' } }, - { id: '1', title: 'Shutdown', data: { action: 'shutdown' } }, - ]} + {id: '-1', title: 'Select command', data: {action: 'none'}}, + {id: '0', title: 'Reset', data: {action: 'reset'}}, + {id: '1', title: 'Shutdown', data: {action: 'shutdown'}}, + ]} />
: -
- } - - {this.state.currentUser.role === "Admin" ? -
- - -
- : -
+
}