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

@ -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;
}