unit/#102-base-management #121

Merged
jkeffects merged 35 commits from unit/#102-base-management into milestone/ff-admin-unit 2025-07-14 13:36:35 +00:00
2 changed files with 13 additions and 13 deletions
Showing only changes of commit 0f3e4488f4 - Show all commits

View file

@ -51,8 +51,8 @@ export async function getAllInspectionPlans(req: Request, res: Response): Promis
* @returns {Promise<*>} * @returns {Promise<*>}
*/ */
export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise<any> { export async function getAllInspectionPlansForRelated(req: Request, res: Response): Promise<any> {
let relation = req.params.related as "vehicle" | "equipment" | "wearable"; let relation = req.params.related as "vehicleType" | "equipmentType" | "wearableType";
let relationId = req.params.relatedId as string; let relationTypeId = req.params.relatedTypeId as string;
let offset = parseInt((req.query.offset as string) ?? "0"); let offset = parseInt((req.query.offset as string) ?? "0");
let count = parseInt((req.query.count as string) ?? "25"); let count = parseInt((req.query.count as string) ?? "25");
let search = (req.query.search as string) ?? ""; let search = (req.query.search as string) ?? "";
@ -60,12 +60,12 @@ export async function getAllInspectionPlansForRelated(req: Request, res: Respons
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i); let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
let where; let where;
if (relation == "equipment") { if (relation == "equipmentType") {
where = { equipmentTypeId: relationId }; where = { equipmentTypeId: relationTypeId };
} else if (relation == "vehicle") { } else if (relation == "vehicleType") {
where = { vehicleTypeId: relationId }; where = { vehicleTypeId: relationTypeId };
} else { } else {
where = { wearableTypeId: relationId }; where = { wearableTypeId: relationTypeId };
} }
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, { let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, {
offset, offset,

View file

@ -22,14 +22,14 @@ router.get("/:id/points", async (req: Request, res: Response) => {
}); });
router.get( router.get(
["/vehicle/:relatedId", "/equipment/:relatedId", "/wearable/:relatedId"], ["/vehicleType/:relatedTypeId", "/equipmentType/:relatedTypeId", "/wearableType/:relatedTypeId"],
async (req: Request, res: Response) => { async (req: Request, res: Response) => {
if (req.path.startsWith("/vehicle")) { if (req.path.startsWith("/vehicleType")) {
req.params.related = "vehicle"; req.params.related = "vehicleType";
} else if (req.path.startsWith("/equipment")) { } else if (req.path.startsWith("/equipmentType")) {
req.params.related = "equipment"; req.params.related = "equipmentType";
} else { } else {
req.params.related = "wearable"; req.params.related = "wearableType";
} }
await getAllInspectionPlansForRelated(req, res); await getAllInspectionPlansForRelated(req, res);