2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2021-02-06 17:08:32 +00:00
|
|
|
<FormBase>
|
|
|
|
<div class="_formItem" v-if="enableTwitterIntegration">
|
|
|
|
<div class="_formLabel"><Fa :icon="faTwitter"/> Twitter</div>
|
|
|
|
<div class="_formPanel" style="padding: 16px;">
|
|
|
|
<p v-if="integrations.twitter">{{ $ts.connectedTo }}: <a :href="`https://twitter.com/${integrations.twitter.screenName}`" rel="nofollow noopener" target="_blank">@{{ integrations.twitter.screenName }}</a></p>
|
|
|
|
<MkButton v-if="integrations.twitter" @click="disconnectTwitter" danger>{{ $ts.disconnectSerice }}</MkButton>
|
|
|
|
<MkButton v-else @click="connectTwitter" primary>{{ $ts.connectSerice }}</MkButton>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
|
2021-02-06 17:08:32 +00:00
|
|
|
<div class="_formItem" v-if="enableDiscordIntegration">
|
|
|
|
<div class="_formLabel"><Fa :icon="faDiscord"/> Discord</div>
|
|
|
|
<div class="_formPanel" style="padding: 16px;">
|
|
|
|
<p v-if="integrations.discord">{{ $ts.connectedTo }}: <a :href="`https://discord.com/users/${integrations.discord.id}`" rel="nofollow noopener" target="_blank">@{{ integrations.discord.username }}#{{ integrations.discord.discriminator }}</a></p>
|
|
|
|
<MkButton v-if="integrations.discord" @click="disconnectDiscord" danger>{{ $ts.disconnectSerice }}</MkButton>
|
|
|
|
<MkButton v-else @click="connectDiscord" primary>{{ $ts.connectSerice }}</MkButton>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
|
2021-02-06 17:08:32 +00:00
|
|
|
<div class="_formItem" v-if="enableGithubIntegration">
|
|
|
|
<div class="_formLabel"><Fa :icon="faGithub"/> GitHub</div>
|
|
|
|
<div class="_formPanel" style="padding: 16px;">
|
|
|
|
<p v-if="integrations.github">{{ $ts.connectedTo }}: <a :href="`https://github.com/${integrations.github.login}`" rel="nofollow noopener" target="_blank">@{{ integrations.github.login }}</a></p>
|
|
|
|
<MkButton v-if="integrations.github" @click="disconnectGithub" danger>{{ $ts.disconnectSerice }}</MkButton>
|
|
|
|
<MkButton v-else @click="connectGithub" primary>{{ $ts.connectSerice }}</MkButton>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
2021-02-06 17:08:32 +00:00
|
|
|
</FormBase>
|
2020-01-29 19:37:25 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent } from 'vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faTwitter, faDiscord, faGithub } from '@fortawesome/free-brands-svg-icons';
|
2021-03-23 08:30:14 +00:00
|
|
|
import { apiUrl } from '@client/config';
|
|
|
|
import FormBase from '@client/components/form/base.vue';
|
|
|
|
import MkButton from '@client/components/ui/button.vue';
|
|
|
|
import * as os from '@client/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
2021-02-06 17:08:32 +00:00
|
|
|
FormBase,
|
2020-01-29 19:37:25 +00:00
|
|
|
MkButton
|
|
|
|
},
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
emits: ['info'],
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2020-10-17 11:12:00 +00:00
|
|
|
INFO: {
|
2020-12-26 01:47:36 +00:00
|
|
|
title: this.$ts.integration,
|
2020-11-03 11:36:12 +00:00
|
|
|
icon: faShareAlt
|
2020-10-17 11:12:00 +00:00
|
|
|
},
|
2020-01-29 19:37:25 +00:00
|
|
|
apiUrl,
|
|
|
|
twitterForm: null,
|
|
|
|
discordForm: null,
|
|
|
|
githubForm: null,
|
|
|
|
enableTwitterIntegration: false,
|
|
|
|
enableDiscordIntegration: false,
|
|
|
|
enableGithubIntegration: false,
|
|
|
|
faShareAlt, faTwitter, faDiscord, faGithub
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-01-31 22:16:52 +00:00
|
|
|
computed: {
|
|
|
|
integrations() {
|
2020-12-19 01:55:52 +00:00
|
|
|
return this.$i.integrations;
|
2020-02-10 14:17:42 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
meta() {
|
2020-12-19 01:55:52 +00:00
|
|
|
return this.$instance;
|
2020-02-10 14:17:42 +00:00
|
|
|
},
|
2020-01-31 22:16:52 +00:00
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
created() {
|
2020-02-10 14:17:42 +00:00
|
|
|
this.enableTwitterIntegration = this.meta.enableTwitterIntegration;
|
|
|
|
this.enableDiscordIntegration = this.meta.enableDiscordIntegration;
|
|
|
|
this.enableGithubIntegration = this.meta.enableGithubIntegration;
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-10-17 11:12:00 +00:00
|
|
|
this.$emit('info', this.INFO);
|
|
|
|
|
2020-12-19 01:55:52 +00:00
|
|
|
document.cookie = `igi=${this.$i.token}; path=/;` +
|
2020-03-20 04:56:22 +00:00
|
|
|
` max-age=31536000;` +
|
2020-01-29 19:37:25 +00:00
|
|
|
(document.location.protocol.startsWith('https') ? ' secure' : '');
|
2020-03-20 04:56:22 +00:00
|
|
|
|
2020-01-31 22:16:52 +00:00
|
|
|
this.$watch('integrations', () => {
|
|
|
|
if (this.integrations.twitter) {
|
2020-01-29 19:37:25 +00:00
|
|
|
if (this.twitterForm) this.twitterForm.close();
|
|
|
|
}
|
2020-01-31 22:16:52 +00:00
|
|
|
if (this.integrations.discord) {
|
2020-01-29 19:37:25 +00:00
|
|
|
if (this.discordForm) this.discordForm.close();
|
|
|
|
}
|
2020-01-31 22:16:52 +00:00
|
|
|
if (this.integrations.github) {
|
2020-01-29 19:37:25 +00:00
|
|
|
if (this.githubForm) this.githubForm.close();
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
deep: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
connectTwitter() {
|
|
|
|
this.twitterForm = window.open(apiUrl + '/connect/twitter',
|
|
|
|
'twitter_connect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
|
|
|
|
disconnectTwitter() {
|
|
|
|
window.open(apiUrl + '/disconnect/twitter',
|
|
|
|
'twitter_disconnect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
|
|
|
|
connectDiscord() {
|
|
|
|
this.discordForm = window.open(apiUrl + '/connect/discord',
|
|
|
|
'discord_connect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
|
|
|
|
disconnectDiscord() {
|
|
|
|
window.open(apiUrl + '/disconnect/discord',
|
|
|
|
'discord_disconnect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
|
|
|
|
connectGithub() {
|
|
|
|
this.githubForm = window.open(apiUrl + '/connect/github',
|
|
|
|
'github_connect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
|
|
|
|
disconnectGithub() {
|
|
|
|
window.open(apiUrl + '/disconnect/github',
|
|
|
|
'github_disconnect_window',
|
|
|
|
'height=570, width=520');
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|