diff --git a/package-lock.json b/package-lock.json index c98fe59..5351b5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "unplugin-vue-markdown": "^28.3.1", "uuid": "^11.1.0", "vue": "^3.5.13", + "vue-qrcode-reader": "^5.7.1", "vue-router": "^4.5.1" }, "devDependencies": { @@ -3788,6 +3789,18 @@ "@types/underscore": "*" } }, + "node_modules/@types/dom-webcodecs": { + "version": "0.1.14", + "resolved": "https://registry.npmjs.org/@types/dom-webcodecs/-/dom-webcodecs-0.1.14.tgz", + "integrity": "sha512-ba9aF0qARLLQpLihONIRbj8VvAdUxO+5jIxlscVcDAQTcJmq5qVr781+ino5qbQUJUmO21cLP2eLeXYWzao5Vg==", + "license": "MIT" + }, + "node_modules/@types/emscripten": { + "version": "1.40.1", + "resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.40.1.tgz", + "integrity": "sha512-sr53lnYkQNhjHNN0oJDdUm5564biioI5DuOpycufDVK7D3y+GR3oUswe2rlwY1nPNyusHbrJ9WoTyIHl4/Bpwg==", + "license": "MIT" + }, "node_modules/@types/eslint": { "version": "9.6.1", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz", @@ -4824,6 +4837,16 @@ "dev": true, "license": "MIT" }, + "node_modules/barcode-detector": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/barcode-detector/-/barcode-detector-2.2.2.tgz", + "integrity": "sha512-JcSekql+EV93evfzF9zBr+Y6aRfkR+QFvgyzbwQ0dbymZXoAI9+WgT7H1E429f+3RKNncHz2CW98VQtaaKpmfQ==", + "license": "MIT", + "dependencies": { + "@types/dom-webcodecs": "^0.1.11", + "zxing-wasm": "1.1.3" + } + }, "node_modules/birpc": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/birpc/-/birpc-2.3.0.tgz", @@ -9855,6 +9878,12 @@ "dev": true, "license": "MIT" }, + "node_modules/sdp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/sdp/-/sdp-3.2.0.tgz", + "integrity": "sha512-d7wDPgDV3DDiqulJjKiV2865wKsJ34YI+NDREbm+FySq6WuKOikwyNQcm+doLAZ1O6ltdO0SeKle2xMpN3Brgw==", + "license": "MIT" + }, "node_modules/section-matter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", @@ -11492,6 +11521,19 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/vue-qrcode-reader": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/vue-qrcode-reader/-/vue-qrcode-reader-5.7.2.tgz", + "integrity": "sha512-MRwo8IWM+1UzvfRhOQQBqEap06nl0E8QFIb+/HxS1KiH8BqL2qhlzMVvJgMUti4m5x+XH2YlGS0v1Qshpg+Hbw==", + "license": "MIT", + "dependencies": { + "barcode-detector": "2.2.2", + "webrtc-adapter": "8.2.3" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/vue-router": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.5.1.tgz", @@ -11543,6 +11585,19 @@ "integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==", "license": "MIT" }, + "node_modules/webrtc-adapter": { + "version": "8.2.3", + "resolved": "https://registry.npmjs.org/webrtc-adapter/-/webrtc-adapter-8.2.3.tgz", + "integrity": "sha512-gnmRz++suzmvxtp3ehQts6s2JtAGPuDPjA1F3a9ckNpG1kYdYuHWYpazoAnL9FS5/B21tKlhkorbdCXat0+4xQ==", + "license": "BSD-3-Clause", + "dependencies": { + "sdp": "^3.2.0" + }, + "engines": { + "node": ">=6.0.0", + "npm": ">=3.10.0" + } + }, "node_modules/whatwg-url": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", @@ -12255,6 +12310,15 @@ "peerDependencies": { "zod": "^3.24.1" } + }, + "node_modules/zxing-wasm": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/zxing-wasm/-/zxing-wasm-1.1.3.tgz", + "integrity": "sha512-MYm9k/5YVs4ZOTIFwlRjfFKD0crhefgbnt1+6TEpmKUDFp3E2uwqGSKwQOd2hOIsta/7Usq4hnpNRYTLoljnfA==", + "license": "MIT", + "dependencies": { + "@types/emscripten": "^1.39.10" + } } } } diff --git a/package.json b/package.json index c671aac..d9c1265 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "unplugin-vue-markdown": "^28.3.1", "uuid": "^11.1.0", "vue": "^3.5.13", + "vue-qrcode-reader": "^5.7.1", "vue-router": "^4.5.1" }, "devDependencies": { diff --git a/src/components/CodeDetector.vue b/src/components/CodeDetector.vue new file mode 100644 index 0000000..373fc9d --- /dev/null +++ b/src/components/CodeDetector.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/components/Modal.vue b/src/components/Modal.vue index fac5fcf..2b296bd 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -9,6 +9,7 @@ @@ -23,7 +24,7 @@ import { useModalStore } from "@/stores/modal"; - - diff --git a/src/components/ScanInput.vue b/src/components/ScanInput.vue new file mode 100644 index 0000000..9c98885 --- /dev/null +++ b/src/components/ScanInput.vue @@ -0,0 +1,57 @@ + + + + + diff --git a/src/components/admin/unit/damageReport/DamageReportListItem.vue b/src/components/admin/unit/damageReport/DamageReportListItem.vue new file mode 100644 index 0000000..82fd74b --- /dev/null +++ b/src/components/admin/unit/damageReport/DamageReportListItem.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/src/components/admin/unit/equipment/EquipmentListItem.vue b/src/components/admin/unit/equipment/EquipmentListItem.vue new file mode 100644 index 0000000..dc9d7f3 --- /dev/null +++ b/src/components/admin/unit/equipment/EquipmentListItem.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue b/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue new file mode 100644 index 0000000..bbe3a80 --- /dev/null +++ b/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/src/components/admin/unit/equipmentType/DeleteEquipmentTypeModal.vue b/src/components/admin/unit/equipmentType/DeleteEquipmentTypeModal.vue new file mode 100644 index 0000000..5324d74 --- /dev/null +++ b/src/components/admin/unit/equipmentType/DeleteEquipmentTypeModal.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/components/admin/unit/equipmentType/EquipmentTypeListItem.vue b/src/components/admin/unit/equipmentType/EquipmentTypeListItem.vue new file mode 100644 index 0000000..c8cb5ea --- /dev/null +++ b/src/components/admin/unit/equipmentType/EquipmentTypeListItem.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/components/admin/unit/inspection/OkNotOk.vue b/src/components/admin/unit/inspection/OkNotOk.vue new file mode 100644 index 0000000..460c3df --- /dev/null +++ b/src/components/admin/unit/inspection/OkNotOk.vue @@ -0,0 +1,63 @@ + + + + + diff --git a/src/components/admin/unit/inspection/ResultInput.vue b/src/components/admin/unit/inspection/ResultInput.vue new file mode 100644 index 0000000..2e68a1b --- /dev/null +++ b/src/components/admin/unit/inspection/ResultInput.vue @@ -0,0 +1,52 @@ + + + + + diff --git a/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue b/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue new file mode 100644 index 0000000..25217eb --- /dev/null +++ b/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue b/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue new file mode 100644 index 0000000..4ade7a4 --- /dev/null +++ b/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/components/admin/unit/wearable/WearableListItem.vue b/src/components/admin/unit/wearable/WearableListItem.vue new file mode 100644 index 0000000..6358323 --- /dev/null +++ b/src/components/admin/unit/wearable/WearableListItem.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/components/admin/unit/wearableType/CreateWearableTypeModal.vue b/src/components/admin/unit/wearableType/CreateWearableTypeModal.vue new file mode 100644 index 0000000..8a97cfb --- /dev/null +++ b/src/components/admin/unit/wearableType/CreateWearableTypeModal.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/src/components/admin/unit/wearableType/DeleteWearableTypeModal.vue b/src/components/admin/unit/wearableType/DeleteWearableTypeModal.vue new file mode 100644 index 0000000..1fc1576 --- /dev/null +++ b/src/components/admin/unit/wearableType/DeleteWearableTypeModal.vue @@ -0,0 +1,84 @@ + + + + + diff --git a/src/components/admin/unit/wearableType/WearableTypeListItem.vue b/src/components/admin/unit/wearableType/WearableTypeListItem.vue new file mode 100644 index 0000000..8f959ad --- /dev/null +++ b/src/components/admin/unit/wearableType/WearableTypeListItem.vue @@ -0,0 +1,27 @@ + + + + + diff --git a/src/components/search/EquipmentSearchSelect.vue b/src/components/search/EquipmentSearchSelect.vue new file mode 100644 index 0000000..2f60486 --- /dev/null +++ b/src/components/search/EquipmentSearchSelect.vue @@ -0,0 +1,196 @@ + + + + + diff --git a/src/components/search/EquipmentTypeSearchSelect.vue b/src/components/search/EquipmentTypeSearchSelect.vue new file mode 100644 index 0000000..77fa8b6 --- /dev/null +++ b/src/components/search/EquipmentTypeSearchSelect.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/src/components/search/InspectionPlanSearchSelect.vue b/src/components/search/InspectionPlanSearchSelect.vue new file mode 100644 index 0000000..58a514b --- /dev/null +++ b/src/components/search/InspectionPlanSearchSelect.vue @@ -0,0 +1,178 @@ + + + + + diff --git a/src/components/admin/MemberSearchSelect.vue b/src/components/search/MemberSearchSelectMultiple.vue similarity index 99% rename from src/components/admin/MemberSearchSelect.vue rename to src/components/search/MemberSearchSelectMultiple.vue index b5e0bd0..f244851 100644 --- a/src/components/admin/MemberSearchSelect.vue +++ b/src/components/search/MemberSearchSelectMultiple.vue @@ -18,7 +18,7 @@ @after-leave="query = ''" >
  • diff --git a/src/components/search/MemberSearchSelectSingle.vue b/src/components/search/MemberSearchSelectSingle.vue new file mode 100644 index 0000000..aca85a9 --- /dev/null +++ b/src/components/search/MemberSearchSelectSingle.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/src/components/search/VehicleSearchSelect.vue b/src/components/search/VehicleSearchSelect.vue new file mode 100644 index 0000000..5f19211 --- /dev/null +++ b/src/components/search/VehicleSearchSelect.vue @@ -0,0 +1,196 @@ + + + + + diff --git a/src/components/search/VehicleTypeSearchSelect.vue b/src/components/search/VehicleTypeSearchSelect.vue new file mode 100644 index 0000000..09490cb --- /dev/null +++ b/src/components/search/VehicleTypeSearchSelect.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/src/components/search/WearableTypeSearchSelect.vue b/src/components/search/WearableTypeSearchSelect.vue new file mode 100644 index 0000000..33c42b4 --- /dev/null +++ b/src/components/search/WearableTypeSearchSelect.vue @@ -0,0 +1,174 @@ + + + + + diff --git a/src/demodata/damageReport.ts b/src/demodata/damageReport.ts new file mode 100644 index 0000000..d65e381 --- /dev/null +++ b/src/demodata/damageReport.ts @@ -0,0 +1,30 @@ +import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models"; +import { equipmentDemoData } from "./equipment"; + +export const damageReportDemoData: Array = [ + { + id: "sdfgh", + reported: new Date(), + status: "in Arbeit", + done: false, + description: "knjgljna g", + providedImage: [], + relatedId: "abc", + related: { + id: "abc", + code: "0456984224498", + name: "B-Schlauch", + location: "HLF", + commissioned: new Date(), + equipmentTypeId: "xyz", + equipmentType: { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [], + }, + inspections: [], + }, + assigned: "equipment", + }, +]; diff --git a/src/demodata/equipment.ts b/src/demodata/equipment.ts new file mode 100644 index 0000000..06563b5 --- /dev/null +++ b/src/demodata/equipment.ts @@ -0,0 +1,17 @@ +import type { EquipmentViewModel } from "@/viewmodels/admin/unit/equipment/equipment.models"; +import { equipmentTypeDemoData } from "./equipmentType"; +import { inspectionDemoData } from "./inspectionPlan"; + +export const equipmentDemoData: Array = [ + { + id: "abc", + code: "0456984224498", + name: "B-Schlauch", + location: "HLF", + commissioned: new Date(), + decommissioned: undefined, + equipmentTypeId: equipmentTypeDemoData[0].id, + equipmentType: equipmentTypeDemoData[0], + inspections: [inspectionDemoData[0]], + }, +]; diff --git a/src/demodata/equipmentType.ts b/src/demodata/equipmentType.ts new file mode 100644 index 0000000..df604cd --- /dev/null +++ b/src/demodata/equipmentType.ts @@ -0,0 +1,11 @@ +import type { EquipmentTypeViewModel } from "@/viewmodels/admin/unit/equipmentType/equipmentType.models"; +import { inspectionPlanDemoData } from "./inspectionPlan"; + +export const equipmentTypeDemoData: Array = [ + { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [inspectionPlanDemoData[0], inspectionPlanDemoData[1]], + }, +]; diff --git a/src/demodata/inspectionPlan.ts b/src/demodata/inspectionPlan.ts new file mode 100644 index 0000000..9482312 --- /dev/null +++ b/src/demodata/inspectionPlan.ts @@ -0,0 +1,156 @@ +import type { + InspectionPlanViewModel, + InspectionPointViewModel, +} from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import type { + InspectionPointResultViewModel, + InspectionViewModel, +} from "@/viewmodels/admin/unit/inspection/inspection.models"; + +export const inspectionPointDemoData: Array = [ + { + id: "edf", + title: "vorhandene Spritzstellen ausgebessert", + description: "", + type: "number", + }, + { + id: "ghi", + title: "Einband der Kupplung sitzt fest", + description: "", + type: "iO-niO", + }, + { + id: "lmn", + title: "Das überstehende Drahtende des Knaggenteiles sitzt versenkt", + description: "", + type: "iO-niO", + }, + { + id: "jgj", + title: "Gebrauchsprüfdruck 12bar", + description: "", + type: "iO-niO", + }, +]; + +export const inspectionPlanDemoData: Array = [ + { + id: "abc", + title: "Sichtprüfung", + version: 1, + inspectionInterval: "1-m", + remindTime: "1-m", + created: new Date(), + inspectionPoints: [inspectionPointDemoData[0], inspectionPointDemoData[1], inspectionPointDemoData[2]], + relatedId: "xyz", + related: { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [], + }, + assigned: "equipment", + }, + { + id: "cba", + title: "Druckprüfung", + version: 1, + inspectionInterval: "1-m", + remindTime: "22/10", + created: new Date(), + inspectionPoints: [inspectionPointDemoData[3]], + relatedId: "xyz", + related: { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [], + }, + assigned: "equipment", + }, +]; + +export const inspectionPointResultDemoData: Array = [ + { + inspectionId: "jkvshdfg", + inspectionVersionedPlanId: inspectionPlanDemoData[0].id, + inspectionPointId: inspectionPointDemoData[0].id, + value: "5", + }, + { + inspectionId: "jkvshdfg", + inspectionVersionedPlanId: inspectionPlanDemoData[0].id, + inspectionPointId: inspectionPointDemoData[1].id, + value: "", + }, + { + inspectionId: "jkvshdfg", + inspectionVersionedPlanId: inspectionPlanDemoData[0].id, + inspectionPointId: inspectionPointDemoData[1].id, + value: "", + }, +]; + +export const inspectionDemoData: Array = [ + { + id: "jkvshdfg", + inspectionPlanId: inspectionPlanDemoData[0].id, + inspectionPlan: inspectionPlanDemoData[0], + inspectionVersionedPlanId: inspectionPlanDemoData[0].id, + inspectionVersionedPlan: inspectionPlanDemoData[0], + context: "", + created: new Date(), + finished: undefined, + nextInspection: undefined, + isOpen: true, + checks: [inspectionPointResultDemoData[0], inspectionPointResultDemoData[1], inspectionPointResultDemoData[2]], + relatedId: "abc", + related: { + id: "abc", + code: "0456984224498", + name: "B-Schlauch", + location: "HLF", + commissioned: new Date(), + equipmentTypeId: "xyz", + equipmentType: { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [], + }, + inspections: [], + }, + assigned: "equipment", + }, + { + id: "jkvshdfg", + inspectionPlanId: inspectionPlanDemoData[0].id, + inspectionPlan: inspectionPlanDemoData[0], + inspectionVersionedPlanId: inspectionPlanDemoData[0].id, + inspectionVersionedPlan: inspectionPlanDemoData[0], + context: "sohgfpb", + created: new Date(), + finished: new Date(), + nextInspection: new Date(), + isOpen: false, + checks: [inspectionPointResultDemoData[0], inspectionPointResultDemoData[1], inspectionPointResultDemoData[2]], + relatedId: "abc", + related: { + id: "abc", + code: "0456984224498", + name: "B-Schlauch", + location: "HLF", + commissioned: new Date(), + equipmentTypeId: "xyz", + equipmentType: { + id: "xyz", + type: "B-Schlauch", + description: "Shläuche vom Typ B", + inspectionPlans: [], + }, + inspections: [], + }, + assigned: "equipment", + }, +]; diff --git a/src/demodata/respiratoryGear.ts b/src/demodata/respiratoryGear.ts new file mode 100644 index 0000000..caf4de0 --- /dev/null +++ b/src/demodata/respiratoryGear.ts @@ -0,0 +1,10 @@ +import type { RespiratoryGearViewModel } from "@/viewmodels/admin/unit/respiratoryGear/respiratoryGear.models"; +import { equipmentDemoData } from "./equipment"; + +export const respiratoryGearDemoData: Array = [ + { + id: "adfsg", + equipmentId: equipmentDemoData[0].id, + equipment: equipmentDemoData[0], + }, +]; diff --git a/src/demodata/respiratoryMission.ts b/src/demodata/respiratoryMission.ts new file mode 100644 index 0000000..e32c39e --- /dev/null +++ b/src/demodata/respiratoryMission.ts @@ -0,0 +1,11 @@ +import type { RespiratoryMissionViewModel } from "@/viewmodels/admin/unit/respiratoryMission/respiratoryMission.models"; +import { equipmentDemoData } from "./equipment"; + +export const respiratoryMissionDemoData: Array = [ + { + id: "adfsg", + date: new Date(), + title: "B5", + description: "B5 Einsatz", + }, +]; diff --git a/src/demodata/respiratoryWearer.ts b/src/demodata/respiratoryWearer.ts new file mode 100644 index 0000000..01019a0 --- /dev/null +++ b/src/demodata/respiratoryWearer.ts @@ -0,0 +1,17 @@ +import type { RespiratoryWearerViewModel } from "@/viewmodels/admin/unit/respiratoryWearer/respiratoryWearer.models"; + +export const respiratoryWearerDemoData: Array = [ + { + id: "dfghj", + memberId: "9469991d-fa22-4899-82ce-b1ba5de990dc", + member: { + id: "9469991d-fa22-4899-82ce-b1ba5de990dc", + salutation: { id: 3, salutation: "Herr" }, + firstname: "Julian", + lastname: "Krauser", + nameaffix: "", + birthdate: new Date("2003-09-20"), + internalId: "1312", + }, + }, +]; diff --git a/src/demodata/vehicle.ts b/src/demodata/vehicle.ts new file mode 100644 index 0000000..b307abb --- /dev/null +++ b/src/demodata/vehicle.ts @@ -0,0 +1,27 @@ +import type { VehicleViewModel } from "@/viewmodels/admin/unit/vehicle/vehicle.models"; +import { vehicleTypeDemoData } from "./vehicleType"; + +export const vehicleDemoData: Array = [ + { + id: "kjhb", + code: "", + name: "HLF", + location: "Tor 1", + commissioned: new Date(), + decommissioned: undefined, + vehicleTypeId: vehicleTypeDemoData[0].id, + vehicleType: vehicleTypeDemoData[0], + inspections: [], + }, + { + id: "kjhdfgb", + code: "", + name: "LF", + location: "Tor 2", + commissioned: new Date(), + decommissioned: undefined, + vehicleTypeId: vehicleTypeDemoData[1].id, + vehicleType: vehicleTypeDemoData[1], + inspections: [], + }, +]; diff --git a/src/demodata/vehicleType.ts b/src/demodata/vehicleType.ts new file mode 100644 index 0000000..bf25718 --- /dev/null +++ b/src/demodata/vehicleType.ts @@ -0,0 +1,16 @@ +import type { VehicleTypeViewModel } from "@/viewmodels/admin/unit/vehicleType/vehicleType.models"; + +export const vehicleTypeDemoData: Array = [ + { + id: "xyfgdghfz", + type: "HLF 20/10", + description: "HLF", + inspectionPlans: [], + }, + { + id: "abc", + type: "LF 8/6", + description: "LF", + inspectionPlans: [], + }, +]; diff --git a/src/demodata/wearable.ts b/src/demodata/wearable.ts new file mode 100644 index 0000000..973de4a --- /dev/null +++ b/src/demodata/wearable.ts @@ -0,0 +1,25 @@ +import type { WearableViewModel } from "@/viewmodels/admin/unit/wearable/wearable.models"; +import { wearableTypeDemoData } from "./wearableType"; + +export const wearableDemoData: Array = [ + { + id: "absdfgc", + code: "0456984224498", + name: "Jacke", + location: "Spint", + commissioned: new Date(), + decommissioned: undefined, + wearerId: "9469991d-fa22-4899-82ce-b1ba5de990dc", + wearer: { + id: "9469991d-fa22-4899-82ce-b1ba5de990dc", + salutation: { id: 3, salutation: "Herr" }, + firstname: "Julian", + lastname: "Krauser", + nameaffix: "", + birthdate: new Date("2003-09-20"), + internalId: "1312", + }, + wearableTypeId: wearableTypeDemoData[0].id, + wearableType: wearableTypeDemoData[0], + }, +]; diff --git a/src/demodata/wearableType.ts b/src/demodata/wearableType.ts new file mode 100644 index 0000000..b5aef7f --- /dev/null +++ b/src/demodata/wearableType.ts @@ -0,0 +1,9 @@ +import type { WearableTypeViewModel } from "@/viewmodels/admin/unit/wearableType/wearableType.models"; + +export const wearableTypeDemoData: Array = [ + { + id: "xyz", + type: "Jacke", + description: "Bayern 2000", + }, +]; diff --git a/src/helpers/codeScanner.ts b/src/helpers/codeScanner.ts new file mode 100644 index 0000000..6894088 --- /dev/null +++ b/src/helpers/codeScanner.ts @@ -0,0 +1,143 @@ +import type { BarcodeFormat, DetectedBarcode } from "barcode-detector/pure"; + +/*** select camera ***/ +export interface Camera { + label: string; + constraints: { + deviceId?: string; + facingMode: string; + }; +} +export const defaultConstraintOptions: Array = [ + { label: "rear camera", constraints: { facingMode: "environment" } }, + { label: "front camera", constraints: { facingMode: "user" } }, +]; + +export async function getAvailableCameras(useDefault: boolean = false): Promise> { + // NOTE: on iOS we can't invoke `enumerateDevices` before the user has given + // camera access permission. `QrcodeStream` internally takes care of + // requesting the permissions. The `camera-on` event should guarantee that this + // has happened. + const devices = await navigator.mediaDevices.enumerateDevices(); + const videoDevices = devices.filter(({ kind }) => kind === "videoinput"); + + return [ + ...(useDefault ? defaultConstraintOptions : []), + ...videoDevices.map(({ deviceId, label }) => ({ + label: `${label}`, //(ID: ${deviceId}) + constraints: { deviceId, facingMode: "custom" }, + })), + ]; +} + +/*** track functons ***/ +export function paintOutline(detectedCodes: DetectedBarcode[], ctx: CanvasRenderingContext2D) { + for (const detectedCode of detectedCodes) { + const [firstPoint, ...otherPoints] = detectedCode.cornerPoints; + + ctx.strokeStyle = "red"; + + ctx.beginPath(); + ctx.moveTo(firstPoint.x, firstPoint.y); + for (const { x, y } of otherPoints) { + ctx.lineTo(x, y); + } + ctx.lineTo(firstPoint.x, firstPoint.y); + ctx.closePath(); + ctx.stroke(); + } +} +export function paintBoundingBox(detectedCodes: DetectedBarcode[], ctx: CanvasRenderingContext2D) { + for (const detectedCode of detectedCodes) { + const { + boundingBox: { x, y, width, height }, + } = detectedCode; + + ctx.lineWidth = 2; + ctx.strokeStyle = "#007bff"; + ctx.strokeRect(x, y, width, height); + } +} +export function paintCenterText(detectedCodes: DetectedBarcode[], ctx: CanvasRenderingContext2D) { + for (const detectedCode of detectedCodes) { + const { boundingBox, rawValue } = detectedCode; + + const centerX = boundingBox.x + boundingBox.width / 2; + const centerY = boundingBox.y + boundingBox.height / 2; + + const fontSize = Math.max(12, (50 * boundingBox.width) / ctx.canvas.width); + + ctx.font = `bold ${fontSize}px sans-serif`; + ctx.textAlign = "center"; + + ctx.lineWidth = 3; + ctx.strokeStyle = "#35495e"; + ctx.strokeText(detectedCode.rawValue, centerX, centerY); + + ctx.fillStyle = "#5cb984"; + ctx.fillText(rawValue, centerX, centerY); + } +} +export const trackFunctionOptions = [ + { text: "nothing (default)", value: undefined }, + { text: "outline", value: paintOutline }, + { text: "centered text", value: paintCenterText }, + { text: "bounding box", value: paintBoundingBox }, + { + text: "mixed", + value: (detectedCodes: DetectedBarcode[], ctx: CanvasRenderingContext2D) => { + paintOutline(detectedCodes, ctx); + paintCenterText(detectedCodes, ctx); + }, + }, +]; + +/*** barcode formats ***/ +export const barcodeFormats: Array = [ + "aztec", + "code_128", + "code_39", + "code_93", + "codabar", + "databar", + "databar_expanded", + "data_matrix", + "dx_film_edge", + "ean_13", + "ean_8", + "itf", + "maxi_code", + "micro_qr_code", + "pdf417", + "qr_code", + "rm_qr_code", + "upc_a", + "upc_e", + "linear_codes", + "matrix_codes", +]; + +/*** error handling ***/ +export function handleScannerError(err: Error) { + let error = `[${err.name}]: `; + + if (err.name === "NotAllowedError") { + error += "you need to grant camera access permission"; + } else if (err.name === "NotFoundError") { + error += "no camera on this device"; + } else if (err.name === "NotSupportedError") { + error += "secure context required (HTTPS, localhost)"; + } else if (err.name === "NotReadableError") { + error += "is the camera already in use?"; + } else if (err.name === "OverconstrainedError") { + error += "installed cameras are not suitable"; + } else if (err.name === "StreamApiNotSupportedError") { + error += "Stream API is not supported in this browser"; + } else if (err.name === "InsecureContextError") { + error += "Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP."; + } else { + error += err.message; + } + + return error; +} diff --git a/src/main.css b/src/main.css index a334a51..b9501d6 100644 --- a/src/main.css +++ b/src/main.css @@ -68,23 +68,23 @@ body { /*:not([headlessui]):not([id*="headlessui"]):not([class*="headlessui"])*/ button:not([class*="ql"] *):not([class*="fc"]):not([id*="headlessui-combobox"]), -a[button] { +[button] { @apply cursor-pointer relative box-border h-10 w-full flex justify-center py-2 px-4 text-sm font-medium rounded-md focus:outline-hidden focus:ring-0; } button[primary]:not([primary="false"]), -a[button][primary]:not([primary="false"]) { +[button][primary]:not([primary="false"]) { @apply border-2 border-transparent text-white bg-primary hover:bg-primary; } button[primary-outline]:not([primary-outline="false"]), -a[button][primary-outline]:not([primary-outline="false"]) { +[button][primary-outline]:not([primary-outline="false"]) { @apply border-2 border-primary text-black hover:bg-primary; } button:disabled, -a[button]:disabled, -a[button].disabled { +[button]:disabled, +[button].disabled { @apply opacity-75 pointer-events-none; } @@ -97,7 +97,7 @@ select { input[readonly], textarea[readonly], select[readonly] { - @apply select-none; + @apply select-none focus:border-gray-300 cursor-default; /* pointer-events-none; */ } diff --git a/src/router/memberGuard.ts b/src/router/club/memberGuard.ts similarity index 100% rename from src/router/memberGuard.ts rename to src/router/club/memberGuard.ts diff --git a/src/router/newsletterGuard.ts b/src/router/club/newsletterGuard.ts similarity index 100% rename from src/router/newsletterGuard.ts rename to src/router/club/newsletterGuard.ts diff --git a/src/router/protocolGuard.ts b/src/router/club/protocolGuard.ts similarity index 100% rename from src/router/protocolGuard.ts rename to src/router/club/protocolGuard.ts diff --git a/src/router/index.ts b/src/router/index.ts index 1684adf..5d7157d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -5,10 +5,20 @@ import { isAuthenticated } from "./authGuard"; import { isSetup } from "./setupGuard"; import { abilityAndNavUpdate } from "./adminGuard"; import type { PermissionType, PermissionSection, PermissionModule } from "@/types/permissionTypes"; -import { resetMemberStores, setMemberId } from "./memberGuard"; -import { resetProtocolStores, setProtocolId } from "./protocolGuard"; -import { resetNewsletterStores, setNewsletterId } from "./newsletterGuard"; -import { setBackupPage } from "./backupGuard"; +import { resetMemberStores, setMemberId } from "./club/memberGuard"; +import { resetProtocolStores, setProtocolId } from "./club/protocolGuard"; +import { resetNewsletterStores, setNewsletterId } from "./club/newsletterGuard"; +import { setBackupPage } from "./management/backupGuard"; +import { resetEquipmentTypeStores, setEquipmentTypeId } from "./unit/equipmentType"; +import { resetEquipmentStores, setEquipmentId } from "./unit/equipment"; +import { resetVehicleStores, setVehicleId } from "./unit/vehicle"; +import { resetRespiratoryGearStores, setRespiratoryGearId } from "./unit/respiratoryGear"; +import { resetRespiratoryWearerStores, setRespiratoryWearerId } from "./unit/respiratoryWearer"; +import { resetRespiratoryMissionStores, setRespiratoryMissionId } from "./unit/respiratoryMission"; +import { resetWearableStores, setWearableId } from "./unit/wearable"; +import { resetInspectionPlanStores, setInspectionPlanId } from "./unit/inspectionPlan"; +import { setVehicleTypeId } from "./unit/vehicleType"; +import { resetInspectionStores, setInspectionId } from "./unit/inspection"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -309,6 +319,570 @@ const router = createRouter({ component: () => import("@/views/RouterView.vue"), meta: { type: "read", section: "unit" }, beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-default", + component: () => import("@/views/admin/ViewSelect.vue"), + meta: { type: "read", section: "unit" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: "equipment", + name: "admin-unit-equipment-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "equipment" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-equipment", + component: () => import("@/views/admin/unit/equipment/Equipment.vue"), + beforeEnter: [resetEquipmentStores], + }, + { + path: "create", + name: "admin-unit-equipment-create", + component: () => import("@/views/admin/unit/equipment/CreateEquipment.vue"), + meta: { type: "create", section: "unit", module: "equipment" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":equipmentId", + name: "admin-unit-equipment-routing", + component: () => import("@/views/admin/unit/equipment/EquipmentRouting.vue"), + beforeEnter: [setEquipmentId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-equipment-overview", + component: () => import("@/views/admin/unit/equipment/Overview.vue"), + props: true, + }, + { + path: "maintenance", + name: "admin-unit-equipment-maintenance", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "inspection", + name: "admin-unit-equipment-inspection", + component: () => import("@/views/admin/unit/equipment/Inspection.vue"), + props: true, + }, + { + path: "report", + name: "admin-unit-equipment-damage_report", + component: () => import("@/views/admin/unit/equipment/DamageReport.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-equipment-edit", + component: () => import("@/views/admin/unit/equipment/UpdateEquipment.vue"), + meta: { type: "update", section: "unit", module: "equipment" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "vehicle", + name: "admin-unit-vehicle-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "vehicle" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-vehicle", + component: () => import("@/views/admin/unit/vehicle/Vehicle.vue"), + beforeEnter: [resetVehicleStores], + }, + { + path: "create", + name: "admin-unit-vehicle-create", + component: () => import("@/views/admin/unit/vehicle/CreateVehicle.vue"), + meta: { type: "create", section: "unit", module: "vehicle" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":vehicleId", + name: "admin-unit-vehicle-routing", + component: () => import("@/views/admin/unit/vehicle/VehicleRouting.vue"), + beforeEnter: [setVehicleId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-vehicle-overview", + component: () => import("@/views/admin/unit/vehicle/Overview.vue"), + props: true, + }, + { + path: "maintenance", + name: "admin-unit-vehicle-maintenance", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "inspection", + name: "admin-unit-vehicle-inspection", + component: () => import("@/views/admin/unit/vehicle/Inspection.vue"), + props: true, + }, + { + path: "report", + name: "admin-unit-vehicle-damage_report", + component: () => import("@/views/admin/unit/vehicle/DamageReport.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-vehicle-edit", + component: () => import("@/views/admin/unit/vehicle/UpdateVehicle.vue"), + meta: { type: "update", section: "unit", module: "vehicle" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "wearable", + name: "admin-unit-wearable-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "wearable" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-wearable", + component: () => import("@/views/admin/unit/wearable/Wearable.vue"), + beforeEnter: [resetWearableStores], + }, + { + path: "create", + name: "admin-unit-wearable-create", + component: () => import("@/views/admin/unit/wearable/CreateWearable.vue"), + meta: { type: "create", section: "unit", module: "wearable" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":wearableId", + name: "admin-unit-wearable-routing", + component: () => import("@/views/admin/unit/wearable/WearableRouting.vue"), + beforeEnter: [setWearableId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-wearable-overview", + component: () => import("@/views/admin/unit/wearable/Overview.vue"), + props: true, + }, + { + path: "maintenance", + name: "admin-unit-wearable-maintenance", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "report", + name: "admin-unit-wearable-damage_report", + component: () => import("@/views/admin/unit/wearable/DamageReport.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-wearable-edit", + component: () => import("@/views/admin/unit/wearable/UpdateWearable.vue"), + meta: { type: "update", section: "unit", module: "wearable" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "respiratory-gear", + name: "admin-unit-respiratory_gear-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "respiratory_gear" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-respiratory_gear", + component: () => import("@/views/admin/unit/respiratoryGear/RespiratoryGear.vue"), + beforeEnter: [resetRespiratoryGearStores], + }, + { + path: "create", + name: "admin-unit-respiratory_gear-create", + component: () => import("@/views/admin/unit/respiratoryGear/CreateRespiratoryGear.vue"), + meta: { type: "create", section: "unit", module: "respiratory_gear" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":respiratoryGearId", + name: "admin-unit-respiratory_gear-routing", + component: () => import("@/views/admin/unit/respiratoryGear/RespiratoryGearRouting.vue"), + beforeEnter: [setRespiratoryGearId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-respiratory_gear-overview", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "maintenance", + name: "admin-unit-respiratory_gear-maintenance", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "inspection", + name: "admin-unit-respiratory_gear-inspection", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "mission", + name: "admin-unit-respiratory_gear-mission", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + ], + }, + ], + }, + { + path: "respiratory-wearer", + name: "admin-unit-respiratory_wearer-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "respiratory_wearer" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-respiratory_wearer", + component: () => import("@/views/admin/unit/respiratoryWearer/RespiratoryWearer.vue"), + beforeEnter: [resetRespiratoryWearerStores], + }, + { + path: "create", + name: "admin-unit-respiratory_wearer-create", + component: () => import("@/views/admin/unit/respiratoryWearer/CreateRespiratoryWearer.vue"), + meta: { type: "create", section: "unit", module: "respiratory_wearer" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":respiratoryWearerId", + name: "admin-unit-respiratory_wearer-routing", + component: () => import("@/views/admin/unit/respiratoryWearer/RespiratoryWearerRouting.vue"), + beforeEnter: [setRespiratoryWearerId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-respiratory_wearer-overview", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "mission", + name: "admin-unit-respiratory_wearer-mission", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "education", + name: "admin-unit-respiratory_wearer-education", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "instruction", + name: "admin-unit-respiratory_wearer-instruction", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "screening", + name: "admin-unit-respiratory_wearer-screening", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "strain", + name: "admin-unit-respiratory_wearer-strain", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + ], + }, + ], + }, + { + path: "respiratory-mission", + name: "admin-unit-respiratory_mission-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "respiratory_mission" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-respiratory_mission", + component: () => import("@/views/admin/unit/respiratoryMission/RespiratoryMission.vue"), + beforeEnter: [resetRespiratoryMissionStores], + }, + { + path: "create", + name: "admin-unit-respiratory_mission-create", + component: () => import("@/views/admin/unit/respiratoryMission/CreateRespiratoryMission.vue"), + meta: { type: "create", section: "unit", module: "respiratory_mission" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":respiratoryMissionId", + name: "admin-unit-respiratory_mission-routing", + component: () => import("@/views/admin/unit/respiratoryMission/RespiratoryMissionRouting.vue"), + beforeEnter: [setRespiratoryMissionId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-respiratory_mission-overview", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "wearer", + name: "admin-unit-respiratory_mission-wearer", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + { + path: "gear", + name: "admin-unit-respiratory_mission-gear", + component: () => import("@/views/admin/ViewSelect.vue"), + props: true, + }, + ], + }, + ], + }, + { + path: "damage-report", + name: "admin-unit-damage_report-route", + component: () => import("@/views/admin/unit/damageReport/DamageReportRouting.vue"), + meta: { type: "read", section: "unit", module: "damage_report" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-damage_report", + component: () => import("@/views/admin/unit/damageReport/DamageReport.vue"), + }, + { + path: "done", + name: "admin-unit-damage_report-done", + component: () => import("@/views/admin/unit/damageReport/DamageReport.vue"), + }, + ], + }, + { + path: "equipment-type", + name: "admin-unit-equipment_type-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "equipment_type" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-equipment_type", + component: () => import("@/views/admin/unit/equipmentType/EquipmentType.vue"), + beforeEnter: [resetEquipmentTypeStores], + }, + { + path: ":equipmentTypeId", + name: "admin-unit-equipment_type-routing", + component: () => import("@/views/admin/unit/equipmentType/EquipmentTypeRouting.vue"), + beforeEnter: [setEquipmentTypeId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-equipment_type-overview", + component: () => import("@/views/admin/unit/equipmentType/Overview.vue"), + props: true, + }, + { + path: "inspection-plan", + name: "admin-unit-equipment_type-inspection_plan", + component: () => import("@/views/admin/unit/equipmentType/InspectionPlans.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-equipment_type-edit", + component: () => import("@/views/admin/unit/equipmentType/UpdateEquipmentType.vue"), + meta: { type: "update", section: "unit", module: "equipment_type" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "vehicle-type", + name: "admin-unit-vehicle_type-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "vehicle_type" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-vehicle_type", + component: () => import("@/views/admin/unit/vehicleType/VehicleType.vue"), + }, + { + path: ":vehicleTypeId", + name: "admin-unit-vehicle_type-routing", + component: () => import("@/views/admin/unit/vehicleType/VehicleTypeRouting.vue"), + beforeEnter: [setVehicleTypeId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-vehicle_type-overview", + component: () => import("@/views/admin/unit/vehicleType/Overview.vue"), + props: true, + }, + { + path: "inspection-plan", + name: "admin-unit-vehicle_type-inspection_plan", + component: () => import("@/views/admin/unit/vehicleType/InspectionPlans.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-vehicle_type-edit", + component: () => import("@/views/admin/unit/vehicleType/UpdateVehicleType.vue"), + meta: { type: "update", section: "unit", module: "vehicle_type" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "wearable-type", + name: "admin-unit-wearable_type-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "wearable_type" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-wearable_type", + component: () => import("@/views/admin/unit/wearableType/WearableType.vue"), + }, + { + path: ":wearableTypeId/edit", + name: "admin-unit-wearable_type-edit", + component: () => import("@/views/admin/unit/wearableType/UpdateWearableType.vue"), + meta: { type: "update", section: "unit", module: "wearable_type" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + { + path: "inspection-plan", + name: "admin-unit-inspection_plan-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "inspection_plan" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-inspection_plan", + component: () => import("@/views/admin/unit/inspectionPlan/InspectionPlan.vue"), + beforeEnter: [resetInspectionPlanStores], + }, + { + path: "create", + name: "admin-unit-inspection_plan-create", + component: () => import("@/views/admin/unit/inspectionPlan/CreateInspectionPlan.vue"), + meta: { type: "create", section: "unit", module: "inspection_plan" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":inspectionPlanId", + name: "admin-unit-inspection_plan-routing", + component: () => import("@/views/admin/unit/inspectionPlan/InspectionPlanRouting.vue"), + beforeEnter: [setInspectionPlanId], + props: true, + children: [ + { + path: "", + name: "admin-unit-inspection_plan-overview", + component: () => import("@/views/admin/unit/inspectionPlan/Overview.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-inspection_plan-edit", + component: () => import("@/views/admin/ViewSelect.vue"), + meta: { type: "update", section: "unit", module: "inspection_plan" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, + { + path: "inspection", + name: "admin-unit-inspection-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "create", section: "unit", module: "inspection" }, + beforeEnter: [abilityAndNavUpdate, resetInspectionStores], + children: [ + { + path: "", + name: "admin-unit-inspection", + redirect: { name: "admin-unit-inspection-plan" }, + }, + { + path: "plan/:type?/:relatedId?/:inspectionPlanId?", + name: "admin-unit-inspection-plan", + component: () => import("@/views/admin/unit/inspection/InspectionPlan.vue"), + beforeEnter: [], + props: true, + }, + { + path: "execute/:inspectionId", + name: "admin-unit-inspection-execute", + component: () => import("@/views/admin/unit/inspection/InspectionExecute.vue"), + beforeEnter: [setInspectionId], + props: true, + }, + ], + }, + ], }, { path: "configuration", diff --git a/src/router/backupGuard.ts b/src/router/management/backupGuard.ts similarity index 100% rename from src/router/backupGuard.ts rename to src/router/management/backupGuard.ts diff --git a/src/router/unit/equipment.ts b/src/router/unit/equipment.ts new file mode 100644 index 0000000..cdb2efa --- /dev/null +++ b/src/router/unit/equipment.ts @@ -0,0 +1,20 @@ +import { useEquipmentStore } from "@/stores/admin/unit/equipment/equipment"; + +export async function setEquipmentId(to: any, from: any, next: any) { + const EquipmentStore = useEquipmentStore(); + EquipmentStore.activeEquipment = to.params?.equipmentId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetEquipmentStores(to: any, from: any, next: any) { + const EquipmentStore = useEquipmentStore(); + EquipmentStore.activeEquipment = null; + EquipmentStore.activeEquipmentObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/equipmentType.ts b/src/router/unit/equipmentType.ts new file mode 100644 index 0000000..84ed750 --- /dev/null +++ b/src/router/unit/equipmentType.ts @@ -0,0 +1,21 @@ +import { useEquipmentTypeStore } from "@/stores/admin/unit/equipmentType/equipmentType"; +import { useEquipmentTypeInspectionPlanStore } from "@/stores/admin/unit/equipmentType/inspectionPlan"; + +export async function setEquipmentTypeId(to: any, from: any, next: any) { + const equipmentTypeStore = useEquipmentTypeStore(); + equipmentTypeStore.activeEquipmentType = to.params?.equipmentTypeId ?? null; + + useEquipmentTypeInspectionPlanStore().$reset(); + + next(); +} + +export async function resetEquipmentTypeStores(to: any, from: any, next: any) { + const equipmentTypeStore = useEquipmentTypeStore(); + equipmentTypeStore.activeEquipmentType = null; + equipmentTypeStore.activeEquipmentTypeObj = null; + + useEquipmentTypeInspectionPlanStore().$reset(); + + next(); +} diff --git a/src/router/unit/inspection.ts b/src/router/unit/inspection.ts new file mode 100644 index 0000000..1232a42 --- /dev/null +++ b/src/router/unit/inspection.ts @@ -0,0 +1,20 @@ +import { useInspectionStore } from "@/stores/admin/unit/inspection/inspection"; + +export async function setInspectionId(to: any, from: any, next: any) { + const InspectionStore = useInspectionStore(); + InspectionStore.activeInspection = to.params?.inspectionId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetInspectionStores(to: any, from: any, next: any) { + const InspectionStore = useInspectionStore(); + InspectionStore.activeInspection = null; + InspectionStore.activeInspectionObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/inspectionPlan.ts b/src/router/unit/inspectionPlan.ts new file mode 100644 index 0000000..7bd43a3 --- /dev/null +++ b/src/router/unit/inspectionPlan.ts @@ -0,0 +1,20 @@ +import { useInspectionPlanStore } from "@/stores/admin/unit/inspectionPlan/inspectionPlan"; + +export async function setInspectionPlanId(to: any, from: any, next: any) { + const InspectionPlanStore = useInspectionPlanStore(); + InspectionPlanStore.activeInspectionPlan = to.params?.inspectionPlanId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetInspectionPlanStores(to: any, from: any, next: any) { + const InspectionPlanStore = useInspectionPlanStore(); + InspectionPlanStore.activeInspectionPlan = null; + InspectionPlanStore.activeInspectionPlanObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/respiratoryGear.ts b/src/router/unit/respiratoryGear.ts new file mode 100644 index 0000000..8059d2a --- /dev/null +++ b/src/router/unit/respiratoryGear.ts @@ -0,0 +1,20 @@ +import { useRespiratoryGearStore } from "@/stores/admin/unit/respiratoryGear/respiratoryGear"; + +export async function setRespiratoryGearId(to: any, from: any, next: any) { + const RespiratoryGearStore = useRespiratoryGearStore(); + RespiratoryGearStore.activeRespiratoryGear = to.params?.respiratoryGearId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetRespiratoryGearStores(to: any, from: any, next: any) { + const RespiratoryGearStore = useRespiratoryGearStore(); + RespiratoryGearStore.activeRespiratoryGear = null; + RespiratoryGearStore.activeRespiratoryGearObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/respiratoryMission.ts b/src/router/unit/respiratoryMission.ts new file mode 100644 index 0000000..db85a2f --- /dev/null +++ b/src/router/unit/respiratoryMission.ts @@ -0,0 +1,20 @@ +import { useRespiratoryMissionStore } from "@/stores/admin/unit/respiratoryMission/respiratoryMission"; + +export async function setRespiratoryMissionId(to: any, from: any, next: any) { + const RespiratoryMissionStore = useRespiratoryMissionStore(); + RespiratoryMissionStore.activeRespiratoryMission = to.params?.respiratoryMissionId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetRespiratoryMissionStores(to: any, from: any, next: any) { + const RespiratoryMissionStore = useRespiratoryMissionStore(); + RespiratoryMissionStore.activeRespiratoryMission = null; + RespiratoryMissionStore.activeRespiratoryMissionObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/respiratoryWearer.ts b/src/router/unit/respiratoryWearer.ts new file mode 100644 index 0000000..37a4499 --- /dev/null +++ b/src/router/unit/respiratoryWearer.ts @@ -0,0 +1,20 @@ +import { useRespiratoryWearerStore } from "@/stores/admin/unit/respiratoryWearer/respiratoryWearer"; + +export async function setRespiratoryWearerId(to: any, from: any, next: any) { + const RespiratoryWearerStore = useRespiratoryWearerStore(); + RespiratoryWearerStore.activeRespiratoryWearer = to.params?.respiratoryWearerId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetRespiratoryWearerStores(to: any, from: any, next: any) { + const RespiratoryWearerStore = useRespiratoryWearerStore(); + RespiratoryWearerStore.activeRespiratoryWearer = null; + RespiratoryWearerStore.activeRespiratoryWearerObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/vehicle.ts b/src/router/unit/vehicle.ts new file mode 100644 index 0000000..c27c47c --- /dev/null +++ b/src/router/unit/vehicle.ts @@ -0,0 +1,20 @@ +import { useVehicleStore } from "@/stores/admin/unit/vehicle/vehicle"; + +export async function setVehicleId(to: any, from: any, next: any) { + const VehicleStore = useVehicleStore(); + VehicleStore.activeVehicle = to.params?.vehicleId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetVehicleStores(to: any, from: any, next: any) { + const VehicleStore = useVehicleStore(); + VehicleStore.activeVehicle = null; + VehicleStore.activeVehicleObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/vehicleType.ts b/src/router/unit/vehicleType.ts new file mode 100644 index 0000000..d7418b9 --- /dev/null +++ b/src/router/unit/vehicleType.ts @@ -0,0 +1,21 @@ +import { useVehicleTypeStore } from "@/stores/admin/unit/vehicleType/vehicleType"; +import { useVehicleTypeInspectionPlanStore } from "@/stores/admin/unit/vehicleType/inspectionPlan"; + +export async function setVehicleTypeId(to: any, from: any, next: any) { + const vehicleTypeStore = useVehicleTypeStore(); + vehicleTypeStore.activeVehicleType = to.params?.vehicleTypeId ?? null; + + useVehicleTypeInspectionPlanStore().$reset(); + + next(); +} + +export async function resetVehicleTypeStores(to: any, from: any, next: any) { + const vehicleTypeStore = useVehicleTypeStore(); + vehicleTypeStore.activeVehicleType = null; + vehicleTypeStore.activeVehicleTypeObj = null; + + useVehicleTypeInspectionPlanStore().$reset(); + + next(); +} diff --git a/src/router/unit/wearable.ts b/src/router/unit/wearable.ts new file mode 100644 index 0000000..1a0fb91 --- /dev/null +++ b/src/router/unit/wearable.ts @@ -0,0 +1,20 @@ +import { useWearableStore } from "@/stores/admin/unit/wearable/wearable"; + +export async function setWearableId(to: any, from: any, next: any) { + const WearableStore = useWearableStore(); + WearableStore.activeWearable = to.params?.wearableId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetWearableStores(to: any, from: any, next: any) { + const WearableStore = useWearableStore(); + WearableStore.activeWearable = null; + WearableStore.activeWearableObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/stores/admin/navigation.ts b/src/stores/admin/navigation.ts index 41e2300..da06a34 100644 --- a/src/stores/admin/navigation.ts +++ b/src/stores/admin/navigation.ts @@ -62,7 +62,7 @@ export const useNavigationStore = defineStore("navigation", { { key: "unit", title: "Wehr", - levelDefault: "", + levelDefault: "equipment", } as topLevelNavigationModel, ] : []), @@ -104,8 +104,42 @@ export const useNavigationStore = defineStore("navigation", { ...(abilityStore.can("read", "club", "listprint") ? [{ key: "listprint", title: "Liste Drucken" }] : []), ], }, + unit: { + mainTitle: "Wehr", + main: [ + ...(abilityStore.can("read", "unit", "equipment") ? [{ key: "equipment", title: "Gerätschaften" }] : []), + ...(abilityStore.can("read", "unit", "vehicle") ? [{ key: "vehicle", title: "Fahrzeuge" }] : []), + ...(abilityStore.can("read", "unit", "wearable") ? [{ key: "wearable", title: "Kleidung" }] : []), + ...(abilityStore.can("read", "unit", "respiratory_gear") + ? [{ key: "respiratory_gear", title: "Atemschutz-Geräte" }] + : []), + ...(abilityStore.can("read", "unit", "respiratory_wearer") + ? [{ key: "respiratory_wearer", title: "Atemschutz-Träger" }] + : []), + ...(abilityStore.can("read", "unit", "respiratory_mission") + ? [{ key: "respiratory_mission", title: "Atemschutz-Einsätze" }] + : []), + ...(abilityStore.can("create", "unit", "inspection") ? [{ key: "inspection", title: "Prüfungen" }] : []), + ...(abilityStore.can("read", "unit", "damage_report") + ? [{ key: "damage_report", title: "Schadensmeldungen" }] + : []), + { key: "divider1", title: "Basisdaten" }, + ...(abilityStore.can("read", "unit", "equipment_type") + ? [{ key: "equipment_type", title: "Geräte-Typen" }] + : []), + ...(abilityStore.can("read", "unit", "vehicle_type") + ? [{ key: "vehicle_type", title: "Fahrzeug-Arten" }] + : []), + ...(abilityStore.can("read", "unit", "wearable_type") + ? [{ key: "wearable_type", title: "Kleidungs-Arten" }] + : []), + ...(abilityStore.can("read", "unit", "inspection_plan") + ? [{ key: "inspection_plan", title: "Prüfpläne" }] + : []), + ], + }, configuration: { - mainTitle: "Einstellungen", + mainTitle: "Konfiguration", main: [ { key: "divider1", title: "Mitgliederdaten" }, ...(abilityStore.can("read", "configuration", "salutation") diff --git a/src/stores/admin/unit/damageReport/damageReport.ts b/src/stores/admin/unit/damageReport/damageReport.ts new file mode 100644 index 0000000..04c6b7c --- /dev/null +++ b/src/stores/admin/unit/damageReport/damageReport.ts @@ -0,0 +1,91 @@ +import { defineStore } from "pinia"; +import type { + DamageReportViewModel, + CreateDamageReportViewModel, + UpdateDamageReportViewModel, +} from "@/viewmodels/admin/unit/damageReport/damageReport.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import type { VehicleViewModel } from "@/viewmodels/admin/unit/vehicle/vehicle.models"; +import { damageReportDemoData } from "@/demodata/damageReport"; + +export const useDamageReportStore = defineStore("damageReport", { + state: () => { + return { + damageReports: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchDamageReports(offset = 0, count = 25, search = "", clear = false) { + this.damageReports = damageReportDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.damageReports.length; + this.loading = "fetched"; + return; + if (clear) this.damageReports = []; + this.loading = "loading"; + http + .get(`/admin/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.damageReports + .filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1) + .map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: DamageReportViewModel & { tab_pos: number }) => { + this.damageReports.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllDamageReports(): Promise> { + return await http.get(`/admin/damageReport?noLimit=true`).then((res) => { + return { ...res, data: res.data.damageReports }; + }); + }, + async getDamageReportsByIds(ids: Array): Promise> { + return await http + .post(`/admin/damageReport/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.damageReports }; + }); + }, + async searchDamageReports(search: string): Promise> { + return await http.get(`/admin/damageReport?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.damageReports }; + }); + }, + fetchDamageReportById(id: string) { + return http.get(`/admin/damageReport/${id}`); + }, + async createDamageReport(damageReport: CreateDamageReportViewModel): Promise> { + const result = await http.post(`/admin/damageReport`, { + // TODO: data + }); + this.fetchDamageReports(); + return result; + }, + async updateDamageReport(damageReport: UpdateDamageReportViewModel): Promise> { + const result = await http.patch(`/admin/damageReport/${damageReport.id}`, { + // TODO: data + }); + this.fetchDamageReports(); + return result; + }, + async deleteDamageReport(damageReport: number): Promise> { + const result = await http.delete(`/admin/damageReport/${damageReport}`); + this.fetchDamageReports(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/equipment/damageReport.ts b/src/stores/admin/unit/equipment/damageReport.ts new file mode 100644 index 0000000..5b757d3 --- /dev/null +++ b/src/stores/admin/unit/equipment/damageReport.ts @@ -0,0 +1,50 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import { useEquipmentStore } from "./equipment"; +import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models"; +import { damageReportDemoData } from "@/demodata/damageReport"; + +export const useEquipmentDamageReportStore = defineStore("equipmentDamageReport", { + state: () => { + return { + damageReports: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchDamageReportForEquipment(offset = 0, count = 25, search = "", clear = false) { + const equipmentId = useEquipmentStore().activeEquipment; + this.damageReports = damageReportDemoData + .filter((drdd) => drdd.relatedId == equipmentId) + .map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.damageReports.length; + this.loading = "fetched"; + return; + if (clear) this.damageReports = []; + this.loading = "loading"; + http + .get( + `/admin/equipment/${equipmentId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}` + ) + .then((result) => { + this.totalCount = result.data.total; + result.data.reports + .filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1) + .map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: DamageReportViewModel & { tab_pos: number }) => { + this.damageReports.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/equipment/equipment.ts b/src/stores/admin/unit/equipment/equipment.ts new file mode 100644 index 0000000..7550a23 --- /dev/null +++ b/src/stores/admin/unit/equipment/equipment.ts @@ -0,0 +1,108 @@ +import { defineStore } from "pinia"; +import type { + EquipmentViewModel, + CreateEquipmentViewModel, + UpdateEquipmentViewModel, +} from "@/viewmodels/admin/unit/equipment/equipment.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { equipmentDemoData } from "@/demodata/equipment"; + +export const useEquipmentStore = defineStore("equipment", { + state: () => { + return { + equipments: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeEquipment: null as string | null, + activeEquipmentObj: null as EquipmentViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchEquipments(offset = 0, count = 25, search = "", clear = false) { + this.equipments = equipmentDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.equipments.length; + this.loading = "fetched"; + return; + if (clear) this.equipments = []; + this.loading = "loading"; + http + .get(`/admin/equipment?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.equipments + .filter((elem: EquipmentViewModel) => this.equipments.findIndex((m) => m.id == elem.id) == -1) + .map((elem: EquipmentViewModel, index: number): EquipmentViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: EquipmentViewModel & { tab_pos: number }) => { + this.equipments.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllEquipments(): Promise> { + return await http.get(`/admin/equipment?noLimit=true`).then((res) => { + return { ...res, data: res.data.equipments }; + }); + }, + async getEquipmentsByIds(ids: Array): Promise> { + return await http + .post(`/admin/equipment/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.equipments }; + }); + }, + async searchEquipments(search: string): Promise> { + return await http.get(`/admin/equipment?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.equipments }; + }); + }, + fetchEquipmentByActiveId() { + this.activeEquipmentObj = equipmentDemoData.find((e) => e.id == this.activeEquipment) as EquipmentViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/equipment/${this.activeEquipment}`) + .then((res) => { + this.activeEquipmentObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchEquipmentById(id: string) { + return http.get(`/admin/equipment/${id}`); + }, + async createEquipment(equipment: CreateEquipmentViewModel): Promise> { + const result = await http.post(`/admin/equipment`, { + // TODO: data + }); + this.fetchEquipments(); + return result; + }, + async updateActiveEquipment(equipment: UpdateEquipmentViewModel): Promise> { + const result = await http.patch(`/admin/equipment/${equipment.id}`, { + // TODO: data + }); + this.fetchEquipments(); + return result; + }, + async deleteEquipment(equipment: number): Promise> { + const result = await http.delete(`/admin/equipment/${equipment}`); + this.fetchEquipments(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/equipment/inspection.ts b/src/stores/admin/unit/equipment/inspection.ts new file mode 100644 index 0000000..3a3e715 --- /dev/null +++ b/src/stores/admin/unit/equipment/inspection.ts @@ -0,0 +1,50 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models"; +import { inspectionDemoData } from "@/demodata/inspectionPlan"; +import { useEquipmentStore } from "./equipment"; + +export const useEquipmentInspectionStore = defineStore("equipmentInspection", { + state: () => { + return { + inspections: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionForEquipment(offset = 0, count = 25, search = "", clear = false) { + const equipmentId = useEquipmentStore().activeEquipment; + this.inspections = inspectionDemoData + .filter((idd) => idd.relatedId == equipmentId) + .map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.inspections.length; + this.loading = "fetched"; + return; + if (clear) this.inspections = []; + this.loading = "loading"; + http + .get( + `/admin/equipment/${equipmentId}/inspection?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}` + ) + .then((result) => { + this.totalCount = result.data.total; + result.data.inspections + .filter((elem: InspectionViewModel) => this.inspections.findIndex((m) => m.id == elem.id) == -1) + .map((elem: InspectionViewModel, index: number): InspectionViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: InspectionViewModel & { tab_pos: number }) => { + this.inspections.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/equipmentType/equipmentType.ts b/src/stores/admin/unit/equipmentType/equipmentType.ts new file mode 100644 index 0000000..c35b859 --- /dev/null +++ b/src/stores/admin/unit/equipmentType/equipmentType.ts @@ -0,0 +1,101 @@ +import { defineStore } from "pinia"; +import type { + EquipmentTypeViewModel, + CreateEquipmentTypeViewModel, + UpdateEquipmentTypeViewModel, +} from "@/viewmodels/admin/unit/equipmentType/equipmentType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { equipmentTypeDemoData } from "@/demodata/equipmentType"; + +export const useEquipmentTypeStore = defineStore("equipmentType", { + state: () => { + return { + equipmentTypes: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeEquipmentType: null as string | null, + activeEquipmentTypeObj: null as EquipmentTypeViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchEquipmentTypes(offset = 0, count = 25, search = "", clear = false) { + this.equipmentTypes = equipmentTypeDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.equipmentTypes.length; + this.loading = "fetched"; + return; + if (clear) this.equipmentTypes = []; + this.loading = "loading"; + http + .get(`/admin/equipmentType?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.equipments + .filter((elem: EquipmentTypeViewModel) => this.equipmentTypes.findIndex((m) => m.id == elem.id) == -1) + .map((elem: EquipmentTypeViewModel, index: number): EquipmentTypeViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: EquipmentTypeViewModel & { tab_pos: number }) => { + this.equipmentTypes.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllEquipmentTypes(): Promise> { + return await http.get(`/admin/equipmentType?noLimit=true`).then((res) => { + return { ...res, data: res.data.equipments }; + }); + }, + async searchEquipmentTypes(search: string): Promise> { + return await http.get(`/admin/equipmentType?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.equipments }; + }); + }, + fetchEquipmentTypeByActiveId() { + this.activeEquipmentTypeObj = equipmentTypeDemoData.find( + (e) => e.id == this.activeEquipmentType + ) as EquipmentTypeViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/equipmentType/${this.activeEquipmentType}`) + .then((res) => { + this.activeEquipmentTypeObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchEquipmentTypeById(id: string) { + return http.get(`/admin/equipmentType/${id}`); + }, + async createEquipmentType(equipmentType: CreateEquipmentTypeViewModel): Promise> { + const result = await http.post(`/admin/equipmentType`, { + // TODO: data + }); + this.fetchEquipmentTypes(); + return result; + }, + async updateActiveEquipmentType(equipmentType: UpdateEquipmentTypeViewModel): Promise> { + const result = await http.patch(`/admin/equipmentType/${equipmentType.id}`, { + // TODO: data + }); + this.fetchEquipmentTypes(); + return result; + }, + async deleteEquipmentType(equipmentType: number): Promise> { + const result = await http.delete(`/admin/equipmentType/${equipmentType}`); + this.fetchEquipmentTypes(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/equipmentType/inspectionPlan.ts b/src/stores/admin/unit/equipmentType/inspectionPlan.ts new file mode 100644 index 0000000..c412056 --- /dev/null +++ b/src/stores/admin/unit/equipmentType/inspectionPlan.ts @@ -0,0 +1,39 @@ +import { defineStore } from "pinia"; +import type { + EquipmentTypeViewModel, + CreateEquipmentTypeViewModel, + UpdateEquipmentTypeViewModel, +} from "@/viewmodels/admin/unit/equipmentType/equipmentType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { equipmentTypeDemoData } from "@/demodata/equipmentType"; +import type { InspectionPlanViewModel } from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import { inspectionPlanDemoData } from "@/demodata/inspectionPlan"; +import { useEquipmentTypeStore } from "./equipmentType"; + +export const useEquipmentTypeInspectionPlanStore = defineStore("equipmentTypeInspectionPlan", { + state: () => { + return { + inspectionPlans: [] as Array, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionPlanForEquipmentType() { + const equipmentTypeId = useEquipmentTypeStore().activeEquipmentType; + this.inspectionPlans = inspectionPlanDemoData.filter((ipdd) => ipdd.relatedId == equipmentTypeId); + this.loading = "fetched"; + return; + this.loading = "loading"; + http + .get(`/admin/equipmentType/${equipmentTypeId}/inspectionPlan`) + .then((result) => { + this.inspectionPlans = result.data; + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/inspection/inspection.ts b/src/stores/admin/unit/inspection/inspection.ts new file mode 100644 index 0000000..30b7b8b --- /dev/null +++ b/src/stores/admin/unit/inspection/inspection.ts @@ -0,0 +1,55 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { inspectionDemoData } from "@/demodata/inspectionPlan"; +import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models"; + +export const useInspectionStore = defineStore("inspection", { + state: () => { + return { + activeInspection: null as string | null, + activeInspectionObj: null as InspectionViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionByActiveId() { + this.loadingActive = "loading"; + this.activeInspectionObj = inspectionDemoData.find((e) => e.id == this.activeInspection) as InspectionViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/inspection/${this.activeInspection}`) + .then((res) => { + this.activeInspectionObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchInspectionById(id: string) { + return http.get(`/admin/inspection/${id}`); + }, + async createInspection(inspection: any): Promise> { + const result = await http.post(`/admin/inspection`, { + // TODO: data + }); + this.fetchInspectionByActiveId(); + return result; + }, + async updateActiveInspection(inspection: any): Promise> { + const result = await http.patch(`/admin/inspection/${inspection.id}`, { + // TODO: data + }); + this.fetchInspectionByActiveId(); + return result; + }, + async deleteInspection(inspection: number): Promise> { + const result = await http.delete(`/admin/inspection/${inspection}`); + this.fetchInspectionByActiveId(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts b/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts new file mode 100644 index 0000000..02ab39d --- /dev/null +++ b/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts @@ -0,0 +1,110 @@ +import { defineStore } from "pinia"; +import type { + InspectionPlanViewModel, + CreateInspectionPlanViewModel, + UpdateInspectionPlanViewModel, +} from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { inspectionPlanDemoData } from "@/demodata/inspectionPlan"; + +export const useInspectionPlanStore = defineStore("inspectionPlan", { + state: () => { + return { + inspectionPlans: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeInspectionPlan: null as string | null, + activeInspectionPlanObj: null as InspectionPlanViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionPlans(offset = 0, count = 25, search = "", clear = false) { + this.inspectionPlans = inspectionPlanDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.inspectionPlans.length; + this.loading = "fetched"; + return; + if (clear) this.inspectionPlans = []; + this.loading = "loading"; + http + .get(`/admin/inspectionPlan?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.inspectionPlans + .filter((elem: InspectionPlanViewModel) => this.inspectionPlans.findIndex((m) => m.id == elem.id) == -1) + .map((elem: InspectionPlanViewModel, index: number): InspectionPlanViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: InspectionPlanViewModel & { tab_pos: number }) => { + this.inspectionPlans.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllInspectionPlans(): Promise> { + return await http.get(`/admin/inspectionPlan?noLimit=true`).then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + async getInspectionPlansByIds(ids: Array): Promise> { + return await http + .post(`/admin/inspectionPlan/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + async searchInspectionPlans(search: string): Promise> { + return await http.get(`/admin/inspectionPlan?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + fetchInspectionPlanByActiveId() { + this.activeInspectionPlanObj = inspectionPlanDemoData.find( + (e) => e.id == this.activeInspectionPlan + ) as InspectionPlanViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/inspectionPlan/${this.activeInspectionPlan}`) + .then((res) => { + this.activeInspectionPlanObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchInspectionPlanById(id: string) { + return http.get(`/admin/inspectionPlan/${id}`); + }, + async createInspectionPlan(inspectionPlan: CreateInspectionPlanViewModel): Promise> { + const result = await http.post(`/admin/inspectionPlan`, { + // TODO: data + }); + this.fetchInspectionPlans(); + return result; + }, + async updateActiveInspectionPlan(inspectionPlan: UpdateInspectionPlanViewModel): Promise> { + const result = await http.patch(`/admin/inspectionPlan/${inspectionPlan.id}`, { + // TODO: data + }); + this.fetchInspectionPlans(); + return result; + }, + async deleteInspectionPlan(inspectionPlan: number): Promise> { + const result = await http.delete(`/admin/inspectionPlan/${inspectionPlan}`); + this.fetchInspectionPlans(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/respiratoryGear/respiratoryGear.ts b/src/stores/admin/unit/respiratoryGear/respiratoryGear.ts new file mode 100644 index 0000000..2b2e548 --- /dev/null +++ b/src/stores/admin/unit/respiratoryGear/respiratoryGear.ts @@ -0,0 +1,103 @@ +import { defineStore } from "pinia"; +import type { + RespiratoryGearViewModel, + CreateRespiratoryGearViewModel, + UpdateRespiratoryGearViewModel, +} from "@/viewmodels/admin/unit/respiratoryGear/respiratoryGear.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { respiratoryGearDemoData } from "@/demodata/respiratoryGear"; + +export const useRespiratoryGearStore = defineStore("respiratoryGear", { + state: () => { + return { + respiratoryGears: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeRespiratoryGear: null as string | null, + activeRespiratoryGearObj: null as RespiratoryGearViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchRespiratoryGears(offset = 0, count = 25, search = "", clear = false) { + this.respiratoryGears = respiratoryGearDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.respiratoryGears.length; + this.loading = "fetched"; + return; + if (clear) this.respiratoryGears = []; + this.loading = "loading"; + http + .get(`/admin/respiratoryGear?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.respiratoryGears + .filter((elem: RespiratoryGearViewModel) => this.respiratoryGears.findIndex((m) => m.id == elem.id) == -1) + .map((elem: RespiratoryGearViewModel, index: number): RespiratoryGearViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: RespiratoryGearViewModel & { tab_pos: number }) => { + this.respiratoryGears.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllRespiratoryGears(): Promise> { + return await http.get(`/admin/respiratoryGear?noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryGears }; + }); + }, + async searchRespiratoryGears(search: string): Promise> { + return await http.get(`/admin/respiratoryGear?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryGears }; + }); + }, + fetchRespiratoryGearByActiveId() { + this.activeRespiratoryGearObj = respiratoryGearDemoData.find( + (e) => e.id == this.activeRespiratoryGear + ) as RespiratoryGearViewModel; + this.loading = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/respiratoryGear/${this.activeRespiratoryGear}`) + .then((res) => { + this.activeRespiratoryGearObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchRespiratoryGearById(id: string) { + return http.get(`/admin/respiratoryGear/${id}`); + }, + async createRespiratoryGear(respiratoryGear: CreateRespiratoryGearViewModel): Promise> { + const result = await http.post(`/admin/respiratoryGear`, { + // TODO: data + }); + this.fetchRespiratoryGears(); + return result; + }, + async updateActiveRespiratoryGear( + respiratoryGear: UpdateRespiratoryGearViewModel + ): Promise> { + const result = await http.patch(`/admin/respiratoryGear/${respiratoryGear.id}`, { + // TODO: data + }); + this.fetchRespiratoryGears(); + return result; + }, + async deleteRespiratoryGear(respiratoryGear: number): Promise> { + const result = await http.delete(`/admin/respiratoryGear/${respiratoryGear}`); + this.fetchRespiratoryGears(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/respiratoryMission/respiratoryMission.ts b/src/stores/admin/unit/respiratoryMission/respiratoryMission.ts new file mode 100644 index 0000000..cc890ed --- /dev/null +++ b/src/stores/admin/unit/respiratoryMission/respiratoryMission.ts @@ -0,0 +1,109 @@ +import { defineStore } from "pinia"; +import type { + RespiratoryMissionViewModel, + CreateRespiratoryMissionViewModel, + UpdateRespiratoryMissionViewModel, +} from "@/viewmodels/admin/unit/respiratoryMission/respiratoryMission.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { respiratoryMissionDemoData } from "@/demodata/respiratoryMission"; + +export const useRespiratoryMissionStore = defineStore("respiratoryMission", { + state: () => { + return { + respiratoryMissions: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeRespiratoryMission: null as string | null, + activeRespiratoryMissionObj: null as RespiratoryMissionViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchRespiratoryMissions(offset = 0, count = 25, search = "", clear = false) { + this.respiratoryMissions = respiratoryMissionDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.respiratoryMissions.length; + this.loading = "fetched"; + return; + if (clear) this.respiratoryMissions = []; + this.loading = "loading"; + http + .get(`/admin/respiratoryMission?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.respiratoryMissions + .filter( + (elem: RespiratoryMissionViewModel) => this.respiratoryMissions.findIndex((m) => m.id == elem.id) == -1 + ) + .map( + (elem: RespiratoryMissionViewModel, index: number): RespiratoryMissionViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + } + ) + .forEach((elem: RespiratoryMissionViewModel & { tab_pos: number }) => { + this.respiratoryMissions.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllRespiratoryMissions(): Promise> { + return await http.get(`/admin/respiratoryMission?noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryMissions }; + }); + }, + async searchRespiratoryMissions(search: string): Promise> { + return await http.get(`/admin/respiratoryMission?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryMissions }; + }); + }, + fetchRespiratoryMissionByActiveId() { + this.activeRespiratoryMissionObj = this.respiratoryMissions.find( + (e) => e.id == this.activeRespiratoryMission + ) as RespiratoryMissionViewModel; + this.loading = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/respiratoryMission/${this.activeRespiratoryMission}`) + .then((res) => { + this.activeRespiratoryMissionObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchRespiratoryMissionById(id: string) { + return http.get(`/admin/respiratoryMission/${id}`); + }, + async createRespiratoryMission( + respiratoryMission: CreateRespiratoryMissionViewModel + ): Promise> { + const result = await http.post(`/admin/respiratoryMission`, { + // TODO: data + }); + this.fetchRespiratoryMissions(); + return result; + }, + async updateActiveRespiratoryMission( + respiratoryMission: UpdateRespiratoryMissionViewModel + ): Promise> { + const result = await http.patch(`/admin/respiratoryMission/${respiratoryMission.id}`, { + // TODO: data + }); + this.fetchRespiratoryMissions(); + return result; + }, + async deleteRespiratoryMission(respiratoryMission: number): Promise> { + const result = await http.delete(`/admin/respiratoryMission/${respiratoryMission}`); + this.fetchRespiratoryMissions(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/respiratoryWearer/respiratoryWearer.ts b/src/stores/admin/unit/respiratoryWearer/respiratoryWearer.ts new file mode 100644 index 0000000..6f17e98 --- /dev/null +++ b/src/stores/admin/unit/respiratoryWearer/respiratoryWearer.ts @@ -0,0 +1,109 @@ +import { defineStore } from "pinia"; +import type { + RespiratoryWearerViewModel, + CreateRespiratoryWearerViewModel, + UpdateRespiratoryWearerViewModel, +} from "@/viewmodels/admin/unit/respiratoryWearer/respiratoryWearer.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { respiratoryWearerDemoData } from "@/demodata/respiratoryWearer"; + +export const useRespiratoryWearerStore = defineStore("respiratoryWearer", { + state: () => { + return { + respiratoryWearers: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeRespiratoryWearer: null as string | null, + activeRespiratoryWearerObj: null as RespiratoryWearerViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchRespiratoryWearers(offset = 0, count = 25, search = "", clear = false) { + this.respiratoryWearers = respiratoryWearerDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.respiratoryWearers.length; + this.loading = "fetched"; + return; + if (clear) this.respiratoryWearers = []; + this.loading = "loading"; + http + .get(`/admin/respiratoryWearer?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.respiratoryWearers + .filter( + (elem: RespiratoryWearerViewModel) => this.respiratoryWearers.findIndex((m) => m.id == elem.id) == -1 + ) + .map( + (elem: RespiratoryWearerViewModel, index: number): RespiratoryWearerViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + } + ) + .forEach((elem: RespiratoryWearerViewModel & { tab_pos: number }) => { + this.respiratoryWearers.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllRespiratoryWearers(): Promise> { + return await http.get(`/admin/respiratoryWearer?noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryWearers }; + }); + }, + async searchRespiratoryWearers(search: string): Promise> { + return await http.get(`/admin/respiratoryWearer?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.respiratoryWearers }; + }); + }, + fetchRespiratoryWearerByActiveId() { + this.activeRespiratoryWearerObj = respiratoryWearerDemoData.find( + (e) => e.id == this.activeRespiratoryWearer + ) as RespiratoryWearerViewModel; + this.loading = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/respiratoryWearer/${this.activeRespiratoryWearer}`) + .then((res) => { + this.activeRespiratoryWearerObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchRespiratoryWearerById(id: string) { + return http.get(`/admin/respiratoryWearer/${id}`); + }, + async createRespiratoryWearer( + respiratoryWearer: CreateRespiratoryWearerViewModel + ): Promise> { + const result = await http.post(`/admin/respiratoryWearer`, { + // TODO: data + }); + this.fetchRespiratoryWearers(); + return result; + }, + async updateActiveRespiratoryWearer( + respiratoryWearer: UpdateRespiratoryWearerViewModel + ): Promise> { + const result = await http.patch(`/admin/respiratoryWearer/${respiratoryWearer.id}`, { + // TODO: data + }); + this.fetchRespiratoryWearers(); + return result; + }, + async deleteRespiratoryWearer(respiratoryWearer: number): Promise> { + const result = await http.delete(`/admin/respiratoryWearer/${respiratoryWearer}`); + this.fetchRespiratoryWearers(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/vehicle/damageReport.ts b/src/stores/admin/unit/vehicle/damageReport.ts new file mode 100644 index 0000000..7774732 --- /dev/null +++ b/src/stores/admin/unit/vehicle/damageReport.ts @@ -0,0 +1,50 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import { useVehicleStore } from "./vehicle"; +import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models"; +import { damageReportDemoData } from "@/demodata/damageReport"; + +export const useVehicleDamageReportStore = defineStore("vehicleDamageReport", { + state: () => { + return { + damageReports: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchDamageReportForVehicle(offset = 0, count = 25, search = "", clear = false) { + const vehicleId = useVehicleStore().activeVehicle; + this.damageReports = damageReportDemoData + .filter((drdd) => drdd.relatedId == vehicleId) + .map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.damageReports.length; + this.loading = "fetched"; + return; + if (clear) this.damageReports = []; + this.loading = "loading"; + http + .get( + `/admin/vehicle/${vehicleId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}` + ) + .then((result) => { + this.totalCount = result.data.total; + result.data.reports + .filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1) + .map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: DamageReportViewModel & { tab_pos: number }) => { + this.damageReports.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/vehicle/inspection.ts b/src/stores/admin/unit/vehicle/inspection.ts new file mode 100644 index 0000000..00314f2 --- /dev/null +++ b/src/stores/admin/unit/vehicle/inspection.ts @@ -0,0 +1,50 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import type { InspectionViewModel } from "@/viewmodels/admin/unit/inspection/inspection.models"; +import { inspectionDemoData } from "@/demodata/inspectionPlan"; +import { useVehicleStore } from "./vehicle"; + +export const useVehicleInspectionStore = defineStore("vehicleInspection", { + state: () => { + return { + inspections: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionForVehicle(offset = 0, count = 25, search = "", clear = false) { + const vehicleId = useVehicleStore().activeVehicle; + this.inspections = inspectionDemoData + .filter((idd) => idd.relatedId == vehicleId) + .map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.inspections.length; + this.loading = "fetched"; + return; + if (clear) this.inspections = []; + this.loading = "loading"; + http + .get( + `/admin/vehicle/${vehicleId}/inspection?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}` + ) + .then((result) => { + this.totalCount = result.data.total; + result.data.inspections + .filter((elem: InspectionViewModel) => this.inspections.findIndex((m) => m.id == elem.id) == -1) + .map((elem: InspectionViewModel, index: number): InspectionViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: InspectionViewModel & { tab_pos: number }) => { + this.inspections.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/vehicle/vehicle.ts b/src/stores/admin/unit/vehicle/vehicle.ts new file mode 100644 index 0000000..75e54f6 --- /dev/null +++ b/src/stores/admin/unit/vehicle/vehicle.ts @@ -0,0 +1,108 @@ +import { defineStore } from "pinia"; +import type { + VehicleViewModel, + CreateVehicleViewModel, + UpdateVehicleViewModel, +} from "@/viewmodels/admin/unit/vehicle/vehicle.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { vehicleDemoData } from "@/demodata/vehicle"; + +export const useVehicleStore = defineStore("vehicle", { + state: () => { + return { + vehicles: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeVehicle: null as string | null, + activeVehicleObj: null as VehicleViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchVehicles(offset = 0, count = 25, search = "", clear = false) { + this.vehicles = vehicleDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.vehicles.length; + this.loading = "fetched"; + return; + if (clear) this.vehicles = []; + this.loading = "loading"; + http + .get(`/admin/vehicle?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.vehicles + .filter((elem: VehicleViewModel) => this.vehicles.findIndex((m) => m.id == elem.id) == -1) + .map((elem: VehicleViewModel, index: number): VehicleViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: VehicleViewModel & { tab_pos: number }) => { + this.vehicles.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllVehicles(): Promise> { + return await http.get(`/admin/vehicle?noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + async getVehiclesByIds(ids: Array): Promise> { + return await http + .post(`/admin/vehicle/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + async searchVehicles(search: string): Promise> { + return await http.get(`/admin/vehicle?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + fetchVehicleByActiveId() { + this.activeVehicleObj = vehicleDemoData.find((e) => e.id == this.activeVehicle) as VehicleViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/vehicle/${this.activeVehicle}`) + .then((res) => { + this.activeVehicleObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchVehicleById(id: string) { + return http.get(`/admin/vehicle/${id}`); + }, + async createVehicle(vehicle: CreateVehicleViewModel): Promise> { + const result = await http.post(`/admin/vehicle`, { + // TODO: data + }); + this.fetchVehicles(); + return result; + }, + async updateActiveVehicle(vehicle: UpdateVehicleViewModel): Promise> { + const result = await http.patch(`/admin/vehicle/${vehicle.id}`, { + // TODO: data + }); + this.fetchVehicles(); + return result; + }, + async deleteVehicle(vehicle: number): Promise> { + const result = await http.delete(`/admin/vehicle/${vehicle}`); + this.fetchVehicles(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/vehicleType/inspectionPlan.ts b/src/stores/admin/unit/vehicleType/inspectionPlan.ts new file mode 100644 index 0000000..9b6aa27 --- /dev/null +++ b/src/stores/admin/unit/vehicleType/inspectionPlan.ts @@ -0,0 +1,40 @@ +import { defineStore } from "pinia"; +import type { + VehicleTypeViewModel, + CreateVehicleTypeViewModel, + UpdateVehicleTypeViewModel, +} from "@/viewmodels/admin/unit/vehicleType/vehicleType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { vehicleTypeDemoData } from "@/demodata/vehicleType"; +import type { InspectionPlanViewModel } from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import { inspectionPlanDemoData } from "@/demodata/inspectionPlan"; +import { useVehicleTypeStore } from "./vehicleType"; + +export const useVehicleTypeInspectionPlanStore = defineStore("vehicleTypeInspectionPlan", { + state: () => { + return { + inspectionPlans: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionPlanForVehicleType() { + const vehicleTypeId = useVehicleTypeStore().activeVehicleType; + this.inspectionPlans = inspectionPlanDemoData.filter((ipdd) => ipdd.relatedId == vehicleTypeId); + this.loading = "fetched"; + return; + this.loading = "loading"; + http + .get(`/admin/vehicleType/${vehicleTypeId}/inspectionPlan`) + .then((result) => { + this.inspectionPlans = result.data; + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/vehicleType/vehicleType.ts b/src/stores/admin/unit/vehicleType/vehicleType.ts new file mode 100644 index 0000000..257716f --- /dev/null +++ b/src/stores/admin/unit/vehicleType/vehicleType.ts @@ -0,0 +1,101 @@ +import { defineStore } from "pinia"; +import type { + VehicleTypeViewModel, + CreateVehicleTypeViewModel, + UpdateVehicleTypeViewModel, +} from "@/viewmodels/admin/unit/vehicleType/vehicleType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { vehicleTypeDemoData } from "@/demodata/vehicleType"; + +export const useVehicleTypeStore = defineStore("vehicleType", { + state: () => { + return { + vehicleTypes: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeVehicleType: null as string | null, + activeVehicleTypeObj: null as VehicleTypeViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchVehicleTypes(offset = 0, count = 25, search = "", clear = false) { + this.vehicleTypes = vehicleTypeDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.vehicleTypes.length; + this.loading = "fetched"; + return; + if (clear) this.vehicleTypes = []; + this.loading = "loading"; + http + .get(`/admin/vehicleType?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.vehicles + .filter((elem: VehicleTypeViewModel) => this.vehicleTypes.findIndex((m) => m.id == elem.id) == -1) + .map((elem: VehicleTypeViewModel, index: number): VehicleTypeViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: VehicleTypeViewModel & { tab_pos: number }) => { + this.vehicleTypes.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllVehicleTypes(): Promise> { + return await http.get(`/admin/vehicleType?noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + async searchVehicleTypes(search: string): Promise> { + return await http.get(`/admin/vehicleType?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + fetchVehicleTypeByActiveId() { + this.activeVehicleTypeObj = vehicleTypeDemoData.find( + (e) => e.id == this.activeVehicleType + ) as VehicleTypeViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/vehicleType/${this.activeVehicleType}`) + .then((res) => { + this.activeVehicleTypeObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchVehicleTypeById(id: string) { + return http.get(`/admin/vehicleType/${id}`); + }, + async createVehicleType(vehicleType: CreateVehicleTypeViewModel): Promise> { + const result = await http.post(`/admin/vehicleType`, { + // TODO: data + }); + this.fetchVehicleTypes(); + return result; + }, + async updateActiveVehicleType(vehicleType: UpdateVehicleTypeViewModel): Promise> { + const result = await http.patch(`/admin/vehicleType/${vehicleType.id}`, { + // TODO: data + }); + this.fetchVehicleTypes(); + return result; + }, + async deleteVehicleType(vehicleType: number): Promise> { + const result = await http.delete(`/admin/vehicleType/${vehicleType}`); + this.fetchVehicleTypes(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/wearable/damageReport.ts b/src/stores/admin/unit/wearable/damageReport.ts new file mode 100644 index 0000000..c4d067c --- /dev/null +++ b/src/stores/admin/unit/wearable/damageReport.ts @@ -0,0 +1,50 @@ +import { defineStore } from "pinia"; +import { http } from "@/serverCom"; +import { useWearableStore } from "./wearable"; +import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models"; +import { damageReportDemoData } from "@/demodata/damageReport"; + +export const useWearableDamageReportStore = defineStore("wearableDamageReport", { + state: () => { + return { + damageReports: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchDamageReportForWearable(offset = 0, count = 25, search = "", clear = false) { + const wearableId = useWearableStore().activeWearable; + this.damageReports = damageReportDemoData + .filter((drdd) => drdd.relatedId == wearableId) + .map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.damageReports.length; + this.loading = "fetched"; + return; + if (clear) this.damageReports = []; + this.loading = "loading"; + http + .get( + `/admin/wearable/${wearableId}/damageReport?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}` + ) + .then((result) => { + this.totalCount = result.data.total; + result.data.reports + .filter((elem: DamageReportViewModel) => this.damageReports.findIndex((m) => m.id == elem.id) == -1) + .map((elem: DamageReportViewModel, index: number): DamageReportViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: DamageReportViewModel & { tab_pos: number }) => { + this.damageReports.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + }, +}); diff --git a/src/stores/admin/unit/wearable/wearable.ts b/src/stores/admin/unit/wearable/wearable.ts new file mode 100644 index 0000000..2b22f21 --- /dev/null +++ b/src/stores/admin/unit/wearable/wearable.ts @@ -0,0 +1,108 @@ +import { defineStore } from "pinia"; +import type { + WearableViewModel, + CreateWearableViewModel, + UpdateWearableViewModel, +} from "@/viewmodels/admin/unit/wearable/wearable.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { wearableDemoData } from "@/demodata/wearable"; + +export const useWearableStore = defineStore("wearable", { + state: () => { + return { + wearables: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeWearable: null as string | null, + activeWearableObj: null as WearableViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchWearables(offset = 0, count = 25, search = "", clear = false) { + this.wearables = wearableDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.wearables.length; + this.loading = "fetched"; + return; + if (clear) this.wearables = []; + this.loading = "loading"; + http + .get(`/admin/wearable?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.wearables + .filter((elem: WearableViewModel) => this.wearables.findIndex((m) => m.id == elem.id) == -1) + .map((elem: WearableViewModel, index: number): WearableViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: WearableViewModel & { tab_pos: number }) => { + this.wearables.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllWearables(): Promise> { + return await http.get(`/admin/wearable?noLimit=true`).then((res) => { + return { ...res, data: res.data.wearables }; + }); + }, + async getWearablesByIds(ids: Array): Promise> { + return await http + .post(`/admin/wearable/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.wearables }; + }); + }, + async searchWearables(search: string): Promise> { + return await http.get(`/admin/wearable?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.wearables }; + }); + }, + fetchWearableByActiveId() { + this.activeWearableObj = wearableDemoData.find((e) => e.id == this.activeWearable) as WearableViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/wearable/${this.activeWearable}`) + .then((res) => { + this.activeWearableObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchWearableById(id: string) { + return http.get(`/admin/wearable/${id}`); + }, + async createWearable(wearable: CreateWearableViewModel): Promise> { + const result = await http.post(`/admin/wearable`, { + // TODO: data + }); + this.fetchWearables(); + return result; + }, + async updateActiveWearable(wearable: UpdateWearableViewModel): Promise> { + const result = await http.patch(`/admin/wearable/${wearable.id}`, { + // TODO: data + }); + this.fetchWearables(); + return result; + }, + async deleteWearable(wearable: number): Promise> { + const result = await http.delete(`/admin/wearable/${wearable}`); + this.fetchWearables(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/wearableType/wearableType.ts b/src/stores/admin/unit/wearableType/wearableType.ts new file mode 100644 index 0000000..884f532 --- /dev/null +++ b/src/stores/admin/unit/wearableType/wearableType.ts @@ -0,0 +1,81 @@ +import { defineStore } from "pinia"; +import type { + WearableTypeViewModel, + CreateWearableTypeViewModel, + UpdateWearableTypeViewModel, +} from "@/viewmodels/admin/unit/wearableType/wearableType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { wearableTypeDemoData } from "@/demodata/wearableType"; + +export const useWearableTypeStore = defineStore("wearableType", { + state: () => { + return { + wearableTypes: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchWearableTypes(offset = 0, count = 25, search = "", clear = false) { + this.wearableTypes = wearableTypeDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.wearableTypes.length; + this.loading = "fetched"; + return; + if (clear) this.wearableTypes = []; + this.loading = "loading"; + http + .get(`/admin/wearableType?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.wearables + .filter((elem: WearableTypeViewModel) => this.wearableTypes.findIndex((m) => m.id == elem.id) == -1) + .map((elem: WearableTypeViewModel, index: number): WearableTypeViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: WearableTypeViewModel & { tab_pos: number }) => { + this.wearableTypes.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllWearableTypes(): Promise> { + return await http.get(`/admin/wearableType?noLimit=true`).then((res) => { + return { ...res, data: res.data.wearables }; + }); + }, + async searchWearableTypes(search: string): Promise> { + return await http.get(`/admin/wearableType?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.wearables }; + }); + }, + fetchWearableTypeById(id: string) { + return http.get(`/admin/wearableType/${id}`); + }, + async createWearableType(wearableType: CreateWearableTypeViewModel): Promise> { + const result = await http.post(`/admin/wearableType`, { + // TODO: data + }); + this.fetchWearableTypes(); + return result; + }, + async updateWearableType(wearableType: UpdateWearableTypeViewModel): Promise> { + const result = await http.patch(`/admin/wearableType/${wearableType.id}`, { + // TODO: data + }); + this.fetchWearableTypes(); + return result; + }, + async deleteWearableType(wearableType: number): Promise> { + const result = await http.delete(`/admin/wearableType/${wearableType}`); + this.fetchWearableTypes(); + return result; + }, + }, +}); diff --git a/src/stores/modal.ts b/src/stores/modal.ts index cdc4c49..a537848 100644 --- a/src/stores/modal.ts +++ b/src/stores/modal.ts @@ -4,19 +4,22 @@ export const useModalStore = defineStore("modal", { state: () => { return { show: false, - component_ref: null as any, - data: null as any, + component_ref: undefined as any, + data: undefined as any, + callback: undefined as undefined | Function, }; }, actions: { - openModal(component_ref: any, data?: any) { + openModal(component_ref: any, data?: any, callback?: Function) { this.component_ref = component_ref; this.data = data; + this.callback = callback; this.show = true; }, closeModal() { - this.component_ref = null; - this.data = null; + this.component_ref = undefined; + this.data = undefined; + this.callback = undefined; this.show = false; }, }, diff --git a/src/types/permissionTypes.ts b/src/types/permissionTypes.ts index 16a79ec..d6ec391 100644 --- a/src/types/permissionTypes.ts +++ b/src/types/permissionTypes.ts @@ -1,27 +1,43 @@ export type PermissionSection = "club" | "unit" | "configuration" | "management"; export type PermissionModule = + // club | "member" | "calendar" | "newsletter" - | "newsletter_config" | "protocol" + | "query" | "listprint" + // unit + | "equipment" + | "equipment_type" + | "vehicle" + | "vehicle_type" + | "wearable" + | "wearable_type" + | "inspection" + | "inspection_plan" + | "respiratory_gear" + | "respiratory_wearer" + | "respiratory_mission" + | "damage_report" + // configuration | "qualification" | "award" | "executive_position" | "communication_type" | "membership_status" + | "newsletter_config" | "salutation" | "calendar_type" - | "user" - | "role" - | "webapi" - | "query" | "query_store" | "template" | "template_usage" | "backup" + // management + | "user" + | "role" + | "webapi" | "setting"; export type PermissionType = "read" | "create" | "update" | "delete"; @@ -58,33 +74,62 @@ export type SectionsAndModulesObject = { export const permissionSections: Array = ["club", "unit", "configuration", "management"]; export const permissionModules: Array = [ + // club "member", "calendar", "newsletter", - "newsletter_config", "protocol", + "query", "listprint", + // unit + "equipment", + "equipment_type", + "vehicle", + "vehicle_type", + "wearable", + "wearable_type", + "inspection", + "inspection_plan", + "respiratory_gear", + "respiratory_wearer", + "respiratory_mission", + "damage_report", + // configuration "qualification", "award", "executive_position", "communication_type", "membership_status", + "newsletter_config", "salutation", "calendar_type", - "user", - "role", - "webapi", - "query", "query_store", "template", "template_usage", "backup", + // management + "user", + "role", + "webapi", "setting", ]; export const permissionTypes: Array = ["read", "create", "update", "delete"]; export const sectionsAndModules: SectionsAndModulesObject = { club: ["member", "calendar", "newsletter", "protocol", "query", "listprint"], - unit: [], + unit: [ + "equipment", + "equipment_type", + "vehicle", + "vehicle_type", + "wearable", + "wearable_type", + "inspection", + "inspection_plan", + "respiratory_gear", + "respiratory_wearer", + "respiratory_mission", + "damage_report", + ], configuration: [ "qualification", "award", diff --git a/src/viewmodels/admin/unit/damageReport/damageReport.models.ts b/src/viewmodels/admin/unit/damageReport/damageReport.models.ts new file mode 100644 index 0000000..e1d7075 --- /dev/null +++ b/src/viewmodels/admin/unit/damageReport/damageReport.models.ts @@ -0,0 +1,38 @@ +import type { EquipmentViewModel } from "../equipment/equipment.models"; +import type { VehicleViewModel } from "../vehicle/vehicle.models"; +import type { WearableViewModel } from "../wearable/wearable.models"; + +export type DamageReportViewModel = { + id: string; + reported: Date; + status: string; + done: boolean; + description: string; + providedImage: Array; + relatedId: string; +} & ( + | { + assigned: "equipment"; + related: EquipmentViewModel; + } + | { + assigned: "vehicle"; + related: VehicleViewModel; + } + | { + assigned: "wearable"; + related: WearableViewModel; + } +); + +export interface CreateDamageReportViewModel { + description: string; + affectedId: string; + affected: "equipment" | "vehicle" | "wearable"; +} + +export interface UpdateDamageReportViewModel { + id: string; + status: string; + done: boolean; +} diff --git a/src/viewmodels/admin/unit/equipment/equipment.models.ts b/src/viewmodels/admin/unit/equipment/equipment.models.ts new file mode 100644 index 0000000..dcd4cea --- /dev/null +++ b/src/viewmodels/admin/unit/equipment/equipment.models.ts @@ -0,0 +1,31 @@ +import type { EquipmentTypeViewModel } from "../equipmentType/equipmentType.models"; +import type { InspectionViewModel } from "../inspection/inspection.models"; + +export interface EquipmentViewModel { + id: string; + code?: string; + name: string; + location: string; + commissioned: Date; + decommissioned?: Date; + equipmentTypeId: string; + equipmentType: EquipmentTypeViewModel; + inspections: Array; +} + +export interface CreateEquipmentViewModel { + code?: string; + name: string; + location: string; + commissioned: Date; + equipmentTypeId: string; +} + +export interface UpdateEquipmentViewModel { + id: string; + code?: string; + name: string; + location: string; + commissioned: Date; + decommissioned?: Date; +} diff --git a/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts b/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts new file mode 100644 index 0000000..e3116c9 --- /dev/null +++ b/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts @@ -0,0 +1,19 @@ +import type { InspectionPlanViewModel } from "../inspectionPlan/inspectionPlan.models"; + +export interface EquipmentTypeViewModel { + id: string; + type: string; + description: string; + inspectionPlans: Array; +} + +export interface CreateEquipmentTypeViewModel { + type: string; + description: string; +} + +export interface UpdateEquipmentTypeViewModel { + id: string; + type: string; + description: string; +} diff --git a/src/viewmodels/admin/unit/inspection/inspection.models.ts b/src/viewmodels/admin/unit/inspection/inspection.models.ts new file mode 100644 index 0000000..8cd2e5f --- /dev/null +++ b/src/viewmodels/admin/unit/inspection/inspection.models.ts @@ -0,0 +1,37 @@ +import type { EquipmentViewModel } from "../equipment/equipment.models"; +import type { + InspectionPlanViewModel, + InspectionVersionedPlanViewModel, +} from "../inspectionPlan/inspectionPlan.models"; +import type { VehicleViewModel } from "../vehicle/vehicle.models"; + +export type InspectionViewModel = { + id: string; + inspectionPlanId: string; + inspectionPlan: InspectionPlanViewModel; + inspectionVersionedPlanId: string; + inspectionVersionedPlan: InspectionVersionedPlanViewModel; + context: string; + created: Date; + finished?: Date; + isOpen: boolean; + nextInspection?: Date; + checks: Array; + relatedId: string; +} & ( + | { + assigned: "equipment"; + related: EquipmentViewModel; + } + | { + assigned: "vehicle"; + related: VehicleViewModel; + } +); + +export interface InspectionPointResultViewModel { + inspectionId: string; + inspectionVersionedPlanId: string; + inspectionPointId: string; + value: string; +} diff --git a/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts b/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts new file mode 100644 index 0000000..5f2df34 --- /dev/null +++ b/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts @@ -0,0 +1,54 @@ +import type { EquipmentTypeViewModel } from "../equipmentType/equipmentType.models"; +import type { VehicleTypeViewModel } from "../vehicleType/vehicleType.models"; + +export type PlanTimeDefinition = `${number}-${"d" | "m" | "y"}` | `${number}/${number | "*"}`; + +export type InspectionPlanViewModel = { + id: string; + title: string; + inspectionInterval: PlanTimeDefinition; + remindTime: PlanTimeDefinition; + version: number; + created: Date; + inspectionPoints: InspectionPointViewModel[]; + relatedId: string; +} & ( + | { + assigned: "equipment"; + related: EquipmentTypeViewModel; + } + | { + assigned: "vehicle"; + related: VehicleTypeViewModel; + } +); + +export interface InspectionVersionedPlanViewModel { + id: string; + version: number; + created: Date; + inspectionPoints: InspectionPointViewModel[]; +} + +export interface InspectionPointViewModel { + id: string; + title: string; + description: string; + type: "iO-niO" | "text" | "number"; + min?: number; +} + +export interface CreateInspectionPlanViewModel { + title: string; + inspectionInterval: PlanTimeDefinition; + remindTime: PlanTimeDefinition; + relatedId: string; + assigned: "vehicle" | "equipment"; +} + +export interface UpdateInspectionPlanViewModel { + id: string; + title: string; + inspectionInterval: PlanTimeDefinition; + remindTime?: PlanTimeDefinition; +} diff --git a/src/viewmodels/admin/unit/respiratoryGear/respiratoryGear.models.ts b/src/viewmodels/admin/unit/respiratoryGear/respiratoryGear.models.ts new file mode 100644 index 0000000..07f4ec8 --- /dev/null +++ b/src/viewmodels/admin/unit/respiratoryGear/respiratoryGear.models.ts @@ -0,0 +1,16 @@ +import type { EquipmentViewModel } from "../equipment/equipment.models"; + +export interface RespiratoryGearViewModel { + id: string; + equipmentId: string; + equipment: EquipmentViewModel; +} + +export interface CreateRespiratoryGearViewModel { + equipmentId: string; +} + +export interface UpdateRespiratoryGearViewModel { + id: string; + equipmentId: string; +} diff --git a/src/viewmodels/admin/unit/respiratoryMission/respiratoryMission.models.ts b/src/viewmodels/admin/unit/respiratoryMission/respiratoryMission.models.ts new file mode 100644 index 0000000..49c6e7f --- /dev/null +++ b/src/viewmodels/admin/unit/respiratoryMission/respiratoryMission.models.ts @@ -0,0 +1,20 @@ +export interface RespiratoryMissionViewModel { + id: string; + date: Date; + title: string; + description: string; + // refs to used respiratory gear and wearers +} + +export interface CreateRespiratoryMissionViewModel { + date: Date; + title: string; + description: string; +} + +export interface UpdateRespiratoryMissionViewModel { + id: string; + date: Date; + title: string; + description: string; +} diff --git a/src/viewmodels/admin/unit/respiratoryWearer/respiratoryWearer.models.ts b/src/viewmodels/admin/unit/respiratoryWearer/respiratoryWearer.models.ts new file mode 100644 index 0000000..eca9194 --- /dev/null +++ b/src/viewmodels/admin/unit/respiratoryWearer/respiratoryWearer.models.ts @@ -0,0 +1,16 @@ +import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models"; + +export interface RespiratoryWearerViewModel { + id: string; + memberId: string; + member: MemberViewModel; +} + +export interface CreateRespiratoryWearerViewModel { + memberId: string; +} + +export interface UpdateRespiratoryWearerViewModel { + id: string; + memberId: string; +} diff --git a/src/viewmodels/admin/unit/vehicle/vehicle.models.ts b/src/viewmodels/admin/unit/vehicle/vehicle.models.ts new file mode 100644 index 0000000..0bfccb6 --- /dev/null +++ b/src/viewmodels/admin/unit/vehicle/vehicle.models.ts @@ -0,0 +1,31 @@ +import type { InspectionViewModel } from "../inspection/inspection.models"; +import type { VehicleTypeViewModel } from "../vehicleType/vehicleType.models"; + +export interface VehicleViewModel { + id: string; + code?: string; + name: string; + location: string; + commissioned: Date; + decommissioned?: Date; + vehicleTypeId: string; + vehicleType: VehicleTypeViewModel; + inspections: Array; +} + +export interface CreateVehicleViewModel { + code?: string; + name: string; + location: string; + commissioned: Date; + vehicleTypeId: string; +} + +export interface UpdateVehicleViewModel { + id: string; + code?: string; + name: string; + location: string; + commissioned: Date; + decommissioned?: Date; +} diff --git a/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts b/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts new file mode 100644 index 0000000..2de497f --- /dev/null +++ b/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts @@ -0,0 +1,19 @@ +import type { InspectionPlanViewModel } from "../inspectionPlan/inspectionPlan.models"; + +export interface VehicleTypeViewModel { + id: string; + type: string; + description: string; + inspectionPlans: Array; +} + +export interface CreateVehicleTypeViewModel { + type: string; + description: string; +} + +export interface UpdateVehicleTypeViewModel { + id: string; + type: string; + description: string; +} diff --git a/src/viewmodels/admin/unit/wearable/wearable.models.ts b/src/viewmodels/admin/unit/wearable/wearable.models.ts new file mode 100644 index 0000000..cec2ece --- /dev/null +++ b/src/viewmodels/admin/unit/wearable/wearable.models.ts @@ -0,0 +1,34 @@ +import type { MemberViewModel } from "@/viewmodels/admin/club/member/member.models"; +import type { WearableTypeViewModel } from "../wearableType/wearableType.models"; + +export interface WearableViewModel { + id: string; + code?: string; + name: string; + location: string; + commissioned: Date; + decommissioned?: Date; + wearerId?: string; + wearer?: MemberViewModel; + wearableTypeId: string; + wearableType: WearableTypeViewModel; +} + +export interface CreateWearableViewModel { + code?: string; + name: string; + wearerId?: string; + location?: string; + commissioned: Date; + wearableTypeId: string; +} + +export interface UpdateWearableViewModel { + id: string; + code?: string; + name: string; + location?: string; + commissioned: Date; + decommissioned?: Date; + wearerId?: string; +} diff --git a/src/viewmodels/admin/unit/wearableType/wearableType.models.ts b/src/viewmodels/admin/unit/wearableType/wearableType.models.ts new file mode 100644 index 0000000..b3f49fc --- /dev/null +++ b/src/viewmodels/admin/unit/wearableType/wearableType.models.ts @@ -0,0 +1,16 @@ +export interface WearableTypeViewModel { + id: string; + type: string; + description: string; +} + +export interface CreateWearableTypeViewModel { + type: string; + description: string; +} + +export interface UpdateWearableTypeViewModel { + id: string; + type: string; + description: string; +} diff --git a/src/views/admin/club/newsletter/NewsletterRecipients.vue b/src/views/admin/club/newsletter/NewsletterRecipients.vue index 5335e82..e2678f1 100644 --- a/src/views/admin/club/newsletter/NewsletterRecipients.vue +++ b/src/views/admin/club/newsletter/NewsletterRecipients.vue @@ -15,7 +15,7 @@
    - diff --git a/src/views/admin/club/protocol/ProtocolPresence.vue b/src/views/admin/club/protocol/ProtocolPresence.vue index 4792116..a18a499 100644 --- a/src/views/admin/club/protocol/ProtocolPresence.vue +++ b/src/views/admin/club/protocol/ProtocolPresence.vue @@ -5,7 +5,7 @@ ↺ laden fehlgeschlagen

    - diff --git a/src/views/admin/unit/damageReport/DamageReport.vue b/src/views/admin/unit/damageReport/DamageReport.vue new file mode 100644 index 0000000..78133df --- /dev/null +++ b/src/views/admin/unit/damageReport/DamageReport.vue @@ -0,0 +1,46 @@ + + + + + diff --git a/src/views/admin/unit/damageReport/DamageReportRouting.vue b/src/views/admin/unit/damageReport/DamageReportRouting.vue new file mode 100644 index 0000000..356e095 --- /dev/null +++ b/src/views/admin/unit/damageReport/DamageReportRouting.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/src/views/admin/unit/equipment/CreateEquipment.vue b/src/views/admin/unit/equipment/CreateEquipment.vue new file mode 100644 index 0000000..247b3db --- /dev/null +++ b/src/views/admin/unit/equipment/CreateEquipment.vue @@ -0,0 +1,105 @@ + + + + + diff --git a/src/views/admin/unit/equipment/DamageReport.vue b/src/views/admin/unit/equipment/DamageReport.vue new file mode 100644 index 0000000..5e5d887 --- /dev/null +++ b/src/views/admin/unit/equipment/DamageReport.vue @@ -0,0 +1,55 @@ + + + + + diff --git a/src/views/admin/unit/equipment/Equipment.vue b/src/views/admin/unit/equipment/Equipment.vue new file mode 100644 index 0000000..4576190 --- /dev/null +++ b/src/views/admin/unit/equipment/Equipment.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/admin/unit/equipment/EquipmentRouting.vue b/src/views/admin/unit/equipment/EquipmentRouting.vue new file mode 100644 index 0000000..5eb9ced --- /dev/null +++ b/src/views/admin/unit/equipment/EquipmentRouting.vue @@ -0,0 +1,75 @@ + + + + + diff --git a/src/views/admin/unit/equipment/Inspection.vue b/src/views/admin/unit/equipment/Inspection.vue new file mode 100644 index 0000000..d1a3791 --- /dev/null +++ b/src/views/admin/unit/equipment/Inspection.vue @@ -0,0 +1,69 @@ + + + + + diff --git a/src/views/admin/unit/equipment/Overview.vue b/src/views/admin/unit/equipment/Overview.vue new file mode 100644 index 0000000..99304e6 --- /dev/null +++ b/src/views/admin/unit/equipment/Overview.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/src/views/admin/unit/equipment/UpdateEquipment.vue b/src/views/admin/unit/equipment/UpdateEquipment.vue new file mode 100644 index 0000000..60c0531 --- /dev/null +++ b/src/views/admin/unit/equipment/UpdateEquipment.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/src/views/admin/unit/equipmentType/EquipmentType.vue b/src/views/admin/unit/equipmentType/EquipmentType.vue new file mode 100644 index 0000000..8403461 --- /dev/null +++ b/src/views/admin/unit/equipmentType/EquipmentType.vue @@ -0,0 +1,67 @@ + + + + + diff --git a/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue b/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue new file mode 100644 index 0000000..765cd81 --- /dev/null +++ b/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/src/views/admin/unit/equipmentType/InspectionPlans.vue b/src/views/admin/unit/equipmentType/InspectionPlans.vue new file mode 100644 index 0000000..924055a --- /dev/null +++ b/src/views/admin/unit/equipmentType/InspectionPlans.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/views/admin/unit/equipmentType/Overview.vue b/src/views/admin/unit/equipmentType/Overview.vue new file mode 100644 index 0000000..76418a1 --- /dev/null +++ b/src/views/admin/unit/equipmentType/Overview.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/src/views/admin/unit/equipmentType/UpdateEquipmentType.vue b/src/views/admin/unit/equipmentType/UpdateEquipmentType.vue new file mode 100644 index 0000000..eb372e7 --- /dev/null +++ b/src/views/admin/unit/equipmentType/UpdateEquipmentType.vue @@ -0,0 +1,116 @@ + + + + + diff --git a/src/views/admin/unit/inspection/InspectionExecute.vue b/src/views/admin/unit/inspection/InspectionExecute.vue new file mode 100644 index 0000000..1c8bc08 --- /dev/null +++ b/src/views/admin/unit/inspection/InspectionExecute.vue @@ -0,0 +1,158 @@ + + + + + diff --git a/src/views/admin/unit/inspection/InspectionPlan.vue b/src/views/admin/unit/inspection/InspectionPlan.vue new file mode 100644 index 0000000..c1cafc1 --- /dev/null +++ b/src/views/admin/unit/inspection/InspectionPlan.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/src/views/admin/unit/inspectionPlan/CreateInspectionPlan.vue b/src/views/admin/unit/inspectionPlan/CreateInspectionPlan.vue new file mode 100644 index 0000000..c1a3c4a --- /dev/null +++ b/src/views/admin/unit/inspectionPlan/CreateInspectionPlan.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/src/views/admin/unit/inspectionPlan/InspectionPlan.vue b/src/views/admin/unit/inspectionPlan/InspectionPlan.vue new file mode 100644 index 0000000..fdee7b4 --- /dev/null +++ b/src/views/admin/unit/inspectionPlan/InspectionPlan.vue @@ -0,0 +1,65 @@ + + + + + diff --git a/src/views/admin/unit/inspectionPlan/InspectionPlanRouting.vue b/src/views/admin/unit/inspectionPlan/InspectionPlanRouting.vue new file mode 100644 index 0000000..7c6913a --- /dev/null +++ b/src/views/admin/unit/inspectionPlan/InspectionPlanRouting.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/src/views/admin/unit/inspectionPlan/Overview.vue b/src/views/admin/unit/inspectionPlan/Overview.vue new file mode 100644 index 0000000..361a11c --- /dev/null +++ b/src/views/admin/unit/inspectionPlan/Overview.vue @@ -0,0 +1,58 @@ + + + + + diff --git a/src/views/admin/unit/inspectionPlan/UpdateInspectionPlan.vue b/src/views/admin/unit/inspectionPlan/UpdateInspectionPlan.vue new file mode 100644 index 0000000..eaad622 --- /dev/null +++ b/src/views/admin/unit/inspectionPlan/UpdateInspectionPlan.vue @@ -0,0 +1,117 @@ + + + + + diff --git a/src/views/admin/unit/respiratoryGear/CreateRespiratoryGear.vue b/src/views/admin/unit/respiratoryGear/CreateRespiratoryGear.vue new file mode 100644 index 0000000..3d84221 --- /dev/null +++ b/src/views/admin/unit/respiratoryGear/CreateRespiratoryGear.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/src/views/admin/unit/respiratoryGear/RespiratoryGear.vue b/src/views/admin/unit/respiratoryGear/RespiratoryGear.vue new file mode 100644 index 0000000..c4f3a2c --- /dev/null +++ b/src/views/admin/unit/respiratoryGear/RespiratoryGear.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/src/views/admin/unit/respiratoryGear/RespiratoryGearRouting.vue b/src/views/admin/unit/respiratoryGear/RespiratoryGearRouting.vue new file mode 100644 index 0000000..c000096 --- /dev/null +++ b/src/views/admin/unit/respiratoryGear/RespiratoryGearRouting.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/views/admin/unit/respiratoryMission/CreateRespiratoryMission.vue b/src/views/admin/unit/respiratoryMission/CreateRespiratoryMission.vue new file mode 100644 index 0000000..6a422fd --- /dev/null +++ b/src/views/admin/unit/respiratoryMission/CreateRespiratoryMission.vue @@ -0,0 +1,94 @@ +