5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 07:56:23 +00:00

Merge branch 'rails' of 0xacab.org:sutty/sutty into panel.testing.sutty.nl

This commit is contained in:
f 2024-05-02 15:25:36 -03:00
commit 943237bfa3
No known key found for this signature in database
9 changed files with 38 additions and 10 deletions

View file

@ -22,6 +22,12 @@ class SitesController < ApplicationController
render('sites/status', layout: false) if stale? site render('sites/status', layout: false) if stale? site
end end
def button
authorize site
render('sites/build', layout: false)
end
# No tenemos propiedades de un sitio aún, así que vamos al listado de # No tenemos propiedades de un sitio aún, así que vamos al listado de
# artículos # artículos
def show def show

View file

@ -0,0 +1,7 @@
// Cancela las peticiones pendientes de htmx para todos los elementos al
// cambiar de página.
document.addEventListener("turbolinks:click", () => {
for (const hx of document.querySelectorAll("[hx-get]")) {
window.htmx.trigger(hx, "htmx:abort");
}
});

View file

@ -6,3 +6,4 @@ import './timezone'
import './turbolinks-anchors' import './turbolinks-anchors'
import './validation' import './validation'
import './new_editor' import './new_editor'
import './htmx_abort'

View file

@ -9,9 +9,16 @@ try {
host: window.env.PANEL_URL host: window.env.PANEL_URL
}); });
const ignoredErrors = ["htmx:afterRequest", "htmx:sendAbort"];
console.originalError = console.error; console.originalError = console.error;
console.error = (...e) => { console.error = (...e) => {
const msg = e.join(" ");
if (!ignoredErrors.some(x => msg.includes(x))) {
window.airbrake.notify(e.join(" ")); window.airbrake.notify(e.join(" "));
}
return console.originalError(...e); return console.originalError(...e);
}; };
} catch(e) { } catch(e) {

View file

@ -61,6 +61,10 @@ class SitePolicy
show? && usuarie? show? && usuarie?
end end
def button?
show?
end
def enqueue? def enqueue?
build? build?
end end

View file

@ -1,4 +1,5 @@
- if policy(site).build? - if policy(site).build?
%div{ 'hx-get': site_button_path(site, class: local_assigns[:class]), 'hx-trigger': 'every 10s', 'hx-swap': 'outerHTML' }
= form_tag site_enqueue_path(site), = form_tag site_enqueue_path(site),
method: :post, method: :post,
class: 'form-inline inline' do class: 'form-inline inline' do
@ -6,4 +7,4 @@
class: "btn btn-secondary #{local_assigns[:class]}", class: "btn btn-secondary #{local_assigns[:class]}",
title: site.enqueued? ? t('help.sites.enqueued') : t('help.sites.enqueue'), title: site.enqueued? ? t('help.sites.enqueued') : t('help.sites.enqueue'),
data: { disable_with: t('sites.enqueued') }, data: { disable_with: t('sites.enqueued') },
disabled: site.enqueued? disabled: !site.waiting?

View file

@ -18,7 +18,7 @@
- message = t('.available') - message = t('.available')
- link = true - link = true
-# TODO: Calcular cada cuanto sería óptimo recargar -# TODO: Calcular cada cuánto sería óptimo recargar
%div{ 'hx-get': site_status_path(site), 'hx-trigger': 'every 10s', 'hx-swap': 'outerHTML' } %div{ 'hx-get': site_status_path(site), 'hx-trigger': 'every 10s', 'hx-swap': 'outerHTML' }
= render 'bootstrap/alert' do = render 'bootstrap/alert' do
= link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link' = link_to_if link, message.html_safe, site_build_stats_path(site), class: 'alert-link'

View file

@ -0,0 +1 @@
= render 'sites/build', site: @site, class: params.permit(:class)[:class]

View file

@ -53,6 +53,7 @@ Rails.application.routes.draw do
post 'pull', to: 'sites#merge' post 'pull', to: 'sites#merge'
get 'status', to: 'sites#status' get 'status', to: 'sites#status'
get 'button', to: 'sites#button'
# Gestionar usuaries # Gestionar usuaries
get 'usuaries/invite', to: 'usuaries#invite' get 'usuaries/invite', to: 'usuaries#invite'