From dc4b87a942d2d7ee6629e011bdefc4a3bfa0b1d9 Mon Sep 17 00:00:00 2001 From: geoffrey45 Date: Sat, 25 Dec 2021 20:36:28 +0300 Subject: [PATCH] client: improve quick access - default to opened sidebar --- server/app/api.py | 36 +++++++++++++++++----- server/app/models.py | 17 ++-------- src/App.vue | 2 +- src/assets/css/global.scss | 25 +++++++-------- src/components/FolderView/SongList.vue | 5 ++- src/components/LeftSidebar/Navigation.vue | 5 +-- src/components/LeftSidebar/PinnedStuff.vue | 25 ++++++++++++--- src/components/RightSideBar/NowPlaying.vue | 29 +++++++++++++---- 8 files changed, 91 insertions(+), 53 deletions(-) diff --git a/server/app/api.py b/server/app/api.py index d9d4968..8025859 100644 --- a/server/app/api.py +++ b/server/app/api.py @@ -1,5 +1,4 @@ -import typing -from app.models import Folders, Artists +from app.models import Artists from app.helpers import ( all_songs_instance, @@ -30,7 +29,6 @@ from flask import Blueprint, request, send_from_directory bp = Blueprint('api', __name__, url_prefix='') artist_instance = Artists() -folder_instance = Folders() img_path = "http://127.0.0.1:8900/images/thumbnails/" @@ -190,11 +188,12 @@ def populate_images(): return {'sample': artists_in_db_array[:25]} - -@bp.route("/artist") -def getArtistData(): - artist = urllib.parse.unquote(request.args.get('q')) - artist_obj = artist_instance.find_artists_by_name(artist) +@bp.route("/artist/") +@cache.cached() +def getArtistData(artist: str): + print(artist) + artist = urllib.parse.unquote(artist) + artist_obj = artist_instance.get_artists_by_name(artist) artist_obj_json = convert_to_json(artist_obj) def getArtistSongs(): @@ -340,3 +339,24 @@ def post(): return {'songs': songs_array} return {'msg': 'ok'} + +@bp.route('/qwerty') +def populateArtists(): + all_songs = all_songs_instance.get_all_songs() + songs = convert_to_json(all_songs) + + artists = [] + + for song in songs: + artist = song['artists'].split(', ') + + for a in artist: + a_obj = { + "name": a, + } + + if a_obj not in artists: + artists.append(a_obj) + + + return {'songs': artists} \ No newline at end of file diff --git a/server/app/models.py b/server/app/models.py index 7d49586..c5af569 100644 --- a/server/app/models.py +++ b/server/app/models.py @@ -7,19 +7,6 @@ class Mongo: mongo_uri = pymongo.MongoClient() self.db = mongo_uri[database] - -class Folders(Mongo): - def __init__(self): - super(Folders, self).__init__('LOCAL_FOLDERS') - self.collection = self.db['LOCAL_FOLDERS'] - - def insert_folder(self, folder): - self.collection.insert_one(folder) - - def find_folder(self, folder_id): - return self.collection.find_one({'_id': ObjectId(folder_id)}) - - class Artists(Mongo): def __init__(self): super(Artists, self).__init__('ALL_ARTISTS') @@ -34,8 +21,8 @@ class Artists(Mongo): def get_artist_by_id(self, artist_id): return self.collection.find_one({'_id': ObjectId(artist_id)}) - def find_artists_by_name(self, query): - return self.collection.find({'name': {'$regex': query, '$options': 'i'}}) + def get_artists_by_name(self, query): + return self.collection.find({'name': query}).limit(20) class AllSongs(Mongo): diff --git a/src/App.vue b/src/App.vue index 41390a4..5233030 100644 --- a/src/App.vue +++ b/src/App.vue @@ -53,7 +53,7 @@ export default { }, setup() { - const collapsed = ref(true); + const collapsed = ref(false); perks.readQueue(); diff --git a/src/assets/css/global.scss b/src/assets/css/global.scss index 5b6c735..947436c 100644 --- a/src/assets/css/global.scss +++ b/src/assets/css/global.scss @@ -12,7 +12,9 @@ body { margin: 0; background: #0d0e0e; color: #fff; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; font-size: 1rem; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, + Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + font-size: 1rem; } .heading { @@ -37,7 +39,7 @@ a { } .separator { - border-top: .1px $separator solid; + border-top: 0.1px $separator solid; color: transparent; margin: $small 0 $small 0; } @@ -72,13 +74,6 @@ a { z-index: -1; } -.collapsed .l-sidebar { - width: 70px; - transition-timing-function: ease-in-out; - transition-duration: 0.3s; - transition-property: width; -} - .l-sidebar { width: 15em; grid-area: l-sidebar; @@ -86,11 +81,14 @@ a { margin: 0.5rem 0 0.5rem 0.5rem; border-radius: 0.5rem; background-color: #131313b2; - transition-timing-function: cubic-bezier(0.165, 0.84, 0.44, 1); - transition-duration: 0.3s; - transition-property: width; } +.collapsed .l-sidebar { + width: 70px; + transition: all 0.3s ease; +} + + .ellip { display: -webkit-box; -webkit-line-clamp: 1; @@ -175,7 +173,6 @@ a { background: rgb(163, 163, 163); } - @-webkit-keyframes similarAlbums { 0% { background-position: 0% 38%; @@ -219,4 +216,4 @@ a { 100% { background-position: 0% 38%; } -} \ No newline at end of file +} diff --git a/src/components/FolderView/SongList.vue b/src/components/FolderView/SongList.vue index ecf7c10..68d6d2e 100644 --- a/src/components/FolderView/SongList.vue +++ b/src/components/FolderView/SongList.vue @@ -191,13 +191,12 @@ td .artist { tbody tr { cursor: pointer; - transition: all 0.5s ease; + transition: all 0.1s ease; &:hover { & { - background-color: rgba(255, 174, 0, 0.534); + background-color: rgb(5, 80, 150); } - transform: scale(0.99); } } } diff --git a/src/components/LeftSidebar/Navigation.vue b/src/components/LeftSidebar/Navigation.vue index 7e7663f..dfa8d5d 100644 --- a/src/components/LeftSidebar/Navigation.vue +++ b/src/components/LeftSidebar/Navigation.vue @@ -98,13 +98,14 @@ export default { background-color: transparent; height: 100%; padding: 10px; - transition: all 0.3s ease-in-out; + // transition: all .3s ease-in-out; + // transition-delay: 1s; } .collapsed .nav-button { font-size: smaller; margin-top: 5px; - transition: all 0.2s ease-in-out; + // transition: all 2s ease-in-out; } .side-nav-container .nav-button:hover { diff --git a/src/components/LeftSidebar/PinnedStuff.vue b/src/components/LeftSidebar/PinnedStuff.vue index 1657c43..dab89c8 100644 --- a/src/components/LeftSidebar/PinnedStuff.vue +++ b/src/components/LeftSidebar/PinnedStuff.vue @@ -1,6 +1,6 @@