unit/#107-damage-reports #125
22 changed files with 350 additions and 21 deletions
|
@ -1,14 +1,17 @@
|
|||
export interface CreateDamageReportCommand {
|
||||
description: string;
|
||||
location: string;
|
||||
noteByReporter: string;
|
||||
reportedBy: string;
|
||||
imageCount: number;
|
||||
affectedId: string;
|
||||
affected: "equipment" | "vehicle" | "wearable";
|
||||
images: string[];
|
||||
affectedId?: string;
|
||||
affected?: "equipment" | "vehicle" | "wearable";
|
||||
}
|
||||
|
||||
export interface UpdateDamageReportCommand {
|
||||
id: string;
|
||||
status: string;
|
||||
noteByWorker: string;
|
||||
done: boolean;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@ export default abstract class DamageReportCommandHandler {
|
|||
.values({
|
||||
status: "eingereicht",
|
||||
description: createDamageReport.description,
|
||||
location: createDamageReport.location,
|
||||
noteByReporter: createDamageReport.noteByReporter,
|
||||
reportedBy: createDamageReport.reportedBy,
|
||||
imageCount: createDamageReport.imageCount,
|
||||
images: createDamageReport.images,
|
||||
equipmentId: createDamageReport.affected == "equipment" ? createDamageReport.affectedId : null,
|
||||
vehicleId: createDamageReport.affected == "vehicle" ? createDamageReport.affectedId : null,
|
||||
wearableId: createDamageReport.affected == "wearable" ? createDamageReport.affectedId : null,
|
||||
|
@ -48,6 +50,7 @@ export default abstract class DamageReportCommandHandler {
|
|||
.update(damageReport)
|
||||
.set({
|
||||
status: updateDamageReport.status,
|
||||
noteByWorker: updateDamageReport.noteByWorker,
|
||||
done: updateDamageReport.done,
|
||||
})
|
||||
.where("id = :id", { id: updateDamageReport.id })
|
||||
|
@ -86,6 +89,7 @@ export default abstract class DamageReportCommandHandler {
|
|||
* @returns {Promise<void>}
|
||||
*/
|
||||
static async delete(deleteDamageReport: DeleteDamageReportCommand): Promise<void> {
|
||||
// TODO: remove related images
|
||||
return await dataSource
|
||||
.createQueryBuilder()
|
||||
.delete()
|
||||
|
|
|
@ -4,6 +4,7 @@ import DamageReportFactory from "../../../factory/admin/unit/damageReport";
|
|||
import { CreateDamageReportCommand, UpdateDamageReportCommand } from "../../../command/unit/damageReportCommand";
|
||||
import DamageReportCommandHandler from "../../../command/unit/damageReportCommandHandler";
|
||||
import BadRequestException from "../../../exceptions/badRequestException";
|
||||
import { FileSystemHelper } from "../../../helpers/fileSystemHelper";
|
||||
|
||||
/**
|
||||
* @description get all damageReports by status
|
||||
|
@ -71,6 +72,21 @@ export async function getDamageReportById(req: Request, res: Response): Promise<
|
|||
res.json(DamageReportFactory.mapToSingle(damageReport));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description provide uploaded image for damage report
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function provideDamageReportImageUpload(req: Request, res: Response): Promise<any> {
|
||||
const damageReportId = req.params.id;
|
||||
const filename = req.params.filename;
|
||||
|
||||
let filepath = FileSystemHelper.formatPath("damageReport", filename);
|
||||
|
||||
res.sendFile(filepath);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create damageReport
|
||||
* @param req {Request} Express req object
|
||||
|
@ -79,7 +95,10 @@ export async function getDamageReportById(req: Request, res: Response): Promise<
|
|||
*/
|
||||
export async function createDamageReport(req: Request, res: Response): Promise<any> {
|
||||
const description = req.body.description;
|
||||
const location = req.body.location;
|
||||
const note = req.body.note;
|
||||
const reportedBy = req.body.reportedBy;
|
||||
const images = req.files as Express.Multer.File[];
|
||||
const affectedId = req.body.affectedId;
|
||||
const affected = req.body.affected;
|
||||
|
||||
|
@ -88,8 +107,10 @@ export async function createDamageReport(req: Request, res: Response): Promise<a
|
|||
|
||||
let createDamageReport: CreateDamageReportCommand = {
|
||||
description,
|
||||
location,
|
||||
noteByReporter: note,
|
||||
reportedBy,
|
||||
imageCount: 0,
|
||||
images: images.map((i) => i.filename),
|
||||
affectedId,
|
||||
affected,
|
||||
};
|
||||
|
@ -107,11 +128,13 @@ export async function createDamageReport(req: Request, res: Response): Promise<a
|
|||
export async function updateDamageReportById(req: Request, res: Response): Promise<any> {
|
||||
const damageReportId = req.params.id;
|
||||
const status = req.body.status;
|
||||
const noteByWorker = req.body.noteByWorker;
|
||||
const done = req.body.done;
|
||||
|
||||
let updateDamageReport: UpdateDamageReportCommand = {
|
||||
id: damageReportId,
|
||||
status,
|
||||
noteByWorker,
|
||||
done,
|
||||
};
|
||||
await DamageReportCommandHandler.update(updateDamageReport);
|
||||
|
|
|
@ -12,6 +12,17 @@ import { FileSystemHelper } from "../helpers/fileSystemHelper";
|
|||
import { SocketConnectionTypes } from "../enums/socketEnum";
|
||||
import SocketServer from "../websocket";
|
||||
import BadRequestException from "../exceptions/badRequestException";
|
||||
import EquipmentService from "../service/unit/equipment/equipmentService";
|
||||
import VehicleService from "../service/unit/vehicle/vehicleService";
|
||||
import WearableService from "../service/unit/wearable/wearableService";
|
||||
import EquipmentFactory from "../factory/admin/unit/equipment/equipment";
|
||||
import VehicleFactory from "../factory/admin/unit/vehicle/vehicle";
|
||||
import WearableFactory from "../factory/admin/unit/wearable/wearable";
|
||||
import { MinifiedEquipmentViewModel } from "../viewmodel/admin/unit/equipment/equipment.models";
|
||||
import { MinifiedVehicleViewModel } from "../viewmodel/admin/unit/vehicle/vehicle.models";
|
||||
import { MinifiedWearableViewModel } from "../viewmodel/admin/unit/wearable/wearable.models";
|
||||
import DamageReportCommandHandler from "../command/unit/damageReportCommandHandler";
|
||||
import { CreateDamageReportCommand } from "../command/unit/damageReportCommand";
|
||||
|
||||
/**
|
||||
* @description get all calendar items by types or nscdr
|
||||
|
@ -58,8 +69,8 @@ export async function getCalendarItemsByTypes(req: Request, res: Response): Prom
|
|||
}
|
||||
|
||||
/**
|
||||
* @description get all calendar items by types or nscdr
|
||||
* @summary passphrase is passed as value pair like `type:passphrase`
|
||||
* @description check if scanner session exists
|
||||
* @summary existance is checked by room exists
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
|
@ -77,6 +88,58 @@ export async function checkScannerRoomExists(req: Request, res: Response): Promi
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipment, vehicle, wearable by code
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function searchStuffByCode(req: Request, res: Response): Promise<any> {
|
||||
let code = req.query.code.toString();
|
||||
|
||||
let e = await EquipmentService.getAllByCode(code);
|
||||
let v = await VehicleService.getAllByCode(code);
|
||||
let w = await WearableService.getAllByCode(code);
|
||||
|
||||
res.json([
|
||||
...EquipmentFactory.mapToBaseMinifed(e),
|
||||
...VehicleFactory.mapToBaseMinifed(v),
|
||||
...WearableFactory.mapToBaseMinifed(w),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create damagereport to equipment, vehicle, wearable
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function createDamageReport(req: Request, res: Response): Promise<any> {
|
||||
const related = (req.body.related ? JSON.parse(req.body.related) : undefined) as
|
||||
| undefined
|
||||
| MinifiedEquipmentViewModel
|
||||
| MinifiedVehicleViewModel
|
||||
| MinifiedWearableViewModel;
|
||||
const description = req.body.description;
|
||||
const location = req.body.location;
|
||||
const note = req.body.note;
|
||||
const reportedBy = req.body.reportedBy;
|
||||
const images = req.files as Express.Multer.File[];
|
||||
|
||||
let createDamageReport: CreateDamageReportCommand = {
|
||||
description: description,
|
||||
location: location,
|
||||
noteByReporter: note,
|
||||
reportedBy: reportedBy,
|
||||
images: images.map((i) => i.filename),
|
||||
affectedId: related ? related.id : undefined,
|
||||
affected: related ? related.assigned : undefined,
|
||||
};
|
||||
await DamageReportCommandHandler.create(createDamageReport);
|
||||
|
||||
res.sendStatus(204);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get configuration of UI
|
||||
* @param req {Request} Express req object
|
||||
|
@ -91,6 +154,7 @@ export async function getApplicationConfig(req: Request, res: Response): Promise
|
|||
"club.website": SettingHelper.getSetting("club.website"),
|
||||
"app.custom_login_message": SettingHelper.getSetting("app.custom_login_message"),
|
||||
"app.show_link_to_calendar": SettingHelper.getSetting("app.show_link_to_calendar"),
|
||||
"app.show_link_to_damagereport": SettingHelper.getSetting("app.show_link_to_damagereport"),
|
||||
};
|
||||
|
||||
res.json(config);
|
||||
|
|
|
@ -21,12 +21,31 @@ export class damageReport {
|
|||
@Column({ type: "text" })
|
||||
description: string;
|
||||
|
||||
@Column({ type: "text" })
|
||||
location: string;
|
||||
|
||||
@Column({ type: "text" })
|
||||
noteByReporter: string;
|
||||
|
||||
@Column({ type: "text" })
|
||||
noteByWorker: string;
|
||||
|
||||
@Column({
|
||||
type: "text",
|
||||
transformer: {
|
||||
from(value: string): Array<string> {
|
||||
return value.split(",").filter((i) => !!i);
|
||||
},
|
||||
to(value: Array<string>): string {
|
||||
return value.join(",");
|
||||
},
|
||||
},
|
||||
})
|
||||
images: string[];
|
||||
|
||||
@Column({ type: "varchar", length: 255 })
|
||||
reportedBy: string;
|
||||
|
||||
@Column({ type: "int", default: 0 })
|
||||
imageCount: number;
|
||||
|
||||
@Column({ nullable: true, default: null })
|
||||
equipmentId?: string;
|
||||
|
||||
|
|
|
@ -25,12 +25,18 @@ export default abstract class DamageReportFactory {
|
|||
assigned: "vehicle",
|
||||
related: VehicleFactory.mapToSingle(record.vehicle),
|
||||
};
|
||||
} else {
|
||||
} else if (record?.wearableId) {
|
||||
assigned = {
|
||||
relatedId: record.wearableId,
|
||||
assigned: "wearable",
|
||||
related: WearableFactory.mapToSingle(record.wearable),
|
||||
};
|
||||
} else {
|
||||
assigned = {
|
||||
relatedId: undefined,
|
||||
assigned: undefined,
|
||||
related: undefined,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -39,7 +45,10 @@ export default abstract class DamageReportFactory {
|
|||
status: record.status,
|
||||
done: record.done,
|
||||
description: record.description,
|
||||
imageCount: record.imageCount,
|
||||
location: record.location,
|
||||
noteByReporter: record.noteByReporter,
|
||||
noteByWorker: record.noteByWorker,
|
||||
images: record.images,
|
||||
reportedBy: record?.reportedBy,
|
||||
...assigned,
|
||||
maintenance: record.maintenance ? MaintenanceFactory.mapToSingle(record.maintenance) : null,
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { equipment } from "../../../../entity/unit/equipment/equipment";
|
||||
import { EquipmentViewModel } from "../../../../viewmodel/admin/unit/equipment/equipment.models";
|
||||
import {
|
||||
EquipmentViewModel,
|
||||
MinifiedEquipmentViewModel,
|
||||
} from "../../../../viewmodel/admin/unit/equipment/equipment.models";
|
||||
import EquipmentTypeFactory from "./equipmentType";
|
||||
|
||||
export default abstract class EquipmentFactory {
|
||||
|
@ -29,4 +32,28 @@ export default abstract class EquipmentFactory {
|
|||
public static mapToBase(records: Array<equipment>): Array<EquipmentViewModel> {
|
||||
return records.map((r) => this.mapToSingle(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map record to minifed equipment
|
||||
* @param {equipment} record
|
||||
* @returns {MinifiedEquipmentViewModel}
|
||||
*/
|
||||
public static mapToSingleMinified(record: equipment): MinifiedEquipmentViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
type: record?.equipmentType.type,
|
||||
assigned: "equipment",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map records to minified equipment
|
||||
* @param {Array<equipment>} records
|
||||
* @returns {Array<MinifiedEquipmentViewModel>}
|
||||
*/
|
||||
public static mapToBaseMinifed(records: Array<equipment>): Array<MinifiedEquipmentViewModel> {
|
||||
return records.map((r) => this.mapToSingleMinified(r));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { vehicle } from "../../../../entity/unit/vehicle/vehicle";
|
||||
import { VehicleViewModel } from "../../../../viewmodel/admin/unit/vehicle/vehicle.models";
|
||||
import { MinifiedVehicleViewModel, VehicleViewModel } from "../../../../viewmodel/admin/unit/vehicle/vehicle.models";
|
||||
import VehicleTypeFactory from "./vehicleType";
|
||||
|
||||
export default abstract class VehicleFactory {
|
||||
|
@ -29,4 +29,28 @@ export default abstract class VehicleFactory {
|
|||
public static mapToBase(records: Array<vehicle>): Array<VehicleViewModel> {
|
||||
return records.map((r) => this.mapToSingle(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map record to minifed vehicle
|
||||
* @param {vehicle} record
|
||||
* @returns {MinifiedVehicleViewModel}
|
||||
*/
|
||||
public static mapToSingleMinified(record: vehicle): MinifiedVehicleViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
type: record?.vehicleType.type,
|
||||
assigned: "vehicle",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map records to minified vehicle
|
||||
* @param {Array<vehicle>} records
|
||||
* @returns {Array<MinifiedVehicleViewModel>}
|
||||
*/
|
||||
public static mapToBaseMinifed(records: Array<vehicle>): Array<MinifiedVehicleViewModel> {
|
||||
return records.map((r) => this.mapToSingleMinified(r));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { wearable } from "../../../../entity/unit/wearable/wearable";
|
||||
import { WearableViewModel } from "../../../../viewmodel/admin/unit/wearable/wearable.models";
|
||||
import {
|
||||
MinifiedWearableViewModel,
|
||||
WearableViewModel,
|
||||
} from "../../../../viewmodel/admin/unit/wearable/wearable.models";
|
||||
import MemberFactory from "../../club/member/member";
|
||||
import WearableTypeFactory from "./wearableType";
|
||||
|
||||
|
@ -32,4 +35,28 @@ export default abstract class WearableFactory {
|
|||
public static mapToBase(records: Array<wearable>): Array<WearableViewModel> {
|
||||
return records.map((r) => this.mapToSingle(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map record to minifed wearable
|
||||
* @param {wearable} record
|
||||
* @returns {MinifiedWearableViewModel}
|
||||
*/
|
||||
public static mapToSingleMinified(record: wearable): MinifiedWearableViewModel {
|
||||
return {
|
||||
id: record.id,
|
||||
code: record?.code,
|
||||
name: record.name,
|
||||
type: record?.wearableType.type,
|
||||
assigned: "wearable",
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description map records to minified wearable
|
||||
* @param {Array<wearable>} records
|
||||
* @returns {Array<MinifiedWearableViewModel>}
|
||||
*/
|
||||
public static mapToBaseMinifed(records: Array<wearable>): Array<MinifiedWearableViewModel> {
|
||||
return records.map((r) => this.mapToSingleMinified(r));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ import {
|
|||
UrlConverter,
|
||||
} from "./convertHelper";
|
||||
import cloneDeep from "lodash.clonedeep";
|
||||
import { rejects } from "assert";
|
||||
import InternalException from "../exceptions/internalException";
|
||||
import MailHelper from "./mailHelper";
|
||||
|
||||
export default abstract class SettingHelper {
|
||||
|
|
|
@ -2,6 +2,7 @@ import multer from "multer";
|
|||
import { FileSystemHelper } from "../helpers/fileSystemHelper";
|
||||
import path from "path";
|
||||
import BadRequestException from "../exceptions/badRequestException";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
/**Settings image upload */
|
||||
export const clubImageStorage = multer.diskStorage({
|
||||
|
@ -58,3 +59,28 @@ export const inspectionFileMulter = multer({
|
|||
});
|
||||
|
||||
export const inspectionFileUpload = inspectionFileMulter.array("files");
|
||||
|
||||
/**public damage report upload */
|
||||
export const pDamageReportFileStorage = multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
FileSystemHelper.createFolder("damageReport");
|
||||
cb(null, FileSystemHelper.formatPath("damageReport"));
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
const fileExtension = path.extname(file.originalname).toLowerCase();
|
||||
cb(null, uuid() + fileExtension);
|
||||
},
|
||||
});
|
||||
|
||||
export const pDamageReportFileMulter = multer({
|
||||
storage: pDamageReportFileStorage,
|
||||
fileFilter(req, file, cb) {
|
||||
if (file.mimetype.startsWith("image/")) {
|
||||
cb(null, true);
|
||||
} else {
|
||||
cb(new BadRequestException("Wrong file format"));
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export const pDamageReportFileUpload = pDamageReportFileMulter.array("images");
|
||||
|
|
|
@ -9,8 +9,11 @@ export const damage_report_table = new Table({
|
|||
{ name: "status", ...getTypeByORM("varchar") },
|
||||
{ name: "done", ...getTypeByORM("boolean"), default: getDefaultByORM("boolean", false) },
|
||||
{ name: "description", ...getTypeByORM("text") },
|
||||
{ name: "location", ...getTypeByORM("text") },
|
||||
{ name: "noteByReporter", ...getTypeByORM("text") },
|
||||
{ name: "noteByWorker", ...getTypeByORM("text") },
|
||||
{ name: "reportedBy", ...getTypeByORM("varchar") },
|
||||
{ name: "imageCount", ...getTypeByORM("int"), default: getDefaultByORM("number", 0) },
|
||||
{ name: "images", ...getTypeByORM("text") },
|
||||
{ name: "equipmentId", ...getTypeByORM("uuid", true) },
|
||||
{ name: "vehicleId", ...getTypeByORM("uuid", true) },
|
||||
{ name: "wearableId", ...getTypeByORM("uuid", true) },
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
getAllDamageReportsByStatus,
|
||||
getAllDamageReportsForRelated,
|
||||
getDamageReportById,
|
||||
provideDamageReportImageUpload,
|
||||
updateDamageReportById,
|
||||
} from "../../../controller/admin/unit/damageReportController";
|
||||
|
||||
|
@ -39,6 +40,10 @@ router.get("/:id", async (req: Request, res: Response) => {
|
|||
await getDamageReportById(req, res);
|
||||
});
|
||||
|
||||
router.get("/:id/:filename", async (req: Request, res: Response) => {
|
||||
await provideDamageReportImageUpload(req, res);
|
||||
});
|
||||
|
||||
router.patch(
|
||||
"/:id",
|
||||
PermissionHelper.passCheckMiddleware("update", "unit", "inspection"),
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
import express from "express";
|
||||
import {
|
||||
checkScannerRoomExists,
|
||||
createDamageReport,
|
||||
getApplicationConfig,
|
||||
getApplicationFavicon,
|
||||
getApplicationIcon,
|
||||
getApplicationLogo,
|
||||
getApplicationManifest,
|
||||
getCalendarItemsByTypes,
|
||||
searchStuffByCode,
|
||||
} from "../controller/publicController";
|
||||
import { pDamageReportFileUpload } from "../middleware/multer";
|
||||
|
||||
var router = express.Router({ mergeParams: true });
|
||||
|
||||
|
@ -15,8 +18,12 @@ router.get("/calendar", async (req, res) => {
|
|||
await getCalendarItemsByTypes(req, res);
|
||||
});
|
||||
|
||||
router.post("/reportdamage", async (req, res) => {
|
||||
res.send("TODO");
|
||||
router.get("/reportdamage", async (req, res) => {
|
||||
await searchStuffByCode(req, res);
|
||||
});
|
||||
|
||||
router.post("/reportdamage", pDamageReportFileUpload, async (req, res) => {
|
||||
await createDamageReport(req, res);
|
||||
});
|
||||
|
||||
router.post("/checkscannerroom", async (req, res) => {
|
||||
|
|
|
@ -58,6 +58,26 @@ export default abstract class EquipmentService {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipment by code
|
||||
* @returns {Promise<Array<equipment>>}
|
||||
*/
|
||||
static async getAllByCode(code: string): Promise<Array<equipment>> {
|
||||
return await dataSource
|
||||
.getRepository(equipment)
|
||||
.createQueryBuilder("equipment")
|
||||
.leftJoinAndSelect("equipment.equipmentType", "equipmenttype")
|
||||
.where({ code: Like(`%${code}%`) })
|
||||
.orderBy("name", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "equipment", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipment by id
|
||||
* @returns {Promise<equipment>}
|
||||
|
|
|
@ -58,6 +58,26 @@ export default abstract class VehicleService {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get vehicle by code
|
||||
* @returns {Promise<Array<vehicle>>}
|
||||
*/
|
||||
static async getAllByCode(code: string): Promise<Array<vehicle>> {
|
||||
return await dataSource
|
||||
.getRepository(vehicle)
|
||||
.createQueryBuilder("vehicle")
|
||||
.leftJoinAndSelect("vehicle.vehicleType", "vehicletype")
|
||||
.where({ code: Like(`%${code}%`) })
|
||||
.orderBy("name", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "vehicle", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get vehicle by id
|
||||
* @returns {Promise<vehicle>}
|
||||
|
|
|
@ -59,6 +59,26 @@ export default abstract class WearableService {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get wearable by code
|
||||
* @returns {Promise<Array<wearable>>}
|
||||
*/
|
||||
static async getAllByCode(code: string): Promise<Array<wearable>> {
|
||||
return await dataSource
|
||||
.getRepository(wearable)
|
||||
.createQueryBuilder("wearable")
|
||||
.leftJoinAndSelect("wearable.wearableType", "wearabletype")
|
||||
.where({ code: Like(`%${code}%`) })
|
||||
.orderBy("name", "ASC")
|
||||
.getMany()
|
||||
.then((res) => {
|
||||
return res;
|
||||
})
|
||||
.catch((err) => {
|
||||
throw new DatabaseActionException("SELECT", "wearable", err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get wearable by id
|
||||
* @returns {Promise<wearable>}
|
||||
|
|
|
@ -10,6 +10,7 @@ export type SettingString =
|
|||
| "club.website"
|
||||
| "app.custom_login_message"
|
||||
| "app.show_link_to_calendar"
|
||||
| "app.show_link_to_damagereport"
|
||||
| "session.jwt_expiration"
|
||||
| "session.refresh_expiration"
|
||||
| "session.pwa_refresh_expiration"
|
||||
|
@ -34,6 +35,7 @@ export type SettingValueMapping = {
|
|||
"club.website": string;
|
||||
"app.custom_login_message": string;
|
||||
"app.show_link_to_calendar": boolean;
|
||||
"app.show_link_to_damagereport": boolean;
|
||||
"session.jwt_expiration": ms.StringValue;
|
||||
"session.refresh_expiration": ms.StringValue;
|
||||
"session.pwa_refresh_expiration": ms.StringValue;
|
||||
|
@ -68,6 +70,7 @@ export const settingsType: SettingsSchema = {
|
|||
"club.website": { type: "url", optional: true },
|
||||
"app.custom_login_message": { type: "string", optional: true },
|
||||
"app.show_link_to_calendar": { type: "boolean", default: true },
|
||||
"app.show_link_to_damagereport": { type: "boolean", default: false },
|
||||
"session.jwt_expiration": { type: "ms", default: "15m" },
|
||||
"session.refresh_expiration": { type: "ms", default: "1d" },
|
||||
"session.pwa_refresh_expiration": { type: "ms", default: "5d" },
|
||||
|
|
|
@ -26,7 +26,10 @@ export type DamageReportViewModel = {
|
|||
status: string;
|
||||
done: boolean;
|
||||
description: string;
|
||||
imageCount: number;
|
||||
location: string;
|
||||
noteByReporter: string;
|
||||
noteByWorker: string;
|
||||
images: string[];
|
||||
reportedBy: string;
|
||||
maintenance?: MaintenanceViewModel;
|
||||
} & DamageReportAssigned;
|
||||
|
|
|
@ -10,3 +10,11 @@ export interface EquipmentViewModel {
|
|||
equipmentTypeId: string;
|
||||
equipmentType: EquipmentTypeViewModel;
|
||||
}
|
||||
|
||||
export interface MinifiedEquipmentViewModel {
|
||||
id: string;
|
||||
code?: string;
|
||||
name: string;
|
||||
type: string;
|
||||
assigned: "equipment";
|
||||
}
|
||||
|
|
|
@ -10,3 +10,11 @@ export interface VehicleViewModel {
|
|||
vehicleTypeId: string;
|
||||
vehicleType: VehicleTypeViewModel;
|
||||
}
|
||||
|
||||
export interface MinifiedVehicleViewModel {
|
||||
id: string;
|
||||
code?: string;
|
||||
name: string;
|
||||
type: string;
|
||||
assigned: "vehicle";
|
||||
}
|
||||
|
|
|
@ -13,3 +13,11 @@ export interface WearableViewModel {
|
|||
wearableTypeId: string;
|
||||
wearableType: WearableTypeViewModel;
|
||||
}
|
||||
|
||||
export interface MinifiedWearableViewModel {
|
||||
id: string;
|
||||
code?: string;
|
||||
name: string;
|
||||
type: string;
|
||||
assigned: "wearable";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue