aboutsummaryrefslogtreecommitdiff
path: root/frontend/src
diff options
context:
space:
mode:
authorEmiliano Ciavatta2021-05-05 17:33:55 +0000
committerGitHub2021-05-05 17:33:55 +0000
commitd6defddd70a548f0375e25e2ad8ad3080c71039d (patch)
treead76a43865cd9f18309552412039b94d57911c69 /frontend/src
parent9df980cf9c4c75f2de0b5303c83f7f04117397a6 (diff)
parent801eab3b3ec305706b9107d928d52a0c4c042eef (diff)
Merge pull request #24 from EvilBunnyWrote/main
Add Delete Service Functionality
Diffstat (limited to 'frontend/src')
-rw-r--r--frontend/src/components/panels/ServicesPane.js15
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>