addded single asset

This commit is contained in:
2024-02-16 15:53:27 +01:00
parent e900ff4777
commit e18c605c8c
34 changed files with 972 additions and 1749 deletions

View File

@ -53,8 +53,8 @@
<div class="additional">
<div class="description">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Description:</h3>
<pre v-if="!editable" :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"
id="description">{{ item.description }}</pre>
<input v-if="!editable" v-model="item.description"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="description">
<input v-if="editable" v-model="item.description"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="description">
</div>
@ -62,8 +62,8 @@
<div class="additional">
<div class="notes">
<h3 :class="['area-title', darkMode ? 'h3-darkmode' : 'h3-lightmode']">Notes:</h3>
<pre v-if="!editable" :class="['data', darkMode ? 'data-darkmode' : 'data-lightmode']"
id="notes">{{ item.notes }}</pre>
<input v-if="!editable" v-model="item.notes"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">
<input v-if="editable" v-model="item.notes"
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']" id="notes">
</div>
@ -84,11 +84,10 @@ const item = ref({});
// get config item from id
const getItemById = async () => {
// later itemIndex from route params
let itemIndex = 9;
console.log(this.chosenAssetId)
try {
const response = await Axios.get(
`https://${serversideConfig.url}:3000/api/getConfigItem/${itemIndex}`
`https://${serversideConfig.url}:3000/api/getConfigItem/${chosenAssetId}`
);
item.value = response.data;
} catch (err) {
@ -96,6 +95,63 @@ const getItemById = async () => {
}
}
//update data
const updateConfigItem = async () => {
if (item.assetName.trim() === "") {
alert("Please add a config item name!");
return;
} else {
var counter = 0;
//later check if ci already exists
// for (let key in item.value) {
// if (this.configItems[key].assetName === this.item.assetName) {
// counter += 1;
// }
// }
if (counter == 1) {
alert("This asset name already exists. Please choose an unique asset name or modify respectively delete the old one!");
return;
}
try {
await Axios.put(
`https://${serversideConfig.url}:3000/api/updateConfigItem/${itemIndex}`,
{
primaryID: item.primaryID,
assetName: item.assetName,
customerID: item.customerID,
customer: item.customer,
location: item.location,
remoteLocation: item.remoteLocation,
type: item.type,
description: item.description,
notes: item.notes,
state: item.state,
lastView: item.lastView,
user: item.user,
hardwareBool: item.hardwareBool,
model: item.model,
serialnumber: item.serialnumber,
CPU: item.CPU,
RAM: item.RAM,
storageConfiguration: item.storageConfiguration,
miscellaneous: item.miscellaneous,
softwareBool: item.softwareBool,
software: item.software,
version: item.version,
licence: item.licence,
networkBool: item.networkBool,
IPv4: item.IPv4,
IPv6: item.IPv6,
MAC: item.MAC,
subnetmask: item.subnetmask,
}
);
} catch (err) {
console.log(err);
}
}
}
onMounted(() => {
getItemById();
// console.log(editable.value)
@ -109,6 +165,9 @@ export default {
computed: {
editable() {
return this.$store.state.assetEditable
},
chosenAssetId() {
return this.$store.state.chosenAssetId
}
},
}
@ -209,7 +268,7 @@ export default {
.data {
display: flex;
flex-direction: row;
overflow-x: auto;
align-items: flex-start;
padding: 0 0.625rem;
border-radius: 0.3125rem;
@ -231,6 +290,9 @@ export default {
.data#notes,
.data#description {
align-self: stretch;
/* width: 45%; */
scrollbar-width: none;
overflow-x: auto;
}
.asset-data {