Handler for all pages defined in the navbar
This commit is contained in:
parent
163fa89e05
commit
0f0cb303fc
|
@ -54,14 +54,14 @@ impl Database {
|
||||||
|
|
||||||
// Async might become a problem here
|
// Async might become a problem here
|
||||||
pub fn get_tasks(&self) -> templates::Tasks {
|
pub fn get_tasks(&self) -> templates::Tasks {
|
||||||
// TODO: actually get the issues from the db
|
// TODO: actually get the issues from the db based on the category cookies
|
||||||
let vec = vec![templates::Task {
|
let vec = vec![templates::Task {
|
||||||
title: "TODO".to_string(),
|
title: "finish tmtd".to_string(),
|
||||||
date: "TODO".to_string(), // Convert from unix timestamps to
|
date: "yesterday".to_string(), // Convert from unix timestamps to
|
||||||
// the actual date, also timezone info?
|
// the actual date, also timezone info?
|
||||||
status: "TODO".to_string(),
|
status: "assigned".to_string(),
|
||||||
assignee: "TODO".to_string(),
|
assignee: "tmtd contributers".to_string(),
|
||||||
description: "TODO".to_string(),
|
description: "DO SOMETHING AAAAAAA".to_string(),
|
||||||
id: 1,
|
id: 1,
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,18 @@
|
||||||
|
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "index.html")]
|
||||||
|
pub struct Index();
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "users.html")]
|
||||||
|
pub struct Users();
|
||||||
|
|
||||||
|
#[derive(Template)]
|
||||||
|
#[template(path = "admin.html")]
|
||||||
|
pub struct AdminPanel();
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "task/task_page.html")]
|
#[template(path = "task/task_page.html")]
|
||||||
pub struct Tasks {
|
pub struct Tasks {
|
||||||
|
|
25
src/web.rs
25
src/web.rs
|
@ -31,9 +31,12 @@ impl App {
|
||||||
let db = db.clone();
|
let db = db.clone();
|
||||||
let server = HttpServer::new(move || {
|
let server = HttpServer::new(move || {
|
||||||
actix_web::App::new().service((
|
actix_web::App::new().service((
|
||||||
|
web::resource("/").route(web::get().to(index)),
|
||||||
|
web::resource("/users").route(web::get().to(users)),
|
||||||
web::resource("/task")
|
web::resource("/task")
|
||||||
.app_data(web::Data::new(db.clone()))
|
.app_data(web::Data::new(db.clone()))
|
||||||
.route(web::get().to(task)),
|
.route(web::get().to(tasks)),
|
||||||
|
web::resource("/admin").route(web::get().to(admin)),
|
||||||
web::resource("/create").route(web::get().to(create)),
|
web::resource("/create").route(web::get().to(create)),
|
||||||
web::resource("/login").route(web::get().to(login)),
|
web::resource("/login").route(web::get().to(login)),
|
||||||
web::resource("/register").route(web::get().to(register)),
|
web::resource("/register").route(web::get().to(register)),
|
||||||
|
@ -58,12 +61,30 @@ impl App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn task(db: web::Data<Arc<Database>>) -> impl Responder {
|
async fn index() -> impl Responder {
|
||||||
|
let index = templates::Index {};
|
||||||
|
let html = index.render().unwrap();
|
||||||
|
HttpResponseBuilder::new(StatusCode::OK).body(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn tasks(db: web::Data<Arc<Database>>) -> impl Responder {
|
||||||
let tasks = db.get_tasks();
|
let tasks = db.get_tasks();
|
||||||
let html = tasks.render().unwrap();
|
let html = tasks.render().unwrap();
|
||||||
HttpResponseBuilder::new(StatusCode::OK).body(html)
|
HttpResponseBuilder::new(StatusCode::OK).body(html)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn users() -> impl Responder {
|
||||||
|
let users = templates::Users {};
|
||||||
|
let html = users.render().unwrap();
|
||||||
|
HttpResponseBuilder::new(StatusCode::OK).body(html)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn admin() -> impl Responder {
|
||||||
|
let admin_panel = templates::AdminPanel {};
|
||||||
|
let html = admin_panel.render().unwrap();
|
||||||
|
HttpResponseBuilder::new(StatusCode::OK).body(html)
|
||||||
|
}
|
||||||
|
|
||||||
async fn create() -> impl Responder {
|
async fn create() -> impl Responder {
|
||||||
let create = templates::CreateTask {};
|
let create = templates::CreateTask {};
|
||||||
let html = create.render().unwrap();
|
let html = create.render().unwrap();
|
||||||
|
|
8
templates/admin.html
Normal file
8
templates/admin.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "navbar.html" %}
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
10
templates/index.html
Normal file
10
templates/index.html
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "navbar.html" %}
|
||||||
|
|
||||||
|
Dashboard or something?
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
8
templates/users.html
Normal file
8
templates/users.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "navbar.html" %}
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
Loading…
Reference in a new issue