Skip to content

Commit

Permalink
feat(server): add manage-projects page
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxiaohei committed Apr 3, 2024
1 parent 8ccd6fc commit c0e3063
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 3 deletions.
33 changes: 31 additions & 2 deletions land-server/src/server/dash/manage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ pub async fn options(
Ok((
csrf,
RenderHtml(
"manage.hbs",
"manage/options.hbs",
engine,
Vars {
page: PageVars::new("Manage", "/manage", "manage"),
page: PageVars::new("Manage Options", "/manage/options", "manage"),
user,
csrf_token,
tokens,
Expand Down Expand Up @@ -170,3 +170,32 @@ pub async fn update_prom_env(
land_kernel::prom::set_env(prom_env).await?;
Ok(redirect_response("/settings/manage/options"))
}

/// projects is a handler for GET /manage/projects
pub async fn projects(
csrf: CsrfToken,
Extension(user): Extension<SessionUser>,
engine: TemplateEngine,
) -> Result<impl IntoResponse, ServerError> {
#[derive(Serialize)]
struct Vars {
page: PageVars,
user: SessionUser,
csrf_token: String,
}
let csrf_token = csrf.authenticity_token()?;

Ok((
csrf,
RenderHtml(
"manage/projects.hbs",
engine,
Vars {
page: PageVars::new("Manage Projects", "/manage/projects", "manage"),
user,
csrf_token,
},
),
)
.into_response())
}
1 change: 1 addition & 0 deletions land-server/src/server/dash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn router(assets_dir: &str) -> Result<Router> {
"/settings/manage/update-prom-env",
post(manage::update_prom_env),
)
.route("/settings/manage/projects", get(manage::projects))
.nest_service("/static", ServeDir::new(static_assets_dir))
.layer(CsrfLayer::new(config))
.with_state(Engine::from(hbs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{{> partials/nav.hbs}}
<div id="manage-container" class="container mx-auto">
<nav class="nav mt-3 mb-2">
<a class="nav-link active" aria-current="page" href="/settings/manage/options">Options</a>
<a class="nav-link active" href="/settings/manage/options">Options</a>
<a class="nav-link" href="/settings/manage/projects">Projects</a>
</nav>
<div class="row">
<div class="col">
Expand Down
76 changes: 76 additions & 0 deletions land-server/tpls/manage/projects.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!doctype html>
<html lang="en" data-bs-theme="light">

<head>
{{> partials/head.hbs}}
</head>

<body>
{{> partials/nav.hbs}}
<div id="manage-container" class="container mx-auto">
<nav class="nav mt-3 mb-2">
<a class="nav-link" href="/settings/manage/options">Options</a>
<a class="nav-link active" href="/settings/manage/projects">Projects</a>
</nav>
<div class="border-top py-3">
<div class="d-flex justify-content-between align-items-center">
<div class="left">
<h6 class="mb-0">Projects</h6>
<p class="fs-6 text-body-tertiary mb-0">All projects.</p>
</div>
<div class="right">
<form action="/projects" method="get">
<div class="input-group input-group-sm">
<input type="text" class="form-control" name="search" placeholder="Search by domain or name"
value="{{search}}" required>
<button class="btn btn-outline-secondary" type="submit"><i
class='bx bx-search-alt mx-2'></i></button>
</div>
</form>
</div>
</div>
<table class="table mt-3" id="project-list-table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Lang</th>
<th scope="col">User</th>
<th scope="col">URL</th>
<th scope="col">Traffic</th>
<th scope="col">Updated</th>
<th scope="col">Ops</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<p class="name mb-1">
<a href="/projects/prize-gilt-19" class="text-body">prize-gilt-19</a>
</p>
<p class="meta mb-1 small text-body-tertiary fw-light">via <span
class="text-uppercase">playground</span></p>
</th>
<td><span class="text-uppercase text-body-tertiary">js</span></td>
<td><span class="text-body-tertiary">FuXiaoHei</span></td>
<td>
<a class="link" href="http://prize-gilt-19.127-0-0-1.nip.io"
target="_blank">prize-gilt-19.127-0-0-1.nip.io</a>
</td>
<td></td>
<td>
<span class="text-body-tertiary" data-x-timeago="2024-03-27T06:17:44.382866Z">1 week
ago</span>
</td>
<td>
<a href="#">Redeploy</a>
<a href="#">Forbidden</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
{{> partials/footer.hbs}}
</body>

</html>

0 comments on commit c0e3063

Please sign in to comment.