Skip to content

Commit

Permalink
Add smartlist support
Browse files Browse the repository at this point in the history
  • Loading branch information
usox committed Apr 11, 2022
1 parent 4871d6b commit a24ae7b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/components/Navigation/PlayerControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
<div class="amplitude-next control-button">
<font-awesome-icon :icon="['fas', 'step-forward']" :title="$t('player_control.next')" />
</div>
<div class="amplitude-shuffle control-button">
<font-awesome-icon :icon="['fas', 'shuffle']" :title="$t('player_control.shuffle')" />
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -89,6 +92,14 @@ div.control-button {
font-size: 150%;
}
div.amplitude-shuffle-on {
color: rgb(175, 118, 12);
}
div.amplitude-shuffle-on:hover {
color: rgb(85, 57, 5);
}
div.control-button-paused {
animation: blinker 3s linear infinite;
}
Expand Down
32 changes: 29 additions & 3 deletions src/components/Playlist/PlaylistEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
<div>
<input type="text" class="textInput" :placeholder="$t('playlists_edit.input.name_placeholder')" v-model="name" required />
</div>
<div v-if="isNewPlaylist()">
<select v-model="selectedPlaylistType">
<option v-for="option in playlistTypes" :value="option.value" v-bind:key="option.value">
{{ $t(option.label) }}
</option>
</select>
</div>
<div>
<input type="button" class="button" @click="save()" :value="$t('playlists_edit.save')" />
</div>
Expand All @@ -31,7 +38,9 @@ export default defineComponent({
data() {
return {
playlist: new Playlist(),
msg: ''
msg: '',
playlistTypes: null as Array<{value: string, label: string}>|null,
selectedPlaylistType: 1 as number
}
},
components: {
Expand All @@ -51,21 +60,36 @@ export default defineComponent({
let playlistId = +this.$route.params.playlistId;
if (playlistId !== 0) {
EntityLoader.loadPlaylist(playlistId).then((playlist: PlaylistInterface) => this.playlist = playlist);
} else {
HttpRequest.get(
'playlist_types'
).then((response: AxiosResponse): void => {
this.playlistTypes = response.data.items.map((typeId: number): object => {
return {
'value': typeId,
'label': 'playlist_type.' + typeId
};
});
});
}
},
methods: {
async save(): Promise<void> {
if (this.playlist.getId() === 0) {
if (this.isNewPlaylist()) {
this.create();
} else {
this.persist();
}
},
isNewPlaylist(): boolean {
return this.playlist.getId() === 0
},
async create(): Promise<void> {
HttpRequest.post(
'playlist',
{
name: this.playlist.getName(),
typeId: this.selectedPlaylistType,
}
).then((response: AxiosResponse): void => {
let data = response.data;
Expand Down Expand Up @@ -110,7 +134,9 @@ div.creationBox form div {
width: 100%;
}
input[type=text], input[type=password] {
input[type=text],
input[type=password],
select {
width: 80%;
}
Expand Down
7 changes: 6 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"previous": "Letzter",
"next": "Nächster",
"play": "Abspielen",
"pause": "Pausieren"
"pause": "Pausieren",
"shuffle": "Zufallswiedergabe"
},
"songs": {
"title": "Titel",
Expand Down Expand Up @@ -185,5 +186,9 @@
"country_iso2": {
"en": "Englisch",
"de": "Deutsch"
},
"playlist_type": {
"1": "Statische Playlist",
"2": "Favoriten"
}
}
7 changes: 6 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@
"previous": "Previous",
"next": "Next",
"play": "Play",
"pause": "Pause"
"pause": "Pause",
"shuffle": "Shuffle"
},
"songs": {
"title": "Songs",
Expand Down Expand Up @@ -185,5 +186,9 @@
"country_iso2": {
"en": "English",
"de": "German"
},
"playlist_type": {
"1": "Static playlist",
"2": "Favorites"
}
}
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { faTools } from '@fortawesome/free-solid-svg-icons'
import { faPlus } from '@fortawesome/free-solid-svg-icons';
import { faTriangleExclamation } from '@fortawesome/free-solid-svg-icons';
import { faCircleCheck } from '@fortawesome/free-solid-svg-icons';
import { faShuffle } from '@fortawesome/free-solid-svg-icons';
import enLocaleMessages from './locales/en.json'
import deLocaleMessages from './locales/de.json'
import { createI18n } from 'vue-i18n';
Expand Down Expand Up @@ -46,6 +47,7 @@ library.add(faTools);
library.add(faPlus);
library.add(faTriangleExclamation);
library.add(faCircleCheck);
library.add(faShuffle);

const emitter = mitt();

Expand Down

0 comments on commit a24ae7b

Please sign in to comment.