2022-04-15 14:24:30 +00:00
|
|
|
|
<template>
|
|
|
|
|
<section class="text-secondary">
|
2023-12-27 11:49:28 +00:00
|
|
|
|
<h1>
|
|
|
|
|
<span class="lastfm-icon">
|
|
|
|
|
<Icon :icon="faLastfm" />
|
|
|
|
|
</span>
|
|
|
|
|
Last.fm Integration
|
|
|
|
|
</h1>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
|
<div v-if="useLastfm" data-testid="lastfm-integrated">
|
2023-12-27 11:49:28 +00:00
|
|
|
|
<p>Last.fm integration is enabled. Koel will attempt to retrieve album and artist information from Last.fm.</p>
|
|
|
|
|
<p v-if="connected">
|
|
|
|
|
It appears that you have connected your Last.fm account as well – Perfect!
|
2022-04-15 14:24:30 +00:00
|
|
|
|
</p>
|
2023-12-27 11:49:28 +00:00
|
|
|
|
<p v-else>You can also connect your Last.fm account here.</p>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
<p>
|
|
|
|
|
Connecting Koel and your Last.fm account enables such exciting features as
|
|
|
|
|
<a
|
2022-07-15 07:23:55 +00:00
|
|
|
|
class="text-highlight"
|
2022-04-15 14:24:30 +00:00
|
|
|
|
href="https://www.last.fm/about/trackmymusic"
|
|
|
|
|
rel="noopener"
|
2022-04-21 22:51:48 +00:00
|
|
|
|
target="_blank"
|
2022-07-16 22:42:29 +00:00
|
|
|
|
>scrobbling</a>.
|
2022-04-15 14:24:30 +00:00
|
|
|
|
</p>
|
|
|
|
|
<div class="buttons">
|
2022-04-21 22:51:48 +00:00
|
|
|
|
<Btn class="connect" @click.prevent="connect">
|
|
|
|
|
{{ connected ? 'Reconnect' : 'Connect' }}
|
2022-04-15 17:00:08 +00:00
|
|
|
|
</Btn>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
|
<Btn v-if="connected" class="disconnect" gray @click.prevent="disconnect">Disconnect</Btn>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-else data-testid="lastfm-not-integrated">
|
|
|
|
|
<p>
|
2023-12-27 11:49:28 +00:00
|
|
|
|
Last.fm integration is not enabled on this installation of Koel.
|
2022-04-30 14:05:02 +00:00
|
|
|
|
<span v-if="isAdmin" data-testid="lastfm-admin-instruction">
|
2022-04-15 14:24:30 +00:00
|
|
|
|
Visit
|
2022-07-15 07:23:55 +00:00
|
|
|
|
<a href="https://docs.koel.dev/3rd-party.html#last-fm" class="text-highlight" target="_blank">Koel’s Wiki</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
for a quick how-to.
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else data-testid="lastfm-user-instruction">
|
|
|
|
|
Try politely asking an administrator to enable it.
|
|
|
|
|
</span>
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
|
import { faLastfm } from '@fortawesome/free-brands-svg-icons'
|
2022-04-30 14:05:02 +00:00
|
|
|
|
import { computed, defineAsyncComponent } from 'vue'
|
2022-09-15 09:07:25 +00:00
|
|
|
|
import { authService, http } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
import { forceReloadWindow } from '@/utils'
|
2022-04-30 14:05:02 +00:00
|
|
|
|
import { useAuthorization, useThirdPartyServices } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-21 18:39:18 +00:00
|
|
|
|
const Btn = defineAsyncComponent(() => import('@/components/ui/Btn.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-30 14:05:02 +00:00
|
|
|
|
const { currentUser, isAdmin } = useAuthorization()
|
|
|
|
|
const { useLastfm } = useThirdPartyServices()
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
|
const connected = computed(() => Boolean(currentUser.value.preferences!.lastfm_session_key))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* Connect the current user to Last.fm.
|
|
|
|
|
* This method opens a new window.
|
|
|
|
|
* Koel will reload once the connection is successful.
|
|
|
|
|
*/
|
|
|
|
|
const connect = () => window.open(
|
2022-11-16 17:57:38 +00:00
|
|
|
|
`${window.BASE_URL}lastfm/connect?api_token=${authService.getApiToken()}`,
|
2022-04-15 17:00:08 +00:00
|
|
|
|
'_blank',
|
|
|
|
|
'toolbar=no,titlebar=no,location=no,width=1024,height=640'
|
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
|
2022-04-21 22:51:48 +00:00
|
|
|
|
const disconnect = async () => {
|
2022-09-15 09:07:25 +00:00
|
|
|
|
await http.delete('lastfm/disconnect')
|
2022-04-21 22:51:48 +00:00
|
|
|
|
forceReloadWindow()
|
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2023-12-27 11:49:28 +00:00
|
|
|
|
.lastfm-icon {
|
|
|
|
|
color: #d31f27; // Last.fm red
|
|
|
|
|
margin-right: .4rem;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
|
.buttons {
|
|
|
|
|
margin-top: 1.25rem;
|
|
|
|
|
|
2022-04-30 11:59:37 +00:00
|
|
|
|
> * + * {
|
|
|
|
|
margin-left: 0.5rem;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-15 14:24:30 +00:00
|
|
|
|
.connect {
|
2023-12-27 11:49:28 +00:00
|
|
|
|
background: #d31f27;
|
2022-04-15 14:24:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|