Skip to main content

SSE ETL Component & Integration Guide

This document provides a technical guide for developers on the three-stage import system. It covers the purpose of each Vue component, their API (props and events), and the required Laravel backend setup for Server-Sent Events (SSE) interaction.

(English)

Part 1: Component Architecture Overview

The import process is managed by three distinct Vue components that create a robust, three-stage user experience:
  1. AttachmentLinkUpload.vue: The initial file uploader. It handles the first stage (Upload) and, when configured, triggers the second stage.
  2. SseProgressBar.vue: A reusable component that provides real-time progress for any long-running background task (Buffering and Commit stages).
  3. EtlImportModal.vue: The main orchestrator. It controls the overall workflow, showing the correct component for each stage and managing the state of the import process.

Part 2: Component Documentation

1. SseProgressBar.vue

A general-purpose component for displaying real-time progress from an SSE stream.

Purpose

To connect to a server endpoint, listen for progress events, and display the status and percentage to the user.

Props

Events

Usage Example


2. AttachmentLinkUpload.vue

A flexible file uploader that can operate in a standard mode or in a background-processing mode with SSE.

Purpose

To handle the initial file upload. In “SSE mode,” it uploads the file and then immediately hands off to the SseProgressBar to track the background job it just triggered.

Key Props for ETL Integration

Key Events for ETL Integration

Usage Example


3. EtlImportModal.vue

The main modal component that orchestrates the entire import flow.

Purpose

To provide a complete UI for the three-stage import process by managing and displaying the other two components based on the current stage.

Props

Public Methods

Events


Part 3: Backend Setup for SSE Interaction

The frontend components rely on specific backend endpoints to function correctly.

1. Required Routes

Ensure these routes are defined in your routes/api.php file.

2. Controller Logic for SSE

The controller needs methods to handle the SSE connections. A helper function can reduce code duplication. File: app/Http/Controllers/EtlController.php

3. Job Progress Reporting

Your background jobs must periodically update a value in the cache that the controller can read. Example from ProcessImportFileJob.php:


(Bahasa Indonesia)

Bagian 1: Gambaran Arsitektur Komponen

Proses impor dikelola oleh tiga komponen Vue yang berbeda untuk menciptakan pengalaman pengguna tiga tahap yang tangguh:
  1. AttachmentLinkUpload.vue: Pengunggah file awal. Komponen ini menangani tahap pertama (Upload) dan, saat dikonfigurasi, akan memicu tahap kedua.
  2. SseProgressBar.vue: Komponen yang dapat digunakan kembali yang menyediakan progres real-time untuk tugas latar belakang apa pun yang berjalan lama (tahap Buffering dan Commit).
  3. EtlImportModal.vue: Orkestrator utama. Komponen ini mengontrol alur kerja secara keseluruhan, menampilkan komponen yang benar untuk setiap tahap, dan mengelola status proses impor.

Bagian 2: Dokumentasi Komponen

1. SseProgressBar.vue

Komponen serbaguna untuk menampilkan progres real-time dari stream Server-Sent Events (SSE).

Tujuan

Untuk terhubung ke endpoint server, mendengarkan event progres, dan menampilkan status serta persentase kepada pengguna.

Props

Event


2. AttachmentLinkUpload.vue

Pengunggah file fleksibel yang dapat beroperasi dalam mode standar atau mode pemrosesan latar belakang dengan SSE.

Tujuan

Untuk menangani unggahan file awal. Dalam “mode SSE”, komponen ini mengunggah file dan segera menyerahkannya ke SseProgressBar untuk melacak tugas latar belakang yang baru saja dipicu.

Props Kunci untuk Integrasi ETL

Event Kunci untuk Integrasi ETL


3. EtlImportModal.vue

Komponen modal utama yang mengatur seluruh alur impor.

Tujuan

Menyediakan UI lengkap untuk proses impor tiga tahap dengan mengelola dan menampilkan dua komponen lainnya berdasarkan stage saat ini.

Props

Method Publik

Event


Bagian 3: Pengaturan Backend untuk Interaksi SSE

Komponen frontend bergantung pada endpoint backend tertentu agar dapat berfungsi dengan benar.

1. Rute yang Diperlukan

Pastikan rute-rute ini didefinisikan dalam file routes/api.php Anda.

2. Logika Controller untuk SSE

Controller memerlukan method untuk menangani koneksi SSE. Fungsi pembantu dapat mengurangi duplikasi kode. File: app/Http/Controllers/EtlController.php

3. Pelaporan Progres dari Job

Job latar belakang Anda harus secara berkala memperbarui nilai di cache yang dapat dibaca oleh controller. Contoh dari ProcessImportFileJob.php: