Skip to content

Commit 3fdecf9

Browse files
authored
feat: dark mode & sharing plans between users
* feat: init ui * fix: lint fix * fix: lint & format fix * fix: lint fix (why lint is so dump) * fix: script & ui fix * fix: prettier fix * feat: new settings page & ui fix * feat: link to "ToPWR" * feat: share dialog init * feat: sharing plans between users * feat: animate tooltip * feat: texts * feat: texts & more icons in icon component * feat: done migration icons to one file & mobile version fixes
1 parent 714b533 commit 3fdecf9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1855
-455
lines changed

backend/app/controllers/schedules_controller.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export default class SchedulesController {
5252
createdAt: schedule.createdAt,
5353
updatedAt: schedule.updatedAt,
5454
name: schedule.name,
55+
sharedId: schedule.sharedId,
5556
registrations: schedule.registrations.map((reg) => ({
5657
id: reg.id,
5758
...reg.serialize(),
@@ -171,6 +172,7 @@ export default class SchedulesController {
171172
createdAt: schedule.createdAt,
172173
updatedAt: schedule.updatedAt,
173174
name: schedule.name,
175+
sharedId: schedule.sharedId,
174176
registrations: schedule.registrations.map((reg) => ({
175177
id: reg.id,
176178
...reg.serialize(),
@@ -237,6 +239,10 @@ export default class SchedulesController {
237239
currSchedule.name = payload.name;
238240
}
239241

242+
if (payload.sharedId !== undefined) {
243+
currSchedule.sharedId = payload.sharedId;
244+
}
245+
240246
if (payload.groups !== undefined) {
241247
if (payload.groups.length === 0) {
242248
await currSchedule.related("groups").sync([]);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { HttpContext } from "@adonisjs/core/http";
2+
3+
import Shared from "#models/shared";
4+
import { createSharedValidator } from "#validators/shared";
5+
6+
export default class SahredController {
7+
/**
8+
* Display a list of resource
9+
*/
10+
async index(_ctx: HttpContext) {
11+
return Shared.query();
12+
}
13+
14+
/**
15+
* Handle form submission for the create action
16+
*/
17+
async store({ request }: HttpContext) {
18+
const payload = await request.validateUsing(createSharedValidator);
19+
const shared = await Shared.create(payload);
20+
return { message: "Shared plan created.", shared };
21+
}
22+
23+
/**
24+
* Show individual record
25+
*/
26+
async show({ params }: HttpContext) {
27+
try {
28+
const plan = await Shared.findOrFail(params.id);
29+
return { success: true, plan };
30+
} catch {
31+
return { success: false, message: "Shared plan not found." };
32+
}
33+
}
34+
}

backend/app/models/schedule.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export default class Schedule extends BaseModel {
1818
@column()
1919
declare userId: number;
2020

21+
@column()
22+
declare sharedId: string | null;
23+
2124
@manyToMany(() => Group, {
2225
localKey: "id",
2326
pivotForeignKey: "schedule_id",

backend/app/models/shared.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { DateTime } from "luxon";
2+
3+
import { BaseModel, column } from "@adonisjs/lucid/orm";
4+
5+
export default class Shared extends BaseModel {
6+
@column({ isPrimary: true })
7+
declare id: string;
8+
9+
@column()
10+
declare plan: string;
11+
12+
@column.dateTime({ autoCreate: true })
13+
declare createdAt: DateTime;
14+
15+
@column.dateTime({ autoCreate: true, autoUpdate: true })
16+
declare updatedAt: DateTime;
17+
}

backend/app/validators/schedule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const createScheduleValidator = vine.compile(
3030
export const updateScheduleValidator = vine.compile(
3131
vine.object({
3232
name: vine.string().optional(),
33+
sharedId: vine.string().optional(),
3334
groups: vine
3435
.array(
3536
vine.object({

backend/app/validators/shared.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import vine from "@vinejs/vine";
2+
3+
export const createSharedValidator = vine.compile(
4+
vine.object({
5+
id: vine.string(),
6+
plan: vine.string(),
7+
}),
8+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { BaseSchema } from "@adonisjs/lucid/schema";
2+
3+
export default class extends BaseSchema {
4+
protected tableName = "shareds";
5+
6+
async up() {
7+
this.schema.createTable(this.tableName, (table) => {
8+
table.uuid("id").primary();
9+
table.text("plan", "longtext");
10+
11+
table.timestamp("created_at");
12+
table.timestamp("updated_at");
13+
});
14+
}
15+
16+
async down() {
17+
this.schema.dropTable(this.tableName);
18+
}
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { BaseSchema } from "@adonisjs/lucid/schema";
2+
3+
export default class extends BaseSchema {
4+
protected tableName = "schedules";
5+
6+
async up() {
7+
this.schema.alterTable(this.tableName, (table) => {
8+
table.string("shared_id").defaultTo(null);
9+
});
10+
}
11+
}

backend/start/routes.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const DepartmentsController = () =>
1818
import("#controllers/departments_controller");
1919
const AuthController = () => import("#controllers/auth_controller");
2020
const SchedulesController = () => import("#controllers/schedules_controller");
21+
const SharedController = () => import("#controllers/shared_controller");
2122
const RegistrationsController = () =>
2223
import("#controllers/registrations_controller");
2324
const CoursesController = () => import("#controllers/courses_controller");
@@ -35,6 +36,9 @@ router.get("/docs", async () => {
3536
// return AutoSwagger.default.rapidoc("/swagger", "view"); to use RapiDoc instead (pass "view" default, or "read" to change the render-style)
3637
});
3738

39+
router.get("/shared/:id", [SharedController, "show"]);
40+
router.post("/shared", [SharedController, "store"]);
41+
3842
router.get("/departments", [DepartmentsController, "index"]);
3943
router.get("/departments/:id", [DepartmentsController, "show"]);
4044

frontend/package-lock.json

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)