n8n/packages/editor-ui/src/views/ExecutionsView.vue
Csaba Tuncsik 3e0c6cb3d2
Some checks are pending
Test Master / install-and-build (push) Waiting to run
Test Master / Unit tests (18.x) (push) Blocked by required conditions
Test Master / Unit tests (20.x) (push) Blocked by required conditions
Test Master / Unit tests (22.4) (push) Blocked by required conditions
Test Master / Lint (push) Blocked by required conditions
Test Master / Notify Slack on failure (push) Blocked by required conditions
refactor(editor): Move executions under projects (#11541)
2024-11-12 17:01:22 +01:00

92 lines
2.7 KiB
Vue

<script lang="ts" setup>
import { onBeforeMount, onBeforeUnmount, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import GlobalExecutionsList from '@/components/executions/global/GlobalExecutionsList.vue';
import { useI18n } from '@/composables/useI18n';
import { useTelemetry } from '@/composables/useTelemetry';
import { useExternalHooks } from '@/composables/useExternalHooks';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { useExecutionsStore } from '@/stores/executions.store';
import { useToast } from '@/composables/useToast';
import { useDocumentTitle } from '@/composables/useDocumentTitle';
import { storeToRefs } from 'pinia';
import type { ExecutionFilterType } from '@/Interface';
const route = useRoute();
const i18n = useI18n();
const telemetry = useTelemetry();
const externalHooks = useExternalHooks();
const workflowsStore = useWorkflowsStore();
const executionsStore = useExecutionsStore();
const documentTitle = useDocumentTitle();
const toast = useToast();
const { executionsCount, executionsCountEstimated, filters, allExecutions } =
storeToRefs(executionsStore);
onBeforeMount(async () => {
await loadWorkflows();
void externalHooks.run('executionsList.openDialog');
telemetry.track('User opened Executions log', {
workflow_id: workflowsStore.workflowId,
});
});
onMounted(async () => {
documentTitle.set(i18n.baseText('executionsList.workflowExecutions'));
document.addEventListener('visibilitychange', onDocumentVisibilityChange);
await executionsStore.initialize();
});
onBeforeUnmount(() => {
executionsStore.reset();
document.removeEventListener('visibilitychange', onDocumentVisibilityChange);
});
async function loadWorkflows() {
try {
await workflowsStore.fetchAllWorkflows(route.params?.projectId as string | undefined);
} catch (error) {
toast.showError(error, i18n.baseText('executionsList.showError.loadWorkflows.title'));
}
}
function onDocumentVisibilityChange() {
if (document.visibilityState === 'hidden') {
executionsStore.stopAutoRefreshInterval();
} else {
void executionsStore.startAutoRefreshInterval();
}
}
async function onRefreshData() {
try {
await executionsStore.fetchExecutions();
} catch (error) {
toast.showError(error, i18n.baseText('executionsList.showError.refreshData.title'));
}
}
async function onUpdateFilters(newFilters: ExecutionFilterType) {
executionsStore.reset();
executionsStore.setFilters(newFilters);
await executionsStore.initialize();
}
async function onExecutionStop() {
await onRefreshData();
}
</script>
<template>
<GlobalExecutionsList
:executions="allExecutions"
:filters="filters"
:total="executionsCount"
:estimated-total="executionsCountEstimated"
@execution:stop="onExecutionStop"
@update:filters="onUpdateFilters"
/>
</template>