diff --git a/config/pwa.php b/config/pwa.php new file mode 100644 index 000000000..b42c548f7 --- /dev/null +++ b/config/pwa.php @@ -0,0 +1,72 @@ + true, + + /* + |-------------------------------------------------------------------------- + | PWA Manifest Configuration + |-------------------------------------------------------------------------- + | php artisan erag:update-manifest + */ + + // 'manifest' => [ + // 'name' => 'Digital Manufacturing', + // 'short_name' => 'LPT', + // 'background_color' => '#6777ef', + // 'display' => 'standalone', + // 'description' => 'A Progressive Web Application setup for Laravel projects.', + // 'theme_color' => '#6777ef', + // 'icons' => [ + // [ + // 'src' => 'logo.png', + // 'sizes' => '512x512', + // 'type' => 'image/png', + // ], + // ], + // ], + + 'manifest' => [ + 'name' => 'Digital Manufacturing', + 'short_name' => 'PWA', + 'start_url' => '/', + 'background_color' => '#6777ef', + 'display' => 'fullscreen', + 'description' => 'A Progressive Web Application setup for Laravel projects.', + 'theme_color' => '#6777ef', + 'icons' => [ + [ + 'src' => 'logo.png', + 'sizes' => '512x512', + 'type' => 'image/png', + ], + ], + ], + + /* + |-------------------------------------------------------------------------- + | Debug Configuration + |-------------------------------------------------------------------------- + | Toggles the application's debug mode based on the environment variable + */ + + 'debug' => env('APP_DEBUG', false), + + /* + |-------------------------------------------------------------------------- + | Livewire Integration + |-------------------------------------------------------------------------- + | Set to true if you're using Livewire in your application to enable + | Livewire-specific PWA optimizations or features. + */ + + 'livewire-app' => false, +]; diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 000000000..9ada1c54b --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,16 @@ +{ + "name": "Laravel PWA", + "short_name": "LPT", + "background_color": "#6777ef", + "display": "standalone", + "description": "A Progressive Web Application setup for Laravel projects.", + "theme_color": "#6777ef", + "start_url": "/", + "icons": [ + { + "src": "logo.png", + "sizes": "512x512", + "type": "image/png" + } + ] +} diff --git a/public/offline.html b/public/offline.html new file mode 100644 index 000000000..56e0caba1 --- /dev/null +++ b/public/offline.html @@ -0,0 +1,21 @@ + + + + + + Check your internet connection + + + +
+
CONNECTING
+
+
+
+
+
+
+
+
+ + diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 000000000..d3ea5c692 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,47 @@ +"use strict"; + +const CACHE_NAME = "offline-cache-v1"; +const OFFLINE_URL = '/offline.html'; + +const filesToCache = [ + OFFLINE_URL +]; + +self.addEventListener("install", (event) => { + event.waitUntil( + caches.open(CACHE_NAME) + .then((cache) => cache.addAll(filesToCache)) + ); +}); + +self.addEventListener("fetch", (event) => { + if (event.request.mode === 'navigate') { + event.respondWith( + fetch(event.request) + .catch(() => { + return caches.match(OFFLINE_URL); + }) + ); + } else { + event.respondWith( + caches.match(event.request) + .then((response) => { + return response || fetch(event.request); + }) + ); + } +}); + +self.addEventListener('activate', (event) => { + event.waitUntil( + caches.keys().then((cacheNames) => { + return Promise.all( + cacheNames.map((cacheName) => { + if (cacheName !== CACHE_NAME) { + return caches.delete(cacheName); + } + }) + ); + }) + ); +}); diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php new file mode 100644 index 000000000..af387dd2b --- /dev/null +++ b/resources/views/layouts/app.blade.php @@ -0,0 +1,67 @@ +{{-- + + --}} + +{{-- + + + + + + {{ config('app.name', 'Laravel') }} + + + + + + + + + + + + + @yield('content') + + --}} + + + + + + + @yield('title', 'Weight Scale Validation') + + + @PwaHead + + + + + + @yield('content') + + + @RegisterServiceWorkerScript + + + +