Files
habitica/website/client/components/settings/api.vue
Keith Holliday 5995dd235d New client more updates (#8934)
* Added api token to page

* Fixed wiki link

* Added categoires

* Removed extra create challenge button. Add prize model and user balance deduction

* Added pending filter

* Added member sort

* Added confirmation for leaving

* Filtered tavern

* Added redirect to newly created guild

* Made guild links routerlinks

* Fixed wiki link and added fetch recent messages

* Show backgrounds only on edit. Fixed glasses equip

* Added link to register page

* Added yesterdailies

* Added achievement footer

* Update guild badges

* Added avatar to achievement avatar component

* More guild crests updates

* Achievement footer and avatar added

* Added notification read

* Removed duplicate string
2017-08-09 10:56:48 -06:00

124 lines
3.6 KiB
Vue

<template lang="pug">
.row.standard-page
.col-6
h2 {{ $t('API') }}
small {{ $t('APIText') }}
.section
h6 {{ $t('userId') }}
pre.prettyprint {{user.id}}
h6 {{ $t('APIToken') }}
pre.prettyprint {{apiToken}}
small(v-html='$t("APITokenWarning", { hrefTechAssistanceEmail })')
.section
h3 {{ $t('thirdPartyApps') }}
ul
li
a(target='_blank' href='https://www.beeminder.com/habitica') {{ $t('beeminder') }}
br
| {{ $t('beeminderDesc') }}
li
a(target='_blank' href='https://chrome.google.com/webstore/detail/habitrpg-chat-client/hidkdfgonpoaiannijofifhjidbnilbb') {{ $t('chromeChatExtension') }}
br
| {{ $t('chromeChatExtensionDesc') }}
li
a(target='_blank' :href='`http://data.habitrpg.com?uuid= + user._id`') {{ $t('dataTool') }}
br
| {{ $t('dataToolDesc') }}
li(v-html="$t('otherExtensions')")
br
| {{ $t('otherDesc') }}
hr
.col-6
h2 {{ $t('webhooks') }}
table.table.table-striped
thead(v-if='user.webhooks.length')
tr
th {{ $t('enabled') }}
th {{ $t('webhookURL') }}
th
tbody
tr(v-for="(webhook, index) in user.webhooks")
td
input(type='checkbox', v-model='webhook.enabled', @change='saveWebhook(webhook, index)')
td
input.form-control(type='url', v-model='webhook.url')
td
a.btn.btn-warning.checklist-icons(@click='deleteWebhook(webhook, index)')
span.glyphicon.glyphicon-trash(:tooltip="$t('delete')") Delete
a.btn.btn-success.checklist-icons(@click='saveWebhook(webhook, index)') Update
tr
td(colspan=2)
.form-horizontal
.form-group.col-sm-10
input.form-control(type='url', v-model='newWebhook.url', :placeholder="$t('webhookURL')")
.col-sm-2
button.btn.btn-sm.btn-primary(type='submit', @click='addWebhook(newWebhook.url)') {{ $t('add') }}
</template>
<style scope>
.section {
margin-top: 2em;
}
</style>
<script>
import { mapState } from 'client/libs/store';
import uuid from '../../../common/script/libs/uuid';
// @TODO: env.EMAILS.TECH_ASSISTANCE_EMAIL
const TECH_ASSISTANCE_EMAIL = 'admin@habitica.com';
let AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings');
AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS);
export default {
data () {
return {
newWebhook: {
url: '',
},
hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`,
};
},
computed: {
...mapState({user: 'user.data'}),
apiToken () {
return AUTH_SETTINGS.auth.apiToken;
},
},
methods: {
async addWebhook (url) {
let webhookInfo = {
id: uuid(),
type: 'taskActivity',
options: {
created: false,
updated: false,
deleted: false,
scored: true,
},
url,
enabled: true,
};
let webhook = await this.$store.dispatch('user:addWebhook', {webhookInfo});
this.user.webhooks.push(webhook);
this.newWebhook.url = '';
},
async saveWebhook (webhook, index) {
delete webhook._editing;
let updatedWebhook = await this.$store.dispatch('user:updateWebhook', {webhook});
this.user.webhooks[index] = updatedWebhook;
},
async deleteWebhook (webhook, index) {
delete webhook._editing;
await this.$store.dispatch('user:deleteWebhook', {webhook});
this.user.webhooks.splice(index, 1);
},
},
};
</script>