-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): internal storage file preview (#1770)
close #1767
- Loading branch information
Showing
14 changed files
with
383 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<template> | ||
<el-table :data="value" stripe> | ||
<el-table-column v-for="(column, index) in generateTableColumns" :key="index" :prop="column" :label="column" /> | ||
</el-table> | ||
</template> | ||
<script> | ||
export default { | ||
name: "ListPreview", | ||
props: { | ||
value: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
generateTableColumns() { | ||
return Object.keys(this.value[0]); | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<template> | ||
<EyeOutline role="button" @click="getFilePreview(value)" /> | ||
<el-drawer | ||
v-if="selectedPreview === value && filePreview" | ||
v-model="isPreviewOpen" | ||
destroy-on-close | ||
lock-scroll | ||
size="" | ||
:append-to-body="true" | ||
> | ||
<template #header> | ||
<h3>{{ $t("preview") }}</h3> | ||
</template> | ||
<template #default> | ||
<list-preview v-if="filePreview.type === 'LIST'" :value="filePreview.content" /> | ||
<img v-else-if="filePreview.type === 'IMAGE'" :src="imageContent" alt="Image output preview"> | ||
<markdown v-else-if="filePreview.type === 'MARKDOWN'" :source="filePreview.content" /> | ||
<editor v-else :model-value="filePreview.content" :lang="extensionToMonacoLang" read-only /> | ||
</template> | ||
</el-drawer> | ||
</template> | ||
<script> | ||
import Editor from "../inputs/Editor.vue"; | ||
import ListPreview from "../ListPreview.vue"; | ||
import EyeOutline from "vue-material-design-icons/EyeOutline.vue"; | ||
import {mapState} from "vuex"; | ||
import Markdown from "../layout/Markdown.vue"; | ||
export default { | ||
components: {Markdown, EyeOutline, ListPreview, Editor}, | ||
props: { | ||
value: { | ||
type: String, | ||
required: true | ||
}, | ||
executionId: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
data() { | ||
return { | ||
isPreviewOpen: false, | ||
selectedPreview: null | ||
} | ||
}, | ||
computed: { | ||
...mapState("execution", ["filePreview"]), | ||
extensionToMonacoLang() { | ||
switch (this.filePreview.extension) { | ||
case "json": | ||
return "json"; | ||
case "jsonl": | ||
return "jsonl"; | ||
case "yaml": | ||
case "yml": | ||
case "ion": | ||
// little hack to get ion colored with monaco | ||
return "yaml"; | ||
case "csv": | ||
return "csv"; | ||
case "py": | ||
return "python" | ||
default: | ||
return this.filePreview.extension; | ||
} | ||
}, | ||
imageContent() { | ||
return "data:image/" + this.extension + ";base64," + this.filePreview.content; | ||
} | ||
}, | ||
methods: { | ||
getFilePreview(path) { | ||
this.selectedPreview = path; | ||
this.$store | ||
.dispatch("execution/filePreview", { | ||
executionId: this.executionId, | ||
path: path | ||
}) | ||
.then(() => { | ||
this.isPreviewOpen = true; | ||
}); | ||
}, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.