Compare commits
1 Commits
dev/player
...
dev/music-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b9302fee6 |
@@ -2,7 +2,10 @@ from typing import Any
|
||||
|
||||
from django.contrib import admin
|
||||
from django.http import HttpRequest
|
||||
from django.http import HttpResponse
|
||||
from django.urls import path
|
||||
from django.urls import reverse
|
||||
from django.shortcuts import render
|
||||
from django.utils.html import format_html
|
||||
|
||||
from music.models import Track
|
||||
@@ -114,3 +117,15 @@ class MusicLogAdmin(admin.ModelAdmin):
|
||||
search_fields = ("track__title", "track__album__artist__name", "track__album__name")
|
||||
list_filter = ("played_at",)
|
||||
readonly_fields = ("track", "played_at")
|
||||
|
||||
change_list_template = "admin/musiclog/change_list.html"
|
||||
|
||||
def get_urls(self):
|
||||
urls = super().get_urls()
|
||||
custom_urls = [
|
||||
path("statistics/", self.admin_site.admin_view(self.get_statistic_view), name="musiclog_statistics"),
|
||||
]
|
||||
return custom_urls + urls
|
||||
|
||||
def get_statistic_view(self, request: HttpRequest) -> HttpResponse:
|
||||
return render(request, "admin/musiclog/statistics.html")
|
||||
@@ -8,9 +8,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const playPauseBtn = document.getElementById('playPauseBtn');
|
||||
const nextBtn = document.getElementById('nextBtn');
|
||||
const prevBtn = document.getElementById('prevBtn');
|
||||
const volumeControl = document.getElementById('volumeControl');
|
||||
const savedVolume = localStorage.getItem('audioPlayerVolume');
|
||||
|
||||
|
||||
const progressBar = document.getElementById('audioProgress');
|
||||
const currentTimeElem = document.getElementById('currentTime');
|
||||
@@ -37,17 +34,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
if (currentTimeElem) currentTimeElem.textContent = formatTime(current || 0);
|
||||
if (durationElem) durationElem.textContent = formatTime(duration || 0);
|
||||
}
|
||||
// Восстановление сохраненного уровня громкости
|
||||
if (savedVolume !== null) {
|
||||
audioPlayer.volume = parseFloat(savedVolume);
|
||||
}
|
||||
|
||||
// Управление громкостью
|
||||
if (volumeControl) {
|
||||
volumeControl.addEventListener('input', () => {
|
||||
audioPlayer.volume = volumeControl.value;
|
||||
});
|
||||
}
|
||||
|
||||
// Обновление прогресса при воспроизведении
|
||||
audioPlayer.addEventListener('timeupdate', () => {
|
||||
|
||||
10
music_storage/templates/admin/musiclog/change_list.html
Normal file
10
music_storage/templates/admin/musiclog/change_list.html
Normal file
@@ -0,0 +1,10 @@
|
||||
{% extends "admin/change_list.html" %}
|
||||
|
||||
{% block object-tools-items %}
|
||||
{{ block.super }}
|
||||
<li>
|
||||
<a href="{% url 'admin:musiclog_statistics' %}" class="button">
|
||||
statistics
|
||||
</a>
|
||||
</li>
|
||||
{% endblock %}
|
||||
13
music_storage/templates/admin/musiclog/statistics.html
Normal file
13
music_storage/templates/admin/musiclog/statistics.html
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n admin_urls static admin_list %}
|
||||
|
||||
|
||||
{% block title %}{% translate "Music Log Statistics" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<button onclick="history.back()">Back</button>
|
||||
<h1>{% translate "Music Log Statistics" %}</h1>
|
||||
<div>
|
||||
<canvas id="musicLogChart" width="800" height="400"></canvas>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -15,16 +15,6 @@
|
||||
<button class="control-btn" id="prevBtn"><i class="fas fa-backward"></i></button>
|
||||
<button class="control-btn" id="playPauseBtn"><i class="fas fa-play"></i></button>
|
||||
<button class="control-btn" id="nextBtn"><i class="fas fa-forward"></i></button>
|
||||
|
||||
<input
|
||||
type="range"
|
||||
id="volumeControl"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
value="1"
|
||||
title="Громкость"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<audio id="audioPlayer" class="audio-player" preload="metadata">
|
||||
|
||||
Reference in New Issue
Block a user