Skip to content

Commit

Permalink
feat: add format type 'YAML' and 'XML' #110
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed Dec 28, 2023
1 parent 4c9d753 commit 4dc8839
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions backend/types/view_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package types

const FORMAT_RAW = "Raw"
const FORMAT_JSON = "JSON"
const FORMAT_YAML = "YAML"
const FORMAT_XML = "XML"
const FORMAT_HEX = "Hex"
const FORMAT_BINARY = "Binary"

Expand Down
2 changes: 1 addition & 1 deletion backend/utils/string/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func autoDecode(str string) (value, resultDecode string) {
func viewAs(str, formatType string) (value, resultFormat string) {
if len(formatType) > 0 {
switch formatType {
case types.FORMAT_RAW:
case types.FORMAT_RAW, types.FORMAT_YAML, types.FORMAT_XML:
value = str
resultFormat = formatType
return
Expand Down
9 changes: 4 additions & 5 deletions frontend/src/components/content_value/ContentEntryEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ const viewLanguage = computed(() => {
switch (viewAs.format) {
case formatTypes.JSON:
return 'json'
case formatTypes.YAML:
return 'yaml'
case formatTypes.XML:
return 'xml'
default:
return 'plaintext'
}
Expand Down Expand Up @@ -129,11 +133,6 @@ const onFormatChanged = async (decode = null, format = null) => {
}
}
const onUpdateValue = (value) => {
// emit('update:value', value)
viewAs.value = value
}
const onInput = (content) => {
editingContent.value = content
}
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/components/content_value/ContentValueString.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ const viewLanguage = computed(() => {
switch (viewAs.format) {
case formatTypes.JSON:
return 'json'
case formatTypes.YAML:
return 'yaml'
case formatTypes.XML:
return 'xml'
default:
return 'plaintext'
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/consts/value_view_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
export const formatTypes = {
RAW: 'Raw',
JSON: 'JSON',
// XML: 'XML',
// YML: 'YML',
YAML: 'YAML',
XML: 'XML',
HEX: 'Hex',
BINARY: 'Binary',
}
Expand Down

0 comments on commit 4dc8839

Please sign in to comment.