2023-10-16 02:30:03 +02:00
|
|
|
<template>
|
2023-10-18 22:51:30 +02:00
|
|
|
<div class="config-container current"
|
|
|
|
v-if="highlightedCurrentConfig">
|
|
|
|
<CopyButton :text="curYamlConfig" />
|
|
|
|
<pre><code class="config-snippet" v-html="highlightedCurrentConfig" /></pre>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="config-container snippet" :class="{'fullscreen': !highlightedCurrentConfig}">
|
2023-10-17 02:12:12 +02:00
|
|
|
<CopyButton :text="extension.config_snippet" />
|
2023-10-16 02:30:03 +02:00
|
|
|
<pre><code class="config-snippet" v-html="highlightedConfigSnippet" /></pre>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import 'highlight.js/lib/common'
|
2023-10-17 02:10:17 +02:00
|
|
|
import 'highlight.js/styles/stackoverflow-dark.min.css'
|
2023-10-16 02:30:03 +02:00
|
|
|
import hljs from "highlight.js"
|
2023-10-17 02:12:12 +02:00
|
|
|
import CopyButton from "@/components/elements/CopyButton"
|
2023-10-16 02:30:03 +02:00
|
|
|
import Utils from "@/Utils";
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Extension",
|
|
|
|
mixins: [Utils],
|
2023-10-17 02:12:12 +02:00
|
|
|
components: {
|
|
|
|
CopyButton,
|
|
|
|
},
|
2023-10-17 16:38:46 +02:00
|
|
|
|
2023-10-16 02:30:03 +02:00
|
|
|
props: {
|
|
|
|
extension: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
2023-10-17 16:38:46 +02:00
|
|
|
|
2023-10-18 22:51:30 +02:00
|
|
|
config: {
|
|
|
|
type: Object,
|
|
|
|
},
|
|
|
|
|
2023-10-17 16:38:46 +02:00
|
|
|
configFile: {
|
|
|
|
type: String,
|
|
|
|
},
|
2023-10-16 02:30:03 +02:00
|
|
|
},
|
|
|
|
|
2023-10-18 22:51:30 +02:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
curYamlConfig: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2023-10-16 02:30:03 +02:00
|
|
|
computed: {
|
|
|
|
highlightedConfigSnippet() {
|
|
|
|
return hljs.highlight(
|
|
|
|
'yaml',
|
2023-10-18 22:51:30 +02:00
|
|
|
`# Configuration template. You can add it to ${this.configFile}\n` +
|
2023-10-16 02:30:03 +02:00
|
|
|
this.extension.config_snippet,
|
|
|
|
).value.trim()
|
|
|
|
},
|
2023-10-18 22:51:30 +02:00
|
|
|
|
|
|
|
highlightedCurrentConfig() {
|
|
|
|
if (!this.curYamlConfig) {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return hljs.highlight(
|
|
|
|
'yaml',
|
|
|
|
'# Currently loaded configuration\n' +
|
|
|
|
this.curYamlConfig
|
|
|
|
).value.trim()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async loadCurrentConfig() {
|
|
|
|
if (!this.config) {
|
|
|
|
this.curYamlConfig = null
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
this.curYamlConfig = await this.request(
|
|
|
|
'utils.to_yaml', {
|
|
|
|
obj: {
|
|
|
|
[this.extension.name]: this.config,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.loadCurrentConfig()
|
|
|
|
this.$watch('config', this.loadCurrentConfig)
|
2023-10-16 02:30:03 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-10-17 02:12:12 +02:00
|
|
|
@import "common.scss";
|
|
|
|
|
2023-10-16 02:30:03 +02:00
|
|
|
.config-container {
|
|
|
|
width: 100%;
|
2023-10-18 22:51:30 +02:00
|
|
|
max-height: 100%;
|
2023-10-16 02:30:03 +02:00
|
|
|
position: relative;
|
|
|
|
display: flex;
|
2023-10-18 22:51:30 +02:00
|
|
|
flex-grow: 1;
|
|
|
|
overflow: auto;
|
|
|
|
|
|
|
|
pre {
|
|
|
|
border-radius: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.current {
|
|
|
|
height: 34%;
|
|
|
|
margin-bottom: 1.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.snippet {
|
|
|
|
height: 66%;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.fullscreen {
|
|
|
|
height: 100%;
|
|
|
|
|
|
|
|
pre {
|
|
|
|
border-radius: 0;
|
|
|
|
}
|
|
|
|
}
|
2023-10-16 02:30:03 +02:00
|
|
|
}
|
|
|
|
</style>
|