removing old testing pieces
This commit is contained in:
		
							parent
							
								
									23a7930a98
								
							
						
					
					
						commit
						6787986f22
					
				
					 11 changed files with 0 additions and 5706 deletions
				
			
		
							
								
								
									
										2262
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2262
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										20
									
								
								Cargo.toml
									
										
									
									
									
								
							
							
						
						
									
										20
									
								
								Cargo.toml
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,20 +0,0 @@
 | 
			
		|||
[package]
 | 
			
		||||
name = "tfcconnection"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
 | 
			
		||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
multer = "2.1.0"
 | 
			
		||||
actix = "0.13.0"
 | 
			
		||||
actix-rt = "2.8.0"
 | 
			
		||||
actix-web = "4.3.1"
 | 
			
		||||
env_logger = "0.10.0"
 | 
			
		||||
reqwest = { version = "0.11.18", features = ["json", "multipart"] }
 | 
			
		||||
serde = "1.0.163"
 | 
			
		||||
serde_json = "1.0.96"
 | 
			
		||||
async-std = "1.12.0"
 | 
			
		||||
actix-multipart = "0.6.0"
 | 
			
		||||
futures = "0.3.28"
 | 
			
		||||
futures-util = "0.3.28"
 | 
			
		||||
							
								
								
									
										2
									
								
								deps.edn
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								deps.edn
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,2 +0,0 @@
 | 
			
		|||
{:deps {org.clojure/clojurescript {:mvn/version "1.11.54"}
 | 
			
		||||
        thheller/shadow-cljs {:mvn/version "2.23.3"}}}
 | 
			
		||||
							
								
								
									
										1757
									
								
								quicklisp.lisp
									
										
									
									
									
								
							
							
						
						
									
										1757
									
								
								quicklisp.lisp
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							| 
						 | 
				
			
			@ -1,7 +0,0 @@
 | 
			
		|||
{:source-paths ["src"]
 | 
			
		||||
 :dependencies [[cljs-http "0.1.46"]
 | 
			
		||||
                [binaryage/oops "0.7.2"]]
 | 
			
		||||
 :builds {:app {:target :browser
 | 
			
		||||
                :output-dir "static/js"
 | 
			
		||||
                :asset-path "/js"
 | 
			
		||||
                :modules {:forms {:entries [forms]}}}}}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,34 +0,0 @@
 | 
			
		|||
(ns forms)
 | 
			
		||||
(def log "logs everything to the javascript console" (.-log js/console))
 | 
			
		||||
 | 
			
		||||
(defn startup []
 | 
			
		||||
  (def form (js/document.getElementById "form"))
 | 
			
		||||
  (log form)
 | 
			
		||||
  (def data (js/FormData. form))
 | 
			
		||||
  (log data)
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
(defn calc-age [dob]
 | 
			
		||||
  (log "HELLO CHICKENS!")
 | 
			
		||||
  (log dob)
 | 
			
		||||
  (log "HELLO CHICKENS!")
 | 
			
		||||
  (let [diff-ms (- js/Date. dob.getTime)
 | 
			
		||||
        age-dt (js/Date. diff-ms)]
 | 
			
		||||
    (log diff-ms)
 | 
			
		||||
    (log age-dt)
 | 
			
		||||
    (js/Math.abs (- age-dt.getUTCFullyYear 1970))))
 | 
			
		||||
 | 
			
		||||
(defn ^:export submitform [e]
 | 
			
		||||
  (let [form (js/document.getElementById "form")
 | 
			
		||||
        data (js/FormData. form)
 | 
			
		||||
        birthdate (js/Date. (get data "birthdate"))
 | 
			
		||||
        age (calc-age birthdate)]
 | 
			
		||||
    (set! data.age age)
 | 
			
		||||
    (log "HERE IS BIRTHDATE")
 | 
			
		||||
    (log "birthdate" (get data "birtdate"))
 | 
			
		||||
    (log (get data "tetanus-shot"))
 | 
			
		||||
    (if (= (get data "tetanus-shot") "")
 | 
			
		||||
      (set! data.-tetanus-shot "1111-11-11"))
 | 
			
		||||
    (log data)))
 | 
			
		||||
 | 
			
		||||
(js/document.addEventListener "DOMContentLoaded" startup)
 | 
			
		||||
| 
						 | 
				
			
			@ -1,3 +0,0 @@
 | 
			
		|||
(ns health-form)
 | 
			
		||||
(+ 1 9)
 | 
			
		||||
(println "hello-world")
 | 
			
		||||
| 
						 | 
				
			
			@ -1,12 +0,0 @@
 | 
			
		|||
(in-package :tfcconnection)
 | 
			
		||||
 | 
			
		||||
(defun submit-form ()
 | 
			
		||||
  ((@ console log) "hello world")
 | 
			
		||||
  (let ((form ((@ document get-element-by-id) "form"))
 | 
			
		||||
        (data (new (*form-data form))))
 | 
			
		||||
    ((@ console log) form)))
 | 
			
		||||
(defun validate (data)
 | 
			
		||||
  ((@ console log) "validating")
 | 
			
		||||
  (if (= ((@ data get) "tetanus-shot") "")
 | 
			
		||||
      ((@ console warn) "NO DATE FOR TETANUS SHOT")
 | 
			
		||||
      ((@ data set) "tetanus-shot" "1111-11-11")))
 | 
			
		||||
							
								
								
									
										78
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										78
									
								
								src/main.rs
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,78 +0,0 @@
 | 
			
		|||
use actix_multipart::{
 | 
			
		||||
    form::{
 | 
			
		||||
        tempfile::{TempFile, TempFileConfig},
 | 
			
		||||
        MultipartForm,
 | 
			
		||||
    },
 | 
			
		||||
    Multipart,
 | 
			
		||||
};
 | 
			
		||||
use actix_web::{middleware, post, web, App, Error, HttpResponse, HttpServer, Result};
 | 
			
		||||
// use serde::Deserialize;
 | 
			
		||||
use futures_util::StreamExt as _;
 | 
			
		||||
use std::{env, io};
 | 
			
		||||
 | 
			
		||||
// #[derive(Debug, MultipartForm)]
 | 
			
		||||
// struct HealthForm {
 | 
			
		||||
//     firstname: String,
 | 
			
		||||
//     lastname: String,
 | 
			
		||||
//     birthdate: String,
 | 
			
		||||
// }
 | 
			
		||||
 | 
			
		||||
#[actix_web::main]
 | 
			
		||||
async fn main() -> io::Result<()> {
 | 
			
		||||
    env::set_var("RUST_LOG", "actix_web=debug,actix_server=info");
 | 
			
		||||
    env_logger::init();
 | 
			
		||||
 | 
			
		||||
    HttpServer::new(|| {
 | 
			
		||||
        App::new()
 | 
			
		||||
            // enable logger - always register actix-web Logger middleware last
 | 
			
		||||
            .wrap(middleware::Logger::default())
 | 
			
		||||
            .app_data(web::FormConfig::default().limit(1048576))
 | 
			
		||||
            // register HTTP requests handlers
 | 
			
		||||
            .service(form)
 | 
			
		||||
    })
 | 
			
		||||
    .bind("0.0.0.0:4242")?
 | 
			
		||||
    .run()
 | 
			
		||||
    .await
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[post("/health-form")]
 | 
			
		||||
async fn form(mut form: Multipart) -> Result<HttpResponse, Error> {
 | 
			
		||||
    // println!("{form:?}");
 | 
			
		||||
    while let Some(item) = form.next().await {
 | 
			
		||||
        let mut field = item?;
 | 
			
		||||
        // let mut value = "";
 | 
			
		||||
        let name = field.name();
 | 
			
		||||
        let content_type = field.content_type().unwrap().to_string();
 | 
			
		||||
        if content_type == "application/octet-stream" {
 | 
			
		||||
            // Handle file field
 | 
			
		||||
            // You can save the file or process its contents here
 | 
			
		||||
            while let Some(chunk) = field.try_next().await? {
 | 
			
		||||
                // Process file chunk
 | 
			
		||||
            }
 | 
			
		||||
        } else {
 | 
			
		||||
            // Handle other field types (e.g., text fields)
 | 
			
		||||
            let field_value = field
 | 
			
		||||
                .try_next()
 | 
			
		||||
                .await?
 | 
			
		||||
                .expect("Field value not found")
 | 
			
		||||
                .to_utf8()
 | 
			
		||||
                .expect("Failed to decode field value as UTF-8");
 | 
			
		||||
 | 
			
		||||
            // Process the field value (e.g., store in a database, perform validation, etc.)
 | 
			
		||||
            println!("Field {}: {}", name, field_value);
 | 
			
		||||
        }
 | 
			
		||||
        // while let Some(chunk) = field.try_next().await {
 | 
			
		||||
        //     let value = std::str::from_utf8(&chunk?).unwrap();
 | 
			
		||||
        //     println!("{:?}: {:?}", name, value);
 | 
			
		||||
        // }
 | 
			
		||||
    }
 | 
			
		||||
    Ok(HttpResponse::Ok().into())
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
fn get_boundary(s: &str) -> &str {
 | 
			
		||||
    if let Some(index) = s.find("=") {
 | 
			
		||||
        &s[(index + 1)..]
 | 
			
		||||
    } else {
 | 
			
		||||
        s
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1518
									
								
								static/js/forms.js
									
										
									
									
									
								
							
							
						
						
									
										1518
									
								
								static/js/forms.js
									
										
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							| 
						 | 
				
			
			@ -1,13 +0,0 @@
 | 
			
		|||
defpackage(tfcconnection, 'use'(ps));
 | 
			
		||||
function submitForm() {
 | 
			
		||||
    console.log('hello world');
 | 
			
		||||
    var form5 = document.getElementById('form');
 | 
			
		||||
    var data = new FormData(form);
 | 
			
		||||
    __PS_MV_REG = [];
 | 
			
		||||
    return console.log(form5);
 | 
			
		||||
};
 | 
			
		||||
function validate(data) {
 | 
			
		||||
    console.log('validating');
 | 
			
		||||
    __PS_MV_REG = [];
 | 
			
		||||
    return data.get('tetanus-shot') === '' ? console.warn('NO DATE FOR TETANUS SHOT') : data.set('tetanus-shot', '1111-11-11');
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue