koel/resources/assets/js/components/main-wrapper/sidebar/index.vue

281 lines
8.2 KiB
Vue
Raw Normal View History

2015-12-13 04:42:28 +00:00
<template>
<nav class="side side-nav" id="sidebar" :class="{ showing: showing }">
<section class="music">
<h1>Your Music</h1>
<ul class="menu">
<li>
<a class="home" :class="[currentView == 'home' ? 'active' : '']"
@click.prevent="$root.loadMainView('home')">Home</a>
</li>
<li>
<a class="queue"
2015-12-24 09:50:56 +00:00
:class="[currentView == 'queue' ? 'active' : '']"
@click.prevent="$root.loadMainView('queue')"
@dragleave="removeDroppableState"
@dragover.prevent="allowDrop"
@drop.stop.prevent="handleDrop">Current Queue</a>
2015-12-13 04:42:28 +00:00
</li>
<li>
<a class="songs" :class="[currentView == 'songs' ? 'active' : '']"
2015-12-13 04:42:28 +00:00
@click.prevent="$root.loadMainView('songs')">All Songs</a>
</li>
<li>
<a class="albums" :class="[currentView == 'albums' ? 'active' : '']"
2015-12-13 04:42:28 +00:00
@click.prevent="$root.loadMainView('albums')">Albums</a>
</li>
<li>
<a class="artists" :class="[currentView == 'artists' ? 'active' : '']"
2015-12-13 04:42:28 +00:00
@click.prevent="$root.loadMainView('artists')">Artists</a>
</li>
</ul>
</section>
<playlists :current-view="currentView"></playlists>
2015-12-13 04:42:28 +00:00
<section v-if="user.current.is_admin" class="manage">
<h1>Manage</h1>
<ul class="menu">
<li>
<a class="settings" :class="[currentView == 'settings' ? 'active' : '']"
2015-12-13 04:42:28 +00:00
@click.prevent="$root.loadMainView('settings')">Settings</a>
</li>
<li>
<a class="users" :class="[currentView == 'users' ? 'active' : '']"
@click.prevent="$root.loadMainView('users')">Users</a>
</li>
</ul>
</section>
2015-12-27 14:06:10 +00:00
<a
2015-12-27 14:06:10 +00:00
href="https://github.com/phanan/koel/releases"
target="_blank"
v-show="user.current.is_admin && sharedState.currentVersion < sharedState.latestVersion"
2015-12-27 14:06:10 +00:00
class="new-ver">
Koel version {{ sharedState.latestVersion }} is available!
</a>
2015-12-13 04:42:28 +00:00
</nav>
</template>
<script>
import isMobile from 'ismobilejs';
2015-12-24 09:50:56 +00:00
import $ from 'jquery';
2015-12-13 04:42:28 +00:00
import playlists from './playlists.vue';
import userStore from '../../../stores/user';
2015-12-24 09:50:56 +00:00
import songStore from '../../../stores/song';
import queueStore from '../../../stores/queue';
2015-12-27 14:06:10 +00:00
import sharedStore from '../../../stores/shared';
2015-12-13 04:42:28 +00:00
export default {
components: { playlists },
data() {
return {
currentView: 'queue',
user: userStore.state,
showing: !isMobile.phone,
2015-12-27 14:06:10 +00:00
sharedState: sharedStore.state,
2015-12-13 04:42:28 +00:00
};
},
2015-12-24 09:50:56 +00:00
methods: {
/**
* Remove the droppable state when a dragleave event occurs on the playlist's DOM element.
*
2015-12-24 09:50:56 +00:00
* @param {Object} e The dragleave event.
*/
removeDroppableState(e) {
$(e.target).removeClass('droppable');
},
/**
* Add a "droppable" class and set the drop effect when an item is dragged over "Queue" menu.
*
2015-12-24 09:50:56 +00:00
* @param {Object} e The dragover event.
*/
allowDrop(e) {
$(e.target).addClass('droppable');
e.dataTransfer.dropEffect = 'move';
return false;
},
/**
* Handle songs dropped to our Queue menu item.
*
2015-12-24 09:50:56 +00:00
* @param {Object} e The event
*
2016-01-17 14:26:24 +00:00
* @return {Boolean}
2015-12-24 09:50:56 +00:00
*/
handleDrop(e) {
this.removeDroppableState(e);
2016-01-15 07:27:25 +00:00
if (!e.dataTransfer.getData('text/plain')) {
return false;
}
2016-03-16 03:51:07 +00:00
let songs = songStore.byIds(e.dataTransfer.getData('text/plain').split(','));
2015-12-24 09:50:56 +00:00
if (!songs.length) {
return false;
}
queueStore.queue(songs);
return false;
},
},
2015-12-13 04:42:28 +00:00
events: {
'main-content-view:load': function (view) {
this.currentView = view;
// Hide the sidebar if on mobile
if (isMobile.phone) {
this.showing = false;
}
return true;
2015-12-13 04:42:28 +00:00
},
/**
* Listen to sidebar:toggle event to show or hide the sidebar.
* This should only be triggered on a mobile device.
*/
'sidebar:toggle': function () {
this.showing = !this.showing;
},
},
};
</script>
<style lang="sass">
2016-03-13 17:00:32 +00:00
@import "../../../../sass/partials/_vars.scss";
@import "../../../../sass/partials/_mixins.scss";
2015-12-13 04:42:28 +00:00
#sidebar {
flex: 0 0 256px;
background-color: $colorSidebarBgr;
padding: 22px 0 0;
max-height: calc(100vh - #{$headerHeight + $footerHeight});
overflow: auto;
2016-03-13 03:28:43 +00:00
-ms-overflow-style: -ms-autohiding-scrollbar;
2015-12-13 04:42:28 +00:00
2016-03-13 03:28:43 +00:00
html.touchevents & {
2016-02-24 13:29:23 +00:00
// Enable scroll with momentum on touch devices
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
2015-12-20 15:55:32 +00:00
2015-12-24 09:50:56 +00:00
a.droppable {
transform: scale(1.2);
transition: .3s;
transform-origin: center left;
color: $colorMainText;
background-color: rgba(0, 0, 0, .3);
}
2015-12-13 04:42:28 +00:00
section {
margin-bottom: 32px;
h1 {
text-transform: uppercase;
letter-spacing: 1px;
padding: 0 16px;
margin-bottom: 12px;
i {
float: right;
}
}
a {
display: block;
height: 36px;
line-height: 36px;
padding: 0 12px 0 16px;
border-left: 4px solid transparent;
&.active, &:hover {
border-left-color: $colorHighlight;
color: $colorLinkHovered;
background: rgba(255, 255, 255, .05);
}
&:hover {
border-left-color: darken($colorHighlight, 20%);
}
&::before {
width: 24px;
display: inline-block;
font-family: FontAwesome;
}
&.home::before {
content: "\f015";
}
2015-12-13 04:42:28 +00:00
&.queue::before {
content: "\f0cb";
}
&.songs::before {
content: "\f001";
}
&.albums::before {
content: "\f152";
}
&.artists::before {
content: "\f130";
}
&.settings::before {
content: "\f013";
}
&.users::before {
content: "\f0c0";
}
}
}
2015-12-27 14:06:10 +00:00
.new-ver {
margin: 16px;
padding: 16px;
border: 1px solid $color2ndText;
color: $colorMainText;
opacity: .3;
font-size: 90%;
display: block;
transition: .3s;
&:hover {
opacity: .7;
}
}
2015-12-13 04:42:28 +00:00
2016-01-16 18:11:24 +00:00
@media only screen and (max-device-width : 667px) {
2015-12-13 04:42:28 +00:00
position: fixed;
height: calc(100vh - #{$headerHeight + $footerHeight});
padding-bottom: $footerHeight; // make sure the footer can never overlap the content
width: 100%;
z-index: 99;
top: $headerHeight;
left: -100%;
transition: left .3s ease-in;
&.showing {
left: 0;
}
}
}
</style>