diff --git a/css/admin-start.css b/css/admin-start.css index 64ca453..885d5bf 100644 --- a/css/admin-start.css +++ b/css/admin-start.css @@ -1,7 +1,7 @@ .admin-start-container { display: flex; flex-direction: column; - justify-content: center; + justify-content: start; align-items: center; gap: 50px; diff --git a/css/body.css b/css/body.css index 8392a65..c93c364 100644 --- a/css/body.css +++ b/css/body.css @@ -10,3 +10,12 @@ body { justify-content: center; align-items: stretch; } + +.admin-page-container { + padding-top: 110px; + padding-left: 200px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: stretch; +} diff --git a/css/components/admin_nav_bar.css b/css/components/admin_nav_bar.css new file mode 100644 index 0000000..095c48f --- /dev/null +++ b/css/components/admin_nav_bar.css @@ -0,0 +1,75 @@ +.admin-navbar-background { + /*border-top: 3px solid #04B2D9;*/ + position: fixed; + z-index: 1; + height: 100%; + display: flex; + flex-direction: column; + justify-content: start; + align-items: stretch; + background-color: #02114A; + min-width: 170px; + border-right: solid 0.5px #d8d8d8; + padding: 0px 15px +} +.admin-navbar-image { + object-fit: cover; + width: 80%; + height: 130px; + + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +} +.admin-navbar-elements-container { + display: flex; + flex-direction: column; + justify-content: start; + align-items: center; + gap: 5px; + + width: 100%; +} +.admin-navbar-element { + width: 100%; + height: 35px; + color: white; + + text-align: center; + font-size: 16px; + font-family: Source Sans Pro; + font-weight: 500; + + display: flex; + justify-content: center; + align-items: center; +} +.admin-navbar-element:hover { + cursor: pointer; + background-color: #ffffff14; + border-radius: 3px; + transition-duration: 0.3s; +} +.admin-navbar-element-selected { + width: 100%; + height: 35px; + color: rgb(27, 27, 27); + background-color: white; + border-radius: 3px; + + text-align: center; + font-size: 16px; + font-family: Source Sans Pro; + font-weight: 500; + + display: flex; + justify-content: center; + align-items: center; +} +.admin-navbar-element-selected { cursor: default; } +.admin-navbar-divider { + width: 100%; + height: 0.5px; + background-color: #d8d8d8; +} \ No newline at end of file diff --git a/index.html b/index.html index 27ebf47..2b5cb43 100644 --- a/index.html +++ b/index.html @@ -14,13 +14,14 @@ + - + diff --git a/src/components/admin_nav_bar.rs b/src/components/admin_nav_bar.rs new file mode 100644 index 0000000..c673a1e --- /dev/null +++ b/src/components/admin_nav_bar.rs @@ -0,0 +1,34 @@ +use yew::prelude::*; +use yew_router::prelude::{use_navigator, use_route}; + +use crate::{routes::main_router::Route}; +//use yew_router::prelude::use_navigator; + + +#[function_component(AdminNavigationBar)] +pub fn admin_navigation_bar() -> Html { + let current_route: Option = use_route(); + let navigator = use_navigator().unwrap(); + let cloned_navigator_1 = navigator.clone(); + let cloned_navigator_2 = navigator.clone(); + let cloned_navigator_3 = navigator.clone(); + let cloned_navigator_4 = navigator.clone(); + + html! { +
+
+ logo +
+
+
+
{"Inicio"}
+
{"Proyectos"}
+
{"Agentes"}
+
{"Mensajes"}
+
+
+ + +
+ } +} \ No newline at end of file diff --git a/src/components/mod.rs b/src/components/mod.rs index fb0408e..29ee16e 100644 --- a/src/components/mod.rs +++ b/src/components/mod.rs @@ -1,8 +1,8 @@ pub mod nav_bar; -pub mod search_filter; pub mod project_card; pub mod media_slideshow; pub mod floating_widget; pub mod feature; pub mod footer; -pub mod agent_card; \ No newline at end of file +pub mod agent_card; +pub mod admin_nav_bar; \ No newline at end of file diff --git a/src/components/search_filter.rs b/src/components/search_filter.rs deleted file mode 100644 index e69de29..0000000 diff --git a/src/pages/admin/agents.rs b/src/pages/admin/agents.rs new file mode 100644 index 0000000..1e42bd0 --- /dev/null +++ b/src/pages/admin/agents.rs @@ -0,0 +1,17 @@ +use yew::prelude::*; + +use crate::components::admin_nav_bar::AdminNavigationBar; + +#[function_component(AdminAgents)] +pub fn admin_agents() -> Html { + html! { + <> + +
+
+ {""} +
+
+ + } +} \ No newline at end of file diff --git a/src/pages/admin/contacts.rs b/src/pages/admin/contacts.rs new file mode 100644 index 0000000..6246591 --- /dev/null +++ b/src/pages/admin/contacts.rs @@ -0,0 +1,17 @@ +use yew::prelude::*; + +use crate::components::admin_nav_bar::AdminNavigationBar; + +#[function_component(AdminContacts)] +pub fn admin_contacts() -> Html { + html! { + <> + +
+
+ {""} +
+
+ + } +} \ No newline at end of file diff --git a/src/pages/admin/login.rs b/src/pages/admin/login.rs index d0b6546..4d71bf0 100644 --- a/src/pages/admin/login.rs +++ b/src/pages/admin/login.rs @@ -5,6 +5,7 @@ use crate::{utils::input::get_value_from_input_event, routes::main_router::Route #[function_component(AdminLoginPage)] pub fn login_page() -> Html { + // TODO: If logged in go to start let navigator = use_navigator().unwrap(); let error = use_state(|| false); let username = use_state(|| String::new()); diff --git a/src/pages/admin/mod.rs b/src/pages/admin/mod.rs index 72770e0..0b5c509 100644 --- a/src/pages/admin/mod.rs +++ b/src/pages/admin/mod.rs @@ -1,2 +1,5 @@ pub mod login; -pub mod start; \ No newline at end of file +pub mod start; +pub mod projects; +pub mod contacts; +pub mod agents; \ No newline at end of file diff --git a/src/pages/admin/projects.rs b/src/pages/admin/projects.rs new file mode 100644 index 0000000..ead6174 --- /dev/null +++ b/src/pages/admin/projects.rs @@ -0,0 +1,17 @@ +use yew::prelude::*; + +use crate::components::admin_nav_bar::AdminNavigationBar; + +#[function_component(AdminProjects)] +pub fn admin_projects() -> Html { + html! { + <> + +
+
+ {""} +
+
+ + } +} \ No newline at end of file diff --git a/src/pages/admin/start.rs b/src/pages/admin/start.rs index 925871e..da0b5a4 100644 --- a/src/pages/admin/start.rs +++ b/src/pages/admin/start.rs @@ -1,12 +1,17 @@ use yew::prelude::*; +use crate::components::admin_nav_bar::AdminNavigationBar; + #[function_component(AdminStart)] pub fn admin_start() -> Html { html! { -
-
- {""} + <> + +
+
+ {"a"} +
-
+ } } \ No newline at end of file diff --git a/src/routes/main_router.rs b/src/routes/main_router.rs index aa04ab8..e7c005e 100644 --- a/src/routes/main_router.rs +++ b/src/routes/main_router.rs @@ -3,7 +3,7 @@ use yew::prelude::*; use uuid::Uuid; -use crate::{pages::{landing::LandingPage, search::{SearchPage}, details::DetailsPage, not_found::NotFoundPage, contact::ContactPage, admin::{login::AdminLoginPage, start::AdminStart}, agents::AgentsPage}}; +use crate::{pages::{landing::LandingPage, search::{SearchPage}, details::DetailsPage, not_found::NotFoundPage, contact::ContactPage, admin::{login::AdminLoginPage, start::AdminStart, projects::AdminProjects, agents::AdminAgents, contacts::AdminContacts}, agents::AgentsPage}}; #[derive(Clone, Routable, PartialEq)] pub enum Route { @@ -22,6 +22,12 @@ pub enum Route { Admin, #[at("/admin/start")] AdminStart, + #[at("/admin/projects")] + AdminProjects, + #[at("/admin/agents")] + AdminAgents, + #[at("/admin/contacts")] + AdminContacts, #[not_found] #[at("/404")] @@ -39,6 +45,10 @@ pub fn switch(routes: Route) -> Html { Route::Admin => html! { }, Route::AdminStart => html! { }, + Route::AdminProjects => html! { }, + Route::AdminAgents => html! { }, + Route::AdminContacts => html! { }, + } } \ No newline at end of file diff --git a/src/utils/admin_panel.rs b/src/utils/admin_panel.rs new file mode 100644 index 0000000..78153b9 --- /dev/null +++ b/src/utils/admin_panel.rs @@ -0,0 +1,12 @@ +use super::storage; + + +pub fn get_admin_token_from_storage() -> Option { + match storage::get_from_local_storage(storage::StorageKey::AdminUser) { + Ok(opt) => opt, + Err(_) => { + log::error!("No user stored when attempting to use admin panel. Redirect to admin panel."); + None + }, + } +} \ No newline at end of file diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 47709df..30b2736 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -1,3 +1,4 @@ pub mod get_value; pub mod input; -pub mod storage; \ No newline at end of file +pub mod storage; +pub mod admin_panel; \ No newline at end of file diff --git a/src/utils/storage.rs b/src/utils/storage.rs index 2705fef..3e96c1f 100644 --- a/src/utils/storage.rs +++ b/src/utils/storage.rs @@ -1,15 +1,17 @@ -use std::fmt::Display; +use std::fmt::{Display}; use err::{MessageResource, Error}; use web_sys::window; pub enum StorageKey { AgentShortcode, + AdminUser, } impl Display for StorageKey { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { StorageKey::AgentShortcode => write!(f, "agentshortcode"), + StorageKey::AdminUser => write!(f, "adminuser"), } } }