2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="windowVisible" class="binary-data-window">
|
2021-08-29 04:36:17 -07:00
|
|
|
<n8n-button
|
2019-06-23 03:35:23 -07:00
|
|
|
@click.stop="closeWindow"
|
|
|
|
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')"
|
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>
|
2021-12-23 13:29:04 -08:00
|
|
|
<BinaryDataDisplayEmbed v-else :binaryData="binaryData"/>
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2022-11-24 07:54:43 -08:00
|
|
|
import type { IBinaryData, IRunData } from 'n8n-workflow';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2021-12-23 13:29:04 -08:00
|
|
|
import BinaryDataDisplayEmbed from '@/components/BinaryDataDisplayEmbed.vue';
|
|
|
|
|
2022-11-23 04:41:53 -08:00
|
|
|
import { nodeHelpers } from '@/mixins/nodeHelpers';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
import mixins from 'vue-typed-mixins';
|
2022-11-23 04:41:53 -08:00
|
|
|
import { restApi } from '@/mixins/restApi';
|
2022-11-04 06:04:31 -07:00
|
|
|
import { mapStores } from 'pinia';
|
|
|
|
import { useWorkflowsStore } from '@/stores/workflows';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
nodeHelpers,
|
2021-12-23 13:29:04 -08:00
|
|
|
restApi,
|
2019-06-23 03:35:23 -07:00
|
|
|
)
|
|
|
|
.extend({
|
|
|
|
name: 'BinaryDataDisplay',
|
2021-12-23 13:29:04 -08:00
|
|
|
components: {
|
|
|
|
BinaryDataDisplayEmbed,
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
props: [
|
2022-11-24 07:54:43 -08:00
|
|
|
'displayData', // IBinaryData
|
2019-06-23 03:35:23 -07:00
|
|
|
'windowVisible', // boolean
|
|
|
|
],
|
|
|
|
computed: {
|
2022-11-04 06:04:31 -07:00
|
|
|
...mapStores(
|
|
|
|
useWorkflowsStore,
|
|
|
|
),
|
2019-06-23 03:35:23 -07:00
|
|
|
binaryData (): IBinaryData | null {
|
|
|
|
const binaryData = this.getBinaryData(this.workflowRunData, this.displayData.node, this.displayData.runIndex, this.displayData.outputIndex);
|
|
|
|
|
|
|
|
if (binaryData.length === 0) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.displayData.index >= binaryData.length || binaryData[this.displayData.index][this.displayData.key] === undefined) {
|
|
|
|
return null;
|
|
|
|
}
|
2021-12-23 13:29:04 -08:00
|
|
|
|
|
|
|
const binaryDataItem: IBinaryData = binaryData[this.displayData.index][this.displayData.key];
|
|
|
|
|
|
|
|
return binaryDataItem;
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
workflowRunData (): IRunData | null {
|
2022-11-04 06:04:31 -07:00
|
|
|
const workflowExecution = this.workflowsStore.getWorkflowExecution;
|
2019-06-23 03:35:23 -07:00
|
|
|
if (workflowExecution === null) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-11-04 06:04:31 -07:00
|
|
|
const executionData = workflowExecution.data;
|
|
|
|
return executionData? executionData.resultData.runData : null;
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
closeWindow () {
|
|
|
|
// Handle the close externally as the visible parameter is an external prop
|
|
|
|
// and is so not allowed to be changed here.
|
|
|
|
this.$emit('close');
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
|
|
|
.binary-data-window {
|
|
|
|
position: absolute;
|
|
|
|
top: 50px;
|
|
|
|
left: 0;
|
|
|
|
z-index: 10;
|
|
|
|
width: 100%;
|
|
|
|
height: calc(100% - 50px);
|
2022-05-23 08:56:15 -07:00
|
|
|
background-color: var(--color-background-base);
|
2019-06-23 03:35:23 -07:00
|
|
|
overflow: hidden;
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
.binary-data-window-wrapper {
|
2021-08-29 04:36:17 -07:00
|
|
|
margin-top: .5em;
|
2019-06-23 03:35:23 -07:00
|
|
|
padding: 0 1em;
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
|
|
|
|
.el-row,
|
|
|
|
.el-col {
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.binary-data {
|
2022-07-26 03:45:55 -07:00
|
|
|
background-color: var(--color-foreground-xlight);
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
&.image {
|
|
|
|
max-height: calc(100% - 1em);
|
|
|
|
max-width: calc(100% - 1em);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.other {
|
|
|
|
height: calc(100% - 1em);
|
|
|
|
width: calc(100% - 1em);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|