-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
76 additions
and
127 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
service/src/main/kotlin/app/cash/backfila/ui/ProgressUpdater.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// package app.cash.backfila.ui | ||
// | ||
// class ProgressUpdater { | ||
// fun backfillProgress(backfillName: String, numerator: Number, denominator: Number): String { | ||
// println("Backfill $backfillName is ${numerator.toDouble() / denominator.toDouble() * 100}% complete") | ||
// } | ||
// } |
117 changes: 0 additions & 117 deletions
117
service/src/main/kotlin/app/cash/backfila/ui/components/DashboardLayout.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
service/src/main/kotlin/app/cash/backfila/ui/components/ProgressBarReloader.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package app.cash.backfila.ui.components | ||
|
||
import kotlin.math.round | ||
import kotlinx.html.TagConsumer | ||
import kotlinx.html.div | ||
import kotlinx.html.style | ||
|
||
fun TagConsumer<*>.ProgressBarReloader(numerator: Number, denominator: Number) { | ||
div("w-full bg-gray-200 rounded-full dark:bg-gray-700") { | ||
val percentComplete = if (numerator.toInt() == 0) 0 else round((numerator.toDouble() / denominator.toDouble()) * 100) | ||
// Don't show blue sliver for 0%, just show the gray empty bar | ||
val showPartialBarStyle = if (percentComplete.toInt() != 0) "bg-blue-600" else "" | ||
div( | ||
"$showPartialBarStyle text-xs font-medium text-blue-100 text-center p-0.5 leading-none rounded-full", | ||
) { | ||
style = "width: ${if (percentComplete.toInt() == 0) 100 else percentComplete}%" | ||
+"""$percentComplete%""" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
service/src/main/resources/web/static/js/auto_reload_controller.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Application, Controller } from "../cache/stimulus/3.1.0/stimulus.min.js"; | ||
window.Stimulus = Application.start(); | ||
|
||
Stimulus.register("auto-reload", class extends Controller { | ||
static targets = ["frame"]; | ||
|
||
connect() { | ||
console.log("Auto-reload connected..."); | ||
this.reloadInterval = setInterval(() => { | ||
console.log("Reloading Turbo Frame..."); | ||
this.reloadFrame(); | ||
}, 5000); // 5000 milliseconds = 5 seconds | ||
} | ||
|
||
disconnect() { | ||
console.log("Clearing auto-reload interval..."); | ||
clearInterval(this.reloadInterval); | ||
} | ||
|
||
reloadFrame() { | ||
this.frameTarget.src = this.frameTarget.src; | ||
} | ||
}); |