How mec-osh/sama-yas works
Purpose and Entry Points
This is a GitHub Pages-ready Occupational Safety and Health (OSH) site for MEC’s Sama Yas project. It has three browser-delivered entry points:
• Public OSH portal: index.html, app.js
• Administrative dashboard: admin/index.html, admin/admin.js
• Risk assessment document generator: risk-assessment/index.html, risk-assessment/app.js
The application can operate as a local browser demo and is configured to connect to Supabase for shared live data.
Public OSH Portal
The public site presents bilingual English/Arabic OSH content, including RTL behavior, live man-hour and LTI-free-day calculations, safety performance, unsafe-act/condition trend data, document/news/gallery content, contacts, and anonymous safety concerns.
• index.html
• app.js
• styles.css
app.js is the primary public-page controller: it coordinates page interactions, local/demo state, public data presentation, and calculated operational indicators. Public reporting is intentionally separated from individual report records; public trend analysis exposes combined/baseline information rather than private report detail.
Admin Content and Operations Boundary
The admin prototype manages operational data that feeds public-facing sections: performance settings, safety reports, documents, news, galleries, locations, holidays, team profiles, contact content, and enquiries.
• admin/index.html
• admin/admin.js
• supabase-config.js
Admin access uses Supabase email OTP for the configured administrator. The browser client uses a publishable Supabase key; privileged writes, automatic email delivery, Microsoft Graph access, and secrets must remain behind Supabase Edge Functions or another secure backend.
Supabase Persistence and Security
Supabase is the central intended production backend for authentication, relational content/report data, Row-Level Security, and public/private Storage buckets.
• supabase/schema.sql
• supabase/security-setup.sql
• SUPABASE_SETUP.txt
Schema/setup scripts establish the core database and feature-specific additions. Root-level setup files such as TREND_ANALYSIS_SETUP.sql, TEAM_MEMBERS_SETUP.sql, and CONTACT_SECTION_SETUP.sql support incremental deployment, with corresponding versions under supabase/. Storage includes private report photos, accessed by admin export through short-lived signed URLs.
Safety Reporting and Trend Pipeline
Anonymous/public safety concerns and admin-managed safety reports form the reporting pipeline. In demo mode, entered data remains browser-local; live mode persists it to Supabase. Trend analysis combines a supplied historical baseline with newly recorded reports while retaining individual records as private.
• app.js
• admin/admin.js
• TREND_ANALYSIS_SETUP.sql
Admin export produces Excel-compatible reporting, including embedded photo thumbnails sourced from private storage. Email acknowledgements and report alerts are planned backend integrations rather than client-side direct sending.
Risk Assessment Generation
The standalone risk-assessment module loads a curated project risk-register dataset, lets users assemble and edit multiple activities, saves drafts in the browser, and generates a .docx assessment without an external document library.
• risk-assessment/risk-register-data.js
• risk-assessment/legal-references.js
• risk-assessment/docx-generator.js
Its flow is dataset selection → editable assessment state → risk/control and legal-reference enrichment → client-side Word document generation. Legal references preserve source references where available and add applicable ADOSH-SF and ALDAR references.
External Dependencies and Deployment
The runtime is static HTML/CSS/JavaScript hosted on GitHub Pages, with Supabase as the live service dependency.
• README.md
• supabase-config.js
• assets/osh-team-organization-chart.pptx
Operational integrations include Supabase Auth/Database/Storage, optional official UAE holiday data, and a future Microsoft Graph or secure mail-function integration. Direct Microsoft 365 sending is deliberately not embedded in the static site.
Main entry points: admin.js Admin Controller · app.js Public Controller · risk-assessment/app.js Assessment Editor · README.md GitHub Pages
Components 21
Public Portal
- Public OSH Portal
index.html - Public Controller · Presents bilingual content, indicators, trends, and anonymous concerns.
app.js - Portal Styles · Provides English/Arabic and RTL presentation.
styles.css - Public Trend View · Shows combined or baseline trend data, not individual reports.
app.js
Admin Operations
- Admin Dashboard
admin/index.html - Admin Controller · Manages operational content, reports, exports, and settings.
admin/admin.js - Supabase Client Config · Uses a publishable client key only.
supabase-config.js - Excel Report Export · Builds Excel-compatible reports with signed private-photo access.
admin/admin.js
Supabase Live Backend
- Core Schema · Defines relational content and report data.
supabase/schema.sql - RLS and Security Setup · Establishes access controls and feature setup.
supabase/security-setup.sql - Trend Baseline Setup · Supplies historical baseline data for trend analysis.
TREND_ANALYSIS_SETUP.sql - Email OTP Auth · Authenticates the configured administrator.
- Content and Report Data · Stores live public content, operational data, and private reports.
- Private Report Photos · Serves admin exports through short-lived signed URLs.
- Secure Backend Integrations · Reserved for privileged writes, mail, alerts, and Microsoft Graph access.
Risk Assessment
- Risk Assessment UI
risk-assessment/index.html - Assessment Editor · Maintains multi-activity editable state and browser drafts.
risk-assessment/app.js - Risk Register Dataset
risk-assessment/risk-register-data.js - Legal Reference Enrichment · Adds source, ADOSH-SF, and ALDAR references.
risk-assessment/legal-references.js - DOCX Generator · Generates Word assessments without an external document library.
risk-assessment/docx-generator.js
Other components
- GitHub Pages · Hosts the browser-delivered site.
README.md
Connections 22
- GitHub Pages → Public OSH Portal: serves
- GitHub Pages → Admin Dashboard: serves
- GitHub Pages → Risk Assessment UI: serves
- Public OSH Portal → Public Controller: runs
- Public OSH Portal → Portal Styles: styles
- Public Controller → Public Trend View: calculates and presents
- Public Controller → Content and Report Data: reads live data or uses local demo state
- Public Controller → Private Report Photos: submits report photos in live mode
- Admin Dashboard → Admin Controller: runs
- Admin Controller → Supabase Client Config: uses
- Admin Controller → Email OTP Auth: signs in with OTP
- Admin Controller → Content and Report Data: manages operational content
- Admin Controller → Excel Report Export: produces
- Excel Report Export → Private Report Photos: requests signed photo URLs
- Core Schema → Content and Report Data: defines
- RLS and Security Setup → Content and Report Data: protects with RLS
- Trend Baseline Setup → Public Trend View: provides historical baseline
- Admin Controller → Secure Backend Integrations: delegates privileged actions
- Risk Assessment UI → Assessment Editor: runs
- Assessment Editor → Risk Register Dataset: selects activities from
- Assessment Editor → Legal Reference Enrichment: enriches controls with
- Assessment Editor → DOCX Generator: generates assessment with