Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Quartz Progressbar Grails plugin
JavaScript Groovy
tree: ac5dec77e5

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.settings
grails-app
scripts
src/groovy/quartz/progressbar
web-app
.classpath
.gitignore
.project
QuartzProgressBarGrailsPlugin.groovy
README.md
application.properties first version

README.md

Quartz Progressbar Grails Plugin

Controller code:

def save() {
    def myDomainInstance = new MyDomain(params)
    if (!myDomainInstance.save(flush: true)) {
        render(view: "create", model: [myDomainInstance: myDomainInstance])
        return
    }
    def progBarId = QuartzProgressBar.execute{ ctx, progressBar ->
        progressBar.total = 42
        42.times{
            progressBar.step = it + 1
            progressBar.msg = "step ${progressBar.step} of ${progressBar.total}"
            sleep(128)
        }
        progressBar.msg = "done"
    }
    def progBarId2 = QuartzProgressBar.execute{ ctx, progressBar ->
        //ctx.myService.myMethod()
        progressBar.total = 42
        12.times{
            progressBar.step = it + 1
            progressBar.msg = "step ${progressBar.step} of ${progressBar.total}"
            sleep(256)
        }
        progressBar.msg = "done"
        throw new RuntimeException("some error")
    }
    flash.message = message(code: 'default.created.message', args: [message(code: 'myDomain.label', default: 'MyDomain'), myDomainInstance.id])
    redirect(action: "show", id: myDomainInstance.id, params : [progBarId: progBarId, progBarId2: progBarId2])
}

View code:

<script type="text/javascript">
    var config = {
        contextPath: "${request.contextPath}"
    };
</script>
<g:quartzProgressBar id="${params.progBarId }" />
<g:quartzProgressBar id="${params.progBarId2 }" />

How to get quartzProgressData object?

package quartz.progress.bar.sample

public class MySampleJob {

    static triggers = {
        cron name: 'MySampleProgressJob', cronExpression: "1/120 * * * * ?"
    }

    def group = 'MySampleJobs'

    def grailsApplication

    def execute(context) {
        def progressData = context.mergedJobDataMap.get("quartzProgressData")
        progressData.total = 331
        331.times{
            sleep(512)
            progressData.step = it + 1
            progressData.msg = "Step ${progressData.step} of ${progressData.total}"
            println "Step ${progressData.step} of ${progressData.total}"
        }
        progressData.msg = "Done..."
    }
}

All jobs running:

<script type="text/javascript">
    var config = {
        contextPath: "${request.contextPath}"
    };
</script>
<g:quartzProgressBarList />

Sample grails project at: https://github.com/fabiooshiro/quartz-progress-bar-sample

Something went wrong with that request. Please try again.