Finished dev [unoptimized + debuginfo] target(s) in 59.76s
This commit is contained in:
parent
6ecb5dd41f
commit
768d91c5e9
31
src/task.rs
31
src/task.rs
|
@ -16,14 +16,11 @@
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Deserialize)]
|
||||||
pub enum Status {
|
pub struct Request {
|
||||||
Ideas(),
|
r#move: String,
|
||||||
Assigned(String),
|
|
||||||
InProgress(),
|
|
||||||
Done(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
@ -36,13 +33,13 @@ pub struct Task {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Task {
|
impl Task {
|
||||||
pub fn new(title: String, date: String, status: Status, assignee: String, description: String) -> Task {
|
pub fn new(
|
||||||
let status = match status {
|
title: String,
|
||||||
Status::Ideas() => "Ideas".to_string(),
|
date: String,
|
||||||
Status::Assigned(u) => format!("Assiged to {}", u),
|
status: String,
|
||||||
Status::InProgress() => "In prograss".to_string(),
|
assignee: String,
|
||||||
Status::Done() => "Done".to_string(),
|
description: String,
|
||||||
};
|
) -> Task {
|
||||||
Task {
|
Task {
|
||||||
title,
|
title,
|
||||||
date,
|
date,
|
||||||
|
@ -52,3 +49,9 @@ impl Task {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn handle_post(form: Request) -> impl warp::Reply {
|
||||||
|
// TODO: intelligent SQL code here (or maybe in another function idk, it's up to the reader to
|
||||||
|
// decide whats more intelligent)
|
||||||
|
warp::redirect(warp::http::Uri::from_static("/tmtd"))
|
||||||
|
}
|
||||||
|
|
25
src/web.rs
25
src/web.rs
|
@ -27,7 +27,7 @@ use tracing::info;
|
||||||
use warp::Filter;
|
use warp::Filter;
|
||||||
use warp_sessions::{CookieOptions, SameSiteCookieOption, SessionWithStore};
|
use warp_sessions::{CookieOptions, SameSiteCookieOption, SessionWithStore};
|
||||||
|
|
||||||
use crate::{Config, Database};
|
use crate::{task, Config, Database};
|
||||||
|
|
||||||
macro_rules! warp_try {
|
macro_rules! warp_try {
|
||||||
($expr:expr) => {
|
($expr:expr) => {
|
||||||
|
@ -129,24 +129,31 @@ impl App {
|
||||||
warp::reply::html(tera.render("hello.html", &ctx).unwrap())
|
warp::reply::html(tera.render("hello.html", &ctx).unwrap())
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.or(warp::path!("tmtd" / String).map({
|
.or(warp::path("tmtd").map({
|
||||||
let tera = self.tera.clone();
|
let tera = self.tera.clone();
|
||||||
move |_| {
|
move || {
|
||||||
let mut ctx = Context::new();
|
let mut ctx = Context::new();
|
||||||
let mut tasks = Vec::new();
|
let mut tasks = Vec::new();
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
let task_ctx = crate::task::Task::new("TODO".to_string(),
|
let task_ctx = task::Task::new(
|
||||||
"TODO".to_string(),
|
"TODO".to_string(),
|
||||||
crate::task::Status::Ideas(),
|
"TODO".to_string(),
|
||||||
"TODO".to_string(),
|
"TODO".to_string(),
|
||||||
"TODO".to_string());
|
"TODO".to_string(),
|
||||||
|
"TODO".to_string(),
|
||||||
|
);
|
||||||
tasks.push(task_ctx);
|
tasks.push(task_ctx);
|
||||||
}
|
}
|
||||||
ctx.insert("tasks", &tasks);
|
ctx.insert("tasks", &tasks);
|
||||||
tracing::debug!("{:?}", tasks);
|
tracing::debug!("{:?}", tasks);
|
||||||
warp::reply::html(tera.render("task_page.html", &ctx).unwrap())
|
warp::reply::html(tera.render("task_page.html", &ctx).unwrap())
|
||||||
}
|
}
|
||||||
}));
|
}))
|
||||||
|
.or(warp::post()
|
||||||
|
.and(warp::path("api"))
|
||||||
|
.and(warp::path("issues"))
|
||||||
|
.and(warp::body::form::<task::Request>())
|
||||||
|
.then(task::handle_post));
|
||||||
|
|
||||||
let (_, server) =
|
let (_, server) =
|
||||||
warp::serve(route).bind_with_graceful_shutdown(self.config.listen_addr, async move {
|
warp::serve(route).bind_with_graceful_shutdown(self.config.listen_addr, async move {
|
||||||
|
|
|
@ -10,11 +10,14 @@
|
||||||
{{task.description}}
|
{{task.description}}
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<label for="move">Move to:</label>
|
<form action="/api/issues" method="post">
|
||||||
<select name="move" id="move">
|
<label for="move">Move to:</label>
|
||||||
<option value="ideas">ideas</option>
|
<select name="move" id="move">
|
||||||
<option value="assigned">assigned</option>
|
<option value="Ideas">ideas</option>
|
||||||
<option value="in-progress">in progreess</option>
|
<option value="Assigned">assigned</option>
|
||||||
<option value="done">done</option>
|
<option value="InProgress">in progreess</option>
|
||||||
<select>
|
<option value="Done">done</option>
|
||||||
|
<input type="submit" value="Move">
|
||||||
|
</select>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue