2020-01-04 18:53:27 +01:00
|
|
|
<template>
|
2022-02-19 06:18:01 +01:00
|
|
|
<div class="fd-page-with-tabs">
|
2022-02-19 06:39:14 +01:00
|
|
|
<tabs-settings />
|
2020-01-04 18:53:27 +01:00
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2022-05-20 13:44:22 +02:00
|
|
|
<div class="title is-4" v-text="$t('page.settings.services.spotify.title')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
|
|
|
<div v-if="!spotify.spotify_installed" class="notification is-size-7">
|
2022-05-20 13:44:22 +02:00
|
|
|
<p v-text="$t('page.settings.services.spotify.no-support')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
2021-07-04 14:43:54 +02:00
|
|
|
<div v-if="spotify.spotify_installed">
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="notification is-size-7">
|
2022-05-20 13:44:22 +02:00
|
|
|
<b v-text="$t('page.settings.services.spotify.requirements')" />
|
|
|
|
<span v-if="use_libspotity" v-text="$t('page.settings.services.spotify.help')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
2021-07-04 14:43:54 +02:00
|
|
|
<div v-if="use_libspotity">
|
2020-01-04 18:53:27 +01:00
|
|
|
<p class="content">
|
2022-05-20 13:44:22 +02:00
|
|
|
<b v-text="$t('page.settings.services.spotify')" />
|
|
|
|
<span v-text="$t('page.settings.services.spotify.credentials')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
|
|
|
<p v-if="spotify.libspotify_logged_in" class="fd-has-margin-bottom">
|
2022-05-20 13:44:22 +02:00
|
|
|
<span v-text="$t('page.settings.services.spotify.logged-as')" />
|
|
|
|
<b><code v-text="spotify.libspotify_user" /></b>
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-05-20 13:44:22 +02:00
|
|
|
<form v-if="spotify.spotify_installed && !spotify.libspotify_logged_in" @submit.prevent="login_libspotify">
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control is-expanded">
|
2022-05-20 13:44:22 +02:00
|
|
|
<input v-model="libspotify.user" class="input" type="text" placeholder="Username" />
|
|
|
|
<p class="help is-danger" v-text="libspotify.errors.user" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control is-expanded">
|
2022-05-20 13:44:22 +02:00
|
|
|
<input v-model="libspotify.password" class="input" type="password" placeholder="Password" />
|
|
|
|
<p class="help is-danger" v-text="libspotify.errors.password" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
2022-05-20 13:44:22 +02:00
|
|
|
<button class="button is-info" v-text="$t('page.settings.services.login')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="help is-danger" v-text="libspotify.errors.error" />
|
|
|
|
<p class="help" v-text="$t('page.settings.services.spotify.help-1')" />
|
|
|
|
<p class="help" v-text="$t('page.settings.services.spotify.help-2')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="fd-has-margin-top">
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="content" v-html="$t('page.settings.services.spotify.grant-access')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
<p v-if="spotify.webapi_token_valid">
|
2022-05-20 13:44:22 +02:00
|
|
|
<span v-text="$t('page.settings.services.spotify.user')" />
|
|
|
|
<code v-text="spotify.webapi_user" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<p v-if="spotify_missing_scope.length > 0" class="help is-danger">
|
2022-05-20 13:44:22 +02:00
|
|
|
<span v-text="$t('page.settings.services.spotify.reauthorize')" />
|
|
|
|
<code v-text="spotify_missing_scope.join()" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-02-19 06:39:14 +01:00
|
|
|
<div class="field fd-has-margin-top">
|
2020-01-04 18:53:27 +01:00
|
|
|
<div class="control">
|
2022-05-20 13:44:22 +02:00
|
|
|
<a class="button" :class="{ 'is-info': !spotify.webapi_token_valid || spotify_missing_scope.length > 0 }" :href="spotify.oauth_uri" v-text="$t('page.settings.services.spotify.authorize')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<p class="help">
|
2022-05-20 13:44:22 +02:00
|
|
|
<span v-text="$t('page.settings.services.spotify.scopes')" />
|
|
|
|
<code v-text="spotify_required_scope.join()" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</p>
|
2022-05-20 13:44:22 +02:00
|
|
|
<div v-if="spotify.webapi_token_valid" class="field fd-has-margin-top">
|
2021-12-26 20:19:51 +01:00
|
|
|
<div class="control">
|
2022-05-20 13:44:22 +02:00
|
|
|
<a class="button is-danger" @click="logout_spotify" v-text="$t('page.settings.services.logout')" />
|
2021-12-26 20:19:51 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
<content-with-heading>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #heading-left>
|
2022-05-20 13:44:22 +02:00
|
|
|
<div class="title is-4" v-text="$t('page.settings.services.lastfm.title')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</template>
|
2022-02-19 06:39:14 +01:00
|
|
|
<template #content>
|
|
|
|
<div v-if="!lastfm.enabled" class="notification is-size-7">
|
2022-05-20 13:44:22 +02:00
|
|
|
<p v-text="$t('page.settings.services.lastfm.no-support')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="lastfm.enabled">
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="content" v-html="$t('page.settings.services.lastfm.grant-access')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
<div v-if="lastfm.scrobbling_enabled">
|
2022-05-20 13:44:22 +02:00
|
|
|
<a class="button" @click="logoutLastfm" v-text="$t('page.settings.services.lastfm.stop-scrobbling')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="!lastfm.scrobbling_enabled">
|
|
|
|
<form @submit.prevent="login_lastfm">
|
|
|
|
<div class="field is-grouped">
|
|
|
|
<div class="control is-expanded">
|
2022-05-20 13:44:22 +02:00
|
|
|
<input v-model="lastfm_login.user" class="input" type="text" placeholder="Username" />
|
|
|
|
<p class="help is-danger" v-text="lastfm_login.errors.user" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control is-expanded">
|
2022-05-20 13:44:22 +02:00
|
|
|
<input v-model="lastfm_login.password" class="input" type="password" placeholder="Password" />
|
|
|
|
<p class="help is-danger" v-text="lastfm_login.errors.password" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
<div class="control">
|
2022-05-20 13:44:22 +02:00
|
|
|
<button class="button is-info" type="submit" v-text="$t('page.settings.services.login')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-20 13:44:22 +02:00
|
|
|
<p class="help is-danger" v-text="lastfm_login.errors.error" />
|
|
|
|
<p class="help" v-text="$t('page.settings.services.lastfm.info')" />
|
2020-01-04 18:53:27 +01:00
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</content-with-heading>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-02-19 06:18:01 +01:00
|
|
|
import ContentWithHeading from '@/templates/ContentWithHeading.vue'
|
|
|
|
import TabsSettings from '@/components/TabsSettings.vue'
|
2020-01-04 18:53:27 +01:00
|
|
|
import webapi from '@/webapi'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'SettingsPageOnlineServices',
|
|
|
|
components: { ContentWithHeading, TabsSettings },
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
filters: {
|
|
|
|
join(array) {
|
|
|
|
return array.join(', ')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return {
|
2022-02-19 06:39:14 +01:00
|
|
|
libspotify: {
|
|
|
|
user: '',
|
|
|
|
password: '',
|
|
|
|
errors: { user: '', password: '', error: '' }
|
|
|
|
},
|
|
|
|
lastfm_login: {
|
|
|
|
user: '',
|
|
|
|
password: '',
|
|
|
|
errors: { user: '', password: '', error: '' }
|
|
|
|
}
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2022-02-19 06:39:14 +01:00
|
|
|
lastfm() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.$store.state.lastfm
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify() {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.$store.state.spotify
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_required_scope() {
|
2021-12-26 20:19:51 +01:00
|
|
|
if (this.spotify.webapi_required_scope) {
|
2020-01-04 18:53:27 +01:00
|
|
|
return this.spotify.webapi_required_scope.split(' ')
|
|
|
|
}
|
|
|
|
return []
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
spotify_missing_scope() {
|
|
|
|
if (
|
|
|
|
this.spotify.webapi_token_valid &&
|
|
|
|
this.spotify.webapi_granted_scope &&
|
|
|
|
this.spotify.webapi_required_scope
|
|
|
|
) {
|
|
|
|
return this.spotify.webapi_required_scope
|
|
|
|
.split(' ')
|
|
|
|
.filter(
|
|
|
|
(scope) => this.spotify.webapi_granted_scope.indexOf(scope) < 0
|
|
|
|
)
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
return []
|
2021-07-04 14:43:54 +02:00
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
use_libspotify() {
|
2021-07-04 14:43:54 +02:00
|
|
|
return this.$store.state.config.use_libspotify
|
2020-01-04 18:53:27 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
2022-02-19 06:39:14 +01:00
|
|
|
login_libspotify() {
|
|
|
|
webapi.spotify_login(this.libspotify).then((response) => {
|
2020-01-04 18:53:27 +01:00
|
|
|
this.libspotify.user = ''
|
|
|
|
this.libspotify.password = ''
|
|
|
|
this.libspotify.errors.user = ''
|
|
|
|
this.libspotify.errors.password = ''
|
|
|
|
this.libspotify.errors.error = ''
|
|
|
|
|
|
|
|
if (!response.data.success) {
|
|
|
|
this.libspotify.errors.user = response.data.errors.user
|
|
|
|
this.libspotify.errors.password = response.data.errors.password
|
|
|
|
this.libspotify.errors.error = response.data.errors.error
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
logout_spotify() {
|
2021-12-26 20:19:51 +01:00
|
|
|
webapi.spotify_logout()
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
login_lastfm() {
|
|
|
|
webapi.lastfm_login(this.lastfm_login).then((response) => {
|
2020-01-04 18:53:27 +01:00
|
|
|
this.lastfm_login.user = ''
|
|
|
|
this.lastfm_login.password = ''
|
|
|
|
this.lastfm_login.errors.user = ''
|
|
|
|
this.lastfm_login.errors.password = ''
|
|
|
|
this.lastfm_login.errors.error = ''
|
|
|
|
|
|
|
|
if (!response.data.success) {
|
|
|
|
this.lastfm_login.errors.user = response.data.errors.user
|
|
|
|
this.lastfm_login.errors.password = response.data.errors.password
|
|
|
|
this.lastfm_login.errors.error = response.data.errors.error
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
logoutLastfm() {
|
2020-01-04 18:53:27 +01:00
|
|
|
webapi.lastfm_logout()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2022-02-19 06:39:14 +01:00
|
|
|
<style></style>
|