From 94f9d50e6541fbb5aaaa67a31a17e88dddb37991 Mon Sep 17 00:00:00 2001 From: Patrik Svensson Date: Sun, 9 Feb 2020 11:05:53 +0100 Subject: [PATCH] Show version in UI Closes #38 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/api/endpoints.rs | 2 ++ src/api/models.rs | 1 + src/utils/mod.rs | 2 ++ web/src/components/Menu/Sidebar.vue | 2 +- web/src/components/Navigation.vue | 20 +++++++++++++++++++- 7 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7c6d37c..c773d8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -660,7 +660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "duck" -version = "0.1.0" +version = "0.7.0" dependencies = [ "actix-cors 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "actix-files 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 1d42e6b..4046625 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duck" -version = "0.1.0" +version = "0.7.0" authors = ["Patrik Svensson "] edition = "2018" license = "MIT" diff --git a/src/api/endpoints.rs b/src/api/endpoints.rs index 94c1bcd..fcb7c59 100644 --- a/src/api/endpoints.rs +++ b/src/api/endpoints.rs @@ -4,6 +4,7 @@ use actix_web::{get, web}; use actix_web::{HttpResponse, Responder}; use crate::engine::state::EngineState; +use crate::utils::VERSION; use super::models::{BuildViewModel, ServerInfoModel, ViewInfoModel}; @@ -11,6 +12,7 @@ use super::models::{BuildViewModel, ServerInfoModel, ViewInfoModel}; pub fn server_info(state: web::Data>) -> impl Responder { let info = ServerInfoModel { title: &state.title[..], + version: VERSION, views: state .views .get_views() diff --git a/src/api/models.rs b/src/api/models.rs index 2612e9a..d0b3d22 100644 --- a/src/api/models.rs +++ b/src/api/models.rs @@ -6,6 +6,7 @@ use crate::config::ViewConfiguration; #[derive(Serialize, Clone)] pub struct ServerInfoModel<'a> { pub title: &'a str, + pub version: &'static str, pub views: Vec, } diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 6bd8734..00750b7 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -6,3 +6,5 @@ pub mod http; pub mod text; pub type DuckResult = Result; + +pub const VERSION: &'static str = env!("CARGO_PKG_VERSION"); diff --git a/web/src/components/Menu/Sidebar.vue b/web/src/components/Menu/Sidebar.vue index f19928f..ec1cf52 100644 --- a/web/src/components/Menu/Sidebar.vue +++ b/web/src/components/Menu/Sidebar.vue @@ -55,7 +55,7 @@ export default { top: 0; height: 100vh; z-index: 999; - padding: 3rem 20px 2rem 20px; + padding: 1rem 20px 1rem 0px; width: 300px; } diff --git a/web/src/components/Navigation.vue b/web/src/components/Navigation.vue index ff94cc7..045167d 100644 --- a/web/src/components/Navigation.vue +++ b/web/src/components/Navigation.vue @@ -12,6 +12,10 @@ {{ view.name }} +
+ Duck v{{ this.serverInfo.version }} | + GitHub +
@@ -66,9 +70,9 @@ export default { padding-right: 48px; padding-top: 8px; } - ul.sidebar-panel-nav { list-style-type: none; + padding-left: 2rem; } ul.sidebar-panel-nav > li > a { @@ -87,4 +91,18 @@ ul.sidebar-panel-nav > li > a.active { ul.sidebar-panel-nav > li > a:hover { color: #fff; } +.version { + position: fixed; + bottom: 0; + padding-left: 2rem; + padding-bottom: 1rem; + color:#aaa +} +.version > a { + text-decoration: none; + color: #aaa; +} +.version > a:hover { + font-weight: bold; +} \ No newline at end of file