As the title says, I've been trying for hours (while watching the Red Sox win!) to code a way to delete a bundle. Using HPM's code to debug how it's done with apps/drivers, it's pretty straight forward BUT for bundles it seems to be different.
With apps/drivers the page source has this,
<button class="mdl-button mdl-js-button mdl-button--raised mdl-button--accent pull-right" type="button" onclick="deleteApp(); return false">Delete</button>
<form action="/driver/edit/update" method="post" name="deleteform" id="deleteform">
<input type="hidden" name="id" value="112" id="id" />
<input type="hidden" name="_action_delete" value="Delete" class="delete btn btn-danger" />
</form>
and HPM uses that info like this...
def params = [
uri: "http://127.0.0.1:8080",
path: "/driver/editor/update",
requestContentType: "application/x-www-form-urlencoded",
headers: [
"Cookie": state.cookie
],
body: [
id: id,
"_action_delete": "Delete"
],
timeout: 300,
textParser: true,
ignoreSSLIssues: true
]
httpPost(params) { resp ->
if (resp.data == null)
paragraph "Success!"
else {
def matcherText = resp.data.text.replace("\n","").replace("\r","")
def matcher = matcherText.find(/<div class="alert-close close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×<\/span><\/div>(.+?)<\/div>/)
}
}
Which runs:
function deleteApp() {
var resp = confirm("Are you sure?");
if (resp == true) {
document.getElementById('deleteform').submit();
}
}
BUT, Bundles page source shows that they don't have the code needed to virtually push the Delete button! Bundles only have this line but not the rest.
<button class="btn mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" style="width: 8em; margin-right: 0.5em;" onclick="deleteBundle()">Delete</button>
Which sends it to deleteBundle():
function deleteBundle() {
if (confirm('Are you sure?')) {
$.get('/bundle/delete/' + bundleId, function(data) {
window.location.href = '/bundle/list';
});
}
}
Now if you're still reading ...
I can put 'http://(hub ip):8080/bundle/delete/999' in a browser and it will delete the bundle and bring me back to the Bundle list page (like it says it will in the function).
SO, is there a way to do it in Groovy!? Without dumping me out to the bundle list screen?
Thanks