-
Notifications
You must be signed in to change notification settings - Fork 948
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #1767
- Loading branch information
Showing
10 changed files
with
320 additions
and
30 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,40 @@ | ||
<template> | ||
<el-table :data="data" stripe> | ||
<el-table-column v-for="(column, index) in generateTableColumns" :key="index" :prop="column.props.prop" :label="column.label"> | ||
<template #default="scope"> | ||
<span class="">{{ scope.row[index] }}</span> | ||
</template> | ||
</el-table-column> | ||
</el-table> | ||
</template> | ||
<script> | ||
export default { | ||
name: "Csv", | ||
props: { | ||
value: { | ||
type: Object, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
generateTableColumns() { | ||
const columns = []; | ||
for (let i = 0; i < this.value.data[0].length; i++) { | ||
columns.push({ | ||
props: {prop: String(i)}, | ||
label: this.value.data[0][i], | ||
}); | ||
} | ||
return columns; | ||
}, | ||
data() { | ||
return this.value.data.slice(1, this.value.data.length); | ||
} | ||
} | ||
} | ||
</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,66 @@ | ||
<template> | ||
<csv v-if="extensionToMonacoLang === 'csv'" :value="formattedContent" /> | ||
<img v-else-if="extensionToMonacoLang === 'image'" :src="formattedContent" alt="Image output preview"> | ||
<editor v-else :model-value="formattedContent" :lang="extensionToMonacoLang" format-on-start /> | ||
</template> | ||
<script> | ||
import Editor from "../inputs/Editor.vue"; | ||
import * as ion from "ion-js"; | ||
import Papa from "papaparse"; | ||
import Csv from "../Csv.vue"; | ||
export default { | ||
components: {Csv, Editor}, | ||
props: { | ||
content: { | ||
type: String, | ||
required: true | ||
}, | ||
extension: { | ||
type: String, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
extensionToMonacoLang() { | ||
switch(this.extension) { | ||
case "json": | ||
return "json"; | ||
case "yaml": | ||
case "yml": | ||
case "ion": | ||
// little hack to get ion colored with monaco | ||
return "yaml"; | ||
case "csv": | ||
return "csv"; | ||
case "jpg": | ||
case "jpeg": | ||
case "png": | ||
case "svg": | ||
return "image"; | ||
default: | ||
return "text"; | ||
} | ||
}, | ||
formattedContent() { | ||
switch(this.extension) { | ||
case "json": | ||
return JSON.stringify(JSON.parse(this.content), null, 2); | ||
case "ion": | ||
return ion.dumpPrettyText(ion.load(this.content)); | ||
case "csv": | ||
return Papa.parse(this.content); | ||
case "jpg": | ||
case "jpeg": | ||
case "png": | ||
case "svg": | ||
return "data:image/" + this.extension + ";base64," + this.content; | ||
default: | ||
return this.content; | ||
} | ||
} | ||
}, | ||
methods: { | ||
} | ||
} | ||
</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
Oops, something went wrong.