This commit is contained in:
Johanna Kuehner
2024-03-04 19:31:17 +01:00
82 changed files with 5647 additions and 343 deletions

View File

@ -1,5 +1,5 @@
<template>
<section v-if="!addAssetBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<section v-if="!addBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<h2 v-if="!editable" :class="['asset-name', darkMode ? 'h2-darkmode' : 'h2-lightmode']">{{
item.assetName }}</h2>
<input v-if="editable" v-model="item.assetName" @change="updateConfigItem()"
@ -77,7 +77,7 @@
</div>
</div>
</section>
<section v-if="addAssetBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<section v-if="addBool" :class="['information', darkMode ? 'section-darkmode' : 'section-lightmode']">
<input v-model="newAssetName" @change="updateAsset()"
:class="['data', 'asset-name-input', darkMode ? 'h2-darkmode' : 'h2-lightmode', darkMode ? 'h2-input-darkmode' : 'h2-input-lightmode', 'input']">
<div class="asset-data">
@ -153,10 +153,10 @@ import { useStore } from 'vuex';
import { computed } from 'vue';
const store = useStore();
const editable = computed(() => store.state.assetEditable);
const editable = computed(() => store.state.editable);
const chosenAssetId = computed(() => store.state.chosenAssetId);
const deleteAssetBool = computed(() => store.state.deleteAsset);
const addAssetBool = computed(() => store.state.newAsset);
const deleteBool = computed(() => store.state.deleteBool);
const addBool = computed(() => store.state.new);
const darkMode = ref(true);
const item = ref({});
@ -176,7 +176,7 @@ const newState = ref('');
// get config item from id
const getItemById = async () => {
if (!addAssetBool.value) {
if (!addBool.value) {
try {
const response = await Axios.get(
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${chosenAssetId.value}`
@ -200,7 +200,7 @@ const updateAsset = () => {
description: newDescription.value,
notes: newNotes.value,
state: newState.value
};
};
store.commit('updateAssetComponent', asset);
}
@ -275,17 +275,17 @@ const getCustomers = async () => {
}
const confirmDeleteAsset = async () => {
if (deleteAssetBool.value === true) {
if (deleteBool.value === true) {
if (confirm("Do you really want to delete this config item? It cannot be undone!")) {
try {
await Axios.delete(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/deleteConfigItem/${chosenAssetId.value}`);
store.commit('undoDeleteAsset');
store.commit('undoDelete');
store.commit('changeToAssetlist');
} catch (err) {
console.log(err.response.statusText);
}
} else {
store.commit('undoDeleteAsset');
store.commit('undoDelete');
}
}
}
@ -330,14 +330,13 @@ const triggerBackendCallsWithDelay = async (fetchDataFunc) => {
}, 1500);
}
watch(deleteAssetBool, confirmDeleteAsset);
watch(deleteBool, confirmDeleteAsset);
onMounted(() => {
getItemById();
getConfigItems();
triggerBackendCallsWithDelay(getCustomers);
});
</script>
<script>