This commit is contained in:
parent
3fabc91438
commit
0cc7eb8f40
5 changed files with 53 additions and 21 deletions
|
@ -5,7 +5,7 @@ use based::{
|
|||
use maud::{PreEscaped, html};
|
||||
use rocket::get;
|
||||
|
||||
use pacco::pkg::Repository;
|
||||
use pacco::pkg::{Repository, arch::Architecture};
|
||||
|
||||
use super::render;
|
||||
|
||||
|
@ -13,9 +13,6 @@ use super::render;
|
|||
|
||||
#[get("/<repo>/<pkg_name>")]
|
||||
pub async fn pkg_ui(repo: &str, pkg_name: &str, ctx: RequestContext) -> Option<StringResponse> {
|
||||
// TODO : Implement pkg UI
|
||||
// pkgmeta display
|
||||
|
||||
let repo = Repository::new(repo).unwrap();
|
||||
let pkg = repo.get_pkg_by_name(pkg_name)?;
|
||||
let versions = pkg.versions();
|
||||
|
@ -154,10 +151,10 @@ pub async fn pkg_ui(repo: &str, pkg_name: &str, ctx: RequestContext) -> Option<S
|
|||
};
|
||||
};
|
||||
|
||||
// Install Scripts
|
||||
// Install Script
|
||||
@if let Some(install_script) = install_script {
|
||||
div class="space-y-4 pt-6" {
|
||||
h2 class="text-3xl font-semibold text-gray-700 dark:text-gray-300" { "Install Scripts" }
|
||||
h2 class="text-3xl font-semibold text-gray-700 dark:text-gray-300" { "Install Script" }
|
||||
pre class="bg-gray-100 dark:bg-gray-700 p-4 rounded-lg text-gray-800 dark:text-gray-100 overflow-x-auto text-sm" {
|
||||
(install_script)
|
||||
}
|
||||
|
@ -168,15 +165,18 @@ pub async fn pkg_ui(repo: &str, pkg_name: &str, ctx: RequestContext) -> Option<S
|
|||
Some(render(content, pkg_name, ctx).await)
|
||||
}
|
||||
|
||||
#[get("/<repo>")]
|
||||
pub async fn repo_ui(repo: &str, ctx: RequestContext) -> StringResponse {
|
||||
// TODO : Repo UI
|
||||
// permissions
|
||||
// pkg list
|
||||
#[get("/<repo>?<arch>")]
|
||||
pub async fn repo_ui(repo: &str, ctx: RequestContext, arch: Option<&str>) -> StringResponse {
|
||||
// TODO : permissions
|
||||
let arch = arch.map(|x| Architecture::parse(x).unwrap_or(Architecture::any));
|
||||
|
||||
let repo = Repository::new(repo).unwrap();
|
||||
let architectures: Vec<_> = repo.arch().into_iter().map(|x| x.to_string()).collect();
|
||||
let packages = repo.list_pkg();
|
||||
let packages = if let Some(arch) = arch.clone() {
|
||||
repo.list_pkg_arch(arch)
|
||||
} else {
|
||||
repo.list_pkg()
|
||||
};
|
||||
|
||||
let content = html! {
|
||||
// Repository name and architectures
|
||||
|
@ -186,10 +186,23 @@ pub async fn repo_ui(repo: &str, ctx: RequestContext) -> StringResponse {
|
|||
};
|
||||
|
||||
div class="flex gap-2 mt-2 md:mt-0" {
|
||||
@for arch in architectures {
|
||||
span class="px-3 py-1 text-sm font-medium bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded-full" {
|
||||
(arch)
|
||||
};
|
||||
@for a in architectures {
|
||||
// TODO : Filter per arch with ?arch=
|
||||
@if let Some(arch) = arch.as_ref() {
|
||||
@if arch.to_string() == a {
|
||||
(htmx_link(&format!("/{}", repo.name), "px-3 py-1 text-sm font-medium bg-blue-400 dark:bg-blue-500 text-gray-600 dark:text-gray-300 rounded-full", "", html! {
|
||||
(a)
|
||||
}));
|
||||
} @else {
|
||||
(htmx_link(&format!("/{}?arch={}", repo.name, a), "px-3 py-1 text-sm font-medium bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded-full", "", html! {
|
||||
(a)
|
||||
}));
|
||||
}
|
||||
} @else {
|
||||
(htmx_link(&format!("/{}?arch={}", repo.name, a), "px-3 py-1 text-sm font-medium bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 rounded-full", "", html! {
|
||||
(a)
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -267,7 +280,7 @@ pub fn build_info(key: String, value: String) -> PreEscaped<String> {
|
|||
|
||||
pub fn key_value(key: String, value: String) -> PreEscaped<String> {
|
||||
html! {
|
||||
div class="flex" {
|
||||
div class="flex items-center" {
|
||||
span class="font-bold w-32" { (format!("{key}: ")) };
|
||||
span class="ml-2" { (value) };
|
||||
};
|
||||
|
|
|
@ -173,8 +173,6 @@ pub struct PasswordChangeForm {
|
|||
csrf: String,
|
||||
}
|
||||
|
||||
// TODO : Change password pages
|
||||
|
||||
#[post("/passwd", data = "<form>")]
|
||||
pub async fn change_password_post(form: Form<PasswordChangeForm>, user: User) -> Redirect {
|
||||
if form.password_new != form.password_new_repeat {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue