Compare commits
16 Commits
14a156d929
...
creation-s
Author | SHA1 | Date | |
---|---|---|---|
07eae87855
|
|||
080537fe6d
|
|||
ecd84bf242
|
|||
981a5d34c5
|
|||
681cc7cb83
|
|||
fbc3be564f
|
|||
4871187726
|
|||
67b482ff13
|
|||
34bdea2269
|
|||
20e16f6ae2
|
|||
f42e38228a
|
|||
3712667a04
|
|||
345190dfeb | |||
5712d898a5 | |||
3bd0a02b62 | |||
167a1fbbc2
|
@ -4,5 +4,6 @@ members = [
|
|||||||
"crates/backend",
|
"crates/backend",
|
||||||
"crates/desktop",
|
"crates/desktop",
|
||||||
"crates/sesam-vitale",
|
"crates/sesam-vitale",
|
||||||
|
"crates/services-sesam-vitale-sys",
|
||||||
"crates/utils",
|
"crates/utils",
|
||||||
]
|
]
|
||||||
|
12
crates/services-sesam-vitale-sys/Cargo.toml
Normal file
12
crates/services-sesam-vitale-sys/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[package]
|
||||||
|
name = "services-sesam-vitale-sys"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
#links= "ssvlux64"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bitvec = "1.0.1"
|
||||||
|
deku = "0.17.0"
|
||||||
|
libc = "0.2.155"
|
||||||
|
num_enum = { version = "0.7.3", features = ["complex-expressions"] }
|
||||||
|
thiserror = "1.0.63"
|
104
crates/services-sesam-vitale-sys/src/api.rs
Normal file
104
crates/services-sesam-vitale-sys/src/api.rs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
use deku::{deku_derive, DekuContainerRead, DekuError, DekuReader};
|
||||||
|
use std::{ffi::CString, fmt, path::Path, ptr};
|
||||||
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
bindings::{SSV_InitLIB2, SSV_LireConfig, SSV_TermLIB},
|
||||||
|
types::{common::read_from_buffer, configuration::Configuration},
|
||||||
|
};
|
||||||
|
use num_enum::FromPrimitive;
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
pub struct SesamVitaleError {
|
||||||
|
code: u16,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Eq, PartialEq, FromPrimitive)]
|
||||||
|
#[repr(u16)]
|
||||||
|
enum SSVIntError {
|
||||||
|
CPSNotInserted = 61441,
|
||||||
|
|
||||||
|
#[num_enum(catch_all)]
|
||||||
|
NotImplemented(u16),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_sesam_vitale_error() {
|
||||||
|
let int_error = SSVIntError::from(61441);
|
||||||
|
assert_eq!(int_error, SSVIntError::CPSNotInserted);
|
||||||
|
|
||||||
|
let int_error = SSVIntError::from(123);
|
||||||
|
assert_eq!(int_error, SSVIntError::NotImplemented(123));
|
||||||
|
println!("{:?}", int_error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Error, Debug)]
|
||||||
|
enum SSVError {
|
||||||
|
#[error("Erreur standard de la librairie SSV")]
|
||||||
|
SSVStandard,
|
||||||
|
// #[error("Erreur de parsing")]
|
||||||
|
// Parsing(#[from] ParsingError),
|
||||||
|
#[error("Erreur inattendue de la librairie SSV (TMP)")]
|
||||||
|
SSVUnknownTmp,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for SesamVitaleError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
write!(f, "Got error code {} from SSV_LireConfig", self.code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_library(sesam_ini_path: &Path) -> Result<(), SesamVitaleError> {
|
||||||
|
// TODO: better error handling
|
||||||
|
let path_str = sesam_ini_path.to_str().unwrap();
|
||||||
|
let path_ptr = CString::new(path_str).expect("failed to create cstring");
|
||||||
|
|
||||||
|
let exit_code: u16 = unsafe { SSV_InitLIB2(path_ptr.as_ptr()) };
|
||||||
|
if exit_code != 0 {
|
||||||
|
let error = SesamVitaleError { code: exit_code };
|
||||||
|
return Err(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
pub fn close_library() -> Result<(), SesamVitaleError> {
|
||||||
|
let exit_code: u16 = unsafe { SSV_TermLIB() };
|
||||||
|
if exit_code != 0 {
|
||||||
|
let error = SesamVitaleError { code: exit_code };
|
||||||
|
return Err(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_config() -> Result<Configuration, SesamVitaleError> {
|
||||||
|
let mut buffer_ptr: *mut libc::c_void = ptr::null_mut();
|
||||||
|
let mut size: libc::size_t = 0;
|
||||||
|
|
||||||
|
let buffer_ptr_ptr: *mut *mut libc::c_void = &mut buffer_ptr;
|
||||||
|
let size_ptr: *mut libc::size_t = &mut size;
|
||||||
|
|
||||||
|
// Need to add proper error handling -> return a result with error code pointing to an error
|
||||||
|
// enum
|
||||||
|
let exit_code: u16 = unsafe { SSV_LireConfig(buffer_ptr_ptr, size_ptr) };
|
||||||
|
|
||||||
|
if exit_code != 0 {
|
||||||
|
let error = SesamVitaleError { code: exit_code };
|
||||||
|
return Err(error);
|
||||||
|
};
|
||||||
|
|
||||||
|
let buffer: &[u8] = unsafe { std::slice::from_raw_parts(buffer_ptr as *const u8, size) };
|
||||||
|
|
||||||
|
// TODO: Improve error handling
|
||||||
|
let configuration: Configuration = read_from_buffer(buffer).unwrap();
|
||||||
|
|
||||||
|
// TODO: Call library function for memory delocating
|
||||||
|
unsafe { libc::free(buffer_ptr) };
|
||||||
|
|
||||||
|
Ok(configuration)
|
||||||
|
}
|
288
crates/services-sesam-vitale-sys/src/bindings.rs
Normal file
288
crates/services-sesam-vitale-sys/src/bindings.rs
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
#![allow(non_upper_case_globals)]
|
||||||
|
#![allow(non_camel_case_types)]
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
// Generated using bindgen
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
// Fonctions de gestion des données
|
||||||
|
|
||||||
|
pub fn SSV_LireCartePS(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_LireDroitsVitale(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
DateConsultation: *const ::std::os::raw::c_char,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_FormaterFactures(
|
||||||
|
cFactureACreer: ::std::os::raw::c_char,
|
||||||
|
cModeSecur: ::std::os::raw::c_char,
|
||||||
|
cTypeFlux: ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
TailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_ChiffrerFacture(
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
TailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_SignerFactureVitale(
|
||||||
|
pcNomRessourceVitale: *const ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_CalculerHashFactureAssure(
|
||||||
|
pcNumSerie: *const ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_AjouterSignatureAssureDansFacture(
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_SignerFactureCPS(
|
||||||
|
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
cNologSituation: ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_FormaterLot(
|
||||||
|
NBZDataIn: ::std::os::raw::c_short,
|
||||||
|
TZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneIn: *mut usize,
|
||||||
|
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_SignerLotCPS(
|
||||||
|
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
cNologSituation: ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_FormaterFichier(
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
TailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_TraduireARL(
|
||||||
|
NbZDonneesEntree: ::std::os::raw::c_short,
|
||||||
|
TZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneIn: *mut usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_LireNumSerieCarteVitale(
|
||||||
|
pcNomRessource: *mut ::std::os::raw::c_char,
|
||||||
|
numeroSerie: *mut ::std::os::raw::c_uchar,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_CalculerHashFacturePS(
|
||||||
|
pcNumSerieCPS: *const ::std::os::raw::c_char,
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
usTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pusTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_AjouterSignaturePSFacture(
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_DechargerFacturesPdT(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
pcNumFact: *const ::std::os::raw::c_char,
|
||||||
|
sNbZDataIn: ::std::os::raw::c_short,
|
||||||
|
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
psTTailleDataIn: *mut usize,
|
||||||
|
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_TraduireFSE(
|
||||||
|
pZDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
TailleDataIn: usize,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pTailleZone: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
// Fonctions TLA
|
||||||
|
// TLA (Terminal Lecteur Applicatif) -> lecteur autre que PC-SC, on ne prend pas en compte cela
|
||||||
|
|
||||||
|
pub fn SSV_IdentifierTLA(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
NumVersionCDC: *const ::std::os::raw::c_char,
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
tailleDataOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_ChargerDonneesTLA(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
sNbZDataIn: ::std::os::raw::c_short,
|
||||||
|
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
psTTailleDataIn: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_ChargerFacturesPdT(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcNumFacturation: *const ::std::os::raw::c_char,
|
||||||
|
sNbZDataIn: ::std::os::raw::c_short,
|
||||||
|
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
psTTailleDataIn: *mut usize,
|
||||||
|
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_DechargerFSETLA(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
pcNumFact: *const ::std::os::raw::c_char,
|
||||||
|
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_DechargerFSETLANC(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
pcNumFact: *const ::std::os::raw::c_char,
|
||||||
|
pNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
TZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
TTailleZoneOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_DechargerBeneficiaires(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
cNumFacturation: *const ::std::os::raw::c_char,
|
||||||
|
sNbZDataOut: *mut ::std::os::raw::c_short,
|
||||||
|
pTZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
sTTailleDataOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_EffacerTLA(
|
||||||
|
NomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
NomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
CodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
cNumFacturation: *const ::std::os::raw::c_char,
|
||||||
|
cTypeDonnee: *const ::std::os::raw::c_char,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
pub fn SSV_SecuriserFacture(
|
||||||
|
pcNomRessourcePS: *const ::std::os::raw::c_char,
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcCodePorteurPS: *const ::std::os::raw::c_char,
|
||||||
|
cNologSituation: ::std::os::raw::c_char,
|
||||||
|
pcNumFact: *const ::std::os::raw::c_char,
|
||||||
|
pvDataIn: *mut ::std::os::raw::c_void,
|
||||||
|
szTailleDataIn: usize,
|
||||||
|
pvDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
pszTailleDataOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
// Fonctions de gestion de configuration (GALSS)
|
||||||
|
|
||||||
|
pub fn SSV_LireConfig(
|
||||||
|
pZDataOut: *mut *mut ::std::os::raw::c_void,
|
||||||
|
psTailleDataOut: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_LireDateLecteur(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcDateHeure: *mut ::std::os::raw::c_char,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_MajDateLecteur(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
pcDateHeure: *const ::std::os::raw::c_char,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
pub fn SSV_ChargerAppli(
|
||||||
|
pcNomRessourceLecteur: *const ::std::os::raw::c_char,
|
||||||
|
sNbZDataIn: ::std::os::raw::c_short,
|
||||||
|
pvTZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
psTTailleDataIn: *mut usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
// Fonctions techniques
|
||||||
|
|
||||||
|
// La fonction Initialiser Librairie a pour objet de charger et d’initialiser dans la mémoire du système :
|
||||||
|
// - dans le cas où le GALSS est installé sur le poste :
|
||||||
|
// - la bibliothèque du Gestionnaire d’Accès au Lecteur Santé Social (GALSS),
|
||||||
|
// - qui charge la bibliothèque du Protocole Santé Social (PSS),
|
||||||
|
// - la configuration du poste de travail à l’aide du fichier galssinf,
|
||||||
|
// - les variables globales communes aux différents Services SESAM-Vitale,
|
||||||
|
// - les fichiers de tables et scripts des répertoires par défaut.
|
||||||
|
// Cette fonction accède au référentiel électronique en utilisant le chemin complet indiqué dans le fichier sesam.ini.
|
||||||
|
pub fn SSV_InitLIB2(pcFichierSesam: *const ::std::os::raw::c_char) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
// La fonction Terminer a pour objet de décharger de la mémoire du système les éléments
|
||||||
|
// chargés par la fonction Initialiser Librairie, qui ne sont plus utiles.
|
||||||
|
pub fn SSV_TermLIB() -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
/// Fonctions de Tracage
|
||||||
|
//La fonction Allouer Zone Mémoire a un rôle purement technique : elle permet d’allouer, autrement dit de réserver une zone ou partie de la mémoire du poste de travail pour y écrire les données à passer en entrée d’un Service SESAM-Vitale.
|
||||||
|
// Cette fonction doit être utilisée pour allouer toutes les zones de mémoire requises en entrée des Services SESAM-Vitale de manière à permettre un diagnostic fiable par le « mode trace » en cas de dysfonctionnement. En effet, son mode d’exécution est susceptible de fournir des informations utiles au « mode trace » lorsqu’il est activé.
|
||||||
|
pub fn SSV_AllouerZoneMem(
|
||||||
|
pZDataIn: *mut *mut ::std::os::raw::c_void,
|
||||||
|
taille: usize,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
// La fonction Libérer Zone Mémoire a un rôle purement technique : elle permet de libérer une zone de mémoire du poste de travail précédemment allouée après exploitation des données qu’elle contient.
|
||||||
|
// Cette fonction doit être utilisée pour libérer toutes les zones de mémoire :
|
||||||
|
// - celles qui ont été allouées par le progiciel de santé pour fournir les données nécessaires à l’entrée des Services SESAM-Vitale, avant leur appel, celles qui ont été allouées par les Services SESAM-Vitale pour fournir en sortie les données utiles au progiciel de santé qui a fait appel à ces services,
|
||||||
|
// - de façon à permettre un diagnostic fiable par le mode trace en cas de dysfonctionnement
|
||||||
|
//En effet, son exécution est susceptible de fournir des informations utiles au « mode trace » lorsqu’il est activé.
|
||||||
|
pub fn SSV_LibererZoneMem(pZone: *mut ::std::os::raw::c_void);
|
||||||
|
|
||||||
|
// La fonction Initialiser Trace a pour objet de permettre l’activation du « mode trace ».
|
||||||
|
// Ce mode de fonctionnement est prévu pour permettre à l’assistance technique du GIE
|
||||||
|
// SESAM-Vitale d’analyser les problèmes de mise en œuvre des Services SESAM-Vitale,
|
||||||
|
// notamment lorsque une fonction retourne un code d’erreur de valeur hexadécimale supérieure à FF00.
|
||||||
|
pub fn SSV_InitTrace(
|
||||||
|
pathConf: *mut ::std::os::raw::c_char,
|
||||||
|
ModeOuvertureFicherLog: *mut ::std::os::raw::c_char,
|
||||||
|
ModuleLog: ::std::os::raw::c_ushort,
|
||||||
|
NiveauLog: ::std::os::raw::c_uchar,
|
||||||
|
) -> ::std::os::raw::c_ushort;
|
||||||
|
|
||||||
|
}
|
6
crates/services-sesam-vitale-sys/src/lib.rs
Normal file
6
crates/services-sesam-vitale-sys/src/lib.rs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
pub mod api;
|
||||||
|
mod bindings;
|
||||||
|
pub mod types;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {}
|
144
crates/services-sesam-vitale-sys/src/types/common.rs
Normal file
144
crates/services-sesam-vitale-sys/src/types/common.rs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
use crate::types::configuration::{
|
||||||
|
ConfigurationHeader, PCSCReader, ReaderConfiguration, SESAMVitaleComponent,
|
||||||
|
};
|
||||||
|
|
||||||
|
use std::{error::Error, str::FromStr};
|
||||||
|
|
||||||
|
use bitvec::index::BitIdx;
|
||||||
|
use deku::{
|
||||||
|
bitvec::{BitStore, Msb0},
|
||||||
|
ctx::ByteSize,
|
||||||
|
deku_derive,
|
||||||
|
reader::{Reader, ReaderRet},
|
||||||
|
DekuContainerRead, DekuError, DekuReader,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct NumericString(#[deku(map = "convert_from_data_field")] String);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct AlphaNumericString(#[deku(map = "convert_from_data_field")] String);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct BinaryData(#[deku(map = "extract_from_data_field")] Vec<u8>);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
|
#[deku(endian = "big")]
|
||||||
|
pub(crate) struct GroupId(u16);
|
||||||
|
|
||||||
|
trait MapToDekuParseError<T> {
|
||||||
|
fn map_to_deku_parse_error(self) -> Result<T, DekuError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T, E: Error> MapToDekuParseError<T> for Result<T, E> {
|
||||||
|
fn map_to_deku_parse_error(self) -> Result<T, DekuError> {
|
||||||
|
self.map_err(|e| DekuError::Parse(e.to_string().into()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_size<R: std::io::Read>(reader: &mut Reader<R>) -> Result<ByteSize, DekuError> {
|
||||||
|
let first_byte: u8 = u8::from_reader_with_ctx(reader, ())?;
|
||||||
|
|
||||||
|
let is_length_expanded = first_byte.get_bit::<Msb0>(BitIdx::new(0).map_to_deku_parse_error()?);
|
||||||
|
|
||||||
|
match is_length_expanded {
|
||||||
|
true => {
|
||||||
|
let size_of_data_size: ByteSize = ByteSize((first_byte & 0b0111_1111) as usize);
|
||||||
|
|
||||||
|
if size_of_data_size.0 > 4 {
|
||||||
|
return Err(DekuError::Parse("Size of the length encoding is > 4, this is not normal. Probable parsing error".to_string().into()));
|
||||||
|
};
|
||||||
|
|
||||||
|
// maximum size of the buffer is 4, we use the offset to read values less than 4 bytes
|
||||||
|
let buffer: &mut [u8; 4] = &mut [0; 4];
|
||||||
|
let write_offset = 4 - size_of_data_size.0;
|
||||||
|
|
||||||
|
match reader.read_bytes(size_of_data_size.0, &mut buffer[write_offset..])? {
|
||||||
|
ReaderRet::Bits(_bit_vec) => Err(DekuError::Parse("Got bits when trying to read bytes -> reader is unaligned, this is not normal.".to_string().into())),
|
||||||
|
ReaderRet::Bytes => Ok(ByteSize(u32::from_be_bytes(*buffer) as usize)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false => Ok(ByteSize(first_byte as usize)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Using this as the map function asks deku to parse a datafield
|
||||||
|
// We then use the datafield and convert it to the corresponding value
|
||||||
|
pub(super) fn convert_from_data_field<T>(data_field: DataField) -> Result<T, DekuError>
|
||||||
|
where
|
||||||
|
T: FromStr,
|
||||||
|
T::Err: Error,
|
||||||
|
{
|
||||||
|
let text = String::from_utf8(data_field.data).map_to_deku_parse_error()?;
|
||||||
|
T::from_str(&text).map_to_deku_parse_error()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn extract_from_data_field(data_field: DataField) -> Result<Vec<u8>, DekuError> {
|
||||||
|
Ok(data_field.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub(crate) struct DataField {
|
||||||
|
#[deku(reader = "read_size(deku::reader)")]
|
||||||
|
pub(crate) data_size: ByteSize,
|
||||||
|
|
||||||
|
#[deku(bytes_read = "data_size.0")]
|
||||||
|
pub(crate) data: Vec<u8>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub(crate) struct BlockHeader {
|
||||||
|
pub(crate) group_id: GroupId,
|
||||||
|
|
||||||
|
#[deku(reader = "read_size(deku::reader)")]
|
||||||
|
pub(crate) data_size: ByteSize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub(crate) struct DataBlock {
|
||||||
|
pub(crate) header: BlockHeader,
|
||||||
|
|
||||||
|
#[deku(ctx = "header.group_id")]
|
||||||
|
pub(crate) inner: DataGroup,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
#[deku(ctx = "group_id: GroupId", id = "group_id.0")]
|
||||||
|
pub enum DataGroup {
|
||||||
|
#[deku(id = 60)]
|
||||||
|
ConfigurationHeader(ConfigurationHeader),
|
||||||
|
#[deku(id = 61)]
|
||||||
|
ReaderConfiguration(ReaderConfiguration),
|
||||||
|
#[deku(id = 64)]
|
||||||
|
SESAMVitaleComponent(SESAMVitaleComponent),
|
||||||
|
#[deku(id = 67)]
|
||||||
|
PCSCReader(PCSCReader),
|
||||||
|
}
|
||||||
|
pub(crate) fn read_from_buffer<T>(buffer: &[u8]) -> Result<T, T::Error>
|
||||||
|
where
|
||||||
|
T: TryFrom<Vec<DataBlock>>,
|
||||||
|
{
|
||||||
|
let mut data_blocks: Vec<DataBlock> = Vec::new();
|
||||||
|
let mut offset = 0;
|
||||||
|
|
||||||
|
let mut remaining_buffer = buffer;
|
||||||
|
|
||||||
|
while !remaining_buffer.is_empty() {
|
||||||
|
// TODO: properly handle errors
|
||||||
|
let (rest, data_block) = DataBlock::from_bytes((remaining_buffer, offset)).unwrap();
|
||||||
|
|
||||||
|
data_blocks.push(data_block);
|
||||||
|
|
||||||
|
(remaining_buffer, offset) = rest;
|
||||||
|
}
|
||||||
|
|
||||||
|
T::try_from(data_blocks)
|
||||||
|
}
|
137
crates/services-sesam-vitale-sys/src/types/configuration.rs
Normal file
137
crates/services-sesam-vitale-sys/src/types/configuration.rs
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
use crate::types::common::DataBlock;
|
||||||
|
use std::{error::Error, fmt, vec::Vec};
|
||||||
|
|
||||||
|
use crate::types::common::convert_from_data_field;
|
||||||
|
use deku::{deku_derive, DekuReader};
|
||||||
|
|
||||||
|
use super::common::{AlphaNumericString, DataGroup};
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct SSVVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct GALSSVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct PSSVersionNumber(#[deku(map = "convert_from_data_field")] u16);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct ConfigurationHeader {
|
||||||
|
pub ssv_version: SSVVersionNumber,
|
||||||
|
pub galss_version: GALSSVersionNumber,
|
||||||
|
pub pss_version: PSSVersionNumber,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct PCSCReaderName(AlphaNumericString);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct CardType(#[deku(map = "convert_from_data_field")] u8);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct PCSCReader {
|
||||||
|
pub name: PCSCReaderName,
|
||||||
|
pub card_type: CardType,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct SESAMVitaleComponentID(#[deku(map = "convert_from_data_field")] u16);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct SESAMVitaleComponentDescription(AlphaNumericString);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct SESAMVitaleComponentVersion(AlphaNumericString);
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct SESAMVitaleComponent {
|
||||||
|
pub id: SESAMVitaleComponentID,
|
||||||
|
pub description: SESAMVitaleComponentDescription,
|
||||||
|
pub version: SESAMVitaleComponentVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[deku_derive(DekuRead)]
|
||||||
|
#[derive(Debug, PartialEq)]
|
||||||
|
pub struct ReaderConfiguration {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum ConfigurationError {
|
||||||
|
MultipleConfigurationHeaders,
|
||||||
|
MissingConfigurationHeader,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ConfigurationError {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
ConfigurationError::MultipleConfigurationHeaders => {
|
||||||
|
write!(f, "Multiple ConfigurationHeader blocks found")
|
||||||
|
}
|
||||||
|
ConfigurationError::MissingConfigurationHeader => {
|
||||||
|
write!(f, "Missing ConfigurationHeader block")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for ConfigurationError {}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct Configuration {
|
||||||
|
pub configuration_header: ConfigurationHeader,
|
||||||
|
pub reader_configurations: Vec<ReaderConfiguration>,
|
||||||
|
pub sesam_vitale_components: Vec<SESAMVitaleComponent>,
|
||||||
|
pub pcsc_readers: Vec<PCSCReader>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<Vec<DataBlock>> for Configuration {
|
||||||
|
type Error = ConfigurationError;
|
||||||
|
|
||||||
|
fn try_from(data_blocks: Vec<DataBlock>) -> Result<Self, Self::Error> {
|
||||||
|
let mut configuration_header: Option<ConfigurationHeader> = None;
|
||||||
|
let mut reader_configurations: Vec<ReaderConfiguration> = Vec::new();
|
||||||
|
let mut sesam_vitale_components: Vec<SESAMVitaleComponent> = Vec::new();
|
||||||
|
let mut pcsc_readers: Vec<PCSCReader> = Vec::new();
|
||||||
|
|
||||||
|
for block in data_blocks {
|
||||||
|
match block.inner {
|
||||||
|
DataGroup::ConfigurationHeader(header) => {
|
||||||
|
if configuration_header.is_some() {
|
||||||
|
return Err(ConfigurationError::MultipleConfigurationHeaders);
|
||||||
|
}
|
||||||
|
configuration_header = Some(header);
|
||||||
|
}
|
||||||
|
DataGroup::ReaderConfiguration(configuration) => {
|
||||||
|
reader_configurations.push(configuration)
|
||||||
|
}
|
||||||
|
DataGroup::SESAMVitaleComponent(component) => {
|
||||||
|
sesam_vitale_components.push(component);
|
||||||
|
}
|
||||||
|
DataGroup::PCSCReader(reader) => {
|
||||||
|
pcsc_readers.push(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let configuration_header = match configuration_header {
|
||||||
|
Some(header) => header,
|
||||||
|
None => return Err(ConfigurationError::MissingConfigurationHeader),
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Self {
|
||||||
|
configuration_header,
|
||||||
|
reader_configurations,
|
||||||
|
sesam_vitale_components,
|
||||||
|
pcsc_readers,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
3
crates/services-sesam-vitale-sys/src/types/mod.rs
Normal file
3
crates/services-sesam-vitale-sys/src/types/mod.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod common;
|
||||||
|
pub mod configuration;
|
||||||
|
// pub mod droits_vitale;
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<NuxtRouteAnnouncer />
|
<NuxtRouteAnnouncer />
|
||||||
<NuxtWelcome />
|
<NavBar />
|
||||||
|
<NuxtPage />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
22
frontend/components/Avatar.vue
Normal file
22
frontend/components/Avatar.vue
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<template>
|
||||||
|
<div class="avatar">
|
||||||
|
<div class="rounded-full">
|
||||||
|
<img :src="getAvatarUrl(user)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { User } from '~/types/user';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
user: User,
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const getAvatarUrl = (user: User) => {
|
||||||
|
if (user.avatar) {
|
||||||
|
return user.avatar;
|
||||||
|
}
|
||||||
|
return 'https://avatar.iran.liara.run/username?username=' + user.name;
|
||||||
|
};
|
||||||
|
</script>
|
71
frontend/components/LoginModal.vue
Normal file
71
frontend/components/LoginModal.vue
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<template>
|
||||||
|
<dialog
|
||||||
|
id="login_modal"
|
||||||
|
ref="login_modal"
|
||||||
|
@cancel.prevent=""
|
||||||
|
@keyup="handleKeyPress"
|
||||||
|
class="modal"
|
||||||
|
>
|
||||||
|
<div class="modal-box">
|
||||||
|
<h3 class="text-3xl text-center mb-6">Connexion</h3>
|
||||||
|
<div class="flex flex-wrap gap-5 justify-center">
|
||||||
|
<template v-for="(user, index) in users" :key="user.id">
|
||||||
|
<LoginModalAvatar
|
||||||
|
:user="user"
|
||||||
|
:rank="index+1"
|
||||||
|
@selectUser="login"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form method="dialog" class="modal-backdrop">
|
||||||
|
<button class="cursor-default">close</button>
|
||||||
|
</form>
|
||||||
|
</dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { User } from '~/types/user';
|
||||||
|
|
||||||
|
const users: User[] = [
|
||||||
|
{ id: 1, name: 'John Doe', avatar: 'https://img.daisyui.com/images/stock/photo-1534528741775-53994a69daeb.webp' },
|
||||||
|
{ id: 2, name: 'Jane Doe', avatar: 'https://avatar.iran.liara.run/public' },
|
||||||
|
{ id: 3, name: 'Michel Moulin', avatar: '' },
|
||||||
|
{ id: 4, name: 'Jean Paris', avatar: '' },
|
||||||
|
{ id: 5, name: 'Marie Dupont', avatar: '' },
|
||||||
|
{ id: 6, name: 'Émilie Fournier', avatar: '' },
|
||||||
|
{ id: 7, name: 'Pierre Lefevre', avatar: '' },
|
||||||
|
{ id: 8, name: 'Sophie Lemoine', avatar: '' },
|
||||||
|
{ id: 9, name: 'Lucie Simon', avatar: '' },
|
||||||
|
{ id: 10, name: 'Kevin Boucher', avatar: '' },
|
||||||
|
];
|
||||||
|
|
||||||
|
const loginModal = useTemplateRef('login_modal');
|
||||||
|
|
||||||
|
const current_user = useCurrentUser();
|
||||||
|
|
||||||
|
const login = (user: User) => {
|
||||||
|
console.log('login', user);
|
||||||
|
current_user.value = user;
|
||||||
|
loginModal.value?.close();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyPress = (event: KeyboardEvent) => {
|
||||||
|
// Extract the rank from the event.code : Digit7 -> 7
|
||||||
|
const rank = event.code.match(/\d/);
|
||||||
|
if (!rank) {
|
||||||
|
console.debug('Not handled key event', { event });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const user = getUserByRank(parseInt(rank[0]));
|
||||||
|
if (user) {
|
||||||
|
login(user);
|
||||||
|
} else {
|
||||||
|
console.debug('Not handled key event', { event });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const getUserByRank = (rank: number): User => {
|
||||||
|
return users[rank - 1];
|
||||||
|
};
|
||||||
|
</script>
|
17
frontend/components/LoginModalAvatar.vue
Normal file
17
frontend/components/LoginModalAvatar.vue
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<button class="relative" @click="$emit('selectUser', user)">
|
||||||
|
<Avatar class="w-24" :user="user" />
|
||||||
|
<div class="absolute w-fit mx-auto bottom-0 inset-x-0">
|
||||||
|
<kbd class="kbd kbd-sm">{{ rank }}</kbd>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { User } from '~/types/user';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
user: User,
|
||||||
|
rank: Number,
|
||||||
|
}>();
|
||||||
|
</script>
|
35
frontend/components/NavBar.vue
Normal file
35
frontend/components/NavBar.vue
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<template>
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="navbar-start">
|
||||||
|
<a class="btn btn-ghost text-xl" href="/">Chrys4lide</a>
|
||||||
|
</div>
|
||||||
|
<nav class="navbar-center">
|
||||||
|
<NuxtLink to="/" class="btn btn-ghost">Accueil</NuxtLink>
|
||||||
|
<NuxtLink to="/CPS" class="btn btn-ghost">Carte CPS</NuxtLink>
|
||||||
|
</nav>
|
||||||
|
<div class="navbar-end">
|
||||||
|
<template v-if="!current_user">
|
||||||
|
<button class="btn btn-ghost" type="button" onclick="login_modal.showModal()">
|
||||||
|
Connexion
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<details class="dropdown dropdown-end">
|
||||||
|
<summary class="block"><Avatar :user="current_user" class="w-12" role="button" /></summary>
|
||||||
|
<ul class="menu dropdown-content bg-base-100 rounded-box z-[1] w-52 p-2 shadow">
|
||||||
|
<li><a @click="logout">Déconnexion</a></li>
|
||||||
|
</ul>
|
||||||
|
</details>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<LoginModal />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const current_user = useCurrentUser();
|
||||||
|
|
||||||
|
const logout = () => {
|
||||||
|
current_user.value = null;
|
||||||
|
};
|
||||||
|
</script>
|
3
frontend/composables/currentUser.ts
Normal file
3
frontend/composables/currentUser.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import type { User } from '@/types/user';
|
||||||
|
|
||||||
|
export const useCurrentUser = () => useState<User | null>('currentUser', () => null);
|
8
frontend/pages/CPS.vue
Normal file
8
frontend/pages/CPS.vue
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1 class="text-xl">Carte CPS</h1>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
</script>
|
17
frontend/pages/index.vue
Normal file
17
frontend/pages/index.vue
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<h1 class="text-xl">Welcome to your {{ appName }}!</h1>
|
||||||
|
<p v-if="current_user">Logged in as {{ current_user.name }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
const current_user = useCurrentUser();
|
||||||
|
const appName = 'Nuxt App';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
h1 {
|
||||||
|
color: #42b983;
|
||||||
|
}
|
||||||
|
</style>
|
6
frontend/types/user.ts
Normal file
6
frontend/types/user.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export declare interface User {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
email?: string;
|
||||||
|
avatar?: string;
|
||||||
|
}
|
Reference in New Issue
Block a user