implemented poi and mvi

This commit is contained in:
2024-04-01 18:37:15 +02:00
parent 3c063fddca
commit 423ff7e48b
35 changed files with 2111 additions and 497 deletions

View File

@ -331,7 +331,14 @@ const updateNewCustomerID = async () => {
const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 1500);
}, 2000);
}
// include delay to avoid 503 error
const triggerBackendCallsWithSmallDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 500);
}
const getSession = async () => {
@ -356,7 +363,7 @@ watch(modeChanged, getSession)
onMounted(async () => {
await getSession();
await getItemById();
triggerBackendCallsWithSmallDelay(getItemById);
triggerBackendCallsWithDelay(getConfigItems);
triggerBackendCallsWithDelay(getCustomers);
});

View File

@ -1,5 +1,5 @@
<template>
<div :class="['data', darkMode ? 'div-darkmode' : 'div-lightmode']">
<section :class="['instance-checklist-information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<div :class="['label', darkMode ? 'label-darkmode' : 'label-lightmode']">Checklist:</div>
<table class="data-table" id="instance-checklist">
<tbody>
@ -16,38 +16,70 @@
<th
:class="['Comments', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Comments-darkmode' : 'Comments-lightmode']">
Comments</th>
<th :class="['Done', darkMode ? 'th-darkmode' : 'th-lightmode']">Done</th>
<th v-if="!addBool" :class="['Done', darkMode ? 'th-darkmode' : 'th-lightmode']">Done</th>
</tr>
<tr :class="['table-row', darkMode ? 'tr-darkmode' : 'tr-lightmode']" id="row-1">
<tr v-for="todo in poiTodos" :key="todo.primaryID"
:class="['table-row', darkMode ? 'tr-darkmode' : 'tr-lightmode']" id="row-1">
<td
:class="['Step', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Step-darkmode' : 'Step-lightmode']">
...</td>
{{ todo.rowID }}</td>
<td
:class="['Asset', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Asset-darkmode' : 'Asset-lightmode']">
...</td>
{{ todo.asset }}</td>
<td
:class="['Task', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Task-darkmode' : 'Task-lightmode']">
...</td>
<td
{{ todo.task }}</td>
<td v-if="!editable"
:class="['Comments', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Comments-darkmode' : 'Comments-lightmode']">
...</td>
<td :class="['Done', darkMode ? 'td-darkmode' : 'td-lightmode']"><input type="checkbox"
{{ todo.comments }}</td>
<td v-if="editable" :class="['Comments', darkMode ? 'td-darkmode' : 'td-lightmode']"> <input
type="text" v-model="todo.comments" @change="updatePOITodo(todo)"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</td>
<td v-if="!addBool" :class="['Done', darkMode ? 'td-darkmode' : 'td-lightmode']"><input
@change="toggleTodo(todo)" type="checkbox" v-model="todo.done"
:class="[darkMode ? 'checkbox-darkmode' : 'checkbox-lightmode']" /></td>
</tr>
</tbody>
</table>
</div>
</section>
<section v-if="addBool" id="saveNewPOI">
<button :class="[darkMode ? 'saveNewPOI-darkmode' : 'saveNewPOI-lightmode']" @click="addPOI()">Save</button>
</section>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import { useStore } from 'vuex';
import Axios from '../axios.config.js';
import clientsideConfig from '../../clientsideConfig.js';
import { computed } from 'vue';
const store = useStore();
const modeChanged = computed(() => store.state.updateDarkMode);
const darkMode = ref('')
const chosenPOTId = computed(() => store.state.chosenPOTId);
const chosenPOIId = computed(() => store.state.chosenPOIId);
const addBool = computed(() => store.state.new);
const newNamePOI = computed(() => store.state.newNamePOI);
const newTemplateIDPOI = computed(() => store.state.newTemplateIDPOI);
const newCustomerIDPOI = computed(() => store.state.newCustomerIDPOI);
const newCustomerPOI = computed(() => store.state.newCustomerPOI);
const newAssetPOI = computed(() => store.state.newAssetPOI);
const newStatePOI = computed(() => store.state.newStatePOI);
const newCreationDatePOI = computed(() => store.state.newCreationDatePOI);
const newCompletionDatePOI = computed(() => store.state.newCompletionDatePOI);
const newUserPOI = computed(() => store.state.newUserPOI);
const newTemplateDescriptionPOI = computed(() => store.state.newTemplateDescriptionPOI);
const newTemplateNotesPOI = computed(() => store.state.newTemplateNotesPOI);
const newTimeSpentPOI = computed(() => store.state.newTimeSpentPOI);
const newNotesPOI = computed(() => store.state.newNotes);
const editable = computed(() => store.state.editable);
const darkMode = ref('');
const poiTodos = ref([]);
const productionOrderInstances = ref([]);
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
@ -58,6 +90,81 @@ const getSession = async () => {
}
}
// get production order template todos from id
const getPOITodosById = async () => {
if (chosenPOTId.value != -1 && addBool.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosProductionOrderTemplate/${chosenPOTId.value}`
);
poiTodos.value = response.data;
store.commit('updateProductionOrderInstanceTemplateID', chosenPOTId.value)
} catch (err) {
console.log(err.response.statusText);
}
} else if (addBool.value && !(newTemplateIDPOI.value == '')) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosProductionOrderTemplate/${newTemplateIDPOI.value}`
);
poiTodos.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
} else {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosProductionOrderInstance/${chosenPOIId.value}`
);
const poiTodosComment = response.data;
// change the comment und step field name to comments and rowID
poiTodos.value = poiTodosComment.map(obj => {
const { step: rowID, comment: comments, ...rest } = obj;
return { ...rest, rowID, comments };
});
} catch (err) {
console.log(err.response.statusText);
}
}
poiTodos.value = poiTodos.value.map(obj => ({
// convert 'done' to boolean
...obj,
done: obj.done === "1"
}));
}
const toggleTodo = (todo) => {
let doneInput = false;
doneInput = todo.done;
updatePOITodo(todo, true, doneInput);
}
//update data
const updatePOITodo = async (todo, doneChanged = false, doneInput = false) => {
if (doneChanged) {
todo.done = doneInput;
}
if (todo.done) {
todo.done = 1;
}
try {
await Axios.put(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/updatePOITodo`,
{
primaryID: todo.primaryID,
step: todo.rowID,
asset: todo.asset,
task: todo.task,
comment: todo.comments,
done: todo.done,
}
);
await getPOITodosById();
} catch (err) {
console.log(err.response.statusText);
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
@ -66,10 +173,100 @@ function getItem(item) {
}
}
//get all productionOrder instances
const getProductionOrderInstances = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderInstances`);
productionOrderInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// add new production order instance
const addPOI = async () => {
// check if all input data is valid
if (newNamePOI.value.trim() === "") {
alert("Please add a production order instance name!");
return;
} else {
var counter = 0;
if (!(productionOrderInstances.value.length == null)) {
// check if production order instance name already exists
productionOrderInstances.value.forEach(p => {
if (p.name === newNamePOI.value) {
counter += 1;
}
});
if (counter == 1) {
alert("This production order instance name already exists. Please choose an unique production order instance name or modify respectively delete the old one!");
return;
}
}
}
if (newCustomerPOI.value.length === 0) {
alert("Please choose a customer!");
return;
}
// get the time and date
const today = new Date();
const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
const time = today.getHours() + ":" + today.getMinutes();
const dateTime = date + ' ' + time;
try {
const response = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addPOI`,
{
name: newNamePOI.value,
templateID: newTemplateIDPOI.value,
customerID: newCustomerIDPOI.value,
customer: newCustomerPOI.value,
asset: newAssetPOI.value,
state: newStatePOI.value,
creationDate: dateTime,
completionDate: newCompletionDatePOI.value,
user: newUserPOI.value,
templateDescription: newTemplateDescriptionPOI.value,
templateNotes: newTemplateNotesPOI.value,
timeSpent: newTimeSpentPOI.value,
notes: newNotesPOI.value,
});
store.commit('resetStore');
store.commit('changeToInstancelist');
store.commit('seeAllIcon');
poiTodos.value.forEach(async todo => {
try {
const res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addTodoPOI`,
{
templateID: response.data,
step: todo.rowID,
asset: todo.asset,
task: todo.task,
comment: todo.comments,
done: false,
});
} catch (err) {
console.log(err.response.statusText);
}
})
} catch (err) {
console.log(err.response.statusText);
}
}
// include delay to avoid 503 error
const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 1500);
}
watch(modeChanged, getSession)
watch(newTemplateIDPOI, getPOITodosById)
onMounted(async () => {
await getSession();
getSession();
await getPOITodosById();
triggerBackendCallsWithDelay(getProductionOrderInstances);
});
</script>
@ -84,15 +281,13 @@ export default {
<style scoped>
.data {
display: flex;
flex-direction: column;
flex-direction: row;
align-items: flex-start;
justify-content: center;
align-self: stretch;
width: 100%;
padding: 1.25rem 1.875rem;
gap: 1.25rem;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
padding: 0 0.625rem;
border-radius: 0.3125rem;
box-shadow: 0.0625rem 0.0625rem 0.25rem 0rem rgba(0, 0, 0, 0.25) inset;
letter-spacing: 5%;
font: 400 0.75rem/250% Overpass, sans-serif;
}
.div-darkmode {
@ -110,6 +305,20 @@ export default {
border-collapse: collapse;
}
.data-darkmode {
background-color: #212121;
color: #fff;
}
.data-lightmode {
background-color: #EBEBEB;
color: #000;
}
.input {
border: none;
}
.table-row {
display: flex;
flex-direction: row;
@ -119,6 +328,42 @@ export default {
gap: 0.625rem;
}
.saveNewPOI-darkmode {
background: #2c2c2c;
color: #fff;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOI-lightmode {
background: #EBEBEB;
color: #212121;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOI-darkmode:hover {
background-color: #444444;
cursor: pointer;
}
.saveNewPOI-lightmode:hover {
background-color: #ACACAC;
cursor: pointer;
}
#saveNewPOI {
text-align: center;
}
.tr-head-darkmode {
border-top: none;
border-bottom: 0.0625rem solid #000000;
@ -164,11 +409,28 @@ th {
filter: invert(100%);
}
.checkbox-lightmode {
filter: invert(0%);
}
.instance-checklist-information {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
padding: 1.25rem 1.875rem;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.section-darkmode {
background-color: #2c2c2c;
}
.section-lightmode {
background-color: #fff;
}
.Step {
width: 7%;
}

View File

@ -0,0 +1,504 @@
<template>
<section :class="['instance-checklist-information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<div :class="['label', darkMode ? 'label-darkmode' : 'label-lightmode']">Checklist:</div>
<table class="data-table" id="instance-checklist">
<tbody>
<tr :class="['table-row', darkMode ? 'tr-head-darkmode' : 'tr-head-lightmode']" id="table-head">
<th
:class="['Step', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Step-darkmode' : 'Step-lightmode']">
Step</th>
<th
:class="['Asset', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Asset-darkmode' : 'Asset-lightmode']">
Asset</th>
<th
:class="['Task', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Task-darkmode' : 'Task-lightmode']">
Task</th>
<th
:class="['Comments', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Comments-darkmode' : 'Comments-lightmode']">
Comments</th>
<th v-if="!addBool" :class="['Done', darkMode ? 'th-darkmode' : 'th-lightmode']">Done</th>
</tr>
<tr v-for="todo in mviTodos" :key="todo.primaryID"
:class="['table-row', darkMode ? 'tr-darkmode' : 'tr-lightmode']" id="row-1">
<td
:class="['Step', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Step-darkmode' : 'Step-lightmode']">
{{ todo.rowID }}</td>
<td
:class="['Asset', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Asset-darkmode' : 'Asset-lightmode']">
{{ todo.asset }}</td>
<td
:class="['Task', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Task-darkmode' : 'Task-lightmode']">
{{ todo.task }}</td>
<td v-if="!editable"
:class="['Comments', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Comments-darkmode' : 'Comments-lightmode']">
{{ todo.comments }}</td>
<td v-if="editable" :class="['Comments', darkMode ? 'td-darkmode' : 'td-lightmode']"> <input
type="text" v-model="todo.comments" @change="updateMVITodo(todo)"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</td>
<td v-if="!addBool" :class="['Done', darkMode ? 'td-darkmode' : 'td-lightmode']"><input
@change="toggleTodo(todo)" type="checkbox" v-model="todo.done"
:class="[darkMode ? 'checkbox-darkmode' : 'checkbox-lightmode']" /></td>
</tr>
</tbody>
</table>
</section>
<section v-if="addBool" id="saveNewMVI">
<button :class="[darkMode ? 'saveNewMVI-darkmode' : 'saveNewMVI-lightmode']" @click="addMVI()">Save</button>
</section>
</template>
<script setup>
import { ref, onMounted, watch } from 'vue';
import { useStore } from 'vuex';
import Axios from '../axios.config.js';
import clientsideConfig from '../../clientsideConfig.js';
import { computed } from 'vue';
const store = useStore();
const modeChanged = computed(() => store.state.updateDarkMode);
const chosenMVIId = computed(() => store.state.chosenMITId);
const chosenMVTId = computed(() => store.state.chosenMVTId);
const addBool = computed(() => store.state.new);
const newNameMVI = computed(() => store.state.newNameMVI);
const newTemplateIDMVI = computed(() => store.state.newTemplateIDMVI);
const newMaintenanceTypeMVI = computed(() => store.state.newMaintenanceTypeMVI);
const newStateMVI = computed(() => store.state.newStateMVI);
const newCreationDateMVI = computed(() => store.state.newCreationDateMVI);
const newCompletionDateMVI = computed(() => store.state.newCompletionDateMVI);
const newUserMVI = computed(() => store.state.newUserMVI);
const newCustomerIDMVI = computed(() => store.state.newCustomerIDMVI);
const newCustomerMVI = computed(() => store.state.newCustomerMVI);
const newTemplateNotesMVI = computed(() => store.state.newTemplateNotesMVI);
const newTypeMVI = computed(() => store.state.newTypeMVI);
const newTimeSpentMVI = computed(() => store.state.newTimeSpentMVI);
const newNotesMVI = computed(() => store.state.newNotes);
const editable = computed(() => store.state.editable);
const darkMode = ref('');
const mviTodos = ref([]);
const maintenanceVisitInstances = ref([]);
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
// get maintenance visit template todos from id
const getMVITodosById = async () => {
if (chosenMVTId.value != -1 && addBool.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosMaintenanceVisitTemplate/${chosenMVTId.value}`
);
mviTodos.value = response.data;
store.commit('updateMaintenanceVisitInstanceTemplateID', chosenMVTId.value)
} catch (err) {
console.log(err.response.statusText);
}
} else if (addBool.value && !(newTemplateIDMVI.value == '')) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosMaintenanceVisitTemplate/${newTemplateIDMVI.value}`
);
mviTodos.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
} else {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getTodosMaintenanceVisitInstance/${chosenMVIId.value}`
);
const mviTodosComment = response.data;
// change the comment und step field name to comments and rowID
mviTodos.value = mviTodosComment.map(obj => {
const { step: rowID, comment: comments, ...rest } = obj;
return { ...rest, rowID, comments };
});
} catch (err) {
console.log(err.response.statusText);
}
}
mviTodos.value = mviTodos.value.map(obj => ({
// convert 'done' to boolean
...obj,
done: obj.done === "1"
}));
}
const toggleTodo = (todo) => {
let doneInput = false;
doneInput = todo.done;
updateMVITodo(todo, true, doneInput);
}
//update data
const updateMVITodo = async (todo, doneChanged = false, doneInput = false) => {
if (doneChanged) {
todo.done = doneInput;
}
if (todo.done) {
todo.done = 1;
}
try {
await Axios.put(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/updateMVITodo`,
{
primaryID: todo.primaryID,
step: todo.rowID,
asset: todo.asset,
task: todo.task,
comment: todo.comments,
done: todo.done,
}
);
await getMVITodosById();
} catch (err) {
console.log(err.response.statusText);
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
//get all maintenance visit instances
const getMaintenanceVisitInstances = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllMaintenanceVisitInstances`);
maintenanceVisitInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// add new maintenance visit instance
const addMVI = async () => {
// check if all input data is valid
if (newNameMVI.value.trim() === "") {
alert("Please add a maintenance visit instance name!");
return;
} else {
var counter = 0;
if (!(maintenanceVisitInstances.value.length == null)) {
// check if maintenance visit instance name already exists
maintenanceVisitInstances.value.forEach(m => {
if (m.name === newNameMVI.value) {
counter += 1;
}
});
if (counter == 1) {
alert("This maintenance visit instance name already exists. Please choose an unique maintenance visit instance name or modify respectively delete the old one!");
return;
}
}
}
if (newCustomerMVI.value.length === 0) {
alert("Please choose a customer!");
return;
}
// get the time and date
const today = new Date();
const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
const time = today.getHours() + ":" + today.getMinutes();
const dateTime = date + ' ' + time;
try {
const response = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addMVI`,
{
name: newNameMVI.value,
templateID: newTemplateIDMVI.value,
maintenanceType: newMaintenanceTypeMVI.value,
state: newStateMVI.value,
creationDate: dateTime,
completionDate: newCompletionDateMVI.value,
user: newUserMVI.value,
customerID: newCustomerIDMVI.value,
customer: newCustomerMVI.value,
templateNotes: newTemplateNotesMVI.value,
type: newTypeMVI.value,
timeSpent: newTimeSpentMVI.value,
notes: newNotesMVI.value,
});
store.commit('resetStore');
store.commit('changeToInstancelist');
store.commit('seeAllIcon');
mviTodos.value.forEach(async todo => {
try {
const res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addTodoMVI`,
{
templateID: response.data,
step: todo.rowID,
asset: todo.asset,
task: todo.task,
comment: todo.comments,
done: false,
});
} catch (err) {
console.log(err.response.statusText);
}
})
} catch (err) {
console.log(err.response.statusText);
}
}
// include delay to avoid 503 error
const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 1500);
}
watch(modeChanged, getSession)
watch(newTemplateIDMVI, getMVITodosById)
onMounted(async () => {
getSession();
await getMVITodosById();
triggerBackendCallsWithDelay(getMaintenanceVisitInstances);
});
</script>
<script>
export default {
name: "InstanceChecklistMVI",
};
</script>
<style scoped>
.data {
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 0 0.625rem;
border-radius: 0.3125rem;
box-shadow: 0.0625rem 0.0625rem 0.25rem 0rem rgba(0, 0, 0, 0.25) inset;
letter-spacing: 5%;
font: 400 0.75rem/250% Overpass, sans-serif;
}
.div-darkmode {
background-color: #2c2c2c;
}
.div-lightmode {
background-color: #fff;
}
.data-table {
width: 100%;
padding: 0 0.625rem;
table-layout: fixed;
border-collapse: collapse;
}
.data-darkmode {
background-color: #212121;
color: #fff;
}
.data-lightmode {
background-color: #EBEBEB;
color: #000;
}
.input {
border: none;
}
.table-row {
display: flex;
flex-direction: row;
align-items: center;
height: 3.125rem;
padding: 0.625rem;
gap: 0.625rem;
}
.saveNewMVI-darkmode {
background: #2c2c2c;
color: #fff;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewMVI-lightmode {
background: #EBEBEB;
color: #212121;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewMVI-darkmode:hover {
background-color: #444444;
cursor: pointer;
}
.saveNewMVI-lightmode:hover {
background-color: #ACACAC;
cursor: pointer;
}
#saveNewMVI {
text-align: center;
}
.tr-head-darkmode {
border-top: none;
border-bottom: 0.0625rem solid #000000;
}
.tr-head-lightmode {
border-top: none;
border-bottom: 0.0625rem solid #8e8e8e;
}
.tr-darkmode {
border-top: 0.0625rem solid #000000;
}
.tr-lightmode {
border-top: 0.0625rem solid #8e8e8e;
}
th,
td {
height: 1.875rem;
text-align: left;
padding: 0;
letter-spacing: 5%;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
}
th {
font: 700 0.875rem/1.875rem Overpass, sans-serif;
}
.th-darkmode,
.td-darkmode {
color: #ffffff;
}
.th-lightmode,
.td-lightmode {
color: #000;
}
.checkbox-darkmode {
filter: invert(100%);
}
.checkbox-lightmode {
filter: invert(0%);
}
.instance-checklist-information {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
padding: 1.25rem 1.875rem;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.section-darkmode {
background-color: #2c2c2c;
}
.section-lightmode {
background-color: #fff;
}
.Step {
width: 7%;
}
.Step-darkmode {
border-right: 0.0625rem solid #000000;
}
.Step-lightmode {
border-right: 0.0625rem solid #8e8e8e;
}
.Asset {
width: 28%;
}
.Asset-darkmode {
border-right: 0.0625rem solid #000000;
}
.Asset-lightmode {
border-right: 0.0625rem solid #8e8e8e;
}
.Task {
width: 30%;
}
.Task-darkmode {
border-right: 0.0625rem solid #000000;
}
.Task-lightmode {
border-right: 0.0625rem solid #8e8e8e;
}
.Comments {
width: 30%;
}
.Comments-darkmode {
border-right: 0.0625rem solid #000000;
}
.Comments-lightmode {
border-right: 0.0625rem solid #8e8e8e;
}
.Done {
width: 5%;
}
.label {
width: 6.0625em;
height: 1.875em;
font-family: 'Overpass';
font-style: normal;
font-weight: 400;
font-size: 1em;
line-height: 1.875em;
letter-spacing: 0.05em;
}
.label-darkmode {
color: #FFFFFF;
}
.label-lightmode {
color: #000;
}
</style>

View File

@ -106,6 +106,23 @@ const newState = ref('');
const newAmount = ref('');
const newProperties = ref('');
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
//get all issue
const getIssues = async () => {
try {
@ -211,23 +228,6 @@ const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
watch(deleteBool, confirmDeleteIssue);
watch(modeChanged, getSession)
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
onMounted(async () => {
await getSession();
await getIssueById();

View File

@ -67,6 +67,23 @@ const issueSearchFilter = ref('');
const darkMode = ref('');
const issues = ref([]);
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
// update search term
const updateSearchTerm = async () => {
issueSearchFilter.value = '';
@ -114,24 +131,6 @@ const searchIssue = async () => {
watch(stateFilter, getIssues);
watch(searchable, updateSearchTerm);
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
if (loggedInUserDarkModeBool == 1) {
darkMode.value = true;
} else {
darkMode.value = false;
}
}
function getItem(item) {
if (process.client) {
return localStorage.getItem(item)
} else {
return undefined
}
}
watch(modeChanged, getSession)
onMounted(async () => {

View File

@ -1,29 +1,38 @@
<template>
<section :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<h2 :class="['maintenance-visits-instance-name', darkMode ? 'h2-darkmode' : 'h2-lightmode']">Instance ID</h2>
<section v-if="!addBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<h2 v-if="!editable" :class="['maintenance-visits-instance-name', darkMode ? 'h2-darkmode' : 'h2-lightmode']">{{
mvi.name }}</h2>
<input v-if="editable" v-model="mvi.name" @change="updateMVI()"
:class="['data', 'mvi-name-input', darkMode ? 'h2-darkmode' : 'h2-lightmode', darkMode ? 'h2-input-darkmode' : 'h2-input-lightmode', 'input']">
<div class="maintenance-visits-instance-data">
<div class="instanceInfo">
<div class="data-field" id="info">
<div class="templateId-customer-type" id="templateID">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template ID:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.templateID }}</pre>
</div>
<div class="templateId-customer-type" id="customer">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Customer:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.customer }}</pre>
</div>
<div class="templateId-customer-type" id="type">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Type:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.type }}</pre>
<input v-if="editable" v-model="mvi.type" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
</div>
</div>
</div>
<div class="maintenance-visits-instance-data">
<div class="additional">
<div class="additionaFl">
<div class="templateNotes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Template notes:</h3>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']" id="templateNotes">...</pre>
<pre v-if="!editable" :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"
id="templateNotes">{{ mvi.templateNotes }}</pre>
<input v-if="editable" v-model="mvi.templateNotes" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
</div>
</div>
@ -32,15 +41,126 @@
<div class="data-field" id="info">
<div class="maintenanceType-state-user" id="maintenanceType">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Maintenance type:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.maintenanceType }}</pre>
<input v-if="editable" v-model="mvi.maintenanceType" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="maintenanceType-state-user" id="state">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">State:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.state }}</pre>
<input v-if="editable" v-model="mvi.state" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="maintenanceType-state-user" id="user">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">User:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.user }}</pre>
<select v-if="editable" id="assetsDropDownChosenCI" v-model="mvi.user" @change="updateMVI()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="user in userList" :key="user.id">
{{ user.username }}
</option>
</select>
</div>
</div>
<div class="data-field" id="info">
<div class="creationDate-completionDate-timeSpent" id="creationDate">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Creation date:</pre>
<pre
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.creationDate }}</pre>
</div>
<div class="creationDate-completionDate-timeSpent" id="completionDate">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Completion date:</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.completionDate }}</pre>
<input v-if="editable" v-model="mvi.completionDate" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="creationDate-completionDate-timeSpent" id="timeSpent">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Time spent:</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.timeSpent }}</pre>
<input v-if="editable" v-model="mvi.timeSpent" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
</div>
</div>
</div>
<div class="maintenance-visits-instance-data">
<div class="additional">
<div class="notes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Notes:</h3>
<input v-model="mvi.notes" :readonly="!editable" @change="updateMVI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">
</div>
</div>
</div>
</section>
<section v-if="addBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<input v-model="newName" @change="updateMaintenanceVisitInstance()"
:class="['data', 'mvi-name-input', darkMode ? 'h2-darkmode' : 'h2-lightmode', darkMode ? 'h2-input-darkmode' : 'h2-input-lightmode', 'input']">
<div class="maintenance-visits-instance-data">
<div class="instanceInfo">
<div class="data-field" id="info">
<div class="templateId-customer-type" id="templateID">
<pre v-if="mvtSelected"
:class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template ID:</pre>
<pre v-if="!mvtSelected"
:class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template name:</pre>
<pre v-if="mvtSelected"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ chosenMVTId }}</pre>
<select v-if="!mvtSelected" id="assetsDropDownChosenCI" v-model="chosenTemplate"
@change="updateMaintenanceVisitInstance(chosenTemplate)"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="template in maintenanceVisitTemplates" :key="template.checklistID">
{{ template.name }}
</option>
</select>
</div>
<div class="templateId-customer-type" id="customer">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Customer:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ mvi.customer }}</pre>
</div>
<div class="templateId-customer-type" id="type">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Type:</pre>
<input v-model="newType" @change="updateMaintenanceVisitInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
</div>
</div>
</div>
<div class="maintenance-visits-instance-data">
<div class="additionaFl">
<div class="templateNotes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Template notes:</h3>
<input v-model="newTemplateNotes" @change="updateMaintenanceVisitInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
</div>
</div>
<div class="maintenance-visits-instance-data">
<div class="instanceInfo">
<div class="data-field" id="info">
<div class="maintenanceType-state-user" id="maintenanceType">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Maintenance type:</pre>
<input v-model="newMaintenanceType" @change="updateMaintenanceVisitInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="maintenanceType-state-user" id="state">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">State:</pre>
<input v-model="newState" @change="updateMaintenanceVisitInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="maintenanceType-state-user" id="user">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">User:</pre>
<select id="assetsDropDownChosenCI" v-model="newUser" @change="updateMaintenanceVisitInstance()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="user in userList" :key="user.id">
{{ user.username }}
</option>
</select>
</div>
</div>
<div class="data-field" id="info">
@ -63,7 +183,8 @@
<div class="additional">
<div class="notes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Notes:</h3>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">...</pre>
<input v-model="newNotes" @change="updateMaintenanceVisitInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">
</div>
</div>
</div>
@ -75,11 +196,257 @@
import { ref, onMounted, watch } from 'vue';
import { useStore } from 'vuex';
import { computed } from 'vue';
import Axios from '../axios.config.js';
import clientsideConfig from '../../clientsideConfig.js';
const store = useStore();
const modeChanged = computed(() => store.state.updateDarkMode);
const editable = computed(() => store.state.editable);
const chosenMVIId = computed(() => store.state.chosenMITId);
const chosenMVTId = computed(() => store.state.chosenMVTId);
const deleteBool = computed(() => store.state.deleteBool);
const addBool = computed(() => store.state.new);
const darkMode = ref('');
const mvtSelected = ref('');
const mvi = ref({});
const mvt = ref({});
const customers = ref([]);
const newName = ref('');
const newTemplateID = ref('');
const chosenTemplate = ref('');
const newCustomerID = ref('');
const newCustomer = ref('');
const newMaintenanceType = ref('');
const newUser = ref('');
const newState = ref('');
const newNotes = ref('');
const newTemplateNotes = ref('');
const newType = ref('');
const newCreationDate = ref('');
const newCompletionDate = ref('');
const newTimeSpent = ref('');
const maintenanceVisitInstances = ref([]);
const maintenanceVisitTemplates = ref([]);
const userList = ref([]);
//get all customers
const getCustomers = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllCustomers`
);
customers.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
//get all maintenance visit templates
const getMaintenanceVisitTemplates = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllMaintenanceVisitTemplates`);
maintenanceVisitTemplates.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// get maintenance visit template from id
const getMVTById = async () => {
if (chosenMVTId.value == '-1') {
mvtSelected.value = false;
await getMaintenanceVisitTemplates();
} else {
mvtSelected.value = true;
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getMaintenanceVisitTemplate/${chosenMVTId.value}`
);
mvt.value = response.data;
mvi.value.customer = mvt.value.customer;
mvi.value.customerID = mvt.value.customerID;
newCustomer.value = mvt.value.customer;
newCustomerID.value = mvt.value.customerID;
} catch (err) {
console.log(err.response.statusText);
}
}
await getMaintenanceVisitInstances();
}
// get maintenance visit template from id
const getChosenMVTById = async (newMvtId) => {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getMaintenanceVisitTemplate/${newMvtId}`
);
mvt.value = response.data;
mvi.value.customer = mvt.value.customer;
mvi.value.customerID = mvt.value.customerID;
newCustomer.value = mvt.value.customer;
newCustomerID.value = mvt.value.customerID;
} catch (err) {
console.log(err.response.statusText);
}
}
const confirmDeleteMVI = async () => {
if (deleteBool.value === true) {
if (confirm("Do you really want to delete this maintenance visit instance? It cannot be undone!")) {
try {
await Axios.delete(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/deleteMaintenanceVisitInstance/${chosenMVIId.value}`);
} catch (err) {
console.log(err.response.statusText);
}
try {
await Axios.delete(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/deleteTodosMVI/${chosenMVIId.value}`);
} catch (err) {
console.log(err.response.statusText);
}
store.commit('undoDelete');
store.commit('resetStore');
store.commit('changeToInstancelist');
store.commit('seeAllIcon');
} else {
store.commit('undoDelete');
}
}
}
//get all users
const getUsers = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllEmployees`);
userList.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
//update data
const updateMVI = async () => {
if (mvi.value.name.trim() === "") {
alert("Please add a maintenance visit instance name!");
return;
} else {
var counter = 0;
// check if maintenance visit instance name already exists
maintenanceVisitInstances.value.forEach(m => {
if (m.name === mvi.value.name) {
counter += 1;
}
});
if (counter == 2) {
alert("This maintenance visit instance name already exists. Please choose an unique maintenance visit instance name or modify respectively delete the old one!");
mvi.value.name = '';
return;
}
try {
await Axios.put(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/updateMaintenanceVisitInstance`,
{
primaryID: mvi.value.primaryID,
name: mvi.value.name,
templateID: mvi.value.templateID,
maintenanceType: mvi.value.maintenanceType,
state: mvi.value.state,
creationDate: mvi.value.creationDate,
completionDate: mvi.value.completionDate,
user: mvi.value.user,
customerID: mvi.value.customerID,
customer: mvi.value.customer,
type: mvi.value.type,
templateNotes: mvi.value.templateNotes,
timeSpent: mvi.value.timeSpent,
notes: mvi.value.notes,
}
)
await getMVIById();
} catch (err) {
console.log(err.response.statusText);
}
}
}
//get all maintenance visit instances
const getMaintenanceVisitInstances = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllMaintenanceVisitInstances`);
maintenanceVisitInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// update maintenance visit instance fields in the store
const updateMaintenanceVisitInstance = async (newMvtId = -1) => {
let maintenanceVisitInstance = {};
if (mvtSelected.value) {
maintenanceVisitInstance = {
name: newName.value,
templateID: chosenMVTId.value,
maintenanceType: newMaintenanceType.value,
state: newState.value,
creationDate: newCreationDate.value,
completionDate: newCompletionDate.value,
user: newUser.value,
customerID: newCustomerID.value,
customer: newCustomer.value,
templateNotes: newTemplateNotes.value,
type: newType.value,
timeSpent: newTimeSpent.value,
notes: newNotes.value,
};
} else {
if (!(newMvtId == '-1')) {
// Find the object with the selected Name
const selectedObject = maintenanceVisitTemplates.value.find(obj => obj.name === newMvtId);
// Get the templateID
newTemplateID.value = selectedObject ? selectedObject.checklistID : null;
await getChosenMVTById(newTemplateID.value);
}
maintenanceVisitInstance = {
name: newName.value,
templateID: newTemplateID.value,
maintenanceType: newMaintenanceType.value,
state: newState.value,
creationDate: newCreationDate.value,
completionDate: newCompletionDate.value,
user: newUser.value,
customerID: newCustomerID.value,
customer: newCustomer.value,
templateNotes: newTemplateNotes.value,
type: newType.value,
timeSpent: newTimeSpent.value,
notes: newNotes.value,
};
}
store.commit('updateMaintenanceVisitInstanceComponent', maintenanceVisitInstance);
}
// get maintenance visit instance from id
const getMVIById = async () => {
if (!addBool.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getMaintenanceVisitInstance/${chosenMVIId.value}`
);
mvi.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
}
// include delay to avoid 503 error
const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
setTimeout(() => {
fetchDataFunc();
}, 1500);
}
const getSession = async () => {
const loggedInUserDarkModeBool = getItem('logged-in-user-darkMode');
@ -99,9 +466,13 @@ function getItem(item) {
}
watch(modeChanged, getSession)
watch(deleteBool, confirmDeleteMVI);
onMounted(async () => {
await getSession();
getSession();
await getMVIById();
await getMVTById();
triggerBackendCallsWithDelay(getCustomers);
});
</script>
@ -143,6 +514,22 @@ export default {
sans-serif;
}
.select-lightmode {
border: none;
color: black;
background: #EBEBEB;
padding: 0.4rem;
border-radius: 0.3125rem;
}
.select-darkmode {
border: none;
color: white;
background: #212121;
padding: 0.4rem;
border-radius: 0.3125rem;
}
.h2-darkmode {
color: #fff;
}
@ -199,6 +586,36 @@ export default {
font: 400 0.75rem/250% Overpass, sans-serif;
}
.h2-darkmode {
color: #fff;
}
.h2-lightmode {
color: #000;
}
.h2-input-darkmode {
background-color: #212121;
}
.h2-input-lightmode {
background-color: #EBEBEB;
}
.input {
border: none;
}
.mvi-name-input {
/* padding: 1rem 0; */
margin: 1rem;
font-size: initial;
letter-spacing: 5%;
text-decoration-line: underline;
font: italic 400 1rem/187.5% Overpass, -apple-system, Roboto, Helvetica,
sans-serif;
}
.data-darkmode {
background-color: #212121;
color: #fff;

View File

@ -73,6 +73,7 @@ const modeChanged = computed(() => store.state.updateDarkMode);
const chosenMVTId = computed(() => store.state.chosenMVTId);
const searchable = computed(() => store.state.searchable);
const filtered = computed(() => store.state.filtered);
const notAllInstancesIcon = computed(() => store.state.notAllInstancesIcon);
const userSearchFilter = ref('');
const stateSearchFilter = ref('');
const maintenanceVisitInstances = ref([]);
@ -89,11 +90,20 @@ const goToChosenMVI = (id) => {
//get all maintenance visit instances
const getMaintenanceVisitInstances = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getSelectedMVIByMVT/${mvt.value.checklistID}`);
maintenanceVisitInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
if (notAllInstancesIcon.value) {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getSelectedMVIByMVT/${mvt.value.checklistID}`);
maintenanceVisitInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
} else {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllMaintenanceVisitInstances`);
maintenanceVisitInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
}
@ -111,15 +121,17 @@ const updateFilterTerm = async () => {
// get maintenance visit template from id
const getMVTById = async () => {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getMaintenanceVisitTemplate/${chosenMVTId.value}`
);
mvt.value = response.data;
if (notAllInstancesIcon.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getMaintenanceVisitTemplate/${chosenMVTId.value}`
);
mvt.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
await getMaintenanceVisitInstances();
} catch (err) {
console.log(err.response.statusText);
}
}
//get all instances based on the searched state
@ -178,6 +190,7 @@ function getItem(item) {
watch(modeChanged, getSession)
watch(searchable, updateSearchTerm);
watch(filtered, updateFilterTerm);
watch(notAllInstancesIcon, getMaintenanceVisitInstances);
onMounted(async () => {
getSession();

View File

@ -13,14 +13,7 @@
</div>
<div class="templateId-customer" id="customer">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Customer:</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"> {{ poi.customer }}</pre>
<select v-if="editable" id="customersDropDownChosenCI" v-model="poi.customer"
@change="updateCustomerID()" :class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="cust in customers" :key="cust.primaryID">
{{ cust.customername }}
</option>
</select>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"> {{ poi.customer }}</pre>
</div>
</div>
</div>
@ -72,8 +65,12 @@
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">User:</pre>
<pre v-if="!editable"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ poi.user }}</pre>
<input v-if="editable" v-model="poi.user" @change="updatePOI()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
<select v-if="editable" id="assetsDropDownChosenCI" v-model="poi.user" @change="updatePOI()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="user in userList" :key="user.id">
{{ user.username }}
</option>
</select>
</div>
</div>
<div class="data-field" id="info">
@ -110,23 +107,29 @@
</div>
</section>
<section v-if="addBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<input v-model="newName"
<input v-model="newName" @change="updateProductionOrderInstance()"
:class="['data', 'poi-name-input', darkMode ? 'h2-darkmode' : 'h2-lightmode', darkMode ? 'h2-input-darkmode' : 'h2-input-lightmode', 'input']">
<div class="production-orders-instance-data">
<div class="instanceInfo">
<div class="data-field" id="info">
<div class="templateId-customer" id="templateID">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template ID:</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ chosenPOTId }}</pre>
<pre v-if="potSelected"
:class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template ID:</pre>
<pre v-if="!potSelected"
:class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Template name:</pre>
<pre v-if="potSelected"
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">{{ chosenPOTId }}</pre>
<select v-if="!potSelected" id="assetsDropDownChosenCI" v-model="chosenTemplate"
@change="updateProductionOrderInstance(chosenTemplate)"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="template in productionOrderTemplates" :key="template.templateID">
{{ template.name }}
</option>
</select>
</div>
<div class="templateId-customer" id="customer">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Customer:</pre>
<select id="customersDropDownChosenCI" v-model="newCustomer" @change="updateNewCustomerID()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="cust in customers" :key="cust.primaryID">
{{ cust.customername }}
</option>
</select>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"> {{ poi.customer }}</pre>
</div>
</div>
</div>
@ -135,7 +138,7 @@
<div class="additional">
<div class="templateDescription">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Template description:</h3>
<input v-model="newTemplateDescription"
<input v-model="newTemplateDescription" @change="updateProductionOrderInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']"
id="templateDescription">
</div>
@ -143,7 +146,7 @@
<div class="additional">
<div class="templateNotes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Template notes:</h3>
<input v-model="newTemplateNotes"
<input v-model="newTemplateNotes" @change="updateProductionOrderInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="templateNotes">
</div>
</div>
@ -157,7 +160,7 @@
</div>
<div class="ticketNo-asset-state-user" id="asset">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Asset:</pre>
<select id="assetsDropDownChosenCI" v-model="newAsset"
<select id="assetsDropDownChosenCI" v-model="newAsset" @change="updateProductionOrderInstance()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="asset in assets" :key="asset.primaryID">
{{ asset.assetName }}
@ -166,25 +169,27 @@
</div>
<div class="ticketNo-asset-state-user" id="state">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">State:</pre>
<input v-model="newState"
<input v-model="newState" @change="updateProductionOrderInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
</div>
<div class="ticketNo-asset-state-user" id="user">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">User:</pre>
<input v-model="newUser"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
<select id="assetsDropDownChosenCI" v-model="newUser" @change="updateProductionOrderInstance()"
:class="[darkMode ? 'select-darkmode' : 'select-lightmode']">
<option v-for="user in userList" :key="user.id">
{{ user.username }}
</option>
</select>
</div>
</div>
<div class="data-field" id="info">
<div class="creationDate-completionDate-timeSpent" id="creationDate">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Creation date:</pre>
<pre
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
</div>
<div class="creationDate-completionDate-timeSpent" id="completionDate">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Completion date:</pre>
<pre
:class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
<pre :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']">...</pre>
</div>
<div class="creationDate-completionDate-timeSpent" id="timeSpent">
<pre :class="['label', darkMode ? 'pre-darkmode' : 'pre-lightmode']">Time spent:</pre>
@ -197,15 +202,12 @@
<div class="additional">
<div class="notes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Notes:</h3>
<input v-model="newNotes" :class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']"
id="notes">
<input v-model="newNotes" @change="updateProductionOrderInstance()"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">
</div>
</div>
</div>
</section>
<section v-if="addBool" id="saveNewPOI">
<button :class="[darkMode ? 'saveNewPOI-darkmode' : 'saveNewPOI-lightmode']" @click="addPOI()">Save</button>
</section>
</template>
@ -226,14 +228,16 @@ const deleteBool = computed(() => store.state.deleteBool);
const addBool = computed(() => store.state.new);
const darkMode = ref('');
const potSelected = ref('');
const poi = ref({});
const pot = ref({});
const customers = ref([]);
const customer = ref({});
const productionOrderInstances = ref([]);
const assets = ref([]);
const newName = ref('');
const newTemplateID = ref('');
const chosenTemplate = ref('');
const newCustomerID = ref('');
const newCustomer = ref('');
const newUser = ref('');
@ -242,8 +246,12 @@ const newNotes = ref('');
const newTemplateDescription = ref('');
const newTemplateNotes = ref('');
const newAsset = ref('');
const newCreationDate = ref('');
const newCompletionDate = ref('');
const newTimeSpent = ref('');
const productionOrderInstances = ref([]);
const productionOrderTemplates = ref([]);
const userList = ref([]);
//get all customers
const getCustomers = async () => {
@ -256,6 +264,57 @@ const getCustomers = async () => {
}
}
//get all productionOrder templates
const getProductionOrderTemplates = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderTemplates`);
productionOrderTemplates.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
// get production order template from id
const getPOTById = async () => {
if (chosenPOTId.value == '-1') {
potSelected.value = false;
await getProductionOrderTemplates();
} else {
potSelected.value = true;
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getProductionOrderTemplate/${chosenPOTId.value}`
);
pot.value = response.data;
poi.value.customer = pot.value.customer;
poi.value.customerID = pot.value.customerID;
newCustomer.value = pot.value.customer;
newCustomerID.value = pot.value.customerID;
await getConfigItemsFromCustomer();
} catch (err) {
console.log(err.response.statusText);
}
}
await getProductionOrderInstances();
}
// get production order template from id
const getChosenPOTById = async (newPotId) => {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getProductionOrderTemplate/${newPotId}`
);
pot.value = response.data;
poi.value.customer = pot.value.customer;
poi.value.customerID = pot.value.customerID;
newCustomer.value = pot.value.customer;
newCustomerID.value = pot.value.customerID;
await getConfigItemsFromCustomer();
} catch (err) {
console.log(err.response.statusText);
}
}
const confirmDeletePOI = async () => {
if (deleteBool.value === true) {
if (confirm("Do you really want to delete this production order instance? It cannot be undone!")) {
@ -271,18 +330,19 @@ const confirmDeletePOI = async () => {
}
store.commit('undoDelete');
store.commit('resetStore');
store.commit('changeToTemplatelist');
store.commit('changeToInstancelist');
store.commit('seeAllIcon');
} else {
store.commit('undoDelete');
}
}
}
//get all productionOrder instances
const getProductionOrderInstances = async () => {
//get all users
const getUsers = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderInstances`);
productionOrderInstances.value = response.data;
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllEmployees`);
userList.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
@ -333,98 +393,60 @@ const updatePOI = async () => {
}
}
// add new production order instance
const addPOI = async () => {
// check if all input data is valid
if (newName.value.trim() === "") {
alert("Please add a production order instance name!");
return;
} else {
var counter = 0;
if (!(productionOrderInstances.value.length == null)) {
// check if production order instance name already exists
productionOrderInstances.value.forEach(p => {
if (p.name === newName.value) {
counter += 1;
}
});
if (counter == 1) {
alert("This production order instance name already exists. Please choose an unique production order instance name or modify respectively delete the old one!");
return;
}
}
}
if (newCustomer.value.length === 0) {
alert("Please choose a customer!");
return;
}
// get the time and date
const today = new Date();
const date = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + today.getDate();
const time = today.getHours() + ":" + today.getMinutes();
const dateTime = date + ' ' + time;
// add todos
// let allFine = true;
// newTodos.forEach(todo => {
// if (todo.asset.length === 0) {
// alert(`Please choose a config item for all todos.`);
// allFine = false
// }
// })
// if (!allFine) {
// return
// }
//get all productionOrder instances
const getProductionOrderInstances = async () => {
try {
const response = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addPOI`,
{
name: newName.value,
templateID: chosenPOTId.value,
customerID: newCustomerID.value,
customer: newCustomer.value,
asset: newAsset.value,
state: newState.value,
creationDate: dateTime,
completionDate: newCompletionDate.value,
user: newUser.value,
templateDescription: newTemplateDescription.value,
templateNotes: newTemplateNotes.value,
timeSpent: newTimeSpent.value,
notes: newNotes.value,
});
store.commit('resetStore');
store.commit('changeToTemplatelist');
// newTodos.forEach(async todo => {
// try {
// const res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/addTodoPOT`,
// {
// templateID: response.data,
// rowID: todo.rowID,
// asset: todo.asset,
// task: todo.task,
// comment: todo.comments,
// });
// } catch (err) {
// console.log(err.response.statusText);
// }
// })
} catch (err) {
// console.log(err.response.statusText);
console.log(err);
}
}
// update customerid if customer was changed
const updateCustomerID = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCustomerByName/${poi.value.customer}`);
customer.value = response.data;
poi.value.customerID = customer.value.customerID;
store.commit('toggleCustomerChanged');
store.commit('toggleCustomerId', poi.value.customerID);
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderInstances`);
productionOrderInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
await updatePOI();
}
// update production order instance fields in the store
const updateProductionOrderInstance = async (newPotId = -1) => {
let productionOrderInstance = {};
if (potSelected.value) {
productionOrderInstance = {
name: newName.value,
templateID: chosenPOTId.value,
customerID: newCustomerID.value,
customer: newCustomer.value,
asset: newAsset.value,
state: newState.value,
creationDate: newCreationDate.value,
completionDate: newCompletionDate.value,
user: newUser.value,
templateDescription: newTemplateDescription.value,
templateNotes: newTemplateNotes.value,
timeSpent: newTimeSpent.value,
notes: newNotes.value,
};
} else {
if (!(newPotId == '-1')) {
// Find the object with the selected Name
const selectedObject = productionOrderTemplates.value.find(obj => obj.name === newPotId);
// Get the templateID
newTemplateID.value = selectedObject ? selectedObject.templateID : null;
await getChosenPOTById(newTemplateID.value);
}
productionOrderInstance = {
name: newName.value,
templateID: newTemplateID.value,
customerID: newCustomerID.value,
customer: newCustomer.value,
asset: newAsset.value,
state: newState.value,
creationDate: newCreationDate.value,
completionDate: newCompletionDate.value,
user: newUser.value,
templateDescription: newTemplateDescription.value,
templateNotes: newTemplateNotes.value,
timeSpent: newTimeSpent.value,
notes: newNotes.value,
};
}
store.commit('updateProductionOrderInstanceComponent', productionOrderInstance);
}
// get production order instance from id
@ -439,18 +461,6 @@ const getPOIById = async () => {
console.log(err.response.statusText);
}
}
await getConfigItemsFromCustomer();
}
// update customerid if customer was changed
const updateNewCustomerID = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCustomerByName/${newCustomer.value}`);
newCustomerID.value = response.data.customerID;
} catch (err) {
console.log(err.response.statusText);
}
await getConfigItemsFromCustomer();
}
// include delay to avoid 503 error
@ -478,14 +488,12 @@ const getConfigItemsFromCustomer = async () => {
} catch (err) {
console.log(err.response.statusText);
}
} else {
if (newCustomerID.value.length != 0) {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCIFromCustomer/${newCustomerID.value}`);
assets.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
} else if (!(newCustomerID.value == '')) {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getCIFromCustomer/${newCustomerID.value}`);
assets.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
}
@ -500,12 +508,14 @@ function getItem(item) {
watch(modeChanged, getSession);
watch(deleteBool, confirmDeletePOI);
watch(editable, getConfigItemsFromCustomer);
onMounted(async () => {
getSession();
await getPOIById();
await getProductionOrderInstances();
await getPOTById();
triggerBackendCallsWithDelay(getCustomers);
triggerBackendCallsWithDelay(getUsers);
});
</script>
@ -564,42 +574,6 @@ export default {
sans-serif;
}
.saveNewPOI-darkmode {
background: #2c2c2c;
color: #fff;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOI-lightmode {
background: #EBEBEB;
color: #212121;
font: 400 0.875rem/1.875rem Overpass, sans-serif;
border: none;
padding: 1rem 1.875rem;
width: 8%;
border-radius: 0.625rem;
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
}
.saveNewPOI-darkmode:hover {
background-color: #444444;
cursor: pointer;
}
.saveNewPOI-lightmode:hover {
background-color: #ACACAC;
cursor: pointer;
}
#saveNewPOI {
text-align: center;
}
.h2-darkmode {
color: #fff;
}

View File

@ -43,7 +43,12 @@
</td>
<td
:class="['Asset', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Asset-darkmode' : 'Asset-lightmode']">
{{ instance.asset }}</td>
<nuxt-link to="/assets" id="nuxt-link" class="button"
:class="[darkMode ? 'button-darkmode' : 'button-lightmode', darkMode ? 'nuxt-link-darkmode' : 'nuxt-link-lightmode']"
@click="goToChosenAsset(instance.asset)">
{{ instance.asset }}
</nuxt-link>
</td>
<td
:class="['State', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'State-darkmode' : 'State-lightmode']">
{{ instance.state }}</td>
@ -74,6 +79,7 @@ const modeChanged = computed(() => store.state.updateDarkMode);
const chosenPOTId = computed(() => store.state.chosenPOTId);
const searchable = computed(() => store.state.searchable);
const filtered = computed(() => store.state.filtered);
const notAllInstancesIcon = computed(() => store.state.notAllInstancesIcon);
const userSearchFilter = ref('');
const stateSearchFilter = ref('');
const productionOrderInstances = ref([]);
@ -90,11 +96,20 @@ const goToChosenPOI = (id) => {
//get all production order instances
const getProductionOrderInstances = async () => {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getSelectedPOIsByPOT/${pot.value.templateID}`);
productionOrderInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
if (notAllInstancesIcon.value) {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getSelectedPOIsByPOT/${pot.value.templateID}`);
productionOrderInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
} else {
try {
const response = await Axios.get(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getAllProductionOrderInstances`);
productionOrderInstances.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
}
@ -112,16 +127,34 @@ const updateFilterTerm = async () => {
// get production order template from id
const getPOTById = async () => {
if (notAllInstancesIcon.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getProductionOrderTemplate/${chosenPOTId.value}`
);
pot.value = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
await getProductionOrderInstances();
}
const goToChosenAsset = async (name) => {
let ci = {}
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getProductionOrderTemplate/${chosenPOTId.value}`
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getSelectedConfigItemsByAsset/${name}`
);
pot.value = response.data;
await getProductionOrderInstances();
ci = response.data;
} catch (err) {
console.log(err.response.statusText);
}
}
store.commit('setChosenAsset', ci[0].primaryID);
setTimeout(() => {
}, 1000);
store.commit('changeToAsset');
};
//get all instances based on the searched state
const filterPOIByState = async () => {
@ -179,6 +212,7 @@ function getItem(item) {
watch(modeChanged, getSession)
watch(searchable, updateSearchTerm);
watch(filtered, updateFilterTerm);
watch(notAllInstancesIcon, getProductionOrderInstances);
onMounted(async () => {
getSession();