diff options
author | MD-Levitan | 2021-05-03 17:49:40 +0000 |
---|---|---|
committer | MD-Levitan | 2021-05-03 17:49:40 +0000 |
commit | ae8b8b5a5b4943df04f55dbec6c6db7e497d72c8 (patch) | |
tree | 58df22e242d77934dc1d837e270956d959591213 /frontend/src | |
parent | 443e7407b00f0e09e071801ba6fbd99c9fc51884 (diff) |
Add feature to delete service
Diffstat (limited to 'frontend/src')
-rw-r--r-- | frontend/src/components/panels/ServicesPane.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/frontend/src/components/panels/ServicesPane.js b/frontend/src/components/panels/ServicesPane.js index 5986804..9f89485 100644 --- a/frontend/src/components/panels/ServicesPane.js +++ b/frontend/src/components/panels/ServicesPane.js @@ -85,6 +85,19 @@ class ServicesPane extends Component { } }; + deleteService = () => { + const service = this.state.currentService; + if (this.validateService(service)) { + backend.delete("/api/services", service).then((res) => { + this.reset(); + this.setState({serviceStatusCode: res.status}); + this.loadServices(); + }).catch((res) => { + this.setState({serviceStatusCode: res.status, serviceResponse: JSON.stringify(res.json)}); + }); + } + }; + validateService = (service) => { let valid = true; if (!validation.isValidPort(service.port, true)) { @@ -207,6 +220,8 @@ class ServicesPane extends Component { <ButtonField variant={isUpdate ? "blue" : "green"} name={isUpdate ? "update_service" : "add_service"} bordered onClick={this.updateService}/> + {isUpdate ? <ButtonField variant="blue" name= "delete_service" + bordered onClick={this.deleteService}/> : ""} </div> </div> </div> |