A Duty Roster planner for the SAF. It's tailored for unit uses, however the code is customizable. GPL-3.0 License.
View Demo »
In SAF, soldiers are required to do duties, be it guard duty or 24hr ops duty. This project is tailored for unit, where they are required to do 24hr ops duty. The duty roster has these requirements:
To get a local copy up and running follow these simple example steps.
You'll first need a Supabase project which can be made via the Supabase dashboard.
Clone this project with Git
git clone https://github.com/ISnackable/saf-duty
Rename .env.local.example
to .env.local
and update the following:
NEXT_PUBLIC_SUPABASE_URL=[INSERT SUPABASE PROJECT URL]
NEXT_PUBLIC_SUPABASE_ANON_KEY=[INSERT SUPABASE PROJECT API ANON KEY]
Both SUPABASE_API_URL
and SUPABASE_ANON_KEY
can be found in your Supabase project's API settings or by running npx supabase status
.
Configure the vault secrets using the database studio SQL editor. Replace the keys with the appropriate values. Take note, SUPABASE_ROLE_KEY
is different from SUPABASE_ANON_KEY
. Do not mix them up.
insert into vault.secrets (secret, name, description) values ('[INSERT SUPABASE PROJECT URL]', 'project_url'), ('[INSERT SUPABASE ROLE KEY]', 'service_role_key');
You can now run the Next.js local development server:
pnpm dev
The app should now be running on localhost:3000.
As much as this project aims to set up as seamlessly as possible, due to some limitation to Supabase, there are some config that has to be done manually.
Navigate to Project Vault settings in your Supabase Dashboard or.
project_url
.service_role_key
.To Enable Push Notification with Web Push. You will need to deploy the Supabase Edge Function and create the database webhook manually.
The database webhook handler to send push notifications is located in supabase/functions/push/index.ts
. Deploy the function to your linked project and set the WEB_PUSH_PUBLIC_KEY
, WEB_PUSH_PRIVATE_KEY
& WEB_PUSH_EMAIL
secret.
supabase functions deploy push
supabase secrets set --env-file .env.local
Note: The Public and Private keys secrets must be generated using the alastaircoote/webpush-webcrypto package.
Navigate to the Database Webhooks settings in your Supabase Dashboard.
on_after_notifications_created
.notifications
table and tick the Insert
event.push
edge function and leave the method as POST
and timeout as 1000
.application/json
.When a new row is added in your notifications table, a push notification will be sent to the user who has subscribed to push notification.
_Note: There's also a cron job for daily duty reminder if a user is subscribed to push notification._
-- View all scheduled job.
select * from cron.job;
-- Or unschedule it if you want to disable it.
select cron.unschedule('daily-roster-reminder');
If you have a suggestion that would make this better, please fork the repo and create a pull request. Any contributions you make are greatly appreciated.
I recommend you to use GitHub Codespaces for ease of development. Below lists the steps on how you can get started.
Fork the Project
Create a GitHub Codespace instance
Start the local database (If it hasn't already been started already)
npx supabase start
The database should now be running and the supabase studio is at localhost:54323.
Follow this section starting from part 2 onwards.
Distributed under the GNU General Public License v3.0 License. See LICENSE
for more information.