Explorar el Código

saving account data

Johann Woelper hace 7 años
padre
commit
fdf202a096
Se han modificado 3 ficheros con 8 adiciones y 9 borrados
  1. 6 3
      src/server.rs
  2. 1 5
      webapp/app.js
  3. 1 1
      webapp/index.html

+ 6 - 3
src/server.rs

@@ -27,9 +27,12 @@ fn index() -> &'static str {
 #[post("/save", data = "<account>")] //<tasks> means that the function below will have a var called tasks
 fn save(account: Json<HashMap<String, Account>>) -> &'static str {
     dbg!(&account);
-    // let mut old_tasks = TASKS.lock().unwrap();
-    // * old_tasks = tasks.to_vec();
-    "nice..."
+
+    let mut accounts = ACCOUNTS.lock().unwrap();
+    accounts.extend(account.into_inner());
+    dbg!(&accounts);
+    drop(accounts);
+    "Inserted"
 }
 
 // turn tasks into json (serialize)

+ 1 - 5
webapp/app.js

@@ -97,16 +97,12 @@ var app = new Vue({
         delete_query: function (queryname) {
             this.$delete(this.queries, queryname);
         },
-        save_query: function () {
+        save_account: function () {
             let account = {}
             account[this.account] = {queries: this.queries};
             console.log(JSON.stringify(account) );
             
 
-            //     this.account: {
-            //         queries: this.queries
-            //     }
-            // };
             var self = this; 
             console.log("Saving");
             fetch("http://localhost:8000/save", {

+ 1 - 1
webapp/index.html

@@ -104,7 +104,7 @@
             
           <div align="right">
 
-            <button    @click="save_query()">Alle Suchen permanent speichern</button>
+            <button @click="save_account()">Alle Suchen permanent speichern</button>
           </div>
       </div>