Apply all biomejs fixes

This commit is contained in:
2024-10-08 17:14:22 +02:00
parent 20bea62542
commit 7405241b82
25 changed files with 480 additions and 428 deletions

View File

@ -112,7 +112,7 @@
></a>
</div>
<div class="notification">
<a href="#" onclick="display_notif()">
<a href="#" onclick="displayNotif()">
<i class="fa-regular fa-bell"></i>
{% set notification_count = user.notifications.filter(viewed=False).count() %}

View File

@ -15,36 +15,36 @@
{% macro profile_picture(field_name) %}
{% set this_picture = form.instance[field_name] %}
<div class="profile-picture" x-data="camera_{{ field_name }}" >
<div class="profile-picture-display" :aria-busy="loading" :class="{ 'camera-error': is_camera_error }">
<div class="profile-picture-display" :aria-busy="loading" :class="{ 'camera-error': isCameraError }">
<img
x-show="!is_camera_enabled && !is_camera_error"
:src="get_picture()"
x-show="!isCameraEnabled && !isCameraError"
:src="getPicture()"
alt="{%- trans -%}Profile{%- endtrans -%}" title="{%- trans -%}Profile{%- endtrans -%}"
loading="lazy"
/>
<video
x-show="is_camera_enabled"
x-show="isCameraEnabled"
x-ref="video"
></video>
<i
x-show="is_camera_error"
x-show="isCameraError"
x-cloak
class="fa fa-eye-slash"
></i>
</div>
<div class="profile-picture-buttons" x-show="can_edit_picture">
<div class="profile-picture-buttons" x-show="canEditPicture">
<button
x-show="can_edit_picture && !is_camera_enabled"
x-show="canEditPicture && !isCameraEnabled"
class="btn btn-blue"
@click.prevent="enable_camera()"
@click.prevent="enableCamera()"
>
<i class="fa fa-camera"></i>
{% trans %}Enable camera{% endtrans %}
</button>
<button
x-show="is_camera_enabled"
x-show="isCameraEnabled"
class="btn btn-blue"
@click.prevent="take_picture()"
@click.prevent="takePicture()"
>
<i class="fa fa-camera"></i>
{% trans %}Take a picture{% endtrans %}
@ -54,7 +54,7 @@
{%- if form[field_name] -%}
<div>
{{ form[field_name] }}
<button class="btn btn-red" @click.prevent="delete_picture()"
<button class="btn btn-red" @click.prevent="deletePicture()"
{%- if not (this_picture and this_picture.is_owned_by(user)) -%}
:disabled="!picture"
{%- endif -%}
@ -86,7 +86,7 @@
document.addEventListener("alpine:init", () => {
Alpine.data(
"camera_{{ field_name }}",
alpine_webcam_builder(
alpineWebcamBuilder(
{{ default_picture }},
{{ delete_url }},
{{ (this_picture and this_picture.is_owned_by(user))|tojson }}

View File

@ -30,21 +30,21 @@
</label>
<span class="depth-choice">
<button
@click="godfathers_depth--"
:disabled="godfathers_depth <= {{ depth_min }}"
@click="godfathersDepth--"
:disabled="godfathersDepth <= {{ depth_min }}"
><i class="fa fa-minus"></i></button>
<input
x-model="godfathers_depth"
x-model="godfathersDepth"
x-ref="godfather_depth_input"
type="number"
name="godfathers_depth"
name="godfathersDepth"
id="godfather-depth-input"
min="{{ depth_min }}"
max="{{ depth_max }}"
/>
<button
@click="godfathers_depth++"
:disabled="godfathers_depth >= {{ depth_max }}"
@click="godfathersDepth++"
:disabled="godfathersDepth >= {{ depth_max }}"
><i class="fa fa-plus"
></i></button>
</span>
@ -56,22 +56,22 @@
</label>
<span class="depth-choice">
<button
@click="godchildren_depth--"
:disabled="godchildren_depth <= {{ depth_min }}"
@click="godchildrenDepth--"
:disabled="godchildrenDepth <= {{ depth_min }}"
><i
class="fa fa-minus"
></i></button>
<input
x-model="godchildren_depth"
x-model="godchildrenDepth"
type="number"
name="godchildren_depth"
name="godchildrenDepth"
id="godchild-depth-input"
min="{{ depth_min }}"
max="{{ depth_max }}"
/>
<button
@click="godchildren_depth++"
:disabled="godchildren_depth >= {{ depth_max }}"
@click="godchildrenDepth++"
:disabled="godchildrenDepth >= {{ depth_max }}"
><i class="fa fa-plus"
></i></button>
</span>
@ -96,10 +96,10 @@
</div>
<script>
const api_url = "{{ api_url }}";
const active_user = "{{ object.id }}"
const depth_min = {{ depth_min }};
const depth_max = {{ depth_max }};
const apiUrl = "{{ api_url }}";
const activeUser = "{{ object.id }}"
const depthMin = {{ depth_min }};
const depthMax = {{ depth_max }};
</script>
{% endblock %}

View File

@ -21,14 +21,14 @@
{% if user.id == object.id %}
<div x-show="pictures.length > 0" x-cloak>
<button
:disabled="is_downloading"
:disabled="isDownloading"
class="btn btn-blue"
@click="download_zip()"
@click="downloadZip()"
>
<i class="fa fa-download"></i>
{% trans %}Download all my pictures{% endtrans %}
</button>
<progress x-ref="progress" x-show="is_downloading"></progress>
<progress x-ref="progress" x-show="isDownloading"></progress>
</div>
{% endif %}
@ -92,13 +92,13 @@
document.addEventListener("alpine:init", () => {
Alpine.data("user_pictures", () => ({
is_downloading: false,
isDownloading: false,
loading: true,
pictures: [],
albums: {},
async init() {
this.pictures = await fetch_paginated("{{ url("api:pictures") }}" + "?users_identified={{ object.id }}");
this.pictures = await fetchPaginated("{{ url("api:pictures") }}" + "?users_identified={{ object.id }}");
this.albums = this.pictures.reduce((acc, picture) => {
if (!acc[picture.album]){
acc[picture.album] = [];
@ -109,8 +109,8 @@
this.loading = false;
},
async download_zip(){
this.is_downloading = true;
async downloadZip(){
this.isDownloading = true;
const bar = this.$refs.progress;
bar.value = 0;
bar.max = this.pictures.length;
@ -124,16 +124,16 @@
const zipWriter = new zip.ZipWriter(await fileHandle.createWritable());
await Promise.all(this.pictures.map(p => {
const img_name = p.album + "/IMG_" + p.date.replaceAll(/[:\-]/g, "_") + p.name.slice(p.name.lastIndexOf("."));
const imgName = p.album + "/IMG_" + p.date.replaceAll(/[:\-]/g, "_") + p.name.slice(p.name.lastIndexOf("."));
return zipWriter.add(
img_name,
imgName,
new zip.HttpReader(p.full_size_url),
{level: 9, lastModDate: new Date(p.date), onstart: () => bar.value += 1}
);
}));
await zipWriter.close();
this.is_downloading = false;
this.isDownloading = false;
}
}))
});