diff --git a/resources/templates/account.html b/resources/templates/account.html
index 0f36d73..4a785b3 100644
--- a/resources/templates/account.html
+++ b/resources/templates/account.html
@@ -1,4 +1,5 @@
{% set active_navbar_item = 'accounts' %}
+{% set script_chart_js = true %}
{% extends "base.html" %}
@@ -7,7 +8,8 @@
Summary
- | ID | {{ account.id | micro_id }} |
+ | Micro ID | {{ account.id | micro_id }} |
+ | Account ID | {{ account.id }} |
| Label | {{ account.label }} |
| Amount | {{ account.amount | thousand_separator }} |
| Account Type | {{ account.account_type | replace("_", " ") | lower}} |
@@ -15,7 +17,58 @@
| Security | {{ account.security.symbol }} |
+
- {{ "hello" | tojson }}
+
{% endblock %}
\ No newline at end of file
diff --git a/resources/templates/base.html b/resources/templates/base.html
index f2eaf59..4083a3e 100644
--- a/resources/templates/base.html
+++ b/resources/templates/base.html
@@ -1,3 +1,5 @@
+{% set values = {} %}
+
@@ -15,11 +17,17 @@
+ {% if script_chart_js %}
+
+
+
+ {% endif %}
+
-
+
{% include "components/navbar.html" %}
diff --git a/src/db/_account_history.rs b/src/db/_account_history.rs
index 8ad6742..34ce46e 100644
--- a/src/db/_account_history.rs
+++ b/src/db/_account_history.rs
@@ -24,7 +24,7 @@ impl AccountHistory {
pub fn get_account_history(tx: &Connection, account_id: &AccountId) -> CustomResult
{
let q = "
- SELECT amount, CAST(timestamp AS INT) AS timestamp
+ SELECT amount, UNIXEPOCH(timestamp) AS timestamp
FROM accounts_history
WHERE account_id = ?1
ORDER BY account_version ASC
diff --git a/src/services/_accounts.rs b/src/services/_accounts.rs
index 2559ff0..66312bf 100644
--- a/src/services/_accounts.rs
+++ b/src/services/_accounts.rs
@@ -22,9 +22,10 @@ pub struct AccountDTO {
pub label: String,
}
-#[derive(Deserialize, Serialize, Debug)]
+#[derive(Serialize, Debug)]
pub struct AccountHistoryDTO {
-
+ amounts: Vec,
+ timestamps: Vec,
}
impl AccountDTO {
@@ -72,9 +73,14 @@ impl AccountService<'_> {
Ok(AccountDTO::from_entity(ret))
}
- pub fn get_account_history_by_id(&self, account_id: &AccountId, user_id: &UserId) -> CustomResult<()> {
- let ret = account_history::get_account_history(self.conn, account_id)?;
+ pub fn get_account_history_by_id(&self, account_id: &AccountId, user_id: &UserId) -> CustomResult {
+ let ac = account_history::get_account_history(self.conn, account_id)?;
+ // ret.account()
+ let ret = AccountHistoryDTO{
+ amounts: ac.amount().clone(),
+ timestamps: ac.timestamps().clone(),
+ };
- Ok(())
+ Ok(ret)
}
}
\ No newline at end of file
diff --git a/src/webui/views.rs b/src/webui/views.rs
index 4b5eed0..0404412 100644
--- a/src/webui/views.rs
+++ b/src/webui/views.rs
@@ -45,7 +45,8 @@ pub async fn get_account(tmpl_env: MiniJinjaRenderer,
let user_id = auth_service.get_login(&req).unwrap();
let ctx = context!{
- account => account_service.get_account_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?
+ account => account_service.get_account_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?,
+ account_history => account_service.get_account_history_by_id(&account_id, &user_id).map_err(error::ErrorInternalServerError)?
};
tmpl_env.render("account.html", ctx)
}