Merge branch 'beta' into import_quasar_js
gitea/hedera-web/pipeline/pr-beta This commit looks good Details

This commit is contained in:
Javier Segarra 2025-04-03 13:53:17 +00:00
commit 4f922b0512
3 changed files with 55 additions and 53 deletions

View File

@ -3,11 +3,10 @@ import { useI18n } from 'vue-i18n';
import { ref, onMounted, inject, reactive, computed } from 'vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnForm from 'src/components/common/VnForm.vue';
import VnInput from 'src/components/common/VnInput.vue';
import useNotify from 'src/composables/useNotify.js';
import FormModel from 'src/components/common/FormModel.vue';
const jApi = inject('jApi');
const api = inject('api');
const { t } = useI18n();
const { notify } = useNotify();
@ -33,7 +32,7 @@ const statusIcons = {
}
};
const formInitialData = reactive({
schema: 'catalog',
collectionFk: 'catalog',
updateMatching: true
});
const imageCollections = ref([]);
@ -45,9 +44,8 @@ const isSubmitable = computed(() =>
const getImageCollections = async () => {
try {
imageCollections.value = await jApi.query(
'SELECT name, `desc` FROM imageCollection ORDER BY `desc`'
);
const { data } = await api.get('imageCollections');
imageCollections.value = data;
} catch (error) {
console.error('Error getting image collections:', error);
}
@ -61,38 +59,36 @@ const onSubmit = async data => {
const filteredFiles = addedFiles.value.filter(
file => file.uploadStatus === 'pending'
);
const promises = filteredFiles.map((file, index) => {
const promises = filteredFiles.map(async (file, index) => {
const fileIndex = filteredFiles[index].index;
addedFiles.value[fileIndex].uploadStatus = 'uploading';
const formData = new FormData();
formData.append('updateMatching', data.updateMatching);
formData.append('image', file.file);
formData.append('name', file.name);
formData.append('schema', data.schema);
formData.append('srv', 'json:image/upload');
return api({
method: 'post',
url: location.origin,
data: formData,
const now = new Date();
const timestamp = now.getTime();
const fileName = `${file.name}_${timestamp}`;
formData.append('image', file.file, fileName);
await api.post('images/uploadPhotoAdmin', formData, {
params: {
name: fileName,
collection: data.collectionFk,
updateMatching: data.updateMatching
},
headers: {
'Content-Type': 'multipart/form-data'
}
});
});
const results = await Promise.allSettled(promises);
results.forEach((result, index) => {
const fileIndex = filteredFiles[index].index;
addedFiles.value[fileIndex].uploadStatus = result.status;
if (result.status === 'rejected') {
addedFiles.value[fileIndex].errorMessage = t(
result.reason?.response?.data?.data?.message
);
}
});
const allSuccessful = results.every(
result => result.status === 'fulfilled'
);
@ -139,16 +135,17 @@ onMounted(async () => getImageCollections());
<template>
<QPage class="vn-w-sm">
<VnForm
<FormModel
ref="vnFormRef"
:default-actions="false"
:form-initial-data="formInitialData"
separation-between-inputs="md"
show-bottom-actions
:save-fn="onSubmit"
>
<template #form="{ data }">
<VnSelect
v-model="data.schema"
v-model="data.collectionFk"
:label="t('collection')"
option-label="desc"
option-value="name"
@ -269,7 +266,7 @@ onMounted(async () => getImageCollections());
data-cy="photoUploadSubmitBtn"
/>
</template>
</VnForm>
</FormModel>
</QPage>
</template>

View File

@ -10,7 +10,7 @@ import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
const { t } = useI18n();
const jApi = inject('jApi');
const api = inject('api');
const route = useRoute();
const router = useRouter();
const appStore = useAppStore();
@ -24,28 +24,21 @@ const visitsData = ref(null);
const getVisits = async () => {
try {
loading.value = true;
const [visitsResponse] = await jApi.query(
`SELECT browser,
MIN(CAST(version AS DECIMAL(4,1))) minVersion,
MAX(CAST(version AS DECIMAL(4,1))) maxVersion,
MAX(c.stamp) lastVisit,
COUNT(DISTINCT c.id) visits,
SUM(a.firstAccessFk = c.id AND v.firstAgentFk = a.id) newVisits
FROM visitUser e
JOIN visitAccess c ON c.id = e.accessFk
JOIN visitAgent a ON a.id = c.agentFk
JOIN visit v ON v.id = a.visitFk
WHERE c.stamp BETWEEN TIMESTAMP(#from,'00:00:00') AND TIMESTAMP(#to,'23:59:59')
GROUP BY browser ORDER BY visits DESC`,
{
const { data } = await api.get('visitUsers/getVisits', {
params: {
from: date(from.value),
to: date(to.value)
}
);
visitsData.value = visitsResponse;
loading.value = false;
});
if (!data || !data.length) return;
visitsData.value = data[0];
} catch (error) {
console.error('Error getting visits:', error);
} finally {
loading.value = false;
}
};

View File

@ -8,9 +8,10 @@ import { currency, formatDate } from 'src/lib/filters.js';
import { usePrintService } from 'src/composables/usePrintService';
import { useAppStore } from 'stores/app';
import { storeToRefs } from 'pinia';
import { onUserId } from 'src/utils/onUserId';
const { t } = useI18n();
const jApi = inject('jApi');
const api = inject('api');
const { openReport } = usePrintService();
const appStore = useAppStore();
const { isHeaderMounted } = storeToRefs(appStore);
@ -50,27 +51,38 @@ const columns = computed(() => [
}
]);
const fetchInvoices = async () => {
const params = {
const fetchInvoices = async clientFk => {
const { from, to } = {
from: new Date(currentYear.value, 0),
to: new Date(currentYear.value, 11, 31, 23, 59, 59)
};
invoices.value = await jApi.query(
`SELECT id, ref, issued, amount, hasPdf
FROM myInvoice
WHERE issued BETWEEN #from AND #to
ORDER BY issued DESC
LIMIT 100`,
params
);
const filter = {
where: {
clientFk,
issued: {
between: [from, to]
}
},
order: ['issued DESC'],
fields: ['id', 'ref', 'issued', 'amount', 'hasPdf'],
limit: 100
};
const { data } = await api.get('InvoiceOuts', {
params: {
filter: JSON.stringify(filter)
}
});
invoices.value = data;
};
onMounted(async () => {
await fetchInvoices();
for (let year = currentYear.value - 5; year <= currentYear.value; year++) {
years.value.push(year);
}
});
onUserId(fetchInvoices);
</script>
<template>