2019-10-12 14:33:05 +00:00
|
|
|
<template>
|
|
|
|
|
<div class="row standard-page">
|
|
|
|
|
<div class="col-6">
|
2019-10-12 15:05:15 +00:00
|
|
|
<h2>{{ $t('API') }}</h2>
|
|
|
|
|
<p>{{ $t('APIText') }}</p>
|
|
|
|
|
<div class="section">
|
|
|
|
|
<h6>{{ $t('userId') }}</h6>
|
|
|
|
|
<pre class="prettyprint">{{ user.id }}</pre>
|
|
|
|
|
<h6>{{ $t('APIToken') }}</h6>
|
|
|
|
|
<div class="d-flex align-items-center mb-3">
|
2019-10-12 14:33:05 +00:00
|
|
|
<button
|
|
|
|
|
class="btn btn-secondary"
|
|
|
|
|
@click="showApiToken = !showApiToken"
|
|
|
|
|
>
|
|
|
|
|
{{ $t(`${showApiToken ? 'hide' : 'show'}APIToken`) }}
|
2019-10-12 15:05:15 +00:00
|
|
|
</button>
|
|
|
|
|
<pre
|
2019-10-12 14:33:05 +00:00
|
|
|
v-if="showApiToken"
|
|
|
|
|
class="prettyprint ml-4 mb-0"
|
|
|
|
|
>{{ apiToken }}</pre>
|
2019-10-12 15:05:15 +00:00
|
|
|
</div>
|
|
|
|
|
<p v-html="$t('APITokenWarning', { hrefTechAssistanceEmail })"></p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="section">
|
|
|
|
|
<h3>{{ $t('thirdPartyApps') }}</h3>
|
|
|
|
|
<ul>
|
2019-10-12 14:33:05 +00:00
|
|
|
<li>
|
|
|
|
|
<a
|
|
|
|
|
target="_blank"
|
|
|
|
|
href="https://www.beeminder.com/habitica"
|
2019-10-12 15:05:15 +00:00
|
|
|
>{{ $t('beeminder') }}</a>
|
|
|
|
|
<br>
|
|
|
|
|
{{ $t('beeminderDesc') }}
|
|
|
|
|
</li>
|
2019-10-20 11:55:34 +00:00
|
|
|
<li v-html="$t('chatExtension')"></li>
|
|
|
|
|
<span>{{ $t('chatExtensionDesc') }}</span>
|
2019-10-12 15:05:15 +00:00
|
|
|
<li>
|
2019-10-12 14:33:05 +00:00
|
|
|
<a
|
|
|
|
|
target="_blank"
|
|
|
|
|
:href="`https://oldgods.net/habitica/habitrpg_user_data_display.html?uuid=` + user._id"
|
2019-10-12 15:05:15 +00:00
|
|
|
>{{ $t('dataTool') }}</a>
|
|
|
|
|
<br>
|
|
|
|
|
{{ $t('dataToolDesc') }}
|
|
|
|
|
</li>
|
|
|
|
|
<li v-html="$t('otherExtensions')">
|
|
|
|
|
{{ $t('otherDesc') }}
|
2019-10-12 14:33:05 +00:00
|
|
|
</li>
|
2019-10-12 15:05:15 +00:00
|
|
|
</ul>
|
|
|
|
|
<hr>
|
2019-10-12 14:33:05 +00:00
|
|
|
</div>
|
2019-10-12 15:05:15 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="col-6">
|
|
|
|
|
<h2>{{ $t('webhooks') }}</h2>
|
|
|
|
|
<p v-html="$t('webhooksInfo')"></p>
|
|
|
|
|
<table class="table table-striped">
|
2019-10-12 14:33:05 +00:00
|
|
|
<thead v-if="user.webhooks.length">
|
2019-10-12 15:05:15 +00:00
|
|
|
<tr>
|
|
|
|
|
<th>{{ $t('enabled') }}</th>
|
|
|
|
|
<th>{{ $t('webhookURL') }}</th>
|
|
|
|
|
<th></th>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
2019-10-13 16:04:04 +00:00
|
|
|
<tr
|
|
|
|
|
v-for="(webhook, index) in user.webhooks"
|
|
|
|
|
:key="webhook.id"
|
|
|
|
|
>
|
2019-10-12 14:33:05 +00:00
|
|
|
<td>
|
|
|
|
|
<input
|
|
|
|
|
v-model="webhook.enabled"
|
|
|
|
|
type="checkbox"
|
|
|
|
|
@change="saveWebhook(webhook, index)"
|
|
|
|
|
>
|
2019-10-12 15:05:15 +00:00
|
|
|
</td>
|
|
|
|
|
<td>
|
2019-10-12 14:33:05 +00:00
|
|
|
<input
|
|
|
|
|
v-model="webhook.url"
|
|
|
|
|
class="form-control"
|
|
|
|
|
type="url"
|
|
|
|
|
>
|
2019-10-12 15:05:15 +00:00
|
|
|
</td>
|
|
|
|
|
<td>
|
2019-10-12 14:33:05 +00:00
|
|
|
<a
|
|
|
|
|
class="btn btn-warning checklist-icons"
|
|
|
|
|
@click="deleteWebhook(webhook, index)"
|
2019-10-12 15:05:15 +00:00
|
|
|
>
|
|
|
|
|
<span
|
|
|
|
|
class="glyphicon glyphicon-trash"
|
|
|
|
|
:tooltip="$t('delete')"
|
|
|
|
|
>Delete</span>
|
|
|
|
|
</a>
|
|
|
|
|
<a
|
2019-10-12 14:33:05 +00:00
|
|
|
class="btn btn-success checklist-icons"
|
|
|
|
|
@click="saveWebhook(webhook, index)"
|
|
|
|
|
>Update</a>
|
|
|
|
|
</td>
|
2019-10-12 15:05:15 +00:00
|
|
|
</tr>
|
|
|
|
|
<tr>
|
2019-10-12 14:33:05 +00:00
|
|
|
<td colspan="2">
|
|
|
|
|
<div class="form-horizontal">
|
|
|
|
|
<div class="form-group col-sm-10">
|
|
|
|
|
<input
|
|
|
|
|
v-model="newWebhook.url"
|
|
|
|
|
class="form-control"
|
|
|
|
|
type="url"
|
|
|
|
|
:placeholder="$t('webhookURL')"
|
|
|
|
|
>
|
2019-10-12 15:05:15 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-2">
|
2019-10-12 14:33:05 +00:00
|
|
|
<button
|
|
|
|
|
class="btn btn-sm btn-primary"
|
|
|
|
|
type="submit"
|
|
|
|
|
@click="addWebhook(newWebhook.url)"
|
|
|
|
|
>
|
|
|
|
|
{{ $t('add') }}
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2017-07-20 18:01:00 +00:00
|
|
|
</template>
|
|
|
|
|
|
2017-08-31 13:15:17 +00:00
|
|
|
<style scoped>
|
2017-07-20 18:01:00 +00:00
|
|
|
.section {
|
|
|
|
|
margin-top: 2em;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
<script>
|
2019-10-01 13:38:48 +00:00
|
|
|
import { mapState } from '@/libs/store';
|
2019-10-01 14:00:06 +00:00
|
|
|
import uuid from '@/../../common/script/libs/uuid';
|
2017-07-20 18:01:00 +00:00
|
|
|
// @TODO: env.EMAILS.TECH_ASSISTANCE_EMAIL
|
|
|
|
|
const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
data () {
|
|
|
|
|
return {
|
|
|
|
|
newWebhook: {
|
|
|
|
|
url: '',
|
|
|
|
|
},
|
|
|
|
|
hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`,
|
2017-10-23 20:58:33 +00:00
|
|
|
showApiToken: false,
|
2017-07-20 18:01:00 +00:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
2019-10-09 18:08:36 +00:00
|
|
|
...mapState({ user: 'user.data', credentials: 'credentials' }),
|
2017-08-09 16:56:48 +00:00
|
|
|
apiToken () {
|
2017-09-20 13:04:35 +00:00
|
|
|
return this.credentials.API_TOKEN;
|
2017-08-09 16:56:48 +00:00
|
|
|
},
|
2017-07-20 18:01:00 +00:00
|
|
|
},
|
2019-10-11 18:35:49 +00:00
|
|
|
mounted () {
|
|
|
|
|
window.addEventListener('message', this.receiveMessage, false);
|
|
|
|
|
},
|
|
|
|
|
destroy () {
|
|
|
|
|
window.removeEventListener('message', this.receiveMessage);
|
|
|
|
|
},
|
2017-07-20 18:01:00 +00:00
|
|
|
methods: {
|
2018-06-29 16:35:22 +00:00
|
|
|
receiveMessage (eventFrom) {
|
2018-07-01 03:06:18 +00:00
|
|
|
if (eventFrom.origin !== 'https://www.spritely.app') return;
|
2018-06-29 16:35:22 +00:00
|
|
|
|
|
|
|
|
const creds = {
|
|
|
|
|
userId: this.user._id,
|
|
|
|
|
apiToken: this.credentials.API_TOKEN,
|
|
|
|
|
};
|
2018-07-01 03:06:18 +00:00
|
|
|
eventFrom.source.postMessage(creds, eventFrom.origin);
|
2018-06-29 16:35:22 +00:00
|
|
|
},
|
2017-07-20 18:01:00 +00:00
|
|
|
async addWebhook (url) {
|
2019-10-09 18:08:36 +00:00
|
|
|
const webhookInfo = {
|
2017-07-20 18:01:00 +00:00
|
|
|
id: uuid(),
|
|
|
|
|
type: 'taskActivity',
|
|
|
|
|
options: {
|
|
|
|
|
created: false,
|
|
|
|
|
updated: false,
|
|
|
|
|
deleted: false,
|
|
|
|
|
scored: true,
|
|
|
|
|
},
|
|
|
|
|
url,
|
|
|
|
|
enabled: true,
|
|
|
|
|
};
|
|
|
|
|
|
2019-10-09 18:08:36 +00:00
|
|
|
const webhook = await this.$store.dispatch('user:addWebhook', { webhookInfo });
|
2017-07-20 18:01:00 +00:00
|
|
|
this.user.webhooks.push(webhook);
|
|
|
|
|
|
|
|
|
|
this.newWebhook.url = '';
|
|
|
|
|
},
|
|
|
|
|
async saveWebhook (webhook, index) {
|
|
|
|
|
delete webhook._editing;
|
2019-10-09 18:08:36 +00:00
|
|
|
const updatedWebhook = await this.$store.dispatch('user:updateWebhook', { webhook });
|
2017-07-20 18:01:00 +00:00
|
|
|
this.user.webhooks[index] = updatedWebhook;
|
|
|
|
|
},
|
|
|
|
|
async deleteWebhook (webhook, index) {
|
|
|
|
|
delete webhook._editing;
|
2019-10-09 18:08:36 +00:00
|
|
|
await this.$store.dispatch('user:deleteWebhook', { webhook });
|
2017-07-20 18:01:00 +00:00
|
|
|
this.user.webhooks.splice(index, 1);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|