userinfo ausgeben
This commit is contained in:
		@@ -1,6 +1,8 @@
 | 
				
			|||||||
$(document).ready(function() {
 | 
					$(document).ready(function() {
 | 
				
			||||||
    refresh();
 | 
					    refresh();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    userinfo();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    $(document).on("click", ".btn_detail", function() {
 | 
					    $(document).on("click", ".btn_detail", function() {
 | 
				
			||||||
        window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
 | 
					        window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@@ -29,32 +31,44 @@ $(document).ready(function() {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function refresh() {
 | 
					function refresh() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $("tbody").empty();
 | 
					    $("tbody").empty();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $.ajax({
 | 
					    $.ajax({
 | 
				
			||||||
            type: "GET",
 | 
					        type: "GET",
 | 
				
			||||||
            url: "/myshoppinglists",
 | 
					        url: "/myshoppinglists",
 | 
				
			||||||
            success(data) {
 | 
					        success(data) {
 | 
				
			||||||
                for(let item of data) {
 | 
					            for(let item of data) {
 | 
				
			||||||
                    $(".tb_myshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
 | 
					                $(".tb_myshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
 | 
				
			||||||
                     "</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>"  
 | 
					                 "</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>"  
 | 
				
			||||||
                     + "<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
 | 
					                 + "<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        }
 | 
				
			||||||
    
 | 
					    });
 | 
				
			||||||
        $.ajax({
 | 
					
 | 
				
			||||||
            type: "GET",
 | 
					    $.ajax({
 | 
				
			||||||
            url: "/sharedshoppinglists",
 | 
					        type: "GET",
 | 
				
			||||||
            success(data) {
 | 
					        url: "/sharedshoppinglists",
 | 
				
			||||||
                for(let item of data) {
 | 
					        success(data) {
 | 
				
			||||||
                    $(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
 | 
					            for(let item of data) {
 | 
				
			||||||
                    "</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
 | 
					                $(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
 | 
				
			||||||
                }
 | 
					                "</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        }
 | 
				
			||||||
    }
 | 
					    });
 | 
				
			||||||
});
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function userinfo() {
 | 
				
			||||||
 | 
					    $.ajax({
 | 
				
			||||||
 | 
					        type: "GET",
 | 
				
			||||||
 | 
					        url: "/userinfo_json",
 | 
				
			||||||
 | 
					        success(data) {
 | 
				
			||||||
 | 
					            $(".userinfo").empty();
 | 
				
			||||||
 | 
					            $(".userinfo").append("Logged in as: " + data.profile.displayName);
 | 
				
			||||||
 | 
					            $(".user_img").attr("src", data.profile.photos[0].value);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -134,4 +134,8 @@ router.get("/test1", (req, res) => {
 | 
				
			|||||||
  res.render("index1");
 | 
					  res.render("index1");
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					router.get("/userinfo_json", (req, res) => {
 | 
				
			||||||
 | 
					  res.send(req.session.passport.user);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = router;
 | 
					module.exports = router;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,8 @@
 | 
				
			|||||||
<body>
 | 
					<body>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  <div class="container">
 | 
					  <div class="container">
 | 
				
			||||||
      <p>Logged in as: testuser1</p>
 | 
					      <p class="userinfo">Logged in as: testuser1</p>
 | 
				
			||||||
 | 
					      <img class="user_img">
 | 
				
			||||||
      <br>
 | 
					      <br>
 | 
				
			||||||
      <div class="col s6">
 | 
					      <div class="col s6">
 | 
				
			||||||
        <a href="/logout" class="waves-effect waves-light btn">Logout</a>
 | 
					        <a href="/logout" class="waves-effect waves-light btn">Logout</a>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user