Skip to content

Commit

Permalink
Merge pull request #41 from icefoganalytics/main
Browse files Browse the repository at this point in the history
Investigation and Inspections stub
  • Loading branch information
datajohnson authored Nov 7, 2024
2 parents 4fb926a + 55f7d33 commit 70d64ef
Show file tree
Hide file tree
Showing 9 changed files with 460 additions and 23 deletions.
1 change: 1 addition & 0 deletions api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const API_GATEWAY_KEY = process.env.API_GATEWAY_KEY || "";
export const DB_CONFIG = {
client: DB_CLIENT,
connection: { host: DB_HOST, user: DB_USER, password: DB_PASS, database: DB_NAME, port: DB_PORT },
pool: { min: 0, reapIntervalMillis: 600000 },
};

export const DB_CONFIG_DEV = {
Expand Down
8 changes: 4 additions & 4 deletions web/public/serviceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ registerRoute(
plugins: [
new ExpirationPlugin({
maxEntries: 64,
maxAgeSeconds: 60 * 60 * 24 * 30,
maxAgeSeconds: 60 * 60 * 24 * 90,
}),
],
})
Expand All @@ -50,15 +50,15 @@ registerRoute(
cacheName: "api-location",
plugins: [
new ExpirationPlugin({
maxEntries: 16,
maxAgeSeconds: 30 * 24 * 60, // 30 days
maxEntries: 1,
//maxAgeSeconds: 30 * 24 * 60, // 30 days
}),
],
})
);

const bgSyncPlugin = new BackgroundSyncPlugin("reportQueue", {
maxRetentionTime: 30 * 24 * 60, // Retry for max of 30 days (specified in minutes)
maxRetentionTime: 30 * 24 * 60 , // Retry for max of 30 days (specified in minutes)
});

// Queue report submissions
Expand Down
43 changes: 37 additions & 6 deletions web/src/components/incident/DetailsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<v-stepper-vertical-item
v-for="(step, idx) of selectedReport.steps"
:value="idx + 1"
:complete="step.complete_date"
:complete="!isNil(step.complete_date)"
:title="step.step_title"
:color="step.complete_date ? 'success' : ''"
:subtitle="step.complete_date ? `${formatDate(step.complete_date)} by ${step.complete_name}` : ''">
Expand All @@ -49,7 +49,7 @@
<v-stepper-item
v-for="(step, idx) of selectedReport.steps"
:value="idx + 1"
:complete="step.complete_date"
:complete="!isNil(step.complete_date)"
:title="step.step_title"
:color="step.complete_date ? 'success' : ''"
:subtitle="step.complete_date ? `${formatDate(step.complete_date)} by ${step.complete_name}` : ''">
Expand Down Expand Up @@ -147,10 +147,13 @@
</v-col>

<v-col cols="12" md="12">
<v-label>Investigation</v-label>
<!-- <v-label>Investigation</v-label>
<v-textarea v-model="selectedReport.investigation_notes" hide-details />

-->
<v-btn color="primary" class="mb-0 mt-6" @click="saveClick">Save</v-btn>
<v-btn v-if="investigationIsActive" color="primary" class="mb-0 mt-6 ml-6" @click="investigationClick">
Start Investigation
</v-btn>
</v-col>
</v-row>
</v-card>
Expand All @@ -173,6 +176,11 @@
</v-col>
</v-row>
</section>

<InvestigationForm
v-model="showInvestigationDialog"
@complete="completeInvestigation"
@close="showInvestigationDialog = false" />
</div>
</template>

Expand All @@ -181,6 +189,7 @@ import { computed, ref } from "vue";
import { storeToRefs } from "pinia";
import { DateTime } from "luxon";
import { useRoute } from "vue-router";
import { isNil } from "lodash";
import { useDisplay } from "vuetify";
const { smAndDown } = useDisplay();
Expand All @@ -190,23 +199,34 @@ import ActionList from "@/components/action/ActionList.vue";
import HazardList from "@/components/hazard/HazardList.vue";
import ActionCreate from "@/components/action/ActionCreate.vue";
import ActionEdit from "@/components/action/ActionEdit.vue";
import InvestigationForm from "./InvestigationForm.vue";
import { useReportStore } from "@/store/ReportStore";
const reportStore = useReportStore();
const { initialize, loadReport, updateReport, openAttachment } = reportStore;
const { locations, urgencies, selectedReport } = storeToRefs(reportStore);
const { initialize, loadReport, updateReport, openAttachment, completeStep } = reportStore;
const { currentStep, selectedReport } = storeToRefs(reportStore);
const router = useRoute();
const reportId = router.params.id;
await initialize();
await loadReport(reportId);
const showInvestigationDialog = ref(false);
const showActionAdd = ref(false);
const showActionEdit = ref(false);
const actionToEdit = ref(null);
const investigationIsActive = computed(() => {
if (currentStep.value) {
return currentStep.value.step_title.indexOf("Investig") >= 0;
}
return false;
});
const tickLabels = {
0: "Low",
1: "Medium",
Expand Down Expand Up @@ -284,6 +304,17 @@ async function saveClick() {
await updateReport();
}
function investigationClick() {
showInvestigationDialog.value = true;
}
async function completeInvestigation() {
if (currentStep.value) {
await completeStep(currentStep.value);
showInvestigationDialog.value = false;
}
}
function openAttachmentClick(attachment) {
openAttachment(attachment);
}
Expand Down
220 changes: 220 additions & 0 deletions web/src/components/incident/InvestigationForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<template>
<v-dialog max-width="600px" persistent>
<v-card>
<v-toolbar color="info">
<v-toolbar-title class="d-flex"> Investigation </v-toolbar-title>
<v-spacer />
<v-btn icon="mdi-close" @click="close"></v-btn>
</v-toolbar>
<v-window v-model="step" style="max-height: 550px; overflow-y: scroll">
<v-window-item :value="0">
<v-card-text>
<p>How did the natural conditions affect the event? Only check those that apply, if any.</p>
<v-row>
<v-col cols="4"><v-checkbox label="Congestion" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Weather" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Temperature" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Visibility" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Ventilation" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
</v-card-text>
</v-window-item>
<v-window-item :value="1">
<v-card-text>
<p>How did external energy sources affect the event? Only check those that apply, if any.</p>
<v-row>
<v-col cols="4"><v-checkbox label="Noise / Sound" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Lighting" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Vibration" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Radiation" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Other (please explain)" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
</v-card-text>
</v-window-item>
<v-window-item :value="2">
<v-card-text>
<p>How did the worker's circumstance affect the event? Only check those that apply, if any.</p>
<v-row>
<v-col cols="4"><v-checkbox label="Not Physically Capable" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Lack of Knowledge" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Lack of Skill" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Improper Motivation" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Other (please explain)" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
</v-card-text>
</v-window-item>
<v-window-item :value="3">
<v-card-text>
<p>
What processes are missing or not sufficient enough and how did they contribute to the event? Only check
those that apply, if any.
</p>
<v-row>
<v-col cols="4"><v-checkbox label="Leadership" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Supervision" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Engineering" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Purchasing" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Maintenance" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Tools / Equip / Material" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Work Standards" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Wear & Tear" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Abuse or Misuse" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-checkbox label="Other (please explain)" hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
</v-card-text>
</v-window-item>

<v-window-item :value="4">
<v-card-text>
<p>
Root causes are essential system failures that are responsible for starting the series of unsafe acts or
conditions that lead to the event. Examples of a root cause are that a training program or safe work
practice doesn't exist to help the worker complete the activity, or there is no preventative maintenance
program to keep equipment operating properly. There can be more than one root cause.
</p>
<v-divider />
<v-row class="mt-2">
<v-col cols="4">Root Cause</v-col>
<v-col>Describe the inadequate process or program that lead to the event</v-col>
</v-row>
<v-row class="">
<v-col cols="4"><v-text-field hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-text-field hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-text-field hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
<v-row>
<v-col cols="4"><v-text-field hide-details /></v-col>
<v-col><v-textarea rows="2" hide-details /></v-col>
</v-row>
</v-card-text>
</v-window-item>
</v-window>

<v-card-text class="d-flex">
<v-btn :disabled="!isPrev" color="primary" @click="step--">Prev</v-btn>
<v-spacer />
<div class="pt-1">Step {{ step + 1 }}: {{ stepName }}</div>
<v-spacer />
<v-btn v-if="!isDone" :disabled="!isNext" color="primary" @click="step++">Next</v-btn>
<v-btn v-else color="success" @click="save">Save</v-btn>
</v-card-text>
</v-card>
</v-dialog>
</template>

<script setup>
import { computed, ref } from "vue";
const emits = defineEmits(["complete", "close"]);
const step = ref(0);
const stepName = computed(() => {
return steps.value[step.value].name;
});
const steps = ref([
{ name: "Environmental Causes" },
{ name: "Physical Causes" },
{ name: "Personal Causes" },
{ name: "Job or System" },
{ name: "Root Causes" },
/* { name: "Corrective Actions" },
{ name: "Substitution" },
{ name: "Engineering" },
{ name: "Administration" },
{ name: "Personal Protective Equipment (PPE)" }, */
]);
const isPrev = computed(() => {
return step.value > 0;
});
const isNext = computed(() => {
return step.value < steps.value.length - 1;
});
const isDone = computed(() => {
return step.value == steps.value.length - 1;
});
function close() {
emits("close");
step.value = 0;
}
function save() {
emits("complete");
step.value = 0;
}
</script>
12 changes: 1 addition & 11 deletions web/src/components/incident/OperationMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,7 @@ import { useReportStore } from "@/store/ReportStore";
const reportStore = useReportStore();
const { completeStep, revertStep } = reportStore;
const { selectedReport } = storeToRefs(reportStore);
const currentStep = computed(() => {
if (selectedReport.value) {
for (const step of selectedReport.value.steps) {
if (step.complete_date) continue;
return step;
}
}
return {};
});
const { currentStep, selectedReport } = storeToRefs(reportStore);
const previousStep = computed(() => {
if (selectedReport.value) {
Expand Down
Loading

0 comments on commit 70d64ef

Please sign in to comment.