2021-01-11 12:38:34 +01:00
|
|
|
<template>
|
|
|
|
<FormBase>
|
|
|
|
<FormGroup v-if="scopes">
|
|
|
|
<template #label>{{ $ts.system }}</template>
|
|
|
|
<FormLink v-for="scope in scopes" :to="`/settings/registry/keys/system/${scope.join('/')}`" class="_monospace">{{ scope.join('/') }}</FormLink>
|
|
|
|
</FormGroup>
|
2021-11-19 11:36:12 +01:00
|
|
|
<FormButton primary @click="createKey">{{ $ts._registry.createKey }}</FormButton>
|
2021-01-11 12:38:34 +01:00
|
|
|
</FormBase>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
|
|
|
import * as JSON5 from 'json5';
|
2021-11-11 18:02:25 +01:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormSelect from '@/components/form/select.vue';
|
|
|
|
import FormLink from '@/components/debobigego/link.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: {
|
|
|
|
FormBase,
|
|
|
|
FormSelect,
|
|
|
|
FormSwitch,
|
|
|
|
FormButton,
|
|
|
|
FormLink,
|
|
|
|
FormGroup,
|
|
|
|
FormKeyValueView,
|
|
|
|
},
|
|
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
scopes: null,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetch() {
|
|
|
|
os.api('i/registry/scopes').then(scopes => {
|
|
|
|
this.scopes = scopes.slice().sort((a, b) => a.join('/').localeCompare(b.join('/')));
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
async createKey() {
|
|
|
|
const { canceled, result } = await os.form(this.$ts._registry.createKey, {
|
|
|
|
key: {
|
|
|
|
type: 'string',
|
|
|
|
label: this.$ts._registry.key,
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
type: 'string',
|
|
|
|
multiline: true,
|
|
|
|
label: this.$ts.value,
|
|
|
|
},
|
|
|
|
scope: {
|
|
|
|
type: 'string',
|
|
|
|
label: this.$ts._registry.scope,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('i/registry/set', {
|
|
|
|
scope: result.scope.split('/'),
|
|
|
|
key: result.key,
|
|
|
|
value: JSON5.parse(result.value),
|
|
|
|
}).then(() => {
|
|
|
|
this.fetch();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|