8315-devToTest #1094

Merged
alexm merged 253 commits from 8315-devToTest into test 2024-12-18 10:31:55 +00:00
7 changed files with 90 additions and 19 deletions
Showing only changes of commit 8817fd7c55 - Show all commits

View File

@ -1,10 +1,17 @@
import { ref } from 'vue';
import axios from 'axios';
import { boot } from 'quasar/wrappers'; import { boot } from 'quasar/wrappers';
import qFormMixin from './qformMixin'; import qFormMixin from './qformMixin';
import keyShortcut from './keyShortcut'; import keyShortcut from './keyShortcut';
import { i18n } from './i18n';
import useNotify from 'src/composables/useNotify.js'; import useNotify from 'src/composables/useNotify.js';
import { CanceledError } from 'axios'; import { useStateQueryStore } from 'src/stores/useStateQueryStore';
import VnInput from 'src/components/common/VnInput.vue';
import { useVnConfirm } from 'src/composables/useVnConfirm';
const { notify } = useNotify(); const { notify } = useNotify();
const stateQuery = useStateQueryStore();
const { openConfirmationModal } = useVnConfirm();
export default boot(({ app }) => { export default boot(({ app }) => {
app.mixin(qFormMixin); app.mixin(qFormMixin);
@ -40,12 +47,57 @@ export default boot(({ app }) => {
} }
console.error(error); console.error(error);
if (error instanceof CanceledError) { if (error instanceof axios.CanceledError) {
const env = process.env.NODE_ENV; const env = process.env.NODE_ENV;
if (env && env !== 'development') return; if (env && env !== 'development') return;
message = 'Duplicate request'; message = 'Duplicate request';
} }
// Convey to Alex or Juan...
const additionalData = {
frontPath: stateQuery.route.name,
backError: {
config: error.config,
data: error,
},
httpRequest: error.request.response,
};
notify(message ?? 'globals.error', 'negative', 'error'); const opts = {
actions: [
{
icon: 'support_agent',
color: 'primary',
dense: true,
flat: false,
round: true,
noDismiss: true,
handler: async () => {
const reason = ref();
openConfirmationModal(
i18n.global.t('globals.sendCau'),
false,
async () => {
await axios.post('OsTickets/send-to-support', {
reason: reason.value,
additionalData,
});
},
null,
{
component: VnInput,
props: {
modelValue: reason,
'onUpdate:modelValue': (val) => (reason.value = val),
label: i18n.global.t('globals.ExplainReason'),
class: 'full-width',
required: true,
},
}
);
},
},
],
};
notify(message ?? 'globals.error', 'negative', 'error', opts);
}; };
}); });

View File

@ -1,6 +1,7 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useStateQueryStore } from 'src/stores/useStateQueryStore'; import { useStateQueryStore } from 'src/stores/useStateQueryStore';
@ -17,8 +18,10 @@ const stateQuery = useStateQueryStore();
const state = useState(); const state = useState();
const user = state.getUser(); const user = state.getUser();
const appName = 'Lilium'; const appName = 'Lilium';
onMounted(() => {
onMounted(() => stateStore.setMounted()); stateStore.setMounted();
stateQuery.add(useRoute());
});
const pinnedModulesRef = ref(); const pinnedModulesRef = ref();
</script> </script>

View File

@ -2,7 +2,7 @@ import { Notify } from 'quasar';
import { i18n } from 'src/boot/i18n'; import { i18n } from 'src/boot/i18n';
export default function useNotify() { export default function useNotify() {
const notify = (message, type, icon) => { const notify = (message, type, icon, opts = {}) => {
const defaultIcons = { const defaultIcons = {
warning: 'warning', warning: 'warning',
negative: 'error', negative: 'error',
@ -13,6 +13,7 @@ export default function useNotify() {
message: i18n.global.t(message), message: i18n.global.t(message),
type: type, type: type,
icon: icon ? icon : defaultIcons[type], icon: icon ? icon : defaultIcons[type],
...opts,
}); });
}; };

View File

@ -1,20 +1,27 @@
import { h } from 'vue';
import { Dialog } from 'quasar';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
import { useQuasar } from 'quasar';
export function useVnConfirm() { export function useVnConfirm() {
const quasar = useQuasar(); const openConfirmationModal = (
title,
const openConfirmationModal = (title, message, promise, successFn) => { message,
quasar promise,
.dialog({ successFn,
component: VnConfirm, customHTML = {}
componentProps: { ) => {
const { component, props } = customHTML;
Dialog.create({
component: h(
VnConfirm,
{
title: title, title: title,
message: message, message: message,
promise: promise, promise: promise,
}, },
}) { customHTML: () => h(component, props) }
.onOk(async () => { ),
}).onOk(async () => {
if (successFn) successFn(); if (successFn) successFn();
}); });
}; };

View File

@ -314,6 +314,8 @@ globals:
deleteConfirmTitle: Delete selected elements deleteConfirmTitle: Delete selected elements
changeState: Change state changeState: Change state
raid: 'Raid {daysInForward} days' raid: 'Raid {daysInForward} days'
sendCau: Send cau
ExplainReason: Explain why this error should not appear
errors: errors:
statusUnauthorized: Access denied statusUnauthorized: Access denied
statusInternalServerError: An internal server error has ocurred statusInternalServerError: An internal server error has ocurred

View File

@ -318,6 +318,9 @@ globals:
deleteConfirmTitle: Eliminar los elementos seleccionados deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado changeState: Cambiar estado
raid: 'Redada {daysInForward} días' raid: 'Redada {daysInForward} días'
sendCau: Enviar cau
ExplainReason: Explique el motivo por el que no deberia aparecer este fallo
By sending this ticket, all the data related to the error, the section, the user, etc., are already sent.: Al enviar este cau ya se envían todos los datos relacionados con el error, la sección, el usuario, etc
errors: errors:
statusUnauthorized: Acceso denegado statusUnauthorized: Acceso denegado
statusInternalServerError: Ha ocurrido un error interno del servidor statusInternalServerError: Ha ocurrido un error interno del servidor

View File

@ -3,7 +3,9 @@ import { defineStore } from 'pinia';
export const useStateQueryStore = defineStore('stateQueryStore', () => { export const useStateQueryStore = defineStore('stateQueryStore', () => {
const queries = ref(new Set()); const queries = ref(new Set());
const route = computed(() =>
Array.from(queries.value).find((query) => query?.fullPath)
);
function add(query) { function add(query) {
queries.value.add(query); queries.value.add(query);
return query; return query;
@ -27,5 +29,6 @@ export const useStateQueryStore = defineStore('stateQueryStore', () => {
remove, remove,
queries, queries,
reset, reset,
route,
}; };
}); });