parent
68ec57eac0
commit
12d8bc0e21
@ -0,0 +1,12 @@
|
||||
use askama::Template;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use crate::error::{AppError};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "audit.html")]
|
||||
struct AuditLogTemplate;
|
||||
|
||||
|
||||
pub async fn audit_log_handler() -> Result<Response, AppError> {
|
||||
Ok(AuditLogTemplate.into_response())
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
use askama::Template;
|
||||
use axum::extract::State;
|
||||
use sqlx::SqlitePool;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use axum_htmx::HxRequest;
|
||||
use crate::db::inventory_item::{inventory_item_get_search, DbInventoryItem};
|
||||
use crate::error::{AppError, QueryExtractor};
|
||||
use crate::app::SearchQueryArgs;
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "home.html")]
|
||||
struct HomeTemplate {
|
||||
items: Vec<DbInventoryItem>,
|
||||
query: SearchQueryArgs,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "home_search_item_fragment.html")]
|
||||
struct HomeSearchItemFragmentTemplate {
|
||||
items: Vec<DbInventoryItem>,
|
||||
}
|
||||
|
||||
|
||||
pub async fn home(
|
||||
QueryExtractor(query): QueryExtractor<SearchQueryArgs>,
|
||||
HxRequest(hx_request): HxRequest,
|
||||
State(db): State<SqlitePool>
|
||||
) -> Result<Response, AppError> {
|
||||
|
||||
let page = query.page.unwrap_or(0);
|
||||
let page_size = query.page_size.unwrap_or(100);
|
||||
|
||||
let items = match query.search.as_ref() {
|
||||
None => Vec::new(),
|
||||
Some(s) => inventory_item_get_search(&db, s.as_str(), page_size, page).await?,
|
||||
};
|
||||
|
||||
if hx_request {
|
||||
Ok(HomeSearchItemFragmentTemplate { items }.into_response())
|
||||
}
|
||||
else {
|
||||
Ok(HomeTemplate { items, query }.into_response())
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
use askama::Template;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use crate::error::{AppError};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "overview.html")]
|
||||
struct OverviewTemplate;
|
||||
|
||||
|
||||
pub async fn overview_handler() -> Result<Response, AppError> {
|
||||
Ok(OverviewTemplate.into_response())
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
use askama::Template;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use crate::error::{AppError};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "reports.html")]
|
||||
struct ReportsTemplate;
|
||||
|
||||
|
||||
pub async fn reports_handler() -> Result<Response, AppError> {
|
||||
Ok(ReportsTemplate.into_response())
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
use askama::Template;
|
||||
use askama_axum::{IntoResponse, Response};
|
||||
use crate::error::{AppError};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "upload.html")]
|
||||
struct UploadIndexTemplate;
|
||||
|
||||
pub async fn upload_index_handler() -> Result<Response, AppError> {
|
||||
Ok(UploadIndexTemplate.into_response())
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
pub mod catalog;
|
||||
pub mod index;
|
||||
@ -0,0 +1,9 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block title %} Audit Log {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Audit Log (Coming soon)</h1>
|
||||
|
||||
{% endblock %}
|
||||
@ -0,0 +1,23 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block title %} Home {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p>
|
||||
<input id="search" type="search" name="q"
|
||||
placeholder="Search"
|
||||
aria-label="Search"
|
||||
value='{{ query.search.as_deref().unwrap_or("") }}'
|
||||
hx-get="/home/search"
|
||||
hx-trigger="search, keyup delay:500ms changed"
|
||||
hx-target="#items"
|
||||
hx-push-url="true"
|
||||
/>
|
||||
</p>
|
||||
|
||||
<div id="items" class="container">
|
||||
{% include "home_search_item_fragment.html" %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@ -0,0 +1,9 @@
|
||||
{% for item in items %}
|
||||
<article id="item-{{item.id}}-card">
|
||||
<div class="grid">
|
||||
<div><a href="/item/{{item.id}}/" hx-push-url="true">{{ item.name }}</a></div>
|
||||
<div>Count: <span id="item-{{item.id}}-count" hx-get="/item/{{item.id}}/count" hx-trigger="load">0</span></div>
|
||||
<div>Reorder Point: {{ item.reorder_point }}</div>
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
@ -0,0 +1,9 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block title %} Overview {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Overview (Coming soon)</h1>
|
||||
|
||||
{% endblock %}
|
||||
@ -0,0 +1,9 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block title %} Reports {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>Reports (Coming soon)</h1>
|
||||
|
||||
{% endblock %}
|
||||
@ -0,0 +1,15 @@
|
||||
{% extends "main.html" %}
|
||||
|
||||
{% block title %} Upload {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<form action="/upload/catalog" method="post" enctype="multipart/form-data">
|
||||
<h3>Catalog Import</h3>
|
||||
<fieldset role="group">
|
||||
<input type="file" name="file" />
|
||||
<input type="submit" value="Upload">
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
Loading…
Reference in new issue