2021-01-11 12:38:34 +01:00
|
|
|
<template>
|
|
|
|
<FormBase>
|
2021-04-13 18:41:49 +02:00
|
|
|
<FormInfo warn>{{ $ts.editTheseSettingsMayBreakAccount }}</FormInfo>
|
2021-01-11 12:38:34 +01:00
|
|
|
|
|
|
|
<template v-if="value">
|
|
|
|
<FormGroup>
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts._registry.domain }}</template>
|
|
|
|
<template #value>{{ $ts.system }}</template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts._registry.scope }}</template>
|
|
|
|
<template #value>{{ scope.join('/') }}</template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts._registry.key }}</template>
|
|
|
|
<template #value>{{ xKey }}</template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormGroup>
|
2021-09-29 17:50:45 +02:00
|
|
|
<FormTextarea tall v-model="valueForEditor" class="_monospace" style="tab-size: 2;">
|
2021-01-11 12:38:34 +01:00
|
|
|
<span>{{ $ts.value }} (JSON)</span>
|
|
|
|
</FormTextarea>
|
2021-04-20 16:22:59 +02:00
|
|
|
<FormButton @click="save" primary><i class="fas fa-save"></i> {{ $ts.save }}</FormButton>
|
2021-01-11 12:38:34 +01:00
|
|
|
</FormGroup>
|
|
|
|
|
|
|
|
<FormKeyValueView>
|
|
|
|
<template #key>{{ $ts.updatedAt }}</template>
|
|
|
|
<template #value><MkTime :time="value.updatedAt" mode="detail"/></template>
|
|
|
|
</FormKeyValueView>
|
|
|
|
|
2021-04-20 16:22:59 +02:00
|
|
|
<FormButton danger @click="del"><i class="fas fa-trash"></i> {{ $ts.delete }}</FormButton>
|
2021-01-11 12:38:34 +01:00
|
|
|
</template>
|
|
|
|
</FormBase>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
|
|
|
import * as JSON5 from 'json5';
|
2021-11-11 18:02:25 +01:00
|
|
|
import FormInfo from '@/components/debobigego/info.vue';
|
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormSelect from '@/components/form/select.vue';
|
|
|
|
import FormTextarea from '@/components/form/textarea.vue';
|
|
|
|
import FormBase from '@/components/debobigego/base.vue';
|
|
|
|
import FormGroup from '@/components/debobigego/group.vue';
|
|
|
|
import FormButton from '@/components/debobigego/button.vue';
|
|
|
|
import FormKeyValueView from '@/components/debobigego/key-value-view.vue';
|
|
|
|
import * as os from '@/os';
|
|
|
|
import * as symbols from '@/symbols';
|
2021-01-11 12:38:34 +01:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-04-13 18:41:49 +02:00
|
|
|
FormInfo,
|
2021-01-11 12:38:34 +01:00
|
|
|
FormBase,
|
|
|
|
FormSelect,
|
|
|
|
FormSwitch,
|
|
|
|
FormButton,
|
|
|
|
FormTextarea,
|
|
|
|
FormGroup,
|
|
|
|
FormKeyValueView,
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
scope: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
xKey: {
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['info'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: {
|
2021-01-11 12:38:34 +01:00
|
|
|
title: this.$ts.registry,
|
2021-09-29 17:50:45 +02:00
|
|
|
icon: 'fas fa-cogs',
|
|
|
|
bg: 'var(--bg)',
|
2021-01-11 12:38:34 +01:00
|
|
|
},
|
|
|
|
value: null,
|
|
|
|
valueForEditor: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
key() {
|
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2021-04-10 05:54:12 +02:00
|
|
|
this.$emit('info', this[symbols.PAGE_INFO]);
|
2021-01-11 12:38:34 +01:00
|
|
|
this.fetch();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
os.api('i/registry/get-detail', {
|
|
|
|
scope: this.scope,
|
|
|
|
key: this.xKey
|
|
|
|
}).then(value => {
|
|
|
|
this.value = value;
|
|
|
|
this.valueForEditor = JSON5.stringify(this.value.value, null, '\t');
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
save() {
|
|
|
|
try {
|
|
|
|
JSON5.parse(this.valueForEditor);
|
|
|
|
} catch (e) {
|
|
|
|
os.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: this.$ts.invalidValue
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$ts.saveConfirm,
|
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('i/registry/set', {
|
|
|
|
scope: this.scope,
|
|
|
|
key: this.xKey,
|
|
|
|
value: JSON5.parse(this.valueForEditor)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
del() {
|
|
|
|
os.dialog({
|
|
|
|
type: 'warning',
|
|
|
|
text: this.$ts.deleteConfirm,
|
|
|
|
showCancelButton: true
|
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('i/registry/remove', {
|
|
|
|
scope: this.scope,
|
|
|
|
key: this.xKey
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|