Added:
- spinning loading button
This commit is contained in:
@@ -2,17 +2,27 @@
|
|||||||
import { Controller } from "@hotwired/stimulus"
|
import { Controller } from "@hotwired/stimulus"
|
||||||
|
|
||||||
export default class extends Controller {
|
export default class extends Controller {
|
||||||
static targets = ["dropdown"]
|
static targets = ["dropdown", "icon"]
|
||||||
static values = {
|
static values = {
|
||||||
currentSort: String,
|
currentSort: String,
|
||||||
currentOrder: String,
|
currentOrder: String,
|
||||||
currentStatus: String
|
currentStatus: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
window.addEventListener('alert:show', this.stopLoading.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
stopLoading() {
|
||||||
|
this.iconTarget.classList.remove('fa-spin');
|
||||||
|
}
|
||||||
|
|
||||||
refreshMetadata(event) {
|
refreshMetadata(event) {
|
||||||
const mangaId = event.currentTarget.dataset.mangaid;
|
const mangaId = event.currentTarget.dataset.mangaid;
|
||||||
const url = `/refresh_metadata`;
|
const url = `/refresh_metadata`;
|
||||||
|
|
||||||
|
this.iconTarget.classList.add('fa-spin');
|
||||||
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
@@ -26,14 +36,6 @@ export default class extends Controller {
|
|||||||
throw new Error('Network response was not ok');
|
throw new Error('Network response was not ok');
|
||||||
}
|
}
|
||||||
return response.json();
|
return response.json();
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
console.log('Metadata refreshed:', data);
|
|
||||||
// Traitez la réponse ici, par exemple en mettant à jour l'interface utilisateur
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
// Gérez l'erreur ici, par exemple en affichant un message à l'utilisateur
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{{ buttonAttributes|join(' ') }}
|
{{ buttonAttributes|join(' ') }}
|
||||||
>
|
>
|
||||||
<i class="fas fa-{{ icon }} text-xl group-hover:text-green-500"></i>
|
<i data-toolbar-target="icon" class="fas fa-{{ icon }} text-xl group-hover:text-green-500"></i>
|
||||||
<span class="text-xs">{{ text }}</span>
|
<span class="text-xs">{{ text }}</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user