Skip to content

Commit

Permalink
feat: configure Chromium settings in app config for report generation (
Browse files Browse the repository at this point in the history
…#21)

* feat: configure Chromium settings in app config for report generation

* chore: update .gitignore and add .dockerignore for improved file exclusion
  • Loading branch information
fadhilyori authored Feb 25, 2025
1 parent 848ab3b commit f0080c1
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 27 deletions.
136 changes: 136 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Created by https://www.toptal.com/developers/gitignore/api/laravel,phpstorm+all,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=laravel,phpstorm+all,visualstudiocode

### Laravel ###
/vendor/
node_modules/
npm-debug.log
yarn-error.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot

# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot

storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache

### PhpStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### PhpStorm+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/laravel,phpstorm+all,visualstudiocode
158 changes: 136 additions & 22 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,138 @@
/.phpunit.cache
/node_modules
/public/build
/public/hot
/public/storage
/storage/*.key
/storage/pail
/vendor
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
/chrome
Homestead.json
Homestead.yaml
auth.json
# Created by https://www.toptal.com/developers/gitignore/api/laravel,phpstorm+all,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=laravel,phpstorm+all,visualstudiocode

### Laravel ###
/vendor/
node_modules/
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.nova
/.vscode
/.zed

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
public/build

# Laravel 5 & Lumen specific with changed public path
public_html/storage
public_html/hot
public_html/build

storage/*.key
.env
Homestead.yaml
Homestead.json
/.vagrant
.phpunit.result.cache

### PhpStorm+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### PhpStorm+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/laravel,phpstorm+all,visualstudiocode
9 changes: 5 additions & 4 deletions app/Http/Controllers/ReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\URL;
use Carbon\Carbon;
use Illuminate\Support\Facades\Config;

class ReportController extends Controller
{
Expand Down Expand Up @@ -456,11 +457,12 @@ public function downloadReport($id)
$pdfPath = storage_path('app/reports/report_' . $id . '.pdf');
$url = URL::signedRoute('reports.view', ['id' => $id]);
// $headerHtml = view('reports.alert_report_header')->render();
$chromiumIpAddress = env('CHROMIUM_IP_ADDRESS');
$chromiumPort = env('CHROMIUM_PORT');

Browsershot::url($url)
->setRemoteInstance($chromiumIpAddress, $chromiumPort)
->setRemoteInstance(
Config::get('app.chromium.address'),
Config::get('app.chromium.port'),
)
->waitUntilNetworkIdle()
->format('A4')
->showBackground()
Expand Down Expand Up @@ -533,4 +535,3 @@ private function createOrUpdateIdentity($ipAddress): Identity
throw new \InvalidArgumentException("IP address is required");
}
}

7 changes: 6 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],



'chromium' => [
'address' => env('CHROMIUM_IP_ADDRESS', "localhost"),
'port' => env('CHROMIUM_PORT', 9222),
],

];

0 comments on commit f0080c1

Please sign in to comment.