implement easy sitekey addition

This commit is contained in:
realaravinth
2021-12-18 16:42:27 +05:30
parent 081cdcc803
commit a73542cf18
7 changed files with 520 additions and 7 deletions

View File

@@ -22,21 +22,23 @@ use sailfish::TemplateOnce;
const PAGE: &str = "Add Sitekey";
lazy_static! {
static ref INDEX: String = IndexPage::default().render_once().unwrap();
static ref ADVANCE_INDEX: String =
AdvanceIndexPage::default().render_once().unwrap();
static ref EASY_INDEX: String = EasyIndexPage::default().render_once().unwrap();
}
#[derive(TemplateOnce, Clone)]
#[template(path = "panel/sitekey/add/advance/index.html")]
pub struct IndexPage<'a> {
pub struct AdvanceIndexPage<'a> {
pub levels: usize,
pub form_title: &'a str,
pub form_description: &'a str,
pub form_duration: usize,
}
impl<'a> Default for IndexPage<'a> {
impl<'a> Default for AdvanceIndexPage<'a> {
fn default() -> Self {
IndexPage {
Self {
levels: 1,
form_description: "",
form_title: PAGE,
@@ -45,9 +47,44 @@ impl<'a> Default for IndexPage<'a> {
}
}
#[my_codegen::get(path = "crate::PAGES.panel.sitekey.add", wrap = "crate::CheckLogin")]
pub async fn add_sitekey() -> impl Responder {
#[my_codegen::get(
path = "crate::PAGES.panel.sitekey.add_advance",
wrap = "crate::CheckLogin"
)]
pub async fn advance() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(&*INDEX)
.body(&*ADVANCE_INDEX)
}
#[derive(TemplateOnce, Clone)]
#[template(path = "panel/sitekey/add/novice/index.html")]
pub struct EasyIndexPage<'a> {
pub form_description: &'a str,
pub form_title: &'a str,
pub peak_sustainable_traffic: Option<usize>,
pub avg_traffic: Option<usize>,
pub broke_my_site_traffic: Option<usize>,
}
impl<'a> Default for EasyIndexPage<'a> {
fn default() -> Self {
Self {
form_description: "",
peak_sustainable_traffic: None,
avg_traffic: None,
broke_my_site_traffic: None,
form_title: PAGE,
}
}
}
#[my_codegen::get(
path = "crate::PAGES.panel.sitekey.add_easy",
wrap = "crate::CheckLogin"
)]
pub async fn easy() -> impl Responder {
HttpResponse::Ok()
.content_type("text/html; charset=utf-8")
.body(&*EASY_INDEX)
}