scrobble_list.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. {% extends "base.html" %}
  2. {% load humanize %}
  3. {% block content %}
  4. <main class="col-md-4 ms-sm-auto col-lg-10 px-md-4">
  5. <div
  6. class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  7. <h1 class="h2">Dashboard</h1>
  8. <div class="btn-toolbar mb-2 mb-md-0">
  9. {% if user.is_authenticated %}
  10. <div class="btn-group me-2">
  11. {% if user.profile.lastfm_username %}
  12. <form action="{% url 'scrobbles:lastfm-import' %}" method="get">
  13. <button type="submit" class="btn btn-sm btn-outline-secondary">Last.fm Sync</button>
  14. </form>
  15. {% endif %}
  16. <button type="button" class="btn btn-sm btn-outline-secondary" data-bs-toggle="modal"
  17. data-bs-target="#importModal">Import</button>
  18. <button type="button" class="btn btn-sm btn-outline-secondary" data-bs-toggle="modal"
  19. data-bs-target="#exportModal">Export</button>
  20. </div>
  21. {% endif %}
  22. <div class="dropdown">
  23. <button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle" id="graphDateButton"
  24. data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  25. <span data-feather="calendar"></span>
  26. This week
  27. </button>
  28. <div class="dropdown-menu" data-bs-toggle="#graphDataChange" aria-labelledby="graphDateButton">
  29. <a class="dropdown-item" href="#">This month</a>
  30. <a class="dropdown-item" href="#">This year</a>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <canvas class="my-4 w-100" id="myChart" width="900" height="220"></canvas>
  36. <div class="container">
  37. {% if user.is_authenticated %}
  38. <div class="row">
  39. <p>Today <b>{{counts.today}}</b> | This Week <b>{{counts.week}}</b> | This Month <b>{{counts.month}}</b> |
  40. This Year <b>{{counts.year}}</b> | All Time <b>{{counts.alltime}}</b></p>
  41. </div>
  42. <div class="row">
  43. <div class="col-md">
  44. <ul class="nav nav-tabs" id="myTab" role="tablist">
  45. <li class="nav-item" role="presentation">
  46. <button class="nav-link active" id="home-tab" data-bs-toggle="tab"
  47. data-bs-target="#artists-week" type="button" role="tab" aria-controls="home"
  48. aria-selected="true">Weekly Artists</button>
  49. </li>
  50. <li class="nav-item" role="presentation">
  51. <button class="nav-link" id="artist-month-tab" data-bs-toggle="tab"
  52. data-bs-target="#artists-month" type="button" role="tab" aria-controls="home"
  53. aria-selected="true">Monthly Artists</button>
  54. </li>
  55. <li class="nav-item" role="presentation">
  56. <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#tracks-week"
  57. type="button" role="tab" aria-controls="profile" aria-selected="false">Weekly
  58. Tracks</button>
  59. </li>
  60. <li class="nav-item" role="presentation">
  61. <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#tracks-month"
  62. type="button" role="tab" aria-controls="profile" aria-selected="false">Monthly
  63. Tracks</button>
  64. </li>
  65. </ul>
  66. <div class="tab-content" id="myTabContent">
  67. <div class="tab-pane fade show active" id="artists-week" role="tabpanel"
  68. aria-labelledby="artists-week-tab">
  69. <h2>Top artists this week</h2>
  70. <div class="table-responsive">
  71. <table class="table table-striped table-sm">
  72. <thead>
  73. <tr>
  74. <th scope="col">#</th>
  75. <th scope="col">Artist</th>
  76. </tr>
  77. </thead>
  78. <tbody>
  79. {% for artist in top_weekly_artists %}
  80. <tr>
  81. <td>{{artist.num_scrobbles}}</td>
  82. <td>{{artist.name}}</td>
  83. </tr>
  84. {% endfor %}
  85. </tbody>
  86. </table>
  87. </div>
  88. </div>
  89. <div class="tab-pane fade show" id="tracks-week" role="tabpanel" aria-labelledby="tracks-week-tab">
  90. <h2>Top tracks this week</h2>
  91. <div class="table-responsive">
  92. <table class="table table-striped table-sm">
  93. <thead>
  94. <tr>
  95. <th scope="col">#</th>
  96. <th scope="col">Track</th>
  97. <th scope="col">Artist</th>
  98. </tr>
  99. </thead>
  100. <tbody>
  101. {% for track in top_weekly_tracks %}
  102. <tr>
  103. <td>{{track.num_scrobbles}}</td>
  104. <td>{{track.title}}</td>
  105. <td>{{track.artist.name}}</td>
  106. </tr>
  107. {% endfor %}
  108. </tbody>
  109. </table>
  110. </div>
  111. </div>
  112. <div class="tab-pane fade show" id="tracks-month" role="tabpanel"
  113. aria-labelledby="tracks-month-tab">
  114. <h2>Top tracks this month</h2>
  115. <div class="table-responsive">
  116. <table class="table table-striped table-sm">
  117. <thead>
  118. <tr>
  119. <th scope="col">#</th>
  120. <th scope="col">Track</th>
  121. <th scope="col">Artist</th>
  122. </tr>
  123. </thead>
  124. <tbody>
  125. {% for track in top_monthly_tracks %}
  126. <tr>
  127. <td>{{track.num_scrobbles}}</td>
  128. <td>{{track.title}}</td>
  129. <td>{{track.artist.name}}</td>
  130. </tr>
  131. {% endfor %}
  132. </tbody>
  133. </table>
  134. </div>
  135. </div>
  136. <div class="tab-pane fade show " id="artists-month" role="tabpanel"
  137. aria-labelledby="artists-month-tab">
  138. <h2>Top artists this month</h2>
  139. <div class="table-responsive">
  140. <table class="table table-striped table-sm">
  141. <thead>
  142. <tr>
  143. <th scope="col">#</th>
  144. <th scope="col">Artist</th>
  145. </tr>
  146. </thead>
  147. <tbody>
  148. {% for artist in top_monthly_artists %}
  149. <tr>
  150. <td>{{artist.num_scrobbles}}</td>
  151. <td>{{artist.name}}</td>
  152. </tr>
  153. {% endfor %}
  154. </tbody>
  155. </table>
  156. </div>
  157. </div>
  158. </div>
  159. </div>
  160. <div class="col-md">
  161. <ul class="nav nav-tabs" id="myTab" role="tablist">
  162. <li class="nav-item" role="presentation">
  163. <button class="nav-link active" id="home-tab" data-bs-toggle="tab"
  164. data-bs-target="#latest-listened" type="button" role="tab" aria-controls="home"
  165. aria-selected="true">Tracks</button>
  166. </li>
  167. <li class="nav-item" role="presentation">
  168. <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#latest-watched"
  169. type="button" role="tab" aria-controls="profile" aria-selected="false">Videos</button>
  170. </li>
  171. <li class="nav-item" role="presentation">
  172. <button class="nav-link" id="profile-tab" data-bs-toggle="tab"
  173. data-bs-target="#latest-podcasted" type="button" role="tab" aria-controls="profile"
  174. aria-selected="false">Podcasts</button>
  175. </li>
  176. <li class="nav-item" role="presentation">
  177. <button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#latest-sports"
  178. type="button" role="tab" aria-controls="profile" aria-selected="false">Sports</button>
  179. </li>
  180. </ul>
  181. <div class="tab-content" id="myTabContent2">
  182. <div class="tab-pane fade show active" id="latest-listened" role="tabpanel"
  183. aria-labelledby="latest-listened-tab">
  184. <h2>Latest listened</h2>
  185. <div class="table-responsive">
  186. <table class="table table-striped table-sm">
  187. <thead>
  188. <tr>
  189. <th scope="col">Time</th>
  190. <th scope="col">Album</th>
  191. <th scope="col">Track</th>
  192. <th scope="col">Artist</th>
  193. </tr>
  194. </thead>
  195. <tbody>
  196. {% for scrobble in object_list %}
  197. <tr>
  198. <td>{{scrobble.timestamp|naturaltime}}</td>
  199. {% if scrobble.track.album.cover_image %}
  200. <td><img src="{{scrobble.track.album.cover_image.url}}" width=50 height=50
  201. style="border:1px solid black;" /></td>
  202. {% else %}
  203. <td>{{scrobble.track.album.name}}</td>
  204. {% endif %}
  205. <td>{{scrobble.track.title}}</td>
  206. <td>{{scrobble.track.artist.name}}</td>
  207. </tr>
  208. {% endfor %}
  209. </tbody>
  210. </table>
  211. </div>
  212. </div>
  213. <div class="tab-pane fade show" id="latest-watched" role="tabpanel"
  214. aria-labelledby="latest-watched-tab">
  215. <h2>Latest watched</h2>
  216. <div class="table-responsive">
  217. <table class="table table-striped table-sm">
  218. <thead>
  219. <tr>
  220. <th scope="col">Time</th>
  221. <th scope="col">Title</th>
  222. <th scope="col">Series</th>
  223. </tr>
  224. </thead>
  225. <tbody>
  226. {% for scrobble in video_scrobble_list %}
  227. <tr>
  228. <td>{{scrobble.timestamp|naturaltime}}</td>
  229. <td>{% if scrobble.video.tv_series
  230. %}S{{scrobble.video.season_number}}E{{scrobble.video.episode_number}} -{%
  231. endif %} {{scrobble.video.title}}</td>
  232. <td>{% if scrobble.video.tv_series %}{{scrobble.video.tv_series}}{% endif %}
  233. </td>
  234. </tr>
  235. {% endfor %}
  236. </tbody>
  237. </table>
  238. </div>
  239. </div>
  240. <div class="tab-pane fade show" id="latest-sports" role="tabpanel"
  241. aria-labelledby="latest-sports-tab">
  242. <h2>Latest Sports</h2>
  243. <div class="table-responsive">
  244. <table class="table table-striped table-sm">
  245. <thead>
  246. <tr>
  247. <th scope="col">Date</th>
  248. <th scope="col">Title</th>
  249. <th scope="col">League</th>
  250. </tr>
  251. </thead>
  252. <tbody>
  253. {% for scrobble in sport_scrobble_list %}
  254. <tr>
  255. <td>{{scrobble.timestamp|naturaltime}}</td>
  256. <td>{{scrobble.sport_event.title}}</td>
  257. <td>{{scrobble.sport_event.league.abbreviation}}</td>
  258. </tr>
  259. {% endfor %}
  260. </tbody>
  261. </table>
  262. </div>
  263. </div>
  264. <div class="tab-pane fade show" id="latest-podcasted" role="tabpanel"
  265. aria-labelledby="latest-podcasted-tab">
  266. <h2>Latest Podcasted</h2>
  267. <div class="table-responsive">
  268. <table class="table table-striped table-sm">
  269. <thead>
  270. <tr>
  271. <th scope="col">Date</th>
  272. <th scope="col">Title</th>
  273. <th scope="col">Podcast</th>
  274. </tr>
  275. </thead>
  276. <tbody>
  277. {% for scrobble in podcast_scrobble_list %}
  278. <tr>
  279. <td>{{scrobble.timestamp|naturaltime}}</td>
  280. <td>{{scrobble.podcast_episode.title}}</td>
  281. <td>{{scrobble.podcast_episode.podcast}}</td>
  282. </tr>
  283. {% endfor %}
  284. </tbody>
  285. </table>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. {% endif %}
  291. </div>
  292. </main>
  293. <div class="modal fade" id="importModal" tabindex="-1" role="dialog" aria-labelledby="importModalLabel"
  294. aria-hidden="true">
  295. <div class="modal-dialog" role="document">
  296. <div class="modal-content">
  297. <div class="modal-header">
  298. <h5 class="modal-title" id="importModalLabel">Import scrobbles</h5>
  299. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  300. <span aria-hidden="true">&times;</span>
  301. </button>
  302. </div>
  303. <form action="{% url 'audioscrobbler-file-upload' %}" method="post" enctype="multipart/form-data">
  304. <div class="modal-body">
  305. {% csrf_token %}
  306. <div class="form-group">
  307. <label for="tsv_file" class="col-form-label">Audioscrobbler TSV file:</label>
  308. <input type="file" name="tsv_file" class="form-control" id="id_tsv_file">
  309. </div>
  310. </div>
  311. <div class="modal-footer">
  312. <button type="submit" class="btn btn-primary">Import</button>
  313. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  314. </div>
  315. </form>
  316. </div>
  317. </div>
  318. </div>
  319. <div class="modal fade" id="exportModal" tabindex="-1" role="dialog" aria-labelledby="exportModalLabel"
  320. aria-hidden="true">
  321. <div class="modal-dialog" role="document">
  322. <div class="modal-content">
  323. <div class="modal-header">
  324. <h5 class="modal-title" id="exportModalLabel">Export scrobbles</h5>
  325. <button type="button" class="close" data-bs-dismiss="modal" aria-label="Close">
  326. <span aria-hidden="true">&times;</span>
  327. </button>
  328. </div>
  329. <form action="{% url 'scrobbles:export' %}" method="get">
  330. <div class="modal-body">
  331. {% csrf_token %}
  332. <div class="form-group">
  333. {{export_form.as_div}}
  334. </div>
  335. </div>
  336. <div class="modal-footer">
  337. <button type="submit" class="btn btn-primary">Export</button>
  338. <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
  339. </div>
  340. </form>
  341. </div>
  342. </div>
  343. </div>
  344. {% endblock %}
  345. {% block extra_js %}
  346. <script>
  347. $('#importModal').on('shown.bs.modal', function () { $('#importInput').trigger('focus') });
  348. $('#exportModal').on('shown.bs.modal', function () { $('#exportInput').trigger('focus') });
  349. </script>
  350. {% endblock %}