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-07 08:28:10 -08:00
|
|
|
:title="$i.baseText('binaryDataDisplay.backToOverviewPage')"
|
2021-08-29 04:36:17 -07:00
|
|
|
icon="arrow-left"
|
2021-12-07 08:28:10 -08:00
|
|
|
:label="$i.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-07 08:28:10 -08:00
|
|
|
{{ $i.baseText('binaryDataDisplay.noDataFoundToDisplay') }}
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
2021-07-03 05:30:02 -07:00
|
|
|
<video v-else-if="binaryData.mimeType && binaryData.mimeType.startsWith('video/')" controls autoplay>
|
|
|
|
<source :src="'data:' + binaryData.mimeType + ';base64,' + binaryData.data" :type="binaryData.mimeType">
|
2021-12-07 08:28:10 -08:00
|
|
|
{{ $i.baseText('binaryDataDisplay.yourBrowserDoesNotSupport') }}
|
2021-07-03 05:30:02 -07:00
|
|
|
</video>
|
2020-12-26 14:11:25 -08:00
|
|
|
<embed v-else :src="'data:' + binaryData.mimeType + ';base64,' + binaryData.data" class="binary-data" :class="embedClass"/>
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import {
|
|
|
|
IBinaryData,
|
|
|
|
IRunData,
|
|
|
|
IRunExecutionData,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
import { nodeHelpers } from '@/components/mixins/nodeHelpers';
|
|
|
|
|
|
|
|
import mixins from 'vue-typed-mixins';
|
|
|
|
|
|
|
|
export default mixins(
|
|
|
|
nodeHelpers,
|
|
|
|
)
|
|
|
|
.extend({
|
|
|
|
name: 'BinaryDataDisplay',
|
|
|
|
props: [
|
|
|
|
'displayData', // IBinaryDisplayData
|
|
|
|
'windowVisible', // boolean
|
|
|
|
],
|
|
|
|
computed: {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
return binaryData[this.displayData.index][this.displayData.key];
|
|
|
|
},
|
|
|
|
|
|
|
|
embedClass (): string[] {
|
|
|
|
if (this.binaryData !== null &&
|
|
|
|
this.binaryData.mimeType !== undefined &&
|
|
|
|
(this.binaryData.mimeType as string).startsWith('image')
|
|
|
|
) {
|
|
|
|
return ['image'];
|
|
|
|
}
|
|
|
|
return ['other'];
|
|
|
|
},
|
|
|
|
|
|
|
|
workflowRunData (): IRunData | null {
|
|
|
|
const workflowExecution = this.$store.getters.getWorkflowExecution;
|
|
|
|
if (workflowExecution === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
const executionData: IRunExecutionData = workflowExecution.data;
|
|
|
|
return executionData.resultData.runData;
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
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);
|
|
|
|
background-color: #f9f9f9;
|
|
|
|
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 {
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
|
|
&.image {
|
|
|
|
max-height: calc(100% - 1em);
|
|
|
|
max-width: calc(100% - 1em);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.other {
|
|
|
|
height: calc(100% - 1em);
|
|
|
|
width: calc(100% - 1em);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|