Skip to content

Commit a266a48

Browse files
sanagaraj-pivotalashakirin
authored andcommitted
We remove the section when running recipe succeeds. (spring-projects-experimental#551)
1 parent cb48dcf commit a266a48

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

applications/rest-service/src/main/java/org/springframework/sbm/ReportController.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package org.springframework.sbm;
217

318
import org.springframework.beans.factory.annotation.Autowired;

applications/rest-service/src/main/resources/static/js/recipe.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class State {
77

88
isRunningARecipe() {
99
return this.runningARecipe;
10-
this.notifyListeners();
1110
}
1211

1312
startedRunningRecipe() {
@@ -62,37 +61,34 @@ function runRecipe(element) {
6261
*/
6362
function applyRecipes(btn) {
6463

65-
console.log("applying recipes: " + $(btn).attr('recipe'));
64+
const recipeName = $(btn).attr('recipe');
65+
6666
if (state.isRunningARecipe()) {
6767
return;
6868
}
6969

70-
console.log(this)
71-
7270
$.ajax({
7371
type: "POST",
7472
url: "http://localhost:8080/spring-boot-upgrade",
75-
dataType: "json",
7673
contentType: 'application/json',
7774
data: JSON.stringify({
7875
recipes: $(btn).attr('recipe')
7976
}),
8077
beforeSend: function() {
81-
console.log("before")
8278
state.startedRunningRecipe();
8379
},
84-
success: function() {
85-
// remove this section from the report
86-
jQuery(this).closest('h3').next().remove();
87-
88-
},
8980
error: function() {
9081
// mark red flashlights / play alarm sound
9182
}
92-
}).always(function () {
93-
console.log("finished recipes")
94-
state.completedRunningRecipe();
95-
});
83+
})
84+
.done(function () {
85+
$(`.run-a-recipe[recipe='${recipeName}']`)
86+
.closest(".sect2")
87+
.remove();
88+
})
89+
.always(function () {
90+
state.completedRunningRecipe();
91+
});
9692
}
9793

9894
$( document ).ajaxStart(function() {

0 commit comments

Comments
 (0)