-
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
148 additions
and
56 deletions.
There are no files selected for viewing
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
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
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
73 changes: 73 additions & 0 deletions
73
service/src/main/kotlin/app/cash/backfila/ui/pages/IndexAction.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,73 @@ | ||
package app.cash.backfila.ui.pages | ||
|
||
import app.cash.backfila.service.BackfilaConfig | ||
import app.cash.backfila.ui.actions.ServiceAutocompleteAction | ||
import app.cash.backfila.ui.components.AlertSupport | ||
import app.cash.backfila.ui.components.DashboardPageLayout | ||
import javax.inject.Inject | ||
import kotlinx.html.dd | ||
import kotlinx.html.div | ||
import kotlinx.html.dl | ||
import kotlinx.html.dt | ||
import kotlinx.html.h1 | ||
import kotlinx.html.h3 | ||
import kotlinx.html.span | ||
import misk.MiskCaller | ||
import misk.scope.ActionScoped | ||
import misk.security.authz.Authenticated | ||
import misk.web.Get | ||
import misk.web.QueryParam | ||
import misk.web.ResponseContentType | ||
import misk.web.actions.WebAction | ||
import misk.web.mediatype.MediaTypes | ||
|
||
class IndexAction @Inject constructor( | ||
private val config: BackfilaConfig, | ||
private val serviceAutocompleteAction: ServiceAutocompleteAction, | ||
private val dashboardPageLayout: DashboardPageLayout, | ||
private val callerProvider: ActionScoped<MiskCaller?>, | ||
) : WebAction { | ||
@Get(PATH) | ||
@ResponseContentType(MediaTypes.TEXT_HTML) | ||
@Authenticated(capabilities = ["users"]) | ||
fun get( | ||
@QueryParam sc: String?, | ||
): String = dashboardPageLayout | ||
.newBuilder() | ||
.title("Backfila Home") | ||
.build { | ||
h1("text-2xl") { | ||
+"""Welcome to Backfila, """ | ||
span("font-bold font-mono") { +"""${callerProvider.get()?.user}""" } | ||
+"""!""" | ||
} | ||
|
||
// Stats | ||
|
||
div("py-10") { | ||
h3("text-base font-semibold text-gray-900") { +"""Last 30 days""" } | ||
dl("mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3") { | ||
div("overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6") { | ||
this@dl.dt("truncate text-sm font-medium text-gray-500") { +"""Total Records""" } | ||
this@dl.dd("mt-1 text-3xl font-semibold tracking-tight text-gray-900") { +"""1,271,897""" } | ||
} | ||
div("overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6") { | ||
this@dl.dt("truncate text-sm font-medium text-gray-500") { +"""Avg. Progress Rate""" } | ||
this@dl.dd("mt-1 text-3xl font-semibold tracking-tight text-gray-900") { +"""58.16%""" } | ||
} | ||
div("overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6") { | ||
this@dl.dt("truncate text-sm font-medium text-gray-500") { +"""Avg. Records Per Second""" } | ||
this@dl.dd("mt-1 text-3xl font-semibold tracking-tight text-gray-900") { +"""2457""" } | ||
} | ||
} | ||
} | ||
|
||
// Running Backfills | ||
|
||
AlertSupport(config.support_button_label, config.support_button_url) | ||
} | ||
|
||
companion object { | ||
const val PATH = "/" | ||
} | ||
} |
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
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