Compare commits

..

4 Commits

1
client/.gitignore vendored

@ -1,3 +1,2 @@
target/
dist/
pkg/

9
client/Cargo.lock generated

@ -170,7 +170,6 @@ version = "0.1.0"
dependencies = [
"chrono",
"fantoccini",
"lazy_static",
"perseus",
"perseus-axum",
"reqwasm",
@ -1041,9 +1040,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "perseus"
version = "0.4.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b1230830033fe9611e1f65d26639ad18bc628877dbd9ce3034998897dd9e74"
checksum = "c692ad07b59511f3f2faac6ae47136b0f7f28fe92a962da60459b659ddf947ca"
dependencies = [
"async-trait",
"chrono",
@ -1083,9 +1082,9 @@ dependencies = [
[[package]]
name = "perseus-macro"
version = "0.4.1"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "365751b4a34d7b5f0758d08e570c3052fd8e99300fe0433d00f45731ef4453ec"
checksum = "868803376c686cfe84dc5a84114ea631bd561f243f1a48115c4418b19c9d199b"
dependencies = [
"darling",
"proc-macro2",

@ -9,14 +9,13 @@ edition = "2021"
chrono = { version = "0.4.23", features = ["serde"] }
serde = { version = "1.0.152", features = ["derive"] }
serde_json = "1.0.91"
perseus = { version = "0.4.1", features = ["hydrate"] }
perseus = { version = "0.4", features = ["hydrate"] }
sycamore = { version = "^0.8.1", features = [
"ssr",
"serde",
"suspense",
"hydrate",
] }
lazy_static = "1"
[target.'cfg(engine)'.dev-dependencies]
fantoccini = "^0.19.3"

@ -7,7 +7,7 @@ RUN apt-get update \
build-essential curl wget pkg-config
# vars
ENV PERSEUS_VERSION=0.4.1 \
ENV PERSEUS_VERSION=0.4.0 \
PERSEUS_SIZE_OPT_VERSION=0.1.9 \
ESBUILD_VERSION=0.15.18 \
BINARYEN_VERSION=112

@ -1,36 +0,0 @@
use lazy_static::lazy_static;
use perseus::prelude::*;
use sycamore::prelude::*;
use crate::global_state::AppStateRx;
lazy_static! {
pub static ref DARK_MODE_BTN: Capsule<PerseusNodeType, ()> = get_capsule();
}
fn dark_mode_btn<G: Html>(cx: Scope, _props: ()) -> View<G> {
let global_state = Reactor::<G>::from_cx(cx).get_global_state::<AppStateRx>(cx);
let toggle_dark_mode = move |_| {
global_state.dark_mode.set(!*global_state.dark_mode.get());
};
view! { cx,
button (on:click=toggle_dark_mode, class="py-1 px-2 mx-1 rounded-full bg-slate-200 dark:bg-slate-800")
{ "Toggle dark mode" }
}
}
fn fallback<G: Html>(cx: Scope, _props: ()) -> View<G> {
view! { cx,
button (class="py-1 px-2 mx-1 rounded-full bg-slate-200 dark:bg-slate-800")
{ "Toggle dark mode" }
}
}
pub fn get_capsule<G: Html>() -> Capsule<G, ()> {
Capsule::build(Template::build("dark_mode_btn"))
.fallback(fallback)
.view(dark_mode_btn)
.build()
}

@ -1 +0,0 @@
pub mod dark_mode_btn;

@ -1,10 +1,30 @@
use perseus::prelude::*;
use sycamore::prelude::*;
use crate::capsules::dark_mode_btn::DARK_MODE_BTN;
use crate::global_state::AppStateRx;
#[component]
pub fn TheHeader<G: Html>(cx: Scope) -> View<G> {
// This is ugly and is only caused by the get_global_state function panicking when running on the server at build time
let global_state_sig: &Signal<Option<&AppStateRx>> = create_signal(cx, None);
#[cfg(client)]
global_state_sig.set(Some(
Reactor::<G>::from_cx(cx).get_global_state::<AppStateRx>(cx),
));
let dark_mode = create_signal(cx, true);
create_effect(cx, move || {
if let Some(gstate) = *global_state_sig.get() {
dark_mode.set(*gstate.dark_mode.get());
}
});
let toggle_dark_mode = move |_| {
if let Some(gstate) = *global_state_sig.get() {
gstate.dark_mode.set(!*dark_mode.get());
}
};
view! { cx,
header (class="p-2 w-full h-11 align-middle bg-gray-100 shadow-md backdrop-blur-lg dark:bg-slate-500/30") {
div (class="flex") {
@ -19,7 +39,8 @@ pub fn TheHeader<G: Html>(cx: Scope) -> View<G> {
}
}
div (class="flex-none") {
(DARK_MODE_BTN.widget(cx,"",()))
button (on:click=toggle_dark_mode, class="py-1 px-2 mx-1 rounded-full bg-slate-200 dark:bg-slate-800")
{ "Toggle dark mode" }
}
}
}

@ -2,7 +2,6 @@ use perseus::prelude::*;
use sycamore::view;
mod api;
pub mod capsules;
mod components;
mod env;
pub mod error_pages;
@ -14,7 +13,6 @@ pub fn main<G: Html>() -> PerseusApp<G> {
PerseusApp::new()
.template(crate::templates::index::get_template())
.template(crate::templates::transactions::get_template())
.capsule_ref(&*crate::capsules::dark_mode_btn::DARK_MODE_BTN)
.global_state_creator(crate::global_state::get_global_state_creator())
.error_views(crate::error_pages::get_error_views())
.index_view(|cx| {

File diff suppressed because one or more lines are too long

1
server/.gitignore vendored

@ -1 +0,0 @@
target/

2002
server/Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1,4 +1,4 @@
FROM rust:1.84-slim as build
FROM rust:1.69-slim as build
# Install build dependencies
RUN apt-get update \

@ -1,7 +1,7 @@
use crate::{
amf::{
types::{
amf_response::{Document, Source},
amf_response::{Document, Hit},
AMFResponse, TransactionData,
},
TransactionDataTrait,
@ -12,16 +12,16 @@ use crate::{
use super::pdf::AMFPdf;
impl AMFResponse {
pub fn get_hits(&self) -> &Vec<Source> {
&self.hits
pub fn get_hits(&self) -> &Vec<Hit> {
&self.hits.hits
}
}
#[async_trait::async_trait]
impl TransactionDataTrait for Source {
impl TransactionDataTrait for Hit {
type Err = GetAMFTransactionsError;
async fn get_transaction_data(&self) -> Result<TransactionData, Self::Err> {
let foreign_id = self.numero.to_owned();
let foreign_id = self.source.numero.to_owned();
let docs = self.get_documents();
if docs.len() > 1 {
warn!("Transaction number {} contains more than one document, only the first document will be parsed for information", foreign_id);
@ -54,12 +54,12 @@ impl TransactionDataTrait for Source {
}
}
impl Source {
impl Hit {
pub fn get_documents(&self) -> &Vec<Document> {
&self.documents
&self.source.documents
}
pub fn get_foreign_id(&self) -> String {
self.numero.to_owned()
self.source.numero.to_owned()
}
}

@ -4,8 +4,32 @@ use serde_json::Value;
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AMFResponse {
#[serde(rename = "result")]
pub hits: Vec<Source>,
pub hits: Hits,
pub aggregations: Aggregations,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Hits {
pub total: Total,
pub hits: Vec<Hit>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Total {
pub value: i64,
pub relation: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Hit {
#[serde(rename = "_ignored")]
pub ignored: Option<Vec<String>>,
#[serde(rename = "_source")]
pub source: Source,
pub sort: Vec<i64>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
@ -36,12 +60,128 @@ pub struct Source {
pub version: i64,
pub regulateur: String,
pub relations: Vec<Value>,
pub societes: Vec<Societe>,
pub annee_comptable: Value,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Document {
pub accessible: bool,
pub issuer_id: Option<String>,
pub path: String,
pub numero: Value,
pub signature: Option<String>,
pub format: Value,
pub details: Details,
pub doc_regulateur: bool,
pub nom_fichier: String,
pub date_reception: Value,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Details {
pub date: String,
#[serde(rename = "content_type")]
pub content_type: String,
pub language: String,
pub title: String,
#[serde(rename = "content_length")]
pub content_length: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Societe {
pub role: String,
pub raison_sociale: String,
pub jeton: String,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Aggregations {
pub types_information: TypesInformation,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypesInformation {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Bucket>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Bucket {
pub key: String,
#[serde(rename = "doc_count")]
pub doc_count: i64,
pub types_operation: TypesOperation,
pub types_document: TypesDocument,
pub instrument_financier: InstrumentFinancier,
pub marche: Marche,
pub annee_comptable: AnneeComptable,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypesOperation {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Value>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TypesDocument {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Bucket2>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Bucket2 {
pub key: String,
#[serde(rename = "doc_count")]
pub doc_count: i64,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct InstrumentFinancier {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Value>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Marche {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Value>,
}
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AnneeComptable {
#[serde(rename = "doc_count_error_upper_bound")]
pub doc_count_error_upper_bound: i64,
#[serde(rename = "sum_other_doc_count")]
pub sum_other_doc_count: i64,
pub buckets: Vec<Value>,
}

@ -64,7 +64,7 @@ impl GetAMFTransactions {
let list = resp.get_hits();
for hit in list.iter() {
let number = &hit.numero;
let number = &hit.source.numero;
if transaction::Entity::find()
.filter(transaction::Column::ForeignId.eq(number.to_owned()))

Loading…
Cancel
Save