feat: port html pages into tera templates
This commit is contained in:
parent
1c327aaffb
commit
6e62c8d8a9
11 changed files with 611 additions and 1 deletions
67
web_ui/src/identity/employee_exit_organization.rs
Normal file
67
web_ui/src/identity/employee_exit_organization.rs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const EMPLOYEE_EXIT_ORGANIZATION_PAGE: TemplateFile = TemplateFile::new(
|
||||||
|
"identity.employee_exit_organization",
|
||||||
|
"identity/employee_exit_organization.html",
|
||||||
|
);
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
EMPLOYEE_EXIT_ORGANIZATION_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(EMPLOYEE_EXIT_ORGANIZATION_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EmployeeExitOrganizationPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EmployeeExitOrganizationPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(EMPLOYEE_EXIT_ORGANIZATION_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-employee_exit_organization.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(EmployeeExitOrganizationPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
65
web_ui/src/identity/employee_login.rs
Normal file
65
web_ui/src/identity/employee_login.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const EMPLOYEE_LOGIN_PAGE: TemplateFile =
|
||||||
|
TemplateFile::new("identity.employee_login", "identity/employee_login.html");
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
EMPLOYEE_LOGIN_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(EMPLOYEE_LOGIN_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EmployeeLoginPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EmployeeLoginPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(EMPLOYEE_LOGIN_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-employee_login.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(EmployeeLoginPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
67
web_ui/src/identity/employee_register.rs
Normal file
67
web_ui/src/identity/employee_register.rs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const EMPLOYEE_REGISTER_PAGE: TemplateFile = TemplateFile::new(
|
||||||
|
"identity.employee_register",
|
||||||
|
"identity/employee_register.html",
|
||||||
|
);
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
EMPLOYEE_REGISTER_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(EMPLOYEE_REGISTER_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct EmployeeRegisterPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EmployeeRegisterPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(EMPLOYEE_REGISTER_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-employee_register.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(EmployeeRegisterPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,13 +2,31 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
|
pub mod employee_exit_organization;
|
||||||
|
pub mod employee_login;
|
||||||
|
pub mod employee_register;
|
||||||
|
pub mod owner_add_store;
|
||||||
|
pub mod owner_change_password;
|
||||||
|
pub mod owner_delete_user;
|
||||||
|
pub mod owner_login;
|
||||||
|
pub mod owner_register;
|
||||||
pub mod owner_update_email;
|
pub mod owner_update_email;
|
||||||
|
pub mod owner_update_store;
|
||||||
pub mod owner_verify_email;
|
pub mod owner_verify_email;
|
||||||
|
|
||||||
pub fn register_templates(t: &mut tera::Tera) {
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
for template in [
|
for template in [
|
||||||
owner_update_email::ONWER_UPDATE_EMAIL_PAGE,
|
owner_update_email::ONWER_UPDATE_EMAIL_PAGE,
|
||||||
owner_verify_email::ONWER_VERIFY_EMAIL_PAGE,
|
owner_verify_email::ONWER_VERIFY_EMAIL_PAGE,
|
||||||
|
owner_delete_user::ONWER_DELETE_USER_PAGE,
|
||||||
|
owner_change_password::OWNER_CHANGE_PASSWORD_PAGE,
|
||||||
|
employee_register::EMPLOYEE_REGISTER_PAGE,
|
||||||
|
owner_update_store::OWNER_UPDATE_STORE_PAGE,
|
||||||
|
owner_login::OWNER_LOGIN_PAGE,
|
||||||
|
owner_register::OWNER_REGISTER_PAGE,
|
||||||
|
owner_add_store::OWNER_ADD_STORE_PAGE,
|
||||||
|
employee_exit_organization::EMPLOYEE_EXIT_ORGANIZATION_PAGE,
|
||||||
|
employee_login::EMPLOYEE_LOGIN_PAGE,
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
{
|
{
|
||||||
|
|
65
web_ui/src/identity/owner_add_store.rs
Normal file
65
web_ui/src/identity/owner_add_store.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const OWNER_ADD_STORE_PAGE: TemplateFile =
|
||||||
|
TemplateFile::new("identity.owner_add_store", "identity/owner_add_store.html");
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
OWNER_ADD_STORE_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(OWNER_ADD_STORE_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerAddStorePage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerAddStorePage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(OWNER_ADD_STORE_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_add_store.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerAddStorePage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
67
web_ui/src/identity/owner_change_password.rs
Normal file
67
web_ui/src/identity/owner_change_password.rs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const OWNER_CHANGE_PASSWORD_PAGE: TemplateFile = TemplateFile::new(
|
||||||
|
"identity.owner_change_password",
|
||||||
|
"identity/owner_change_password.html",
|
||||||
|
);
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
OWNER_CHANGE_PASSWORD_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(OWNER_CHANGE_PASSWORD_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerChangePasswordPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerChangePasswordPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(OWNER_CHANGE_PASSWORD_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_change_password.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerChangePasswordPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
67
web_ui/src/identity/owner_delete_user.rs
Normal file
67
web_ui/src/identity/owner_delete_user.rs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const ONWER_DELETE_USER_PAGE: TemplateFile = TemplateFile::new(
|
||||||
|
"identity.owner_delete_user",
|
||||||
|
"identity/owner_delete_user.html",
|
||||||
|
);
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
ONWER_DELETE_USER_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(ONWER_DELETE_USER_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerDeleteUserPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerDeleteUserPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(ONWER_DELETE_USER_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_delete_user.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerDeleteUserPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
63
web_ui/src/identity/owner_login.rs
Normal file
63
web_ui/src/identity/owner_login.rs
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const OWNER_LOGIN_PAGE: TemplateFile =
|
||||||
|
TemplateFile::new("identity.owner_login", "identity/owner_login.html");
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
OWNER_LOGIN_PAGE.register(t).expect(OWNER_LOGIN_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerLoginPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerLoginPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(OWNER_LOGIN_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_login.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerLoginPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
65
web_ui/src/identity/owner_register.rs
Normal file
65
web_ui/src/identity/owner_register.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const OWNER_REGISTER_PAGE: TemplateFile =
|
||||||
|
TemplateFile::new("identity.owner_register", "identity/owner_register.html");
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
OWNER_REGISTER_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(OWNER_REGISTER_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerRegisterPage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerRegisterPage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(OWNER_REGISTER_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_register.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerRegisterPage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
67
web_ui/src/identity/owner_update_store.rs
Normal file
67
web_ui/src/identity/owner_update_store.rs
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
// SPDX-FileCopyrightText: 2024 Aravinth Manivannan <realaravinth@batsense.net>
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
use std::cell::RefCell;
|
||||||
|
|
||||||
|
use derive_builder::*;
|
||||||
|
use derive_more::*;
|
||||||
|
use serde::*;
|
||||||
|
use tera::Context;
|
||||||
|
use url::Url;
|
||||||
|
|
||||||
|
pub use super::*;
|
||||||
|
use crate::utils::*;
|
||||||
|
|
||||||
|
pub const OWNER_UPDATE_STORE_PAGE: TemplateFile = TemplateFile::new(
|
||||||
|
"identity.owner_update_store",
|
||||||
|
"identity/owner_update_store.html",
|
||||||
|
);
|
||||||
|
|
||||||
|
pub fn register_templates(t: &mut tera::Tera) {
|
||||||
|
OWNER_UPDATE_STORE_PAGE
|
||||||
|
.register(t)
|
||||||
|
.expect(OWNER_UPDATE_STORE_PAGE.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OwnerUpdateStorePage {
|
||||||
|
ctx: RefCell<Context>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl OwnerUpdateStorePage {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
let mut ctx = context();
|
||||||
|
|
||||||
|
//ctx.insert(PAYLOAD_KEY, p);
|
||||||
|
|
||||||
|
let ctx = RefCell::new(ctx);
|
||||||
|
Self { ctx }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn render(&self) -> String {
|
||||||
|
TEMPLATES
|
||||||
|
.render(OWNER_UPDATE_STORE_PAGE.name, &self.ctx.borrow())
|
||||||
|
.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn page() -> String {
|
||||||
|
let p = Self::new();
|
||||||
|
p.render()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn render_page_and_write() {
|
||||||
|
const FILE: &str = "./tmp/identity-owner_update_store.html";
|
||||||
|
|
||||||
|
let tw = TestWriterBuilder::default()
|
||||||
|
.file(FILE.into())
|
||||||
|
.contents(OwnerUpdateStorePage::page())
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
tw.write();
|
||||||
|
}
|
||||||
|
}
|
|
@ -117,7 +117,6 @@ impl<'a> Footer<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
Loading…
Reference in a new issue