# You must use a tab-size of 4 spaces to edit this file.
---
zenario__administration:
    nav:
        zenario_scheduled_task_manager__scheduled_tasks:
            priv: _PRIV_VIEW_SCHEDULED_TASK
            ord: custom_datasets + 0.1
            name: Scheduled tasks
            tooltip: View and manage tasks that run by themselves, e.g. overnight processes
            link:
                path: zenario__administration/panels/zenario_scheduled_task_manager__scheduled_tasks
        
    panels:
        zenario_scheduled_task_manager__scheduled_tasks:
            title: Scheduled Tasks
            panel_type: list_with_master_switch
            
                        
            notice_site_disabled:
                show: true
                type: warning
                message: The site is disabled. Scheduled tasks will not run whilst the site is disabled.
            notice_master_switch_off:
                show: true
                type: warning
                message: The master switch is Off.
            notice_master_switch_on:
                show: true
                type: information
                message: The master switch is On.
            notice_crontab:
                show: true
                type: error
                message: |
                        crontab isn't invoking Scheduled Task Manager. A server administrator should copy code from below, paste into crontab, wait 1 minute and reload page.
            
            db_items:
                table: '[[DB_PREFIX]]jobs AS j'
                id_column: j.id
                custom_where_statement_if_no_refiner: "WHERE manager_class_name = 'zenario_scheduled_task_manager'"
            columns:
                job_name:
                    title: Method name
                    db_column: j.job_name
                    searchable: true
                    always_show: true
                    width: large
                module:
                    title: Module name
                    db_column: j.module_class_name
                    always_show: true
                    width: medium
                job_type:
                    title: Type
                    db_column: j.job_type
                    show_by_default: false
                    format: enum
                    values:
                        scheduled: Scheduled task
                        background: Background task
                enabled:
                    title: Enabled
                    db_column: j.enabled
                    format: true_or_false
                    true_phrase: Enabled
                    false_phrase: Disabled
                    always_show: true
                    width: xsmall
                    disallow_sorting: true
                script_restart_time:
                    db_column: j.script_restart_time
                status:
                    title: Status
                    db_column: j.status
                    show_by_default: true
                    width: small
                    disallow_sorting: true
                months:
                    title: Months
                    db_column: j.months
                    disallow_sorting: true
                first_n_days_of_month:
                    title: Month days
                    db_column: j.first_n_days_of_month
                    disallow_sorting: true
                email_address_on_error:
                    title: Email address (errors)
                    db_column: j.email_address_on_error
                    disallow_sorting: true
                email_on_action:
                    title: Email on action
                    db_column: j.email_on_action
                    format: yes_or_no
                    disallow_sorting: true
                email_address_on_action:
                    title: Email address (on action)
                    db_column: j.email_address_on_action
                    disallow_sorting: true
                last_run_started:
                    title: Last run started
                    db_column: j.last_run_started
                    format: datetime
                    width: medium
                    disallow_sorting: true
                last_run_finished:
                    title: Last run finished
                    db_column: j.last_run_finished
                    format: datetime
                    show_by_default: true
                    width: medium
                    disallow_sorting: true
                last_successful_run:
                    title: Last successful run
                    db_column: j.last_successful_run
                    format: datetime
                    width: medium
                    disallow_sorting: true
                last_action:
                    title: Last action
                    db_column: j.last_action
                    format: datetime
                    show_by_default: true
                    width: medium
                    disallow_sorting: true
            default_sort_column: job_name
            item:
                name: Scheduled Task
                names: Scheduled Tasks
                css_class: zenario_scheduled_task_manager__task
            no_items_message: |
                No Scheduled Tasks exist.
                If you install and run a module that has a Scheduled Task, it will appear here.
            collection_buttons:
                setup_crontab_dropdown:
                    hide_on_refiner: true
                    label: Setup crontab
                copy_code:
                    parent: setup_crontab_dropdown
                    visible_if: zenario.canCopy()
                    label: Copy code for crontab
                get_code:
                    parent: setup_crontab_dropdown
                    label: Show code for crontab
                    ajax:
                        request:
                            get_code: 1
                
                master_switch:
                    priv: _PRIV_MANAGE_SCHEDULED_TASK
                    hidden: true
                    hide_on_refiner: true
                    label: 'Master switch:'
                master_switch_off:
                    priv: _PRIV_MANAGE_SCHEDULED_TASK
                    parent: master_switch
                    css_class: run
                    ajax:
                        confirm:
                            message: >
                                Turn the master switch to On?
                            button_message: Enable
                            cancel_button_message: Cancel
                            message_type: question
                        request:
                            enable_all: 1
                master_switch_on:
                    priv: _PRIV_MANAGE_SCHEDULED_TASK
                    parent: master_switch
                    css_class: stop
                    ajax:
                        confirm:
                            message: >
                                Are you sure that you wish to turn off the master switch? This will stop all scheduled tasks.
                            button_message: Stop
                            cancel_button_message: Cancel
                            message_type: warning
                        request:
                            suspend_all: 1
            item_buttons:
                enable:
                    ord: 20
                    priv: _PRIV_MANAGE_SCHEDULED_TASK
                    css_class: run
                    label: Enable task
                    multiple_select: true
                    multiple_select_label: Enable selected tasks
                    ajax:
                        request:
                            enable: 1
                    with_columns_set:
                        can_enable: true
                suspend:
                    ord: 20
                    priv: _PRIV_MANAGE_SCHEDULED_TASK
                    css_class: suspend
                    label: Disable task
                    multiple_select: true
                    multiple_select_label: Disable selected tasks
                    ajax:
                        confirm:
                            message: |
                                Are you sure you wish to disable the task with the name "[[job_name]]"?
                            multiple_select_message: |
                                Are you sure you wish to dsable the [[item_count]] selected scheduled tasks?
                            button_message: "Disable"
                            message_type: warning
                            cancel_button_message: Cancel
                            message_type: warning
                        request:
                            suspend: 1
                    with_columns_set:
                        can_suspend: true
                edit:
                    visible_if: |
                        item.job_type == 'scheduled'
                    css_class: settings
                    label: Edit scheduled task
                    ord: 10
                    admin_box:
                        path: zenario_job
                view_log:
                    ord: 50
                    visible_if: |
                        item.job_type == 'scheduled'
                    css_class: log scheduled_task_log
                    label: View log
                    link:
                        path: >
                            zenario__administration/panels/zenario_scheduled_task_manager__scheduled_tasks/hidden_nav/log/panel
                        branch: true
                        refiner: job
                rerun:
                    ord: 40
                    visible_if: |
                        item.job_type == 'scheduled'
                    css_class: run_now
                    label: Rerun within the next minute
                    ajax:
                        request:
                            rerun: 1
                    with_columns_set:
                        can_rerun: true
            
            hidden_nav:
                log:
                    panel:
                        title: Log
                        slidedown_view_microtemplate: summary
                        default_sort_desc: 
                            exists: true
                        db_items:
                            table: '[[DB_PREFIX]]job_logs AS jl'
                            id_column: jl.id
                        refiners:
                            job:
                                sql: 'jl.job_id = [[REFINER_ID]]'
                        columns:
                            started:
                                title: Started
                                db_column: jl.started
                                format: datetime
                                always_show: true
                                disallow_sorting: true
                            finished:
                                title: Finished
                                db_column: jl.finished
                                format: datetime
                                always_show: true
                            status:
                                title: Status
                                db_column: jl.status
                                always_show: true
                                searchable: true
                                disallow_sorting: true
                            summary:
                                title: Message
                                always_show: true
                                searchable: true
                                db_column: jl.note
                                width: xxlarge
                                disallow_sorting: true
                                html: true
                        default_sort_column: finished
                        item:
                            css_class: log scheduled_task_log
                        collection_buttons:
                            truncate:
                                css_class: delete
                                label: Delete all log entries
                                ajax:
                                    confirm:
                                        message: >
                                            Are you sure you wish to delete all log entries for this scheduled task?
                                        button_message: Delete
                                        cancel_button_message: Cancel
                                        message_type: warning
                                    request:
                                        truncate: 1
                        item_buttons:
                            delete:
                                css_class: delete
                                label: Delete this log entry
                                multiple_select: true
                                multiple_select_tooltip: Delete selected log entries
                                ajax:
                                    request:
                                        delete: 1
