Skip to content

Commit

Permalink
Fix broken job delete
Browse files Browse the repository at this point in the history
* fix use of api response in bulkDelete
* improve error message display
  • Loading branch information
gschueler committed Dec 13, 2013
1 parent 1794413 commit 73a4509
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ScheduledExecutionController {
private void error(){
withFormat{
html{
return render(template:"/common/error")
return render(view:"/common/error")
}
xml {
return xmlerror()
Expand Down Expand Up @@ -611,16 +611,31 @@ class ScheduledExecutionController {
/**
*/
def delete = {
return deleteBulk(new ApiBulkJobDeleteRequest(ids: [params.id]))
if (!params.id) {
request.error = g.message(code: 'api.error.parameter.required',args:['id'])
response.setStatus(400)
return error()
}
def jobid=params.id
def Framework framework = frameworkService.getFrameworkFromUserSession(session, request)
def result = scheduledExecutionService.deleteScheduledExecutionById(jobid, framework, session.user, 'delete')
if (!result.success) {
request.error = result.error.message
return error()
} else {
flash.bulkDeleteResult = [success: [result.success]]
redirect(controller: 'menu', action: 'jobs')
}
}
/**
* Delete a set of jobs as specified in the idlist parameter.
* Only allowed via POST http method
*/
def deleteBulk = {ApiBulkJobDeleteRequest deleteRequest ->
log.debug("ScheduledExecutionController: deleteBulk : params: " + params)
if (!apiService.requireAnyParameters(params,response,['ids','idlist'])) {
return
if (!params.ids && !params.idlist) {
flash.error = g.message(code: 'ScheduledExecutionController.bulkDelete.empty')
return redirect(controller: 'menu', action: 'jobs')
}
def Framework framework = frameworkService.getFrameworkFromUserSession(session, request)
def ids = new HashSet<String>()
Expand Down
1 change: 1 addition & 0 deletions rundeckapp/grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ unauthorized.job.kill=You are not authorized to kill Jobs.
unauthorized.job.delete=You are not authorized to delete this job
unauthorized.project.create=You are not authorized to create a project. Ask your RunDeck admin to create one.
ScheduledExecutionController.save.failed=Error saving Job
ScheduledExecutionController.bulkDelete.empty=Select at least one Job to delete
scheduledExecution.nodeset.empty.warning=Warning: The Node filters specified for this Job do not match any nodes, execution may fail.
Workflow.strategy.label.node-first=Node-oriented
Workflow.strategy.label.step-first=Step-oriented
Expand Down
14 changes: 12 additions & 2 deletions rundeckapp/grails-app/views/menu/_workflowsFull.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,20 @@

<div id="${rkey}wffilterform">
<g:if test="${flash.message}">
${flash.message}
<div class="alert alert-dismissable alert-info">
<a class="close" data-dismiss="alert" href="#" aria-hidden="true">&times;</a>
<div>
${flash.message.encodeAsHTML()}
</div>
</div>
</g:if>
<g:if test="${flash.error}">
<span class="error note">${flash.error}</span>
<div class="alert alert-dismissable alert-warning">
<a class="close" data-dismiss="alert" href="#" aria-hidden="true">&times;</a>
<div>
${flash.error.encodeAsHTML()}
</div>
</div>
</g:if>
<g:set var="wasfiltered" value="${paginateParams?.keySet().grep(~/(?!proj).*Filter|groupPath|idlist$/)}"/>
<g:if test="${params.createFilters}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<div class="modal-footer">
<g:form controller="scheduledExecution" action="delete" method="post">
<g:hiddenField name="id" value="${scheduledExecution.id}"/>
<g:hiddenField name="id" value="${scheduledExecution.extid}"/>
<button type="submit" class="btn btn-default btn-sm "
data-dismiss="modal">
Cancel
Expand Down

0 comments on commit 73a4509

Please sign in to comment.