fix web interface bug
This commit is contained in:
parent
1b13b0d34d
commit
a4128e1dc9
@ -86,6 +86,7 @@ def requires_auth(f):
|
|||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
return decorated
|
return decorated
|
||||||
|
|
||||||
|
|
||||||
@web.route("/", methods=['GET', 'POST'])
|
@web.route("/", methods=['GET', 'POST'])
|
||||||
@requires_auth
|
@requires_auth
|
||||||
def index():
|
def index():
|
||||||
@ -128,7 +129,9 @@ def index():
|
|||||||
files = music_library.get_files_recursively(folder)
|
files = music_library.get_files_recursively(folder)
|
||||||
else:
|
else:
|
||||||
files = music_library.get_files(folder)
|
files = music_library.get_files(folder)
|
||||||
files = list(map(lambda file: {'type':'file','path': os.path.join(folder, file), 'user':'Web'}, files))
|
|
||||||
|
files = list(map(lambda file: var.botamusique.get_music_tag_info({'type':'file','path': os.path.join(folder, file), 'user':'Web'}, \
|
||||||
|
var.config.get('bot', 'music_folder') + os.path.join(folder, file)), files))
|
||||||
print('Adding to playlist: ', files)
|
print('Adding to playlist: ', files)
|
||||||
var.playlist.extend(files)
|
var.playlist.extend(files)
|
||||||
|
|
||||||
@ -186,7 +189,8 @@ def index():
|
|||||||
music_library=music_library,
|
music_library=music_library,
|
||||||
os=os,
|
os=os,
|
||||||
playlist=var.playlist,
|
playlist=var.playlist,
|
||||||
user=var.user)
|
user=var.user
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@web.route('/upload', methods=["POST"])
|
@web.route('/upload', methods=["POST"])
|
||||||
|
@ -775,6 +775,7 @@ class MumbleBot:
|
|||||||
im = Image.open(path_thumbnail)
|
im = Image.open(path_thumbnail)
|
||||||
im.thumbnail((100, 100), Image.ANTIALIAS)
|
im.thumbnail((100, 100), Image.ANTIALIAS)
|
||||||
buffer = BytesIO()
|
buffer = BytesIO()
|
||||||
|
im = im.convert('RGB')
|
||||||
im.save(buffer, format="JPEG")
|
im.save(buffer, format="JPEG")
|
||||||
music['thumbnail'] = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
music['thumbnail'] = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
||||||
|
|
||||||
@ -785,6 +786,7 @@ class MumbleBot:
|
|||||||
im = Image.open(BytesIO(tags["APIC:"].data))
|
im = Image.open(BytesIO(tags["APIC:"].data))
|
||||||
im.thumbnail((100, 100), Image.ANTIALIAS)
|
im.thumbnail((100, 100), Image.ANTIALIAS)
|
||||||
buffer = BytesIO()
|
buffer = BytesIO()
|
||||||
|
im = im.convert('RGB')
|
||||||
im.save(buffer, format="JPEG")
|
im.save(buffer, format="JPEG")
|
||||||
music['thumbnail'] = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
music['thumbnail'] = base64.b64encode(buffer.getvalue()).decode('utf-8')
|
||||||
|
|
||||||
|
@ -6,17 +6,20 @@
|
|||||||
<li class="directory list-group-item list-group-item-primary">
|
<li class="directory list-group-item list-group-item-primary">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button type="button" class="btn btn-success btn-sm" onclick="$('#add_folder_{{ subdirpath }}').submit();"><i class="fa fa-plus" aria-hidden="true"></i></button>
|
<form method="post" class="directory">
|
||||||
|
<input type="text" value="{{ subdirpath }}" name="add_folder" hidden>
|
||||||
|
<button type="button" class="btn btn-success btn-sm btn-submit"><i class="fa fa-plus" aria-hidden="true"></i></button>
|
||||||
|
</form>
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button id="btnGroupDrop2" type="button" class="btn btn-success btn-sm dropdown-toggle btn-space" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
<button id="btnGroupDrop2" type="button" class="btn btn-success btn-sm dropdown-toggle btn-space" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
||||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop2" style="">
|
<div class="dropdown-menu" aria-labelledby="btnGroupDrop2" style="">
|
||||||
<form method="post" id="add_folder_{{ subdirpath }}" class="directory">
|
<form method="post" class="directory">
|
||||||
<input type="text" value="{{ subdirpath }}" name="add_folder" hidden>
|
<input type="text" value="{{ subdirpath }}" name="add_folder" hidden>
|
||||||
<a onclick="$('#add_folder_{{ subdirpath }}').submit();" href="#" class="dropdown-item"><i class="fa fa-folder" aria-hidden="true"></i> Entire folder</a>
|
<a href="#" class="dropdown-item a-submit"><i class="fa fa-folder" aria-hidden="true"></i> Entire folder</a>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" id="add_folder_recursively_{{ subdirpath }}" class="directory">
|
<form method="post" class="directory">
|
||||||
<input type="text" value="{{ subdirpath }}" name="add_folder_recursively" hidden>
|
<input type="text" value="{{ subdirpath }}" name="add_folder_recursively" hidden>
|
||||||
<a onclick="$('#add_folder_recursively_{{ subdirpath }}').submit();return false;" href="#" class="dropdown-item"><i class="fa fa-folder" aria-hidden="true"></i> Entire folder and sub-folders</a>
|
<a href="#" class="dropdown-item a-submit"><i class="fa fa-folder" aria-hidden="true"></i> Entire folder and sub-folders</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -43,17 +46,20 @@
|
|||||||
<li class="file list-group-item">
|
<li class="file list-group-item">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button type="button" class="btn btn-success btn-sm" onclick="$('#file_add_bottom_{{ subdirname }}_{{ loop.index0 }}').submit();"><i class="fa fa-plus" aria-hidden="true"></i></button>
|
<form method="post" class="file file_add">
|
||||||
|
<input type="text" value="{{ filepath }}" name="add_file_bottom" hidden>
|
||||||
|
<button type="button" class="btn btn-success btn-sm btn-submit"><i class="fa fa-plus" aria-hidden="true"></i></button>
|
||||||
|
</form>
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button id="btnGroupDrop2" type="button" class="btn btn-success btn-sm dropdown-toggle btn-space" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
<button id="btnGroupDrop2" type="button" class="btn btn-success btn-sm dropdown-toggle btn-space" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>
|
||||||
<div class="dropdown-menu" aria-labelledby="btnGroupDrop2" style="">
|
<div class="dropdown-menu" aria-labelledby="btnGroupDrop2" style="">
|
||||||
<form method="post" id="file_add_bottom_{{ path }}_{{ loop.index0 }}" class="file file_add">
|
<form method="post" class="file file_add">
|
||||||
<input type="text" value="{{ filepath }}" name="add_file_bottom" hidden>
|
<input type="text" value="{{ filepath }}" name="add_file_bottom" hidden>
|
||||||
<a onclick="$('#file_add_bottom_{{ path }}_{{ loop.index0 }}').submit();" href="#" class="dropdown-item"><i class="fa fa-angle-down" aria-hidden="true"></i> To bottom of play list</a>
|
<a href="#" class="dropdown-item a-submit"><i class="fa fa-angle-down" aria-hidden="true"></i> To bottom of play list</a>
|
||||||
</form>
|
</form>
|
||||||
<form method="post" id="file_add_next_{{ path }}_{{ loop.index0 }}" class="file file_add">
|
<form method="post" class="file file_add">
|
||||||
<input type="text" value="{{ filepath }}" name="add_file_next" hidden>
|
<input type="text" value="{{ filepath }}" name="add_file_next" hidden>
|
||||||
<a onclick="$('#file_add_next_{{ path }}_{{ loop.index0 }}').submit();return false;" href="#" class="dropdown-item"><i class="fa fa-angle-right" aria-hidden="true"></i> After current song</a>
|
<a href="#" class="dropdown-item a-submit"><i class="fa fa-angle-right" aria-hidden="true"></i> After current song</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -316,7 +322,10 @@
|
|||||||
var fileName = $(this).val().replace('C:\\fakepath\\', " ");
|
var fileName = $(this).val().replace('C:\\fakepath\\', " ");
|
||||||
//replace the "Choose a file" label
|
//replace the "Choose a file" label
|
||||||
$(this).next('.custom-file-label').html(fileName);
|
$(this).next('.custom-file-label').html(fileName);
|
||||||
})
|
});
|
||||||
|
$('a.a-submit, button.btn-submit').on('click', function (event) {
|
||||||
|
$(event.target).closest('form').submit();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user