walkboy/yii2-ajax-progress-bar

Bootstrap progress bar widget with updating thru ajax feature for yii2

dev-master 2022-03-03 11:15 UTC

This package is auto-updated.

Last update: 2024-04-29 04:34:21 UTC


README

Boostrap 4 progress bar widget with ability to update percent value by periodic ajax request.

Installation

composer require walkboy/yii2-ajax-progress-bar:dev-master

Usage

In your view:

<?= \walkboy\ProgressBar\ProgressBar::widget([
    'bars' => [
        [
            'percent' => $model->progressPercent, // initial percent
            'label' => $model->progressPercent.'&thinsp;%', // initial label
            'options' => ['class' => 'progress-bar-primary progress-bar-animated progress-bar-striped'],
        ],
    ],
    'url' => ['controller/some-progress', 'id' => $model->id],
    // 'period' => '10', // how often update request will be send (default 5 sec)
]) ?>

In your controller:

function actionSomeProgress($id)
{
    $model = $this->findModel($id);
    return [
        'percent' => $model->progressPercent,
        'label' => $model->progressPercent.'&thinsp;%',
    ];
}