add config item
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<section :class="['software-information', darkMode ? 'section-darkmode' : 'section-lightmode']">
|
||||
<section v-if="softwareBoolean && !addAssetBool"
|
||||
:class="['software-information', darkMode ? 'section-darkmode' : 'section-lightmode']">
|
||||
<div :class="['label', darkMode ? 'label-darkmode' : 'label-lightmode']" id="software">Software specifications:
|
||||
<div class="asset-data">
|
||||
<table class="data-table" id="asset-table-no-client">
|
||||
@ -43,6 +44,41 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section v-if="addAssetBool" :class="['software-information', darkMode ? 'section-darkmode' : 'section-lightmode']">
|
||||
<div :class="['label', darkMode ? 'label-darkmode' : 'label-lightmode']" id="software">Software specifications:
|
||||
<div class="asset-data">
|
||||
<table class="data-table" id="asset-table-no-client">
|
||||
<tbody>
|
||||
<tr :class="['table-row', darkMode ? 'tr-head-darkmode' : 'tr-head-lightmode']" id="table-head">
|
||||
<th
|
||||
:class="['Software', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Software-darkmode' : 'Software-lightmode']">
|
||||
Software</th>
|
||||
<th
|
||||
:class="['Version', darkMode ? 'th-darkmode' : 'th-lightmode', darkMode ? 'Version-darkmode' : 'Version-lightmode']">
|
||||
Version</th>
|
||||
<th :class="['License', darkMode ? 'th-darkmode' : 'th-lightmode']">License</th>
|
||||
</tr>
|
||||
<tr :class="['table-row', darkMode ? 'tr-darkmode' : 'tr-lightmode']" id="row-1">
|
||||
<td
|
||||
:class="['Software', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Software-darkmode' : 'Software-lightmode']">
|
||||
<input type="text" v-model="newSoftware" @change="updateAsset()"
|
||||
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
|
||||
</td>
|
||||
<td
|
||||
:class="['Version', darkMode ? 'td-darkmode' : 'td-lightmode', darkMode ? 'Version-darkmode' : 'Version-lightmode']">
|
||||
<input type="text" v-model="newVersion" @change="updateAsset()"
|
||||
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
|
||||
</td>
|
||||
<td :class="['License', darkMode ? 'td-darkmode' : 'td-lightmode']">
|
||||
<input type="text" v-model="newLicense" @change="updateAsset()"
|
||||
:class="['data', 'input', darkMode ? 'data-darkmode' : 'data-lightmode']">
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -55,6 +91,12 @@ import { computed } from 'vue';
|
||||
const store = useStore();
|
||||
const editable = computed(() => store.state.assetEditable);
|
||||
const chosenAssetId = computed(() => store.state.chosenAssetId);
|
||||
const addAssetBool = computed(() => store.state.newAsset);
|
||||
|
||||
const newSoftwareBool = ref(true);
|
||||
const newSoftware = ref('');
|
||||
const newVersion = ref('');
|
||||
const newLicense = ref('');
|
||||
|
||||
const darkMode = ref(true)
|
||||
const item = ref({});
|
||||
@ -67,10 +109,6 @@ const getItemById = async () => {
|
||||
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${chosenAssetId.value}`
|
||||
);
|
||||
item.value = response.data;
|
||||
if ((item.value.softwareBool == 1) && (item.value.version.trim() === "") && (item.value.software.trim() === "")) {
|
||||
item.value.softwareBool = 0;
|
||||
softwareBoolean.value = false;
|
||||
};
|
||||
if (item.value.softwareBool == 1) {
|
||||
softwareBoolean.value = true;
|
||||
};
|
||||
@ -79,8 +117,25 @@ const getItemById = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// update software fields in the store
|
||||
const updateAsset = () => {
|
||||
if (newSoftware.value.length == 0 && newLicense.value.length == 0 && newVersion.value.length == 0) {
|
||||
newSoftwareBool.value = false
|
||||
}
|
||||
const asset = {
|
||||
softwareBool: newSoftwareBool.value,
|
||||
software: newSoftware.value,
|
||||
version: newVersion.value,
|
||||
license: newLicense.value,
|
||||
};
|
||||
store.commit('updateSoftwareComponent', asset);
|
||||
}
|
||||
|
||||
//update data
|
||||
const updateConfigItem = async () => {
|
||||
if (item.value.license.length === 0 && item.value.version.length === 0 && item.value.software.length === 0) {
|
||||
item.value.softwareBool = 0;
|
||||
}
|
||||
try {
|
||||
await Axios.put(
|
||||
`https://${clientsideConfig.url}:${clientsideConfig.port}/api/updateConfigItem`,
|
||||
@ -139,7 +194,6 @@ export default {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 1.25rem 1.875rem;
|
||||
border-radius: 0.625rem;
|
||||
box-shadow: 0.25rem 0.25rem 0.25rem 0rem rgba(0, 0, 0, 0.25);
|
||||
|
||||
Reference in New Issue
Block a user