mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Send IC control commands from status dialog #265
This commit is contained in:
parent
be0c656a22
commit
b24f5cf638
4 changed files with 79 additions and 6 deletions
|
@ -78,6 +78,40 @@ class IcDataDataManager {
|
|||
})
|
||||
}
|
||||
|
||||
restart(url,socketname,token){
|
||||
RestAPI.post(url, null).then(response => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/restart-successful',
|
||||
data: response,
|
||||
token: token,
|
||||
socketname: socketname,
|
||||
});
|
||||
}).catch(error => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/restart-error',
|
||||
error: error
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
shutdown(url,socketname,token){
|
||||
RestAPI.post(url, null).then(response => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/shutdown-successful',
|
||||
data: response,
|
||||
token: token,
|
||||
socketname: socketname,
|
||||
});
|
||||
}).catch(error => {
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/shutdown-error',
|
||||
error: error
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
closeAll() {
|
||||
// close every open socket
|
||||
for (var identifier in this._sockets) {
|
||||
|
|
|
@ -38,7 +38,7 @@ class ICDialog extends React.Component {
|
|||
|
||||
closeConfirmModal(canceled){
|
||||
if(!canceled){
|
||||
this.props.sendControlCommand(this.state.command);
|
||||
this.props.sendControlCommand(this.state.command,this.props.ic);
|
||||
}
|
||||
|
||||
this.setState({confirmCommand: false, command: ''});
|
||||
|
|
|
@ -28,7 +28,7 @@ class ICStatusStore extends ArrayStore {
|
|||
switch(action.type) {
|
||||
|
||||
case 'ic-status/get-status':
|
||||
ICDataDataManager.getStatus(action.url, action.socketname, action.token,action.icid);
|
||||
ICDataDataManager.getStatus(action.url, action.socketname, action.token, action.icid);
|
||||
return super.reduce(state, action);
|
||||
|
||||
case 'ic-status/status-received':
|
||||
|
@ -38,7 +38,29 @@ class ICStatusStore extends ArrayStore {
|
|||
|
||||
case 'ic-status/status-error':
|
||||
console.log("status error");
|
||||
return super.reduce(state, action);
|
||||
return state;
|
||||
|
||||
case 'ic-status/restart':
|
||||
ICDataDataManager.restart(action.url, action.socketname, action.token);
|
||||
return state;
|
||||
|
||||
case 'ic-status/restart-successful':
|
||||
return state;
|
||||
|
||||
case 'ic-status/restart-error':
|
||||
console.log("restart error");
|
||||
return state;
|
||||
|
||||
case 'ic-status/shutdown':
|
||||
ICDataDataManager.shutdown(action.url, action.socketname, action.token);
|
||||
return state;
|
||||
|
||||
case 'ic-status/shutdown-successful':
|
||||
return state;
|
||||
|
||||
case 'ic-status/shutdown-error':
|
||||
console.log("shutdown error");
|
||||
return state;
|
||||
|
||||
default:
|
||||
return super.reduce(state, action);
|
||||
|
|
|
@ -365,8 +365,25 @@ class InfrastructureComponents extends Component {
|
|||
this.setState({ icModal: true, modalIC: ic, modalICStatus: icStatus, modalICGraph: icGraph, modalIndex: index })
|
||||
}
|
||||
|
||||
sendControlCommand(command){
|
||||
console.log(command);
|
||||
sendControlCommand(command,ic){
|
||||
let splitWebsocketURL = ic.websocketurl.split("/");
|
||||
|
||||
if(command === "restart"){
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/restart',
|
||||
url: ic.apiurl + "/restart",
|
||||
socketname: splitWebsocketURL[splitWebsocketURL.length - 1],
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
}else if(command === "shutdown"){
|
||||
AppDispatcher.dispatch({
|
||||
type: 'ic-status/shutdown',
|
||||
url: ic.apiurl + "/shutdown",
|
||||
socketname: splitWebsocketURL[splitWebsocketURL.length - 1],
|
||||
token: this.state.sessionToken,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
|
@ -439,7 +456,7 @@ class InfrastructureComponents extends Component {
|
|||
<NewICDialog show={this.state.newModal} onClose={data => this.closeNewModal(data)} />
|
||||
<EditICDialog show={this.state.editModal} onClose={data => this.closeEditModal(data)} ic={this.state.modalIC} />
|
||||
<ImportICDialog show={this.state.importModal} onClose={data => this.closeImportModal(data)} />
|
||||
<ICDialog show={this.state.icModal} onClose={data => this.closeICModal(data)} ic={this.state.modalIC} token={this.state.sessionToken} icStatus={this.state.modalICStatus} icGraph={this.state.modalICGraph} sendControlCommand={(command) => this.sendControlCommand(command)}/>
|
||||
<ICDialog show={this.state.icModal} onClose={data => this.closeICModal(data)} ic={this.state.modalIC} token={this.state.sessionToken} icStatus={this.state.modalICStatus} icGraph={this.state.modalICGraph} sendControlCommand={(command, ic) => this.sendControlCommand(command, ic)}/>
|
||||
|
||||
<DeleteDialog title="infrastructure-component" name={this.state.modalIC.name || 'Unknown'} show={this.state.deleteModal} onClose={(e) => this.closeDeleteModal(e)} />
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue