mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-05 13:03:02 +00:00
add comments to some store functions
- some refactors to modals
This commit is contained in:
@@ -74,7 +74,7 @@ def fetch_artist_images():
|
|||||||
|
|
||||||
artists = []
|
artists = []
|
||||||
|
|
||||||
for song in tqdm(api.DB_TRACKS, desc="Gathering artists"):
|
for song in tqdm(api.DB_TRACKS, desc="Finding artists"):
|
||||||
this_artists = song["artists"].split(", ")
|
this_artists = song["artists"].split(", ")
|
||||||
|
|
||||||
for artist in this_artists:
|
for artist in this_artists:
|
||||||
|
|||||||
@@ -24,15 +24,16 @@ $gray3: rgb(72, 72, 74);
|
|||||||
$gray4: rgb(58, 58, 60);
|
$gray4: rgb(58, 58, 60);
|
||||||
$gray5: rgb(44, 44, 46);
|
$gray5: rgb(44, 44, 46);
|
||||||
|
|
||||||
$red: #fa4f55;
|
|
||||||
$blue: #0960ef;
|
$red: #FF453A;
|
||||||
|
$blue: #0A84FF;
|
||||||
$green: rgb(20, 160, 55);
|
$green: rgb(20, 160, 55);
|
||||||
$yellow: rgb(255, 214, 10);
|
$yellow: rgb(255, 214, 10);
|
||||||
$orange: rgb(255, 159, 10);
|
$orange: rgb(255, 159, 10);
|
||||||
$pink: rgb(255, 55, 95);
|
$pink: rgb(255, 55, 95);
|
||||||
$purple: rgb(191, 90, 242);
|
$purple: #bf5af2;
|
||||||
$brown: rgb(172, 142, 104);
|
$brown: rgb(172, 142, 104);
|
||||||
$indigo: rgb(94, 92, 230);
|
$indigo: #5E5CE6;
|
||||||
$teal: rgb(64, 200, 224);
|
$teal: rgb(64, 200, 224);
|
||||||
|
|
||||||
// 60 30 10
|
// 60 30 10
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ const context = useContextStore();
|
|||||||
right: -13rem;
|
right: -13rem;
|
||||||
width: 13rem;
|
width: 13rem;
|
||||||
top: -0.5rem;
|
top: -0.5rem;
|
||||||
height: 23.5rem;
|
max-height: 23.5rem;
|
||||||
|
|
||||||
padding: $small !important;
|
padding: $small !important;
|
||||||
background-color: $context;
|
background-color: $context;
|
||||||
|
|||||||
@@ -9,19 +9,25 @@
|
|||||||
id="modal-playlist-name-input"
|
id="modal-playlist-name-input"
|
||||||
/>
|
/>
|
||||||
<br />
|
<br />
|
||||||
<input type="submit" class="rounded" value="Create" />
|
<div class="submit">
|
||||||
|
<input type="submit" class="rounded" value="Create" />
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
import { createNewPlaylist } from "../../composables/playlists";
|
import { createNewPlaylist } from "../../composables/playlists";
|
||||||
import { Track } from "../../interfaces";
|
import { Track } from "../../interfaces";
|
||||||
import { Notification, NotifType } from "../../stores/notification";
|
import { Notification, NotifType } from "../../stores/notification";
|
||||||
|
import usePlaylistStore from "../../stores/playlists";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
track: Track;
|
track?: Track;
|
||||||
}>();
|
}>();
|
||||||
|
const route = useRoute();
|
||||||
|
const playlistStore = usePlaylistStore();
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
document.getElementById("modal-playlist-name-input").focus();
|
document.getElementById("modal-playlist-name-input").focus();
|
||||||
@@ -34,21 +40,29 @@ const emit = defineEmits<{
|
|||||||
|
|
||||||
emit("title", "New Playlist");
|
emit("title", "New Playlist");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new playlist. If this modal is called with a track,
|
||||||
|
* add the track to the new playlist.
|
||||||
|
* @param e Event
|
||||||
|
*/
|
||||||
function create(e: Event) {
|
function create(e: Event) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const name = (e.target as HTMLFormElement).elements["name"].value;
|
const name = (e.target as HTMLFormElement).elements["name"].value;
|
||||||
|
|
||||||
if (name.trim()) {
|
if (name.trim()) {
|
||||||
createNewPlaylist(name, props.track).then((status: boolean) => {
|
createNewPlaylist(name, props.track).then((status) => {
|
||||||
if (status) {
|
emit("hideModal");
|
||||||
emit("hideModal");
|
|
||||||
}
|
if (!status.success) return;
|
||||||
|
|
||||||
|
if (route.name !== "Playlists") return;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
playlistStore.addPlaylist(status.playlist);
|
||||||
|
}, 600);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
new Notification(
|
new Notification("Playlist name can't be empty", NotifType.Error);
|
||||||
"Playlist name can't be empty",
|
|
||||||
NotifType.Error
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -74,16 +88,24 @@ function create(e: Event) {
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.submit {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
input[type="submit"] {
|
input[type="submit"] {
|
||||||
margin: $small 0;
|
margin: $small 0;
|
||||||
background-color: $accent;
|
background-color: rgba(40, 132, 252, 0.884) !important;
|
||||||
color: #fff;
|
color: $white;
|
||||||
width: 7rem;
|
padding: $small 1rem;
|
||||||
padding: 0.75rem;
|
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
border: none;
|
border: solid 2px transparent !important;
|
||||||
outline: none;
|
outline: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
border: 2px solid $gray1 !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -40,7 +40,9 @@
|
|||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" class="rounded" value="Update" />
|
<div class="submit">
|
||||||
|
<input type="submit" class="rounded" value="Update" />
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -113,40 +115,6 @@ function update_playlist(e: Event) {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.new-p-form {
|
.new-p-form {
|
||||||
grid-gap: 1rem;
|
|
||||||
margin-top: 1rem;
|
|
||||||
|
|
||||||
label {
|
|
||||||
font-size: 0.9rem;
|
|
||||||
color: $gray1;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="text"] {
|
|
||||||
margin: $small 0;
|
|
||||||
border: 2px solid $gray3;
|
|
||||||
background-color: transparent;
|
|
||||||
color: #fff;
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.5rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
|
|
||||||
&:focus {
|
|
||||||
border: 2px solid transparent;
|
|
||||||
outline: solid 2px $gray1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="submit"] {
|
|
||||||
margin: $small 0;
|
|
||||||
background-color: $accent;
|
|
||||||
width: 7rem;
|
|
||||||
padding: 0.75rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
#upload {
|
#upload {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: $small;
|
padding: $small;
|
||||||
@@ -184,22 +152,5 @@ function update_playlist(e: Event) {
|
|||||||
outline: solid 2px $gray1;
|
outline: solid 2px $gray1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.colors {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(2rem, 1fr));
|
|
||||||
grid-gap: 0.5rem;
|
|
||||||
margin: 0.5rem 0;
|
|
||||||
|
|
||||||
.color {
|
|
||||||
height: 2.5rem;
|
|
||||||
width: 2.5rem;
|
|
||||||
border-radius: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selected {
|
|
||||||
border: 4px solid $white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="p-card rounded" id="new-playlist-card">
|
<div
|
||||||
|
class="p-card rounded"
|
||||||
|
id="new-playlist-card"
|
||||||
|
@click="Modal.showNewPlaylistModal()"
|
||||||
|
>
|
||||||
<div class="gradient rounded"></div>
|
<div class="gradient rounded"></div>
|
||||||
<div class="plus image p-image"></div>
|
<div class="plus image p-image"></div>
|
||||||
<div>New Playlist</div>
|
<div>New Playlist</div>
|
||||||
@@ -7,6 +11,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import useModalStore from "../../stores/modal";
|
||||||
|
|
||||||
|
const Modal = useModalStore();
|
||||||
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
#new-playlist-card {
|
#new-playlist-card {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -35,10 +45,10 @@
|
|||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
.gradient {
|
.gradient {
|
||||||
background-size: 300rem;
|
background-size: 29rem;
|
||||||
}
|
}
|
||||||
.image {
|
.image {
|
||||||
transform: rotate(270deg);
|
transform: rotate(180deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ const props = defineProps<{
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.75rem;
|
padding: 0.75rem;
|
||||||
transition: all 0.25s ease;
|
transition: all 0.25s ease;
|
||||||
background-position: -10rem;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
|
background-color: #1c1c1e80;
|
||||||
|
|
||||||
.p-image {
|
.p-image {
|
||||||
min-width: 100%;
|
min-width: 100%;
|
||||||
|
|||||||
@@ -7,7 +7,10 @@ import state from "./state";
|
|||||||
* @param playlist_name The name of the playlist to create.
|
* @param playlist_name The name of the playlist to create.
|
||||||
*/
|
*/
|
||||||
async function createNewPlaylist(playlist_name: string, track?: Track) {
|
async function createNewPlaylist(playlist_name: string, track?: Track) {
|
||||||
let status = false;
|
let status = {
|
||||||
|
success: false,
|
||||||
|
playlist: <Playlist>{},
|
||||||
|
};
|
||||||
|
|
||||||
await axios
|
await axios
|
||||||
.post(state.settings.uri + "/playlist/new", {
|
.post(state.settings.uri + "/playlist/new", {
|
||||||
@@ -22,7 +25,8 @@ async function createNewPlaylist(playlist_name: string, track?: Track) {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = true;
|
status.success = true;
|
||||||
|
status.playlist = res.data.playlist;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.response.status == 409) {
|
if (err.response.status == 409) {
|
||||||
|
|||||||
@@ -14,6 +14,12 @@ export default defineStore("album", {
|
|||||||
bio: null,
|
bio: null,
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
/**
|
||||||
|
* Fetches a single album information, artists and its tracks from the server
|
||||||
|
* using the title and album-artist of the album.
|
||||||
|
* @param title title of the album
|
||||||
|
* @param albumartist artist of the album
|
||||||
|
*/
|
||||||
async fetchTracksAndArtists(title: string, albumartist: string) {
|
async fetchTracksAndArtists(title: string, albumartist: string) {
|
||||||
const tracks = await getAlbumTracks(title, albumartist);
|
const tracks = await getAlbumTracks(title, albumartist);
|
||||||
const artists = await getAlbumArtists(title, albumartist);
|
const artists = await getAlbumArtists(title, albumartist);
|
||||||
@@ -22,6 +28,11 @@ export default defineStore("album", {
|
|||||||
this.info = tracks.info;
|
this.info = tracks.info;
|
||||||
this.artists = artists;
|
this.artists = artists;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Fetches the album bio from the server
|
||||||
|
* @param title title of the album
|
||||||
|
* @param albumartist artist of the album
|
||||||
|
*/
|
||||||
fetchBio(title: string, albumartist: string) {
|
fetchBio(title: string, albumartist: string) {
|
||||||
this.bio = null;
|
this.bio = null;
|
||||||
getAlbumBio(title, albumartist).then((bio) => {
|
getAlbumBio(title, albumartist).then((bio) => {
|
||||||
|
|||||||
+6
-2
@@ -19,9 +19,13 @@ export default defineStore("newModal", {
|
|||||||
this.component = modalOption;
|
this.component = modalOption;
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
showNewPlaylistModal(track: Track) {
|
showNewPlaylistModal(track?: Track) {
|
||||||
this.component = ModalOptions.newPlaylist;
|
this.component = ModalOptions.newPlaylist;
|
||||||
this.props.track = track;
|
|
||||||
|
if (track) {
|
||||||
|
this.props.track = track;
|
||||||
|
}
|
||||||
|
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
},
|
},
|
||||||
showEditPlaylistModal(playlist: Playlist) {
|
showEditPlaylistModal(playlist: Playlist) {
|
||||||
|
|||||||
@@ -8,11 +8,21 @@ export default defineStore("playlist-tracks", {
|
|||||||
tracks: <Track[]>[],
|
tracks: <Track[]>[],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
/**
|
||||||
|
* Fetches a single playlist information, and its tracks from the server
|
||||||
|
* @param playlistid The id of the playlist to fetch
|
||||||
|
*/
|
||||||
async fetchAll(playlistid: string) {
|
async fetchAll(playlistid: string) {
|
||||||
const playlist = await getPlaylist(playlistid);
|
const playlist = await getPlaylist(playlistid);
|
||||||
|
|
||||||
this.info = playlist.info;
|
this.info = playlist.info;
|
||||||
this.tracks = playlist.tracks;
|
this.tracks = playlist.tracks;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Updates the playlist header info. This is used when the playlist is
|
||||||
|
* updated.
|
||||||
|
* @param info Playlist info
|
||||||
|
*/
|
||||||
updatePInfo(info: Playlist) {
|
updatePInfo(info: Playlist) {
|
||||||
this.info = info;
|
this.info = info;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,10 +7,22 @@ export default defineStore("playlists", {
|
|||||||
playlists: <Playlist[]>[],
|
playlists: <Playlist[]>[],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
/**
|
||||||
|
* Fetch all playlists from the server
|
||||||
|
*/
|
||||||
async fetchAll() {
|
async fetchAll() {
|
||||||
const playlists = await getAllPlaylists();
|
const playlists = await getAllPlaylists();
|
||||||
|
|
||||||
this.playlists = playlists;
|
this.playlists = playlists;
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Adds a single playlist to the store
|
||||||
|
* @param playlist Playlist to add to the store
|
||||||
|
* @returns void
|
||||||
|
*/
|
||||||
|
addPlaylist(playlist: Playlist) {
|
||||||
|
// add at the beginning
|
||||||
|
this.playlists.unshift(playlist);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user