jQuery.telligent.evolution.ui.components.scheduledfile
UI Component which allows client-side declarative rendering of a scheduled script file execution's status. Transforms the output from core_v2_ui.ScheduledFile(), which is a <span class="ui-scheduledfile"></span> stub. The default implementation uses the evolutionProgressIndicator plugin. Overrides can be provided at the theme level to present file status differently.
Options
- progresskey: Identifier matching the- ProgressKeypassed to- core_v2_widget.ScheduleFile()
- percentcomplete: Optional initial percent complete
- includepercentcomplete: Includes a progress bar displaying completion percentage reported by the script with context_v2_scheduledFile.Report()
- includelatestmessage: Includes only the latest message reported by the script with- context_v2_scheduledFile.Report()
- includeallmessages: Includes a log of all messages reported by the script with- context_v2_scheduledFile.Report()
Example
A barebones UI component override which would result in rendering a read-only message of 'Indicator: [Key] [Percent]'.
$.telligent.evolution.ui.components.scheduledfile = {
    setup: function() {},
    add: function(elm, options) {
        $(elm).html('Indicator ' + options.progresskey + ' ' + options.percentcomplete);
    }
};
Default Implementation
For reference purposes or as the basis for an override:
(function($){
    // Handle scheduleFile API messages and calling updates on the progress indicator
    function handleMessages(context) {
        messaging.subscribe('scheduledFile.complete', getMessageNamespace(context), function(data) {
            if (data.progressKey !== context.progressKey)
                return;
            context.indicator.evolutionProgressIndicator('complete', data);
            dispose(context);
        });
        messaging.subscribe('scheduledFile.error', getMessageNamespace(context), function(data) {
            if (data.progressKey !== context.progressKey)
                return;
            context.indicator.evolutionProgressIndicator('error', data ? data.message : null);
            dispose(context);
        });
        messaging.subscribe('scheduledFile.progress', getMessageNamespace(context), function(data) {
            if (data.progressKey !== context.progressKey)
                return;
            context.indicator.evolutionProgressIndicator('progress', data);
        });
    }
    function dispose(context) {
        setTimeout(function() {
            messaging.unsubscribe(getMessageNamespace(context));
        }, 100);
    }
    function getMessageNamespace(context) {
        return 'messages-' + context.progressKey;
    }
    $.telligent.evolution.ui.components.scheduledfile = {
        setup: function () {
        },
        add: function (elm, options) {
            // Start monitoring the progress key to ensure ajax fallbacks are called
            // in case sockets disconnect so that scheduleFile messages are guaranteed to be raised
            $.telligent.evolution.scheduledFile.monitor(options.progresskey);
            // render an indicator
            var context = $.extend({}, {
                progressKey: options.progresskey,
                percentComplete: options.percentcomplete,
                log: JSON.parse(options.log),
                indicator: $(elm).evolutionProgressIndicator({
                    includePercentComplete: options.includepercentcomplete == 'true',
                    includeLatestMessage: options.includelatestmessage == 'true',
                    includeAllMessages: options.includeallmessages == 'true'
                })
            });
            // If any initial progress or log messages at render-time, render those as well
            if(context.percentComplete && context.percentComplete > 0) {
                context.indicator.evolutionProgressIndicator('progress', {
                    percentComplete: parseFloat(context.percentComplete)
                });
            }
            if(context.log) {
                for (var i = 0; i < context.log.length; i++) {
                    context.indicator.evolutionProgressIndicator('progress', {
                        message: context.log });
                }
            }
            handleMessages(context);
        }
    };
}(jQuery));
                    });
                }
            }
            handleMessages(context);
        }
    };
}(jQuery));
 
				