2018-10-25 23:37:30 +00:00
|
|
|
<template>
|
|
|
|
<ui-card>
|
2018-11-05 16:40:11 +00:00
|
|
|
<div slot="title"><fa icon="key"/> API</div>
|
2018-10-25 23:37:30 +00:00
|
|
|
|
|
|
|
<section class="fit-top">
|
|
|
|
<ui-input :value="$store.state.i.token" readonly>
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('token') }}</span>
|
2018-10-25 23:37:30 +00:00
|
|
|
</ui-input>
|
2018-11-08 18:44:35 +00:00
|
|
|
<p>{{ $t('intro') }}</p>
|
|
|
|
<ui-info warn>{{ $t('caution') }}</ui-info>
|
|
|
|
<p>{{ $t('regeneration-of-token') }}</p>
|
|
|
|
<ui-button @click="regenerateToken"><fa icon="sync-alt"/> {{ $t('regenerate-token') }}</ui-button>
|
2018-10-25 23:37:30 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section>
|
2018-11-08 18:44:35 +00:00
|
|
|
<header><fa icon="terminal"/> {{ $t('console.title') }}</header>
|
2018-10-25 23:37:30 +00:00
|
|
|
<ui-input v-model="endpoint">
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('console.endpoint') }}</span>
|
2018-10-25 23:37:30 +00:00
|
|
|
</ui-input>
|
|
|
|
<ui-textarea v-model="body">
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('console.parameter') }} (JSON or JSON5)</span>
|
|
|
|
<span slot="desc">{{ $t('console.credential-info') }}</span>
|
2018-10-25 23:37:30 +00:00
|
|
|
</ui-textarea>
|
|
|
|
<ui-button @click="send" :disabled="sending">
|
2018-11-08 18:44:35 +00:00
|
|
|
<template v-if="sending">{{ $t('console.sending') }}</template>
|
|
|
|
<template v-else><fa icon="paper-plane"/> {{ $t('console.send') }}</template>
|
2018-10-25 23:37:30 +00:00
|
|
|
</ui-button>
|
2018-10-26 05:47:30 +00:00
|
|
|
<ui-textarea v-if="res" v-model="res" readonly tall>
|
2018-11-08 18:44:35 +00:00
|
|
|
<span>{{ $t('console.response') }}</span>
|
2018-10-25 23:37:30 +00:00
|
|
|
</ui-textarea>
|
|
|
|
</section>
|
|
|
|
</ui-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-08 18:44:35 +00:00
|
|
|
import i18n from '../../../i18n';
|
2018-10-25 23:37:30 +00:00
|
|
|
import * as JSON5 from 'json5';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-08 18:44:35 +00:00
|
|
|
i18n: i18n('common/views/components/api-settings.vue'),
|
2018-10-25 23:37:30 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
endpoint: '',
|
|
|
|
body: '{}',
|
|
|
|
res: null,
|
|
|
|
sending: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
regenerateToken() {
|
|
|
|
(this as any).apis.input({
|
2018-11-08 18:44:35 +00:00
|
|
|
title: this.$t('enter-password'),
|
2018-10-25 23:37:30 +00:00
|
|
|
type: 'password'
|
|
|
|
}).then(password => {
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api('i/regenerate_token', {
|
2018-10-25 23:37:30 +00:00
|
|
|
password: password
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
send() {
|
|
|
|
this.sending = true;
|
2018-11-08 23:13:34 +00:00
|
|
|
this.$root.api(this.endpoint, JSON5.parse(this.body)).then(res => {
|
2018-10-25 23:37:30 +00:00
|
|
|
this.sending = false;
|
|
|
|
this.res = JSON5.stringify(res, null, 2);
|
|
|
|
}, err => {
|
|
|
|
this.sending = false;
|
|
|
|
this.res = JSON5.stringify(err, null, 2);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|