stream logs from pods

This commit is contained in:
Chris Zhu
2025-04-09 12:56:53 -07:00
parent 678727505c
commit f5e4c098ac
3 changed files with 10 additions and 5 deletions
@@ -4,6 +4,9 @@ import { get } from "@rails/request.js"
const REFRESH_INTERVAL = 4000;
export default class extends Controller {
static targets = ["container"]
static values = {
url: String
}
connect() {
// Scroll to the bottom of the container
@@ -23,8 +26,8 @@ export default class extends Controller {
async loadNewLogs() {
// Only do this if the scroll is at the bottom
if (this.containerTarget.scrollTop === this.containerTarget.scrollHeight) {
await get(this.element.dataset.url, {
if (this.containerTarget.scrollTop === (this.containerTarget.scrollHeight - this.containerTarget.offsetHeight)) {
await get(this.urlValue, {
responseKind: 'turbo-stream'
});
this.scrollToBottom();