From 4b90126a81d19998630aa701221261fc9f2e88bb Mon Sep 17 00:00:00 2001 From: sanagaraj-pivotal Date: Mon, 14 Nov 2022 14:44:27 +0000 Subject: [PATCH] We remove the section when running recipe succeeds. --- .../springframework/sbm/ReportController.java | 15 +++++++++++ .../src/main/resources/static/js/recipe.js | 26 ++++++++----------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java b/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java index bb66a1cda..74b144727 100644 --- a/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java +++ b/applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java @@ -1,3 +1,18 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.springframework.sbm; import org.springframework.beans.factory.annotation.Autowired; diff --git a/applications/rest-service/src/main/resources/static/js/recipe.js b/applications/rest-service/src/main/resources/static/js/recipe.js index 3315267d6..5676b81e3 100644 --- a/applications/rest-service/src/main/resources/static/js/recipe.js +++ b/applications/rest-service/src/main/resources/static/js/recipe.js @@ -7,7 +7,6 @@ class State { isRunningARecipe() { return this.runningARecipe; - this.notifyListeners(); } startedRunningRecipe() { @@ -62,37 +61,34 @@ function runRecipe(element) { */ function applyRecipes(btn) { - console.log("applying recipes: " + $(btn).attr('recipe')); + const recipeName = $(btn).attr('recipe'); + if (state.isRunningARecipe()) { return; } - console.log(this) - $.ajax({ type: "POST", url: "http://localhost:8080/spring-boot-upgrade", - dataType: "json", contentType: 'application/json', data: JSON.stringify({ recipes: $(btn).attr('recipe') }), beforeSend: function() { - console.log("before") state.startedRunningRecipe(); }, - success: function() { - // remove this section from the report - jQuery(this).closest('h3').next().remove(); - - }, error: function() { // mark red flashlights / play alarm sound } - }).always(function () { - console.log("finished recipes") - state.completedRunningRecipe(); - }); + }) + .done(function () { + $(`.run-a-recipe[recipe='${recipeName}']`) + .closest(".sect2") + .remove(); + }) + .always(function () { + state.completedRunningRecipe(); + }); } $( document ).ajaxStart(function() {