diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0111090..005bbfd 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -1569,6 +1569,8 @@ $routes->get('app/nursing/(:any)', 'Api\v1\NursingApi::pwaIndex'); $routes->get('app/doctor', 'Api\v1\DoctorApi::pwaIndex'); $routes->get('app/doctor/(:any)', 'Api\v1\DoctorApi::pwaIndex'); $routes->get('app/queue', 'Api\v1\DoctorApi::queueIndex'); +$routes->get('app/queue/sw.js', 'Api\v1\DoctorApi::queueSw'); +$routes->get('app/queue/manifest.json', 'Api\v1\DoctorApi::queueManifest'); $routes->get('app/queue/(:any)', 'Api\v1\DoctorApi::queueIndex'); // Dedicated RESTful JSON API v1 Group for React PWAs & Mobile Apps diff --git a/app/Controllers/Api/v1/DoctorApi.php b/app/Controllers/Api/v1/DoctorApi.php index 6fadb7e..0ee5208 100644 --- a/app/Controllers/Api/v1/DoctorApi.php +++ b/app/Controllers/Api/v1/DoctorApi.php @@ -676,6 +676,33 @@ class DoctorApi extends BaseController return redirect()->to(base_url('app')); } + /** + * Serves the Service Worker script for /app/queue + */ + public function queueSw() + { + $swPath = FCPATH . 'App/Queue/sw.js'; + if (file_exists($swPath)) { + return $this->response->setHeader('Content-Type', 'application/javascript') + ->setHeader('Service-Worker-Allowed', '/') + ->setBody(file_get_contents($swPath)); + } + return $this->response->setStatusCode(404); + } + + /** + * Serves manifest.json for /app/queue + */ + public function queueManifest() + { + $manifestPath = FCPATH . 'App/Queue/manifest.json'; + if (file_exists($manifestPath)) { + return $this->response->setHeader('Content-Type', 'application/json') + ->setBody(file_get_contents($manifestPath)); + } + return $this->response->setStatusCode(404); + } + /** * GET api/v1/opd/queue/live * Returns real-time OPD Tokens & Hospital Showcase Ads for TV Queue Display diff --git a/public/App/Queue/index.html b/public/App/Queue/index.html index ceef0a6..cb0981e 100644 --- a/public/App/Queue/index.html +++ b/public/App/Queue/index.html @@ -4,7 +4,7 @@ OPD Token Tracker & Queue Display - HMS Mobile - + @@ -438,7 +438,7 @@ // Register PWA Service Worker if ('serviceWorker' in navigator) { window.addEventListener('load', function() { - navigator.serviceWorker.register('/App/Queue/sw.js') + navigator.serviceWorker.register('/app/queue/sw.js', { scope: '/app/queue/' }) .then(function(reg) { console.log('Queue PWA Service Worker Registered', reg); }) .catch(function(err) { console.log('Service Worker Registration Failed', err); }); }); diff --git a/public/App/Queue/manifest.json b/public/App/Queue/manifest.json index 3213850..fdf3096 100644 --- a/public/App/Queue/manifest.json +++ b/public/App/Queue/manifest.json @@ -11,6 +11,7 @@ "theme_color": "#0f172a", "display": "standalone", "display_override": ["standalone", "minimal-ui"], + "orientation": "landscape", "categories": ["medical", "health", "utilities"], "prefer_related_applications": false, "icons": [ @@ -50,7 +51,7 @@ "screenshots": [ { "src": "/assets/img/slides-1.jpg", - "sizes": "1280x720", + "sizes": "1024x683", "type": "image/jpeg", "form_factor": "wide", "label": "OPD Token Tracker & Hospital Showcase TV Display"