2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
2022-12-11 05:10:54 -08:00
|
|
|
<div v-if="windowVisible" :class="['binary-data-window', binaryData?.fileType]">
|
2021-08-29 04:36:17 -07:00
|
|
|
<n8n-button
|
2019-06-23 03:35:23 -07:00
|
|
|
size="small"
|
|
|
|
class="binary-data-window-back"
|
2021-12-15 04:16:53 -08:00
|
|
|
:title="$locale.baseText('binaryDataDisplay.backToOverviewPage')"
|
2021-08-29 04:36:17 -07:00
|
|
|
icon="arrow-left"
|
2021-12-15 04:16:53 -08:00
|
|
|
:label="$locale.baseText('binaryDataDisplay.backToList')"
|
2023-12-28 00:49:58 -08:00
|
|
|
@click.stop="closeWindow"
|
2021-08-29 04:36:17 -07:00
|
|
|
/>
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
<div class="binary-data-window-wrapper">
|
2020-12-26 14:11:25 -08:00
|
|
|
<div v-if="!binaryData">
|
2021-12-15 04:16:53 -08:00
|
|
|
{{ $locale.baseText('binaryDataDisplay.noDataFoundToDisplay') }}
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
2023-12-28 00:49:58 -08:00
|
|
|
<BinaryDataDisplayEmbed v-else :binary-data="binaryData" />
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2024-06-18 01:50:28 -07:00
|
|
|
<script setup lang="ts">
|
|
|
|
import { computed } from 'vue';
|
2022-11-24 07:54:43 -08:00
|
|
|
import type { IBinaryData, IRunData } from 'n8n-workflow';
|
2021-12-23 13:29:04 -08:00
|
|
|
import BinaryDataDisplayEmbed from '@/components/BinaryDataDisplayEmbed.vue';
|
2023-05-05 01:41:54 -07:00
|
|
|
import { useWorkflowsStore } from '@/stores/workflows.store';
|
2023-12-08 07:59:03 -08:00
|
|
|
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2024-06-18 01:50:28 -07:00
|
|
|
const props = defineProps<{
|
|
|
|
displayData: IBinaryData;
|
|
|
|
windowVisible: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2024-07-04 00:30:51 -07:00
|
|
|
close: [];
|
2024-06-18 01:50:28 -07:00
|
|
|
}>();
|
|
|
|
|
|
|
|
const nodeHelpers = useNodeHelpers();
|
|
|
|
const workflowsStore = useWorkflowsStore();
|
|
|
|
|
|
|
|
const workflowRunData = computed<IRunData | null>(() => {
|
|
|
|
const workflowExecution = workflowsStore.getWorkflowExecution;
|
|
|
|
if (workflowExecution === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const executionData = workflowExecution.data;
|
|
|
|
return executionData ? executionData.resultData.runData : null;
|
|
|
|
});
|
|
|
|
|
|
|
|
const binaryData = computed<IBinaryData | null>(() => {
|
|
|
|
if (
|
|
|
|
typeof props.displayData.node !== 'string' ||
|
|
|
|
typeof props.displayData.key !== 'string' ||
|
|
|
|
typeof props.displayData.runIndex !== 'number' ||
|
|
|
|
typeof props.displayData.index !== 'number' ||
|
|
|
|
typeof props.displayData.outputIndex !== 'number'
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const binaryDataLocal = nodeHelpers.getBinaryData(
|
|
|
|
workflowRunData.value,
|
|
|
|
props.displayData.node,
|
|
|
|
props.displayData.runIndex,
|
|
|
|
props.displayData.outputIndex,
|
|
|
|
);
|
|
|
|
|
|
|
|
if (binaryDataLocal.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
props.displayData.index >= binaryDataLocal.length ||
|
|
|
|
binaryDataLocal[props.displayData.index][props.displayData.key] === undefined
|
|
|
|
) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const binaryDataItem: IBinaryData =
|
|
|
|
binaryDataLocal[props.displayData.index][props.displayData.key];
|
|
|
|
|
|
|
|
return binaryDataItem;
|
2019-06-23 03:35:23 -07:00
|
|
|
});
|
2024-06-18 01:50:28 -07:00
|
|
|
|
|
|
|
function closeWindow() {
|
|
|
|
// Handle the close externally as the visible parameter is an external prop
|
|
|
|
// and is so not allowed to be changed here.
|
|
|
|
emit('close');
|
|
|
|
return false;
|
|
|
|
}
|
2019-06-23 03:35:23 -07:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.binary-data-window {
|
|
|
|
position: absolute;
|
|
|
|
top: 50px;
|
|
|
|
left: 0;
|
|
|
|
z-index: 10;
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100% - 50px);
|
2024-04-07 23:21:54 -07:00
|
|
|
background-color: var(--color-run-data-background);
|
2019-06-23 03:35:23 -07:00
|
|
|
overflow: hidden;
|
|
|
|
text-align: center;
|
|
|
|
|
2022-12-11 05:10:54 -08:00
|
|
|
&.json {
|
|
|
|
overflow: auto;
|
|
|
|
}
|
|
|
|
|
2019-06-23 03:35:23 -07:00
|
|
|
.binary-data-window-wrapper {
|
2021-08-29 04:36:17 -07:00
|
|
|
margin-top: 0.5em;
|
2019-06-23 03:35:23 -07:00
|
|
|
padding: 0 1em;
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
|
|
|
|
.el-row,
|
|
|
|
.el-col {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|