feat: Added meal food and ingredient record through dataset
This commit is contained in:
315
food_data.txt
Normal file
315
food_data.txt
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
Banana Bread: Flour, sugar, bananas, baking powder, salt, eggs, vegetable oil, vanilla
|
||||||
|
Beef Burrito: Tortilla, ground beef, refried beans, cheddar cheese, lettuce, tomato, onion, salsa
|
||||||
|
Broccoli Cheese Soup: Chicken broth, milk, butter, flour, broccoli, carrots, cheddar cheese, salt, pepper
|
||||||
|
Caesar Salad: Romaine lettuce, croutons, parmesan cheese, Caesar dressing, garlic, anchovies
|
||||||
|
Chicken Alfredo: Penne pasta, chicken, butter, heavy cream, garlic, parmesan cheese, salt, pepper
|
||||||
|
Chocolate Chip Cookies: Flour, sugar, brown sugar, butter, eggs, vanilla, baking soda, salt, chocolate chips
|
||||||
|
Cornbread: Cornmeal, flour, sugar, baking powder, salt, milk, eggs, butter
|
||||||
|
Egg Rolls: Egg roll wrappers, cabbage, carrots, green onions, ground pork, garlic, soy sauce, sesame oil
|
||||||
|
Fajitas: Flour tortillas, sliced chicken, bell peppers, onions, garlic, cumin, chili powder, lime juice
|
||||||
|
French Fries: Potatoes, vegetable oil, salt, pepper
|
||||||
|
Garlic Bread: Baguette, garlic, butter, parmesan cheese
|
||||||
|
Grilled Cheese: Bread, butter, cheddar cheese
|
||||||
|
Hamburger: Buns, beef, lettuce, tomato, onion, pickles, ketchup, mustard
|
||||||
|
Hot Dog: Hot dog bun, hot dog, mustard, ketchup, relish
|
||||||
|
Ice Cream: Cream, milk, sugar, vanilla
|
||||||
|
Jambalaya: Rice, andouille sausage, chicken, onion, green pepper, celery, garlic, tomato, bay leaves, thyme, paprika, cayenne, salt
|
||||||
|
Kung Pao Chicken: Chicken, peanuts, bell pepper, zucchini, carrot, green onion, soy sauce, hoisin sauce, rice vinegar, garlic, ginger, chili peppers
|
||||||
|
Lasagna: Lasagna noodles, ground beef, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil
|
||||||
|
Mac and Cheese: Pasta, milk, butter, flour, cheddar cheese, salt, pepper
|
||||||
|
Meatballs: Ground beef, breadcrumbs, parmesan cheese, garlic, egg, parsley
|
||||||
|
Meatloaf: Ground beef, breadcrumbs, onion, garlic, egg, milk, ketchup, salt, pepper
|
||||||
|
Muffins: Flour, sugar, baking powder, salt, milk, eggs, vegetable oil
|
||||||
|
Nachos: Tortilla chips, beef, beans, cheddar cheese, lettuce, tomato, onion, jalapenos
|
||||||
|
Omelette: Eggs, milk, salt, pepper, cheese, onion, bell pepper
|
||||||
|
Pancakes: Flour, sugar, baking powder, salt, milk, eggs, butter
|
||||||
|
Pasta: Penne, tomato sauce, garlic, onion, basil, olive oil, parmesan cheese
|
||||||
|
Pizza: Dough, tomato sauce, mozzare,cheese, pepperoni, sausage, mushroom, bell pepper, onion, olives
|
||||||
|
Pork Chops: Pork chops, salt, pepper, rosemary
|
||||||
|
Quesadilla: Tortilla, cheese, chicken, beef, beans
|
||||||
|
Queso: American cheese, Velveeta cheese, milk, Rotel
|
||||||
|
Rice: White rice, water, butter, salt
|
||||||
|
Salad: Lettuce, tomato, cucumber, onion
|
||||||
|
Sandwich: Bread, meat, cheese, lettuce, tomato, onion, mayonnaise, mustard, ketchup
|
||||||
|
Shrimp: Shrimp, garlic, butter, lemon
|
||||||
|
Shrimp Scampi: Shrimp, garlic, butter, lemon, white wine, pasta
|
||||||
|
Sloppy Joes: Ground beef, onion, bell pepper, tomato sauce, ketchup, brown sugar, buns
|
||||||
|
Spaghetti: Spaghetti, tomato sauce, garlic, onion, beef
|
||||||
|
Steak: Steak, salt, pepper, garlic
|
||||||
|
Stew: Beef, potatoes, carrots, onion, garlic, beef, chicken, vegetable
|
||||||
|
Stir Fry: Rice, vegetables, chicken, beef, shrimp, tofu
|
||||||
|
Sushi: Rice, seaweed, fish, avocado, cucumber
|
||||||
|
Tacos: Tortillas, meat, cheese, lettuce, tomato, onion, salsa
|
||||||
|
Tater Tots: Tater tots, vegetable oil, ketchup
|
||||||
|
Tuna Salad: Tuna, mayonnaise, onion, celery
|
||||||
|
Vegetable Stir Fry: Rice, vegetables, soy sauce
|
||||||
|
Waffles: Flour, sugar, baking powder, salt, milk, eggs, butter
|
||||||
|
Wings: Chicken wings, sauce
|
||||||
|
Yogurt Parfait: Yogurt, granola, strawberries, blueberries, peaches
|
||||||
|
Ziti: Ziti noodles, tomato sauce, meat, cheese
|
||||||
|
Zucchini Boats: Zucchini, ground beef, tomato sauce, onion, garlic, cheese
|
||||||
|
Baked Potato: Potato, butter, sour cream, cheese, bacon bits
|
||||||
|
Baked Ziti: Ziti noodles, tomato sauce, cheese, ground beef ,meatballs
|
||||||
|
Banana Bread: Flour, sugar, bananas, eggs, butter, baking powder
|
||||||
|
Beef and Broccoli: Beef, broccoli, soy sauce, garlic, brown sugar
|
||||||
|
Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles
|
||||||
|
Berry Cobbler: Fruit, sugar, biscuit mix, butter
|
||||||
|
Breakfast Burrito: Tortilla, eggs, cheese, sausage, potatoes
|
||||||
|
Bratwurst: Bratwurst, buns, sauerkraut
|
||||||
|
Bruschetta: Bread, tomatoes, basil, garlic, oil
|
||||||
|
Buffalo Chicken Dip: Chicken, cream cheese, hot sauce, blue cheese, ranch dressing
|
||||||
|
Burrito Bowl: Rice, beans, chicken, cheese, sour cream, salsa
|
||||||
|
Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic
|
||||||
|
Caesar Salad: Romaine lettuce, croutons, grilled chicken, Caesar dressing
|
||||||
|
Calzones: Pizza dough, tomato sauce, cheese, meat ,vegetables
|
||||||
|
Carbonara: Spaghetti, eggs, bacon, parmesan cheese
|
||||||
|
Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth
|
||||||
|
Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce
|
||||||
|
Chicken Parmesan: Chicken, tomato sauce, cheese, pasta
|
||||||
|
Chicken Penne: Penne pasta, chicken, tomato sauce, cheese
|
||||||
|
Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa
|
||||||
|
Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices
|
||||||
|
Chili: Ground beef, beans, tomato sauce, chili powder
|
||||||
|
Chili Cheese Dog: Hot dog, chili, cheese, bun
|
||||||
|
Chili Rellenos: Poblano pepper, cheese, tomato sauce, eggs
|
||||||
|
Chocolate Chip Cookies: Flour, sugar, butter, eggs, vanilla, chocolate chips, baking powder
|
||||||
|
Chow Mein: Noodles, vegetables, meat
|
||||||
|
Churros: Flour, sugar, water, cinnamon, oil
|
||||||
|
Clam Chowder: Clams, potatoes, onion, milk, bacon
|
||||||
|
Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing
|
||||||
|
Coleslaw: Cabbage, mayonnaise, sugar
|
||||||
|
Cornbread: Cornmeal, flour, sugar, baking powder, eggs, milk
|
||||||
|
Corn on the Cob: Corn, butter, salt
|
||||||
|
Crab Cakes: Crab, breadcrumbs, mayonnaise, spices
|
||||||
|
Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour
|
||||||
|
Crepes: Flour, eggs, milk, sugar
|
||||||
|
Croissants: Flour, butter, yeast, sugar
|
||||||
|
Fried Rice: Rice, eggs, onions, peas, carrots, soy sauce, vegetable oil
|
||||||
|
Beef and Broccoli: Beef, broccoli, soy sauce, garlic, ginger, sugar, cornstarch
|
||||||
|
Chicken Fried Steak: Tenderized steak, flour, eggs, milk, breadcrumbs, salt, pepper, vegetable oil
|
||||||
|
Chicken Curry: Chicken, onions, garlic, ginger, curry powder, coconut milk, chicken broth, tomato paste, salt, pepper, sugar
|
||||||
|
Chicken Fajitas: Chicken, bell peppers, onions, garlic, cumin, chili powder, salt, pepper, flour tortillas
|
||||||
|
Chicken Parmesan: Chicken, breadcrumbs, tomato sauce, mozzarella cheese, parmesan cheese, spaghetti
|
||||||
|
Chicken Shawarma: Chicken, garlic, lemon juice, olive oil, cumin, coriander, paprika, pita bread
|
||||||
|
Chili Relleno: Poblano peppers, cheese, eggs, flour, tomato sauce, vegetable oil
|
||||||
|
Clam Chowder: Clams, potatoes, onions, celery, milk, butter, flour, thyme
|
||||||
|
Cobb Salad: Greens, chicken, bacon, eggs, avocado, tomatoes, blue cheese, vinaigrette
|
||||||
|
Corned Beef and Cabbage: Corned beef, cabbage, carrots, onions, garlic, beef broth
|
||||||
|
Creamy Polenta: Polenta, milk, butter, parmesan cheese, salt
|
||||||
|
Crab Cakes: Crab meat, breadcrumbs, eggs, mayonnaise, mustard, salt, pepper, vegetable oil
|
||||||
|
Crispy Fish Tacos: White fish, flour tortillas, cabbage, cilantro, avocado, lime, chipotle mayo
|
||||||
|
Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread
|
||||||
|
Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika
|
||||||
|
Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers
|
||||||
|
Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder
|
||||||
|
Fettuccine Alfredo: Fettuccine, butter, heavy cream, parmesan cheese, salt, pepper
|
||||||
|
Fish and Chips: Cod ,haddock, flour, beer, baking powder, salt, potatoes, vegetable oil
|
||||||
|
Fried Chicken: Chicken, buttermilk, flour, salt, pepper, vegetable oil
|
||||||
|
Goulash: Ground beef, onions, garlic, paprika, tomato sauce, beef broth, elbow macaroni, sour cream
|
||||||
|
Gumbo: Shrimp, chicken, sausage, okra, onions, garlic, bell peppers, celery, tomato sauce, rice
|
||||||
|
Hamburger Helper: Ground beef, egg noodles, milk, cheese, seasoning packet
|
||||||
|
Hot and Sour Soup: Chicken, tofu, mushrooms, bamboo shoots, eggs, soy sauce, vinegar, cornstarch
|
||||||
|
Jambalaya: Rice, chicken, sausage, shrimp, onions, garlic, bell peppers, tomato sauce, spices
|
||||||
|
Kung Pao Chicken: Chicken, peanuts, bell peppers, dried red chilies, soy sauce, vinegar, sugar, cornstarch
|
||||||
|
Lobster Bisque: Lobster, butter, onion, garlic, tomato paste, flour, chicken broth, sherry, cream
|
||||||
|
Macaroni and Cheese: Macaroni, milk, butter, flour, cheddar cheese, salt
|
||||||
|
Meatballs: Ground beef, breadcrumbs, egg, onion, garlic, parsley
|
||||||
|
Meatloaf: Ground beef, breadcrumbs, egg, onion, garlic, milk, ketchup
|
||||||
|
Moussaka: Eggplant, potatoes, ground beef, onion, garlic, tomato sauce, bechamel sauce
|
||||||
|
Nachos: Tortilla chips, taco seasoning, beef, beans, cheese, salsa
|
||||||
|
Omelette: Egg, milk, butter, salt, pepper, fillings such as cheese, onions, bell peppers
|
||||||
|
Onion Soup: Onion, butter, flour, chicken broth, beef bouillon, sherry
|
||||||
|
Paella: Rice, saffron, chicken, chorizo, onion, garlic, tomato, peas, shrimp
|
||||||
|
Pancakes: Flour, milk, eggs, sugar, baking powder, salt
|
||||||
|
Panna Cotta: Heavy cream, sugar, milk, gelatin
|
||||||
|
Pasta Carbonara: Pasta, bacon, eggs, parmesan cheese, black pepper
|
||||||
|
Pesto: Basil, garlic, pinenuts, parmesan cheese, olive oil, salt
|
||||||
|
Pho: Beef, beef broth, rice noodles, onion, ginger, star anise, cinnamon, cloves, fish sauce
|
||||||
|
Poutine: Fries, cheese curds, gravy
|
||||||
|
Pumpkin Pie: Pumpkin, evaporated milk, eggs, sugar, cinnamon, nutmeg, pie crust
|
||||||
|
Quesadilla: Tortilla, cheese, fillings such as chicken, onions, bell peppers
|
||||||
|
Ratatouille: Eggplant, bell peppers, zucchini, onion, garlic, tomato, herbs
|
||||||
|
Red Velvet Cake: Flour, sugar, cocoa powder, buttermilk, vegetable oil, baking soda, vinegar, cream cheese frosting
|
||||||
|
Roasted Chicken: Chicken, oil, salt, pepper
|
||||||
|
Ropa Vieja: Flank steak, tomato sauce, onion, bell pepper, garlic, olives
|
||||||
|
Rum Cake: Yellow cake, rum, butter, pecans
|
||||||
|
Salmon Cakes: Salmon, breadcrumbs, egg, onion, old bay seasoning, oil
|
||||||
|
Seafood Risotto: Arborio rice, seafood, garlic, white wine, parmesan cheese
|
||||||
|
Shrimp and Grits: Shrimp, grits, bacon, onion, garlic, hot sauce
|
||||||
|
Sloppy Joes: Ground beef, onion, bell pepper, garlic, tomato sauce, spices, served on hamburger buns
|
||||||
|
Spaghetti: Spaghetti, tomato sauce, meatballs ,meat sauce
|
||||||
|
Spaghetti alla Carbonara: Spaghetti, bacon, eggs, parmesan cheese, black pepper
|
||||||
|
Spaghetti and Meatballs: Spaghetti, tomato sauce, meatballs
|
||||||
|
Spinach Artichoke Dip: Spinach, artichoke, cream cheese, parmesan cheese, garlic served with chips ,veggies
|
||||||
|
Stuffed Bell Peppers: Bell peppers, tomato sauce, ,rice, ground beef, onion, garlic, cheese
|
||||||
|
Chicken Alfredo: Fettuccine noodles, chicken breast, heavy cream, garlic, butter, parmesan cheese, salt
|
||||||
|
Beef Tacos: tortillas, ground beef, taco seasoning, lettuce, tomatoes, onions, shredded cheese, sour cream
|
||||||
|
Shrimp Scampi: Linguine noodles, shrimp, garlic, butter, white wine, lemon juice, red pepper flakes, parsley
|
||||||
|
Baked Ziti: Ziti noodles, ground beef, marinara sauce, ricotta cheese, mozzarella cheese, parmesan cheese
|
||||||
|
Grilled Cheese Sandwich: Bread, butter, cheese
|
||||||
|
Chili: Ground beef, kidney beans, onions, garlic, chili powder, cumin, diced tomatoes, beef broth, salt
|
||||||
|
Breakfast Burritos: Flour tortillas, scrambled eggs, bacon ,sausage, potatoes, cheese, salsa
|
||||||
|
Chicken Stir Fry: Chicken breast, broccoli, carrots, onions, garlic, soy sauce, brown sugar
|
||||||
|
Fajitas: Flour tortillas, chicken ,steak, onions, bell peppers, garlic, lime juice, fajita seasoning
|
||||||
|
Meatball Sub: Sub rolls, meatballs, marinara sauce, mozzarella cheese, parmesan cheese
|
||||||
|
Grilled Cheese Sandwich: Bread, cheese, butter Served with tomato soup ,a salad
|
||||||
|
Chicken Caesar Salad: Romaine lettuce, grilled chicken, croutons, Caesar dressing, Parmesan cheese
|
||||||
|
Beef Tacos: shell tortillas, ground beef, lettuce, tomatoes, onions, shredded cheese, salsa
|
||||||
|
Shrimp Scampi: Linguine noodles, shrimp, garlic, butter, white wine, lemon juice, red pepper flakes, parsley
|
||||||
|
BBQ Ribs: Pork ribs, barbecue sauce, brown sugar, spices Served with coleslaw cornbread
|
||||||
|
Vegetable Stir Fry: Bell peppers, broccoli, carrots, onions, garlic, soy sauce, sesame oil Served over rice ,noodles
|
||||||
|
Chicken Fajitas: Flour tortillas, chicken breast, onions, bell peppers, garlic, lime juice, fajita seasoning Served with sour cream, guacamole, salsa
|
||||||
|
Beef and Broccoli: Flank steak, broccoli florets, soy sauce, brown sugar, garlic, ginger, vegetable oil Served over rice
|
||||||
|
Baked Ziti: Ziti pasta, ground beef, marinara sauce, mozzarella cheese, Parmesan cheese
|
||||||
|
Grilled Chicken Breast: Chicken breast, olive oil, lemon juice, garlic, salt, pepper Served with roasted vegetables quinoa
|
||||||
|
Chicken Tikka Masala: Chicken, tomato sauce, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, yogurt, heavy cream, cilantro
|
||||||
|
Samosa: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil, salt
|
||||||
|
Butter Chicken: Chicken, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, garam masala, turmeric, paprika, heavy cream, cilantro
|
||||||
|
Chana Masala: Chickpeas, onion, tomato sauce, garlic, ginger, cumin, coriander, turmeric, garam masala, amchur powder, cilantro
|
||||||
|
Biryani: Basmati rice, chicken, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, bay leaves, coriander, mint
|
||||||
|
Pakora: Chickpea flour, onion, spinach, potatoes, chili powder, coriander, turmeric, salt, water
|
||||||
|
Tandoori Chicken: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala
|
||||||
|
Aloo Gobi: Potatoes, cauliflower, onion, garlic, ginger, turmeric, cumin, coriander, garam masala, cilantro
|
||||||
|
Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder
|
||||||
|
Mango Lassi: Mango, yogurt, milk, sugar, ice
|
||||||
|
Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt
|
||||||
|
Gulab Jamun: Milk solids, flour, baking soda, ghee, yogurt, cardamom, sugar, rose water
|
||||||
|
Palak Paneer: Paneer, spinach, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, cream
|
||||||
|
Naan: flour, yeast, sugar, yogurt, milk, salt, butter
|
||||||
|
Masala Chai: Black tea, milk, sugar, cinnamon, cardamom, ginger
|
||||||
|
Tandoori Chicken: Chicken breasts, yogurt, cumin, coriander, cayenne pepper, cinnamon, cardamom, cumin
|
||||||
|
Bhaji: Onion, gram flour, chili powder, turmeric, coriander
|
||||||
|
Butter Chicken: Chicken, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, garam masala, turmeric
|
||||||
|
Baingan Bharta: Eggplant, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, cilantro
|
||||||
|
Chole Bhature: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, flour, baking powder
|
||||||
|
Dosa: Lentils, rice, fenugreek seeds, salt, oil
|
||||||
|
Idli: Lentils, rice, fenugreek seeds, salt, oil
|
||||||
|
Kadhi: Gram flour, yogurt, onion, garlic, ginger, turmeric, cumin, coriander, mustard seeds, curry leaves, asafetida
|
||||||
|
Korma: Chicken, cream, almonds, onion, garlic, ginger, coriander, cumin, cardamom, cinnamon, cloves
|
||||||
|
Malai Kofta: Paneer, potatoes, onion, garlic, ginger, cashews, cream, tomato, coriander, cumin, cardamom, cinnamon
|
||||||
|
Matar Paneer: Paneer, peas, onion, garlic, ginger, tomato, coriander, cumin, turmeric, garam masala
|
||||||
|
Pongal: Rice, lentils, ghee, cashews, pepper, cumin, curry leaves
|
||||||
|
Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder
|
||||||
|
Rasmalai: Milk, sugar, lemon juice, paneer, cardamom, pistachios, saffron
|
||||||
|
Saag Paneer: Spinach, paneer, onion, garlic, ginger, coriander, cumin, turmeric, garam masala
|
||||||
|
Samosas: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil
|
||||||
|
Shrimp Curry: Shrimp, onion, garlic, ginger, tomato, coriander, cumin, turmeric,
|
||||||
|
Butter Paneer: Paneer, butter, tomato sauce, onion, garlic, ginger, coriander, cumin, turmeric, garam masala, cream
|
||||||
|
Chicken Tikka: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala
|
||||||
|
Lamb Biryani: Basmati rice, lamb, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, bay leaves, coriander, mint
|
||||||
|
Palak Paneer: Paneer, spinach, onion, garlic, ginger, cumin, coriander, turmeric, garam masala, cream
|
||||||
|
Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt
|
||||||
|
Samosa Chaat: Samosa, chickpeas, yogurt, tamarind chutney, mint chutney, sev , chopped onion, cilantro
|
||||||
|
Vegetable Biryani: Basmati rice, mixed vegetables, onion, garlic, ginger, yogurt, saffron, cardamom, cloves, cinnamon, coriander, mint
|
||||||
|
Vindaloo: Chicken, lamb, or pork, vinegar, garlic, ginger, onion, tomato, chili powder, cumin, coriander, turmeric, cinnamon, cloves
|
||||||
|
Aloo Tikki: Potatoes, onion, ginger, green chili, coriander, cumin, chaat masala, bread crumbs, oil
|
||||||
|
Bhel Puri: Puffed rice, sev, boiled potatoes, onion, tomato, cilantro, tamarind chutney, mint chutney
|
||||||
|
Chaat Papdi: Papdi (fried dough wafers), boiled potatoes, chickpeas, yogurt, tamarind chutney, mint chutney
|
||||||
|
Baingan Bharta: Eggplant, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, cilantro
|
||||||
|
Chana Masala: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, amchur powder, cilantro
|
||||||
|
Kadhi: Gram flour, yogurt, onion, garlic, ginger, turmeric, cumin, coriander, mustard seeds, curry leaves, asafetida
|
||||||
|
Korma: Chicken, cream, almonds, onion, garlic, ginger, coriander, cumin, cardamom, cinnamon, cloves
|
||||||
|
Malai Kofta: Paneer, potatoes, onion, garlic, ginger, cashews, cream, tomato, coriander, cumin, cardamom, cinnamon
|
||||||
|
Matar Paneer: Paneer, peas, onion, garlic, ginger, tomato, coriander, cumin, turmeric, garam masala
|
||||||
|
Pongal: Rice, lentils, ghee, cashews, pepper, cumin, curry leaves
|
||||||
|
Raita: Yogurt, cucumber, cilantro, mint, cumin, red chili powder
|
||||||
|
Rasmalai: Milk, sugar, lemon juice, paneer, cardamom, pistachios, saffron
|
||||||
|
Saag Paneer: Spinach, paneer, onion, garlic, ginger, coriander, cumin, turmeric, garam masala, cream
|
||||||
|
Samosas: Potatoes, peas, onion, garlic, ginger, green chilies, coriander, cumin, garam masala, flour, vegetable oil
|
||||||
|
Shrimp Curry: Shrimp, onion, garlic, ginger, tomato, coriander, cumin, turmeric, chili powder, coconut milk
|
||||||
|
Aloo Gobi: Potatoes, cauliflower, onion, garlic, ginger, turmeric, cumin, coriander, garam masala, cilantro
|
||||||
|
Chole Bhature: Chickpeas, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, flour, baking powder
|
||||||
|
Dosa: Lentils, rice, fenugreek seeds, salt, oil
|
||||||
|
Gulab Jamun: Milk solids, flour, baking soda, ghee, yogurt, cardamom, sugar, rose water
|
||||||
|
Idli: Lentils, rice, fenugreek seeds, salt, oil
|
||||||
|
Jalebi: Gram flour, yogurt, water, sugar, saffron, cardamom, oil
|
||||||
|
Kebab: chicken, beef, onion, garlic, ginger, coriander, cumin, chili powder, yogurt, oil
|
||||||
|
Lassi: Yogurt, water, sugar, rose water, cardamom
|
||||||
|
Masala Chai: Black tea, milk, sugar, cinnamon, cardamom, ginger
|
||||||
|
Naan: Flour, yeast, sugar, yogurt, milk, salt, butter
|
||||||
|
Paneer Tikka: Paneer, yogurt, garlic, ginger, cumin, coriander, turmeric, chili powder, oil
|
||||||
|
Rajma: Kidney beans, onion, tomato, garlic, ginger, cumin, coriander, turmeric, garam masala, chili, oil
|
||||||
|
Rogan Josh: Lamb, onion, garlic, ginger, tomato sauce, paprika, cumin, coriander, cinnamon, cardamom, cloves, yogurt
|
||||||
|
Tandoori Chicken: Chicken, yogurt, garlic, ginger, cumin, coriander, paprika, turmeric, cayenne, lemon juice, garam masala
|
||||||
|
Vada Pav: Spiced potato fritters, buns, green chutney, tamarind
|
||||||
|
Biryani: rice, meat, yogurt, onion, garlic, ginger, saffron, cardamom, cloves, cinnamon, coriander, mint, fried onions
|
||||||
|
Chaat: chickpeas, potatoes, yogurt, tamarind chutney, mint chutney, sev , chopped onion, cilantro
|
||||||
|
Chicken 65: Chicken, yogurt, garlic, ginger, chili powder, coriander, cumin, turmeric, vinegar, oil
|
||||||
|
Dhokla: Gram flour, semolina, yogurt, lemon juice, turmeric, baking soda, mustard seeds, sesame seeds, green chili, cilantro
|
||||||
|
Gobi Manchurian: Cauliflower, gram flour, cornstarch, ginger, garlic, green chili, soy sauce, vinegar, ketchup, oil
|
||||||
|
Hakka Noodles: Noodles, carrots, beans, cabbage, soy sauce, vinegar, chili sauce, garlic, oil
|
||||||
|
Hyderabadi Biryani: rice, meat, yogurt, onion, garlic, ginger, saffron, cardamom, cloves, cinnamon, coriander, mint, fried onions, rose water, kewra water
|
||||||
|
Kadai Paneer: Paneer, onion, tomato, garlic, ginger, coriander, cumin, turmeric, garam masala, chili, oil
|
||||||
|
Kati Roll: Paratha, meat, egg, onion, chili sauce, lime
|
||||||
|
Luchi: Flour, ghee, oil, salt
|
||||||
|
Mirchi Bhajji: Green chili, gram flour, chili powder, coriander
|
||||||
|
Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles
|
||||||
|
Bruschetta: Bread, tomatoes, basil, garlic, oil
|
||||||
|
Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic
|
||||||
|
Carbonara: Spaghetti, eggs, bacon, parmesan cheese
|
||||||
|
Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth
|
||||||
|
Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce
|
||||||
|
Chicken Parmesan: Chicken, tomato sauce, cheese, pasta
|
||||||
|
Chicken Penne: Penne pasta, chicken, tomato sauce, cheese
|
||||||
|
Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa
|
||||||
|
Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices
|
||||||
|
Clam Chowder: Clams, potatoes, onion, milk, bacon
|
||||||
|
Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing
|
||||||
|
Coleslaw: Cabbage, mayonnaise, sugar
|
||||||
|
Corn on the Cob: Corn, butter, salt
|
||||||
|
Crab Cakes: Crab, breadcrumbs, mayonnaise, spices
|
||||||
|
Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour
|
||||||
|
Crepes: Flour, eggs, milk, sugar
|
||||||
|
Croissants: Flour, butter, yeast, sugar
|
||||||
|
Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread
|
||||||
|
Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika
|
||||||
|
Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers
|
||||||
|
Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder
|
||||||
|
Fried Rice: Rice, eggs, onions, peas, carrots
|
||||||
|
Beef Bourguignon: Beef, bacon, onion, carrots, mushrooms, red wine, beef broth, tomato paste, garlic, thyme, bay leaves
|
||||||
|
Beef Wellington: Beef tenderloin, puff pastry, mushroom duxelles, prosciutto, Dijon mustard, egg, salt, pepper
|
||||||
|
Bouillabaisse: Fish, shellfish, onion, fennel, garlic, tomato, saffron, white wine, Pernod, fish stock, rouille
|
||||||
|
Carne Asada: Flank steak, lime juice, lemon juice, olive oil, garlic, cumin, chili powder, salt, pepper
|
||||||
|
Chicken Cordon Bleu: Chicken breast, ham, Swiss cheese, egg, breadcrumbs, flour, butter, oil, mustard, salt, pepper
|
||||||
|
Chicken Kiev: Chicken breast, butter, garlic, parsley, egg, breadcrumbs, flour, oil, salt, pepper
|
||||||
|
Cioppino: Fish, shellfish, onion, fennel, garlic, tomato, white wine, fish stock, basil, oregano, thyme, red pepper flakes
|
||||||
|
Coq au Vin: Chicken, bacon, onion, carrots, mushrooms, red wine, chicken broth, tomato paste, garlic, thyme, bay leaves
|
||||||
|
Crab Bisque: Crab, onion, celery, carrots, garlic, tomato, brandy, sherry, heavy cream, fish stock, cayenne pepper
|
||||||
|
Eggplant Parmesan: Eggplant, tomato sauce, mozzarella cheese, Parmesan cheese, breadcrumbs, egg, salt, pepper
|
||||||
|
Etouffee: Shrimp, onion, bell pepper, celery, garlic, tomato,
|
||||||
|
Beef Stroganoff: Beef, mushrooms, onion, beef broth, sour cream, egg noodles
|
||||||
|
Bruschetta: Bread, tomatoes, basil, garlic, oil
|
||||||
|
Butternut Squash Soup: Butternut squash, chicken broth, onion, garlic
|
||||||
|
Carbonara: Spaghetti, eggs, bacon, parmesan cheese
|
||||||
|
Chicken and Dumplings: Chicken, dumplings, vegetables, chicken broth
|
||||||
|
Chicken Fried Rice: Rice, chicken, vegetables, eggs, soy sauce
|
||||||
|
Chicken Parmesan: Chicken, tomato sauce, cheese, pasta
|
||||||
|
Chicken Penne: Penne pasta, chicken, tomato sauce, cheese
|
||||||
|
Chicken Tacos: Tortillas, chicken, cheese, lettuce, tomato, salsa
|
||||||
|
Chicken Tikka Masala: Chicken, tomato sauce, coconut milk, spices
|
||||||
|
Clam Chowder: Clams, potatoes, onion, milk, bacon
|
||||||
|
Cobb Salad: Romaine lettuce, chicken, bacon, avocado, tomato, blue cheese, dressing
|
||||||
|
Coleslaw: Cabbage, mayonnaise, sugar
|
||||||
|
Corn on the Cob: Corn, butter, salt
|
||||||
|
Crab Cakes: Crab, breadcrumbs, mayonnaise, spices
|
||||||
|
Cream of Mushroom Soup: Mushrooms, chicken broth, cream, flour
|
||||||
|
Crepes: Flour, eggs, milk, sugar
|
||||||
|
Croissants: Flour, butter, yeast, sugar
|
||||||
|
Cuban Sandwich: Ham, roasted pork, Swiss cheese, pickles, mustard, Cuban bread
|
||||||
|
Deviled Eggs: Eggs, mayonnaise, mustard, vinegar, salt, pepper, paprika
|
||||||
|
Egg Rolls: Cabbage, carrots, onions, garlic, ground pork, soy sauce, egg roll wrappers
|
||||||
|
Enchiladas: Tortillas, cheese, chicken ,beef, onions, garlic, tomato sauce, chili powder
|
||||||
|
Fried Rice: Rice, eggs, onions, peas, carrots
|
||||||
|
Bruschetta: Bread, tomatoes, basil, garlic, oil
|
||||||
|
Carbonara: Spaghetti, eggs, bacon, parmesan cheese
|
||||||
|
Eggplant Parmesan: Eggplant, tomato sauce, mozzarella cheese, Parmesan cheese, breadcrumbs, egg, salt, pepper
|
||||||
|
Fettuccine Alfredo: Fettuccine, butter, heavy cream, parmesan cheese, salt, pepper
|
||||||
|
Lasagna: Lasagna noodles, ground beef, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil
|
||||||
|
Manicotti: Manicotti shells, ricotta cheese, mozzarella cheese, tomato sauce, garlic, onion, basil
|
||||||
|
Minestrone Soup: Vegetables, beans, pasta, tomato, garlic, onion, herbs
|
||||||
|
Panzanella: Bread, tomatoes, cucumber, onion, basil, vinaigrette
|
||||||
|
Pasta Carbonara: Pasta, bacon, eggs, parmesan cheese, black pepper
|
||||||
|
Pizza: Dough, tomato sauce, mozzarella cheese, toppings of your choice
|
||||||
|
Risotto: Arborio rice, vegetables, broth, butter, parmesan cheese
|
||||||
|
Tiramisu: Ladyfingers, mascarpone cheese, espresso, cocoa powder
|
||||||
|
Tortellini: Tortellini, cheese, tomato sauce, garlic, onion, basil
|
||||||
BIN
formatted_data.xlsx
Normal file
BIN
formatted_data.xlsx
Normal file
Binary file not shown.
@@ -8,11 +8,34 @@ from rest_framework import serializers
|
|||||||
|
|
||||||
from module_iam.models import IAmPrincipal
|
from module_iam.models import IAmPrincipal
|
||||||
|
|
||||||
from ..models import (BeverageRecord, Bowel, ChronicCondition,
|
from ..models import (
|
||||||
FoodIngredientRecord, FoodRecord, Intolerance,
|
BeverageRecord,
|
||||||
MealRecord, MealSymptomRecord, Medication, Medicine,
|
Bowel,
|
||||||
PastTreatment, PrincipalHealthData, Symptoms,
|
ChronicCondition,
|
||||||
SymptomTypeAfterMeal, SymptomTypeBeforeMeal)
|
FoodIngredientRecord,
|
||||||
|
FoodIngredintDataset,
|
||||||
|
FoodRecord,
|
||||||
|
Intolerance,
|
||||||
|
MealRecord,
|
||||||
|
MealSymptomRecord,
|
||||||
|
Medication,
|
||||||
|
Medicine,
|
||||||
|
PastTreatment,
|
||||||
|
PrincipalHealthData,
|
||||||
|
Symptoms,
|
||||||
|
SymptomTypeAfterMeal,
|
||||||
|
SymptomTypeBeforeMeal,
|
||||||
|
)
|
||||||
|
|
||||||
|
class FoodDatasetSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
fields = ["id", "food_name"]
|
||||||
|
|
||||||
|
class FoodIngredientDatasetSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
fields = ['id', 'food_name', 'ingredients']
|
||||||
|
|
||||||
|
|
||||||
class IAmPrincipalSerializer(serializers.ModelSerializer):
|
class IAmPrincipalSerializer(serializers.ModelSerializer):
|
||||||
@@ -28,12 +51,17 @@ class IAmPrincipalSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class PrincipalHealthDataSerializer(serializers.ModelSerializer):
|
class PrincipalHealthDataSerializer(serializers.ModelSerializer):
|
||||||
|
weight = serializers.DecimalField(max_digits=5, decimal_places=2, read_only=True)
|
||||||
|
height = serializers.DecimalField(max_digits=6, decimal_places=2, read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PrincipalHealthData
|
model = PrincipalHealthData
|
||||||
fields = [
|
fields = [
|
||||||
"ethenicity",
|
"ethenicity",
|
||||||
"weight",
|
"weight",
|
||||||
|
"weight_unit",
|
||||||
"height",
|
"height",
|
||||||
|
"height_unit",
|
||||||
"gastrointestinal_health",
|
"gastrointestinal_health",
|
||||||
"exercise_frequency",
|
"exercise_frequency",
|
||||||
"sleep_duration",
|
"sleep_duration",
|
||||||
@@ -44,7 +72,9 @@ class PrincipalHealthDataSerializer(serializers.ModelSerializer):
|
|||||||
class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
||||||
ethenicity = serializers.CharField(read_only=True)
|
ethenicity = serializers.CharField(read_only=True)
|
||||||
weight = serializers.DecimalField(max_digits=5, decimal_places=2, read_only=True)
|
weight = serializers.DecimalField(max_digits=5, decimal_places=2, read_only=True)
|
||||||
|
weight_unit = serializers.CharField(max_length=10, read_only=True)
|
||||||
height = serializers.DecimalField(max_digits=6, decimal_places=2, read_only=True)
|
height = serializers.DecimalField(max_digits=6, decimal_places=2, read_only=True)
|
||||||
|
height_unit = serializers.CharField(max_length=10, read_only=True)
|
||||||
gastrointestinal_health = serializers.CharField(read_only=True)
|
gastrointestinal_health = serializers.CharField(read_only=True)
|
||||||
exercise_frequency = serializers.CharField(read_only=True)
|
exercise_frequency = serializers.CharField(read_only=True)
|
||||||
sleep_duration = serializers.CharField(read_only=True)
|
sleep_duration = serializers.CharField(read_only=True)
|
||||||
@@ -64,19 +94,35 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
|||||||
# "email_verified",
|
# "email_verified",
|
||||||
"ethenicity",
|
"ethenicity",
|
||||||
"weight",
|
"weight",
|
||||||
|
"weight_unit",
|
||||||
"height",
|
"height",
|
||||||
|
"height_unit",
|
||||||
"gastrointestinal_health",
|
"gastrointestinal_health",
|
||||||
"exercise_frequency",
|
"exercise_frequency",
|
||||||
"sleep_duration",
|
"sleep_duration",
|
||||||
"eat_frequency",
|
"eat_frequency",
|
||||||
"profile_complete"
|
"profile_complete",
|
||||||
]
|
]
|
||||||
|
|
||||||
def calculate_profile_completion(self, user):
|
def calculate_profile_completion(self, user):
|
||||||
"""
|
"""
|
||||||
Calculates the profile completion percentage for a user based on the required fields.
|
Calculates the profile completion percentage for a user based on the required fields.
|
||||||
"""
|
"""
|
||||||
fields = self.fields
|
fields = [
|
||||||
|
"profile_photo",
|
||||||
|
"first_name",
|
||||||
|
"email",
|
||||||
|
"date_of_birth",
|
||||||
|
"gender",
|
||||||
|
"phone_no",
|
||||||
|
"ethenicity",
|
||||||
|
"weight",
|
||||||
|
"height",
|
||||||
|
"gastrointestinal_health",
|
||||||
|
"exercise_frequency",
|
||||||
|
"sleep_duration",
|
||||||
|
"eat_frequency",
|
||||||
|
]
|
||||||
try:
|
try:
|
||||||
# Retrieve the user profile from the database
|
# Retrieve the user profile from the database
|
||||||
profile = IAmPrincipal.objects.get(id=user)
|
profile = IAmPrincipal.objects.get(id=user)
|
||||||
@@ -93,10 +139,19 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
|||||||
for field in fields
|
for field in fields
|
||||||
if (
|
if (
|
||||||
# If the field is in the user profile and the field value is not None, not an empty string, and not an instance of datetime.date
|
# If the field is in the user profile and the field value is not None, not an empty string, and not an instance of datetime.date
|
||||||
(field in vars(profile) and vars(profile).get(field, '') and vars(profile).get(field) != datetime.date) or
|
(
|
||||||
|
field in vars(profile)
|
||||||
|
and vars(profile).get(field, "")
|
||||||
|
and vars(profile).get(field) != datetime.date
|
||||||
|
)
|
||||||
|
or
|
||||||
# If health data exists, the field is in the user's health data, and the field value is not None, not an empty string, and not an instance of datetime.date
|
# If health data exists, the field is in the user's health data, and the field value is not None, not an empty string, and not an instance of datetime.date
|
||||||
(health_data and field in vars(health_data) and vars(health_data).get(field, '') and vars(health_data).get(field) != datetime.date)
|
(
|
||||||
|
health_data
|
||||||
|
and field in vars(health_data)
|
||||||
|
and vars(health_data).get(field, "")
|
||||||
|
and vars(health_data).get(field) != datetime.date
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -105,7 +160,7 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Calculate the total number of fields
|
# Calculate the total number of fields
|
||||||
total_fields = len(fields) - 1 # Exclude profile_complete field
|
total_fields = len(fields)
|
||||||
|
|
||||||
# Calculate the profile completion percentage
|
# Calculate the profile completion percentage
|
||||||
completion_percentage = math.floor((completed_fields / total_fields) * 100)
|
completion_percentage = math.floor((completed_fields / total_fields) * 100)
|
||||||
@@ -136,7 +191,9 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
|||||||
health_data = instance.health_data_principal
|
health_data = instance.health_data_principal
|
||||||
data["ethenicity"] = health_data.ethenicity
|
data["ethenicity"] = health_data.ethenicity
|
||||||
data["weight"] = health_data.weight
|
data["weight"] = health_data.weight
|
||||||
|
data["weight_unit"] = health_data.weight_unit
|
||||||
data["height"] = health_data.height
|
data["height"] = health_data.height
|
||||||
|
data["height_unit"] = health_data.height_unit
|
||||||
data["gastrointestinal_health"] = health_data.gastrointestinal_health
|
data["gastrointestinal_health"] = health_data.gastrointestinal_health
|
||||||
data["exercise_frequency"] = health_data.exercise_frequency
|
data["exercise_frequency"] = health_data.exercise_frequency
|
||||||
data["sleep_duration"] = health_data.sleep_duration
|
data["sleep_duration"] = health_data.sleep_duration
|
||||||
@@ -145,7 +202,9 @@ class PrincipalAndHealthSerializer(serializers.ModelSerializer):
|
|||||||
# If health_data_principal doesn't exist or is empty, set empty strings for all attributes
|
# If health_data_principal doesn't exist or is empty, set empty strings for all attributes
|
||||||
data["ethenicity"] = ""
|
data["ethenicity"] = ""
|
||||||
data["weight"] = 0.00
|
data["weight"] = 0.00
|
||||||
|
data["weight_unit"] = "kg"
|
||||||
data["height"] = 0.00
|
data["height"] = 0.00
|
||||||
|
data["height_unit"] = "cm"
|
||||||
data["gastrointestinal_health"] = ""
|
data["gastrointestinal_health"] = ""
|
||||||
data["exercise_frequency"] = ""
|
data["exercise_frequency"] = ""
|
||||||
data["sleep_duration"] = ""
|
data["sleep_duration"] = ""
|
||||||
@@ -168,7 +227,7 @@ class SymptomsSerializer(serializers.ModelSerializer):
|
|||||||
class PastTreatmentSerializer(serializers.ModelSerializer):
|
class PastTreatmentSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PastTreatment
|
model = PastTreatment
|
||||||
fields = ["id", "name", "duration"]
|
fields = ["id", "name", "duration", "is_recurring", "treatment_frequency"]
|
||||||
|
|
||||||
|
|
||||||
class ChronicConditionSerializer(serializers.ModelSerializer):
|
class ChronicConditionSerializer(serializers.ModelSerializer):
|
||||||
@@ -180,7 +239,7 @@ class ChronicConditionSerializer(serializers.ModelSerializer):
|
|||||||
class FoodIngredientRecordSerializer(serializers.ModelSerializer):
|
class FoodIngredientRecordSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = FoodIngredientRecord
|
model = FoodIngredientRecord
|
||||||
fields = ["name"]
|
fields = ["name", "from_dataset"]
|
||||||
|
|
||||||
|
|
||||||
class FoodRecordSerializer(serializers.ModelSerializer):
|
class FoodRecordSerializer(serializers.ModelSerializer):
|
||||||
@@ -194,8 +253,6 @@ class BeverageRecordSerializer(serializers.ModelSerializer):
|
|||||||
model = BeverageRecord
|
model = BeverageRecord
|
||||||
fields = [
|
fields = [
|
||||||
"beverage_type",
|
"beverage_type",
|
||||||
"glass_type",
|
|
||||||
"glass_count",
|
|
||||||
"quantity",
|
"quantity",
|
||||||
"quantity_measure",
|
"quantity_measure",
|
||||||
]
|
]
|
||||||
@@ -334,6 +391,18 @@ class BowelSerializer(serializers.ModelSerializer):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class MealRecordSymptomsSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = MealRecord
|
||||||
|
fields = [
|
||||||
|
"id",
|
||||||
|
"date",
|
||||||
|
"time",
|
||||||
|
"meal_type",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class SymptomTypeBeforeMealSerializer(serializers.ModelSerializer):
|
class SymptomTypeBeforeMealSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = SymptomTypeBeforeMeal
|
model = SymptomTypeBeforeMeal
|
||||||
@@ -349,6 +418,10 @@ class SymptomTypeAfterMealSerializer(serializers.ModelSerializer):
|
|||||||
class MealSymptomRecordSerializer(serializers.ModelSerializer):
|
class MealSymptomRecordSerializer(serializers.ModelSerializer):
|
||||||
symptoms_before_meal = SymptomTypeBeforeMealSerializer(many=True)
|
symptoms_before_meal = SymptomTypeBeforeMealSerializer(many=True)
|
||||||
symptoms_after_meal = SymptomTypeAfterMealSerializer(many=True)
|
symptoms_after_meal = SymptomTypeAfterMealSerializer(many=True)
|
||||||
|
related_meal_id = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=MealRecord.objects.all(), write_only=True
|
||||||
|
) # Added field to accept meal ID
|
||||||
|
related_meal = MealRecordSymptomsSerializer(read_only=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = MealSymptomRecord
|
model = MealSymptomRecord
|
||||||
@@ -360,13 +433,18 @@ class MealSymptomRecordSerializer(serializers.ModelSerializer):
|
|||||||
"interval",
|
"interval",
|
||||||
"symptoms_before_meal",
|
"symptoms_before_meal",
|
||||||
"symptoms_after_meal",
|
"symptoms_after_meal",
|
||||||
|
"related_meal_id",
|
||||||
|
"related_meal"
|
||||||
]
|
]
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
before_meal_data = validated_data.pop("symptoms_before_meal")
|
before_meal_data = validated_data.pop("symptoms_before_meal")
|
||||||
after_meal_data = validated_data.pop("symptoms_after_meal")
|
after_meal_data = validated_data.pop("symptoms_after_meal")
|
||||||
|
related_meal_id = validated_data.pop("related_meal_id")
|
||||||
|
|
||||||
meal_symptom_record = MealSymptomRecord.objects.create(**validated_data)
|
meal_symptom_record = MealSymptomRecord.objects.create(
|
||||||
|
related_meal=related_meal_id, **validated_data
|
||||||
|
)
|
||||||
|
|
||||||
before_meal_list = []
|
before_meal_list = []
|
||||||
for data in before_meal_data:
|
for data in before_meal_data:
|
||||||
@@ -391,6 +469,10 @@ class MealSymptomRecordSerializer(serializers.ModelSerializer):
|
|||||||
)
|
)
|
||||||
instance.interval = validated_data.get("interval", instance.interval)
|
instance.interval = validated_data.get("interval", instance.interval)
|
||||||
|
|
||||||
|
related_meal_id = validated_data.pop("related_meal_id", None) # Extract meal ID
|
||||||
|
if related_meal_id is not None:
|
||||||
|
instance.related_meal = related_meal_id
|
||||||
|
|
||||||
before_meal_data = validated_data.pop("symptoms_before_meal", [])
|
before_meal_data = validated_data.pop("symptoms_before_meal", [])
|
||||||
after_meal_data = validated_data.pop("symptoms_after_meal", [])
|
after_meal_data = validated_data.pop("symptoms_after_meal", [])
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ urlpatterns = [
|
|||||||
path("meal/date/", views.MealDateAPIView.as_view()),
|
path("meal/date/", views.MealDateAPIView.as_view()),
|
||||||
path("meal/<int:pk>/", views.MealAPIView.as_view()),
|
path("meal/<int:pk>/", views.MealAPIView.as_view()),
|
||||||
|
|
||||||
|
path("food/data/", views.FoodDataAPIView.as_view()),
|
||||||
|
path("food/ingredient/data/", views.FoodIngredientSearchAPIView.as_view()),
|
||||||
|
|
||||||
path("report/", views.ReportAPIView.as_view()),
|
path("report/", views.ReportAPIView.as_view()),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ from module_project import constants, date_utils
|
|||||||
from module_project.service import OneSignalNotificationService
|
from module_project.service import OneSignalNotificationService
|
||||||
from module_project.utils import ApiResponse
|
from module_project.utils import ApiResponse
|
||||||
|
|
||||||
from ..models import (Bowel, ChronicCondition, Intolerance, MealRecord,
|
from ..models import (FoodIngredintDataset, Bowel, ChronicCondition, Intolerance, MealRecord,
|
||||||
MealSymptomRecord, Medication, PastTreatment,
|
MealSymptomRecord, Medication, PastTreatment,
|
||||||
PrincipalHealthData, Symptoms)
|
PrincipalHealthData, Symptoms)
|
||||||
from .serializers import (BowelSerializer, ChronicConditionSerializer,
|
from .serializers import (FoodDatasetSerializer, FoodIngredientDatasetSerializer, BowelSerializer, ChronicConditionSerializer,
|
||||||
IAmPrincipalSerializer, IntoleranceSerializer,
|
IAmPrincipalSerializer, IntoleranceSerializer,
|
||||||
MealRecordSerializer, MealSymptomRecordSerializer,
|
MealRecordSerializer, MealSymptomRecordSerializer,
|
||||||
MedicationSerializer, PastTreatmentSerializer,
|
MedicationSerializer, PastTreatmentSerializer,
|
||||||
@@ -157,7 +157,7 @@ class DailyRecordAPIView(APIView):
|
|||||||
).get(id=request.user.id)
|
).get(id=request.user.id)
|
||||||
|
|
||||||
serialized_meal_records = [
|
serialized_meal_records = [
|
||||||
{"type": "Meal", **self.serialize_record(record)}
|
{"type": f"Meal - {record.meal_type}", **self.serialize_record(record)}
|
||||||
for record in principal.filtered_meal_record
|
for record in principal.filtered_meal_record
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -617,6 +617,34 @@ class MealAPIView(APIView):
|
|||||||
message=constants.RECORD_DELETED, status=status.HTTP_204_NO_CONTENT
|
message=constants.RECORD_DELETED, status=status.HTTP_204_NO_CONTENT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class FoodDataAPIView(APIView):
|
||||||
|
authentication_classes = [JWTAuthentication]
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
serializer_class = FoodDatasetSerializer
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
obj = self.model.objects.all().order_by("food_name")
|
||||||
|
serializer = self.serializer_class(obj, many=True)
|
||||||
|
return ApiResponse.success(message=constants.SUCCESS, data=serializer.data)
|
||||||
|
|
||||||
|
class FoodIngredientSearchAPIView(APIView):
|
||||||
|
authentication_classes = [JWTAuthentication]
|
||||||
|
permission_classes = [IsAuthenticated]
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
serializer_class = FoodIngredientDatasetSerializer
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
query = request.query_params.getlist('query')
|
||||||
|
print(f"Query : {query}")
|
||||||
|
obj = self.model.objects.filter(food_name__in=query).values_list('ingredients', flat=True)
|
||||||
|
|
||||||
|
unique_ingredients = set()
|
||||||
|
for ingredients_list in obj:
|
||||||
|
unique_ingredients.update(ingredients_list)
|
||||||
|
# serializer = self.serializer_class(obj, many=True)
|
||||||
|
return ApiResponse.success(message=constants.SUCCESS, data={'ingredients_list': list(unique_ingredients)})
|
||||||
|
|
||||||
class MealDateAPIView(APIView):
|
class MealDateAPIView(APIView):
|
||||||
authentication_classes = [JWTAuthentication]
|
authentication_classes = [JWTAuthentication]
|
||||||
permission_classes = [IsAuthenticated]
|
permission_classes = [IsAuthenticated]
|
||||||
|
|||||||
@@ -3,9 +3,17 @@ from django import forms
|
|||||||
from module_iam.models import IAmPrincipal
|
from module_iam.models import IAmPrincipal
|
||||||
from module_project import constants
|
from module_project import constants
|
||||||
|
|
||||||
from .models import ChronicCondition, Intolerance, PastTreatment, Symptoms
|
from .models import FoodIngredintDataset, ChronicCondition, Intolerance, PastTreatment, Symptoms
|
||||||
|
|
||||||
|
|
||||||
|
class FoodIngredintDatasetForm(forms.ModelForm):
|
||||||
|
class Meta:
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
fields = ['food_name', 'ingredients']
|
||||||
|
|
||||||
|
class UploadFileForm(forms.Form):
|
||||||
|
file = forms.FileField()
|
||||||
|
|
||||||
class IntoleranceForm(forms.ModelForm):
|
class IntoleranceForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Intolerance
|
model = Intolerance
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-26 10:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0009_bowel_active_bowel_created_by_bowel_created_on_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='converted_height_cm',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='The equivalent height converted into centimeters.', max_digits=5, null=True, verbose_name='Converted Height'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='converted_weight_kg',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, help_text='The equivalent weight converted into kilograms.', max_digits=5, null=True, verbose_name='Converted Weight'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='height_unit',
|
||||||
|
field=models.CharField(blank=True, choices=[('cm', 'cm'), ('ft+inch', 'ft+inch')], help_text='Select your height unit.', max_length=10, null=True, verbose_name='Height Unit'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='weight_unit',
|
||||||
|
field=models.CharField(blank=True, choices=[('kg', 'kg'), ('lbs', 'lbs')], help_text='Select your weight unit.', max_length=10, null=True, verbose_name='Weight Unit'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='height',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, default=0.0, help_text='Enter your height in centimeters.', max_digits=6, null=True, verbose_name='Height'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='principalhealthdata',
|
||||||
|
name='weight',
|
||||||
|
field=models.DecimalField(blank=True, decimal_places=2, default=0.0, help_text='Enter your weight in kilograms.', max_digits=5, null=True, verbose_name='Weight'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-27 07:14
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0010_principalhealthdata_converted_height_cm_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='mealsymptomrecord',
|
||||||
|
name='related_meal',
|
||||||
|
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='symptom_related_meal', to='module_activity.mealrecord'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-27 13:55
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0011_mealsymptomrecord_related_meal'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='pasttreatment',
|
||||||
|
name='is_recurring',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='pasttreatment',
|
||||||
|
name='treatment_frequency',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
24
module_activity/migrations/0013_foodingredintdataset.py
Normal file
24
module_activity/migrations/0013_foodingredintdataset.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-28 07:47
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0012_pasttreatment_is_recurring_and_more'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='FoodIngredintDataset',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('food_name', models.CharField(max_length=100)),
|
||||||
|
('ingredients', models.JSONField(default=list)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'food_ingredient_dataset',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-28 13:49
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0013_foodingredintdataset'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='foodingredientrecord',
|
||||||
|
name='from_dataset',
|
||||||
|
field=models.BooleanField(default=False),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-28 14:12
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_activity', '0014_foodingredientrecord_from_dataset'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='beveragerecord',
|
||||||
|
name='glass_count',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='beveragerecord',
|
||||||
|
name='glass_type',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,9 +1,23 @@
|
|||||||
|
import json
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
from module_iam.models import BaseModel, IAmPrincipal
|
from module_iam.models import BaseModel, IAmPrincipal
|
||||||
|
|
||||||
|
|
||||||
# Create your models here.
|
class FoodIngredintDataset(models.Model):
|
||||||
|
food_name = models.CharField(max_length=100)
|
||||||
|
ingredients = models.JSONField(default=list)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
db_table = "food_ingredient_dataset"
|
||||||
|
|
||||||
|
def set_ingredients(self, x):
|
||||||
|
self.ingredients = json.dumps(x)
|
||||||
|
|
||||||
|
def get_ingredients(self):
|
||||||
|
return json.loads(self.ingredients)
|
||||||
|
|
||||||
|
|
||||||
class PrincipalHealthData(BaseModel):
|
class PrincipalHealthData(BaseModel):
|
||||||
principal = models.OneToOneField(
|
principal = models.OneToOneField(
|
||||||
IAmPrincipal,
|
IAmPrincipal,
|
||||||
@@ -53,20 +67,62 @@ class PrincipalHealthData(BaseModel):
|
|||||||
default=0.0,
|
default=0.0,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
verbose_name="Weight (kg)",
|
verbose_name="Weight",
|
||||||
help_text="Enter your weight in kilograms.",
|
help_text="Enter your weight in kilograms.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
weight_unit = models.CharField(
|
||||||
|
max_length=10,
|
||||||
|
choices=[
|
||||||
|
('kg', 'kg'),
|
||||||
|
('lbs', 'lbs'),
|
||||||
|
],
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
verbose_name="Weight Unit",
|
||||||
|
help_text="Select your weight unit.",
|
||||||
|
)
|
||||||
|
|
||||||
|
converted_weight_kg = models.DecimalField(
|
||||||
|
max_digits=5,
|
||||||
|
decimal_places=2,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
verbose_name="Converted Weight",
|
||||||
|
help_text="The equivalent weight converted into kilograms.",
|
||||||
|
)
|
||||||
|
|
||||||
height = models.DecimalField(
|
height = models.DecimalField(
|
||||||
max_digits=6,
|
max_digits=6,
|
||||||
decimal_places=2,
|
decimal_places=2,
|
||||||
default=0.0,
|
default=0.0,
|
||||||
blank=True,
|
blank=True,
|
||||||
null=True,
|
null=True,
|
||||||
verbose_name="Height (cm)",
|
verbose_name="Height",
|
||||||
help_text="Enter your height in centimeters.",
|
help_text="Enter your height in centimeters.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
height_unit = models.CharField(
|
||||||
|
max_length=10,
|
||||||
|
choices=[
|
||||||
|
('cm', 'cm'),
|
||||||
|
('ft+inch', 'ft+inch'),
|
||||||
|
],
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
verbose_name="Height Unit",
|
||||||
|
help_text="Select your height unit.",
|
||||||
|
)
|
||||||
|
|
||||||
|
converted_height_cm = models.DecimalField(
|
||||||
|
max_digits=5,
|
||||||
|
decimal_places=2,
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
verbose_name="Converted Height",
|
||||||
|
help_text="The equivalent height converted into centimeters.",
|
||||||
|
)
|
||||||
|
|
||||||
# Eat frequency (choices if applicable)
|
# Eat frequency (choices if applicable)
|
||||||
eat_frequency = models.CharField(
|
eat_frequency = models.CharField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
@@ -81,6 +137,26 @@ class PrincipalHealthData(BaseModel):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"Health Data for {self.principal}"
|
return f"Health Data for {self.principal}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def converted_height_in_cm(self):
|
||||||
|
if self.height_unit == 'ft+inch':
|
||||||
|
feet, inches = divmod(float(self.height) * 10, 12)
|
||||||
|
return round(feet * 30.48 + inches * 2.54, 2) # Convert feet to cm and inches to cm
|
||||||
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def converted_weight_in_kg(self):
|
||||||
|
if self.weight_unit == 'lbs':
|
||||||
|
return round(float(self.weight) * 0.453592, 2) # Convert pounds to kg
|
||||||
|
return None
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.height_unit == 'ft+inch':
|
||||||
|
self.converted_height_cm = self.converted_height_in_cm # Update converted height
|
||||||
|
if self.weight_unit == 'lbs':
|
||||||
|
self.converted_weight_kg = self.converted_weight_in_kg # Update converted weight
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Intolerance(BaseModel):
|
class Intolerance(BaseModel):
|
||||||
@@ -126,6 +202,8 @@ class PastTreatment(BaseModel):
|
|||||||
)
|
)
|
||||||
name = models.CharField(max_length=255, blank=True, null=True)
|
name = models.CharField(max_length=255, blank=True, null=True)
|
||||||
duration = models.DateField()
|
duration = models.DateField()
|
||||||
|
is_recurring = models.BooleanField(default=False)
|
||||||
|
treatment_frequency = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "past_treatment"
|
db_table = "past_treatment"
|
||||||
@@ -153,6 +231,7 @@ class ChronicCondition(BaseModel):
|
|||||||
|
|
||||||
class FoodIngredientRecord(models.Model):
|
class FoodIngredientRecord(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
|
from_dataset = models.BooleanField(default=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "food_ingredient_record"
|
db_table = "food_ingredient_record"
|
||||||
@@ -166,8 +245,6 @@ class FoodRecord(models.Model):
|
|||||||
|
|
||||||
class BeverageRecord(models.Model):
|
class BeverageRecord(models.Model):
|
||||||
beverage_type = models.CharField(max_length=100)
|
beverage_type = models.CharField(max_length=100)
|
||||||
glass_type = models.CharField(max_length=100)
|
|
||||||
glass_count = models.IntegerField()
|
|
||||||
quantity = models.IntegerField()
|
quantity = models.IntegerField()
|
||||||
quantity_measure = models.CharField(max_length=100)
|
quantity_measure = models.CharField(max_length=100)
|
||||||
|
|
||||||
@@ -278,6 +355,7 @@ class SymptomTypeAfterMeal(models.Model):
|
|||||||
|
|
||||||
class MealSymptomRecord(BaseModel):
|
class MealSymptomRecord(BaseModel):
|
||||||
principal = models.ForeignKey(IAmPrincipal, related_name="meal_symptom_principal", on_delete=models.CASCADE)
|
principal = models.ForeignKey(IAmPrincipal, related_name="meal_symptom_principal", on_delete=models.CASCADE)
|
||||||
|
related_meal = models.ForeignKey(MealRecord, related_name="symptom_related_meal", on_delete=models.SET_NULL, null=True)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
time = models.TimeField()
|
time = models.TimeField()
|
||||||
symptoms_description = models.TextField(blank=True, null=True)
|
symptoms_description = models.TextField(blank=True, null=True)
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ app_name = "module_activity"
|
|||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
||||||
|
|
||||||
|
path('populate/food/dataset/', views.PopulateFoodIngredientView.as_view(), name='populate_food'),
|
||||||
|
|
||||||
path('intolerance/<int:principal_id>/', views.IntoleranceView.as_view(), name='intolerance'),
|
path('intolerance/<int:principal_id>/', views.IntoleranceView.as_view(), name='intolerance'),
|
||||||
path('intolerance/<int:principal_id>/add/', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_add'),
|
path('intolerance/<int:principal_id>/add/', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_add'),
|
||||||
path('intolerance/<int:principal_id>/edit/<int:pk>', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_edit'),
|
path('intolerance/<int:principal_id>/edit/<int:pk>', views.CreateOrUpdateIntoleranceView.as_view(), name='intolerance_edit'),
|
||||||
@@ -37,6 +39,19 @@ urlpatterns = [
|
|||||||
path('chronic_condition/action/', views.ChronicConditionActionView.as_view(), name='chronic_condition_action'),
|
path('chronic_condition/action/', views.ChronicConditionActionView.as_view(), name='chronic_condition_action'),
|
||||||
path('chronic_condition/archive/list/<int:principal_id>/', views.ChronicConditionArchiveView.as_view(), name='chronic_condition_archive'),
|
path('chronic_condition/archive/list/<int:principal_id>/', views.ChronicConditionArchiveView.as_view(), name='chronic_condition_archive'),
|
||||||
|
|
||||||
|
path('user/meal/<int:principal_id>/', views.MealView.as_view(), name='meal_view'),
|
||||||
|
path('user/meal/list/<int:principal_id>/', views.MealListJsonView.as_view(), name='meal_list'),
|
||||||
|
|
||||||
|
path('user/medication/<int:principal_id>/', views.MedicationView.as_view(), name='medication_view'),
|
||||||
|
path('user/medication/list/<int:principal_id>/', views.MedicationListJsonView.as_view(), name='medication_list'),
|
||||||
|
|
||||||
|
path('user/bowel/<int:principal_id>/', views.BowelView.as_view(), name='bowel_view'),
|
||||||
|
path('user/bowel/list/<int:principal_id>/', views.BowelListJsonView.as_view(), name='bowel_list'),
|
||||||
|
|
||||||
|
path('user/meal-symptoms/<int:principal_id>/', views.MealSymptomsView.as_view(), name='meal_symptoms_view'),
|
||||||
|
path('user/meal-symptoms/list/<int:principal_id>/', views.MealSymptomsListJsonView.as_view(), name='meal_symptoms_list'),
|
||||||
|
|
||||||
|
|
||||||
path('user_activity/<int:principal_id>/', views.UserActivityRecordView.as_view(), name='activity_list'),
|
path('user_activity/<int:principal_id>/', views.UserActivityRecordView.as_view(), name='activity_list'),
|
||||||
path('meal_detail/<int:pk>/', views.MealDetialView.as_view(), name='meal_detail'),
|
path('meal_detail/<int:pk>/', views.MealDetialView.as_view(), name='meal_detail'),
|
||||||
path('medication_detail/<int:pk>/', views.MedicationDetailView.as_view(), name='medication_detail'),
|
path('medication_detail/<int:pk>/', views.MedicationDetailView.as_view(), name='medication_detail'),
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
import csv
|
||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.db.models import Count, Prefetch, Q
|
from django.db.models import Count, Prefetch, Q
|
||||||
@@ -17,9 +19,10 @@ from module_project import constants, date_utils
|
|||||||
from module_project.utils import JsonResponseUtil
|
from module_project.utils import JsonResponseUtil
|
||||||
|
|
||||||
from .forms import (ChronicConditionForm, IntoleranceForm, PastTreatmentForm,
|
from .forms import (ChronicConditionForm, IntoleranceForm, PastTreatmentForm,
|
||||||
SymptomsForm)
|
SymptomsForm, UploadFileForm)
|
||||||
from .models import (Bowel, ChronicCondition, Intolerance, MealRecord,
|
from .models import (Bowel, ChronicCondition, FoodIngredintDataset,
|
||||||
MealSymptomRecord, Medication, PastTreatment, Symptoms)
|
Intolerance, MealRecord, MealSymptomRecord, Medication,
|
||||||
|
PastTreatment, Symptoms)
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -29,7 +32,7 @@ class BaseView(generic.TemplateView):
|
|||||||
resource = None
|
resource = None
|
||||||
action = None
|
action = None
|
||||||
template_name = None
|
template_name = None
|
||||||
model = Intolerance
|
model = None
|
||||||
context_objext_name = "obj"
|
context_objext_name = "obj"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
@@ -151,6 +154,62 @@ class BaseArchiveView(generic.TemplateView):
|
|||||||
data["principal_id"] = kwargs.get("principal_id")
|
data["principal_id"] = kwargs.get("principal_id")
|
||||||
data["page_name"] = self.page_name
|
data["page_name"] = self.page_name
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
class PopulateFoodIngredientView(generic.View):
|
||||||
|
# Set the page_name and resource
|
||||||
|
page_name = iam_constant.RESOURCE_MANAGE_DASHBOARD
|
||||||
|
resource = iam_constant.RESOURCE_MANAGE_DASHBOARD
|
||||||
|
template_name = "module_activity/food_ingredient_form.html"
|
||||||
|
model = FoodIngredintDataset
|
||||||
|
form_class = UploadFileForm
|
||||||
|
success_url = reverse_lazy("module_iam:dashboard")
|
||||||
|
error_message = "An error occurred while saving the data."
|
||||||
|
|
||||||
|
# Add page_name and operation to the context
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = {
|
||||||
|
"page_name": self.page_name,
|
||||||
|
"operation": "Add",
|
||||||
|
}
|
||||||
|
context.update(kwargs) # Include any additional context data passed to the view
|
||||||
|
return context
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
form = self.form_class()
|
||||||
|
context = self.get_context_data(form=form)
|
||||||
|
return render(request, self.template_name, context=context)
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
print("Request data: ", request.POST)
|
||||||
|
|
||||||
|
form = self.form_class(request.POST, request.FILES)
|
||||||
|
|
||||||
|
if not form.is_valid():
|
||||||
|
print(form.errors)
|
||||||
|
context = self.get_context_data(form=form)
|
||||||
|
return render(request, self.template_name, context=context)
|
||||||
|
|
||||||
|
uploaded_file = request.FILES['file']
|
||||||
|
# decoded_file = uploaded_file.read().decode('utf-8', errors='ignore').splitlines()
|
||||||
|
# csv_reader = csv.reader(decoded_file)
|
||||||
|
|
||||||
|
df = pd.read_excel(uploaded_file)
|
||||||
|
|
||||||
|
for index, row in df.iterrows():
|
||||||
|
food_name = row['Food'].strip().capitalize()
|
||||||
|
ingredients_str = row['Ingredients'].strip()
|
||||||
|
ingredients = [ingredient.strip().capitalize() for ingredient in ingredients_str.split(',')]
|
||||||
|
|
||||||
|
if self.model.objects.filter(food_name=food_name).exists():
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"{food_name} : {ingredients}")
|
||||||
|
food = self.model(food_name=food_name, ingredients=ingredients)
|
||||||
|
food.save()
|
||||||
|
|
||||||
|
messages.success(self.request, constants.RECORD_CREATED)
|
||||||
|
return redirect(self.success_url)
|
||||||
|
|
||||||
|
|
||||||
class IntoleranceView(BaseView):
|
class IntoleranceView(BaseView):
|
||||||
@@ -249,6 +308,119 @@ class ChronicConditionArchiveView(generic.TemplateView):
|
|||||||
template_name = "module_activity/chronic_condition_archive_list.html"
|
template_name = "module_activity/chronic_condition_archive_list.html"
|
||||||
|
|
||||||
|
|
||||||
|
class MealView(BaseView):
|
||||||
|
template_name = "module_activity/meal_list.html"
|
||||||
|
|
||||||
|
|
||||||
|
class MealListJsonView(BaseDatatableView):
|
||||||
|
model = MealRecord
|
||||||
|
columns = ["id", "date", "time", "meal_type"]
|
||||||
|
order_columns = ["id", "date", "time", "meal_type"]
|
||||||
|
|
||||||
|
def get_initial_queryset(self):
|
||||||
|
principal_id = self.kwargs.get("principal_id")
|
||||||
|
deleted_flag = self.request.GET.get("deleted_flag", None)
|
||||||
|
return self.model.objects.filter(principal=principal_id, deleted=deleted_flag)
|
||||||
|
|
||||||
|
def ordering(self, qs):
|
||||||
|
qs = super().ordering(qs)
|
||||||
|
order = self.request.GET.get('order[0][dir]', None)
|
||||||
|
if order:
|
||||||
|
column_index = int(self.request.GET.get('order[0][column]', None)) - 1
|
||||||
|
order_column = self.order_columns[column_index]
|
||||||
|
|
||||||
|
if order == "asc":
|
||||||
|
qs = qs.order_by(order_column)
|
||||||
|
elif order == "desc":
|
||||||
|
qs = qs.order_by("-" + order_column)
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class MedicationView(BaseView):
|
||||||
|
template_name = "module_activity/medication_list.html"
|
||||||
|
|
||||||
|
|
||||||
|
class MedicationListJsonView(BaseDatatableView):
|
||||||
|
model = Medication
|
||||||
|
columns = ["id", "date", "time"]
|
||||||
|
order_columns = ["id", "date", "time"]
|
||||||
|
|
||||||
|
def get_initial_queryset(self):
|
||||||
|
principal_id = self.kwargs.get("principal_id")
|
||||||
|
deleted_flag = self.request.GET.get("deleted_flag", None)
|
||||||
|
return self.model.objects.filter(principal=principal_id, deleted=deleted_flag)
|
||||||
|
|
||||||
|
def ordering(self, qs):
|
||||||
|
order = self.request.GET.get('order[0][dir]', None)
|
||||||
|
if order:
|
||||||
|
column_index = int(self.request.GET.get('order[0][column]', None)) - 1
|
||||||
|
order_column = self.order_columns[column_index]
|
||||||
|
|
||||||
|
if order == "asc":
|
||||||
|
qs = qs.order_by(order_column)
|
||||||
|
elif order == "desc":
|
||||||
|
qs = qs.order_by("-" + order_column)
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class BowelView(BaseView):
|
||||||
|
template_name = "module_activity/bowel_list.html"
|
||||||
|
|
||||||
|
|
||||||
|
class BowelListJsonView(BaseDatatableView):
|
||||||
|
model = Bowel
|
||||||
|
columns = ["id", "date", "time", "stool_type"]
|
||||||
|
order_columns = ["id", "date", "time", "stool_type"]
|
||||||
|
|
||||||
|
def get_initial_queryset(self):
|
||||||
|
principal_id = self.kwargs.get("principal_id")
|
||||||
|
deleted_flag = self.request.GET.get("deleted_flag", None)
|
||||||
|
return self.model.objects.filter(principal=principal_id, deleted=deleted_flag)
|
||||||
|
|
||||||
|
def ordering(self, qs):
|
||||||
|
order = self.request.GET.get('order[0][dir]', None)
|
||||||
|
if order:
|
||||||
|
column_index = int(self.request.GET.get('order[0][column]', None)) - 1
|
||||||
|
order_column = self.order_columns[column_index]
|
||||||
|
|
||||||
|
if order == "asc":
|
||||||
|
qs = qs.order_by(order_column)
|
||||||
|
elif order == "desc":
|
||||||
|
qs = qs.order_by("-" + order_column)
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
|
class MealSymptomsView(BaseView):
|
||||||
|
template_name = "module_activity/meal_symptoms_list.html"
|
||||||
|
|
||||||
|
|
||||||
|
class MealSymptomsListJsonView(BaseDatatableView):
|
||||||
|
model = MealSymptomRecord
|
||||||
|
columns = ["id", "date", "time"]
|
||||||
|
order_columns = ["id", "date", "time"]
|
||||||
|
|
||||||
|
def get_initial_queryset(self):
|
||||||
|
principal_id = self.kwargs.get("principal_id")
|
||||||
|
deleted_flag = self.request.GET.get("deleted_flag", None)
|
||||||
|
return self.model.objects.filter(principal=principal_id, deleted=deleted_flag)
|
||||||
|
|
||||||
|
def ordering(self, qs):
|
||||||
|
order = self.request.GET.get('order[0][dir]', None)
|
||||||
|
if order:
|
||||||
|
column_index = int(self.request.GET.get('order[0][column]', None)) - 1
|
||||||
|
order_column = self.order_columns[column_index]
|
||||||
|
|
||||||
|
if order == "asc":
|
||||||
|
qs = qs.order_by(order_column)
|
||||||
|
elif order == "desc":
|
||||||
|
qs = qs.order_by("-" + order_column)
|
||||||
|
|
||||||
|
return qs
|
||||||
|
|
||||||
|
|
||||||
class UserActivityRecordView(generic.View):
|
class UserActivityRecordView(generic.View):
|
||||||
def serialize_record(self, record):
|
def serialize_record(self, record):
|
||||||
time_obj = datetime.strptime(str(record.time), "%H:%M:%S")
|
time_obj = datetime.strptime(str(record.time), "%H:%M:%S")
|
||||||
@@ -356,6 +528,7 @@ class BowelDetailView(generic.TemplateView):
|
|||||||
def get_record(self):
|
def get_record(self):
|
||||||
id = self.kwargs.get("pk")
|
id = self.kwargs.get("pk")
|
||||||
obj = get_object_or_404(self.model, id=id)
|
obj = get_object_or_404(self.model, id=id)
|
||||||
|
print(f"obj data of bowel is {obj}")
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
@@ -533,7 +706,7 @@ class ReportDataView(generic.View):
|
|||||||
if not self.enough_records_exist(start_date, end_date):
|
if not self.enough_records_exist(start_date, end_date):
|
||||||
print("report does not exist")
|
print("report does not exist")
|
||||||
return JsonResponseUtil.success(
|
return JsonResponseUtil.success(
|
||||||
message="No report is generated. Minimum Previous 7 days of records required.", status=204
|
message="No report is generated. Minimum Previous 7 days of records required.", status=202
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get top food to avoid
|
# Get top food to avoid
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ from django.urls import reverse_lazy
|
|||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django_datatables_view.base_datatable_view import BaseDatatableView
|
from django_datatables_view.base_datatable_view import BaseDatatableView
|
||||||
|
|
||||||
from module_activity.models import (ChronicCondition, Intolerance,
|
from module_activity.models import (Bowel, ChronicCondition, Intolerance, MealRecord, MealSymptomRecord, Medication,
|
||||||
PastTreatment, PrincipalHealthData,
|
PastTreatment, PrincipalHealthData,
|
||||||
Symptoms)
|
Symptoms)
|
||||||
from module_iam import iam_constant
|
from module_iam import iam_constant
|
||||||
@@ -58,6 +58,7 @@ class AdminLoginView(generic.View):
|
|||||||
return render(request, self.template_name, context=context)
|
return render(request, self.template_name, context=context)
|
||||||
|
|
||||||
login(request, user)
|
login(request, user)
|
||||||
|
messages.success(request, constants.LOGIN_SUCCESS)
|
||||||
logging.info(f"User {user.email} logged in.")
|
logging.info(f"User {user.email} logged in.")
|
||||||
|
|
||||||
return redirect(self.success_url)
|
return redirect(self.success_url)
|
||||||
@@ -85,6 +86,7 @@ class UserDashView(LoginRequiredMixin, generic.TemplateView):
|
|||||||
model = IAmPrincipal
|
model = IAmPrincipal
|
||||||
context_objext_name = "obj"
|
context_objext_name = "obj"
|
||||||
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["page_name"] = self.page_name
|
context["page_name"] = self.page_name
|
||||||
@@ -163,7 +165,7 @@ class UserListJson(BaseDatatableView):
|
|||||||
qs = super().filter_queryset(qs) # Call the built-in filtering first
|
qs = super().filter_queryset(qs) # Call the built-in filtering first
|
||||||
|
|
||||||
for column in self.columns:
|
for column in self.columns:
|
||||||
print(f" columen index pattern {self.request.GET.get(f'columns[{self.columns.index(column)+1}][search][value]', None)}")
|
print(f" columen index pattern {self.request.GET.get(f'columns[{self.columns.index(column)+2}][search][value]', None)}")
|
||||||
search_value = self.request.GET.get(f'columns[{self.columns.index(column)+1}][search][value]', None)
|
search_value = self.request.GET.get(f'columns[{self.columns.index(column)+1}][search][value]', None)
|
||||||
if search_value:
|
if search_value:
|
||||||
column_data = self.request.GET.get(f'columns[{self.columns.index(column)+1}][data]')
|
column_data = self.request.GET.get(f'columns[{self.columns.index(column)+1}][data]')
|
||||||
@@ -177,7 +179,7 @@ class UserListJson(BaseDatatableView):
|
|||||||
def ordering(self, qs):
|
def ordering(self, qs):
|
||||||
order = self.request.GET.get('order[0][dir]', None)
|
order = self.request.GET.get('order[0][dir]', None)
|
||||||
if order:
|
if order:
|
||||||
column_index = int(self.request.GET.get('order[0][column]', None)) - 1
|
column_index = int(self.request.GET.get('order[0][column]', None)) - 2
|
||||||
order_column = self.order_columns[column_index]
|
order_column = self.order_columns[column_index]
|
||||||
|
|
||||||
if order == "asc":
|
if order == "asc":
|
||||||
@@ -220,6 +222,30 @@ class UserRecordView(LoginRequiredMixin, generic.View):
|
|||||||
model = IAmPrincipal
|
model = IAmPrincipal
|
||||||
template_name = "module_auth/user_view.html"
|
template_name = "module_auth/user_view.html"
|
||||||
|
|
||||||
|
def get_recent_meal(self, id):
|
||||||
|
recent_meal_records = MealRecord.objects.filter(
|
||||||
|
principal=id
|
||||||
|
).order_by('-id')[:5]
|
||||||
|
return recent_meal_records
|
||||||
|
|
||||||
|
def get_recent_medication(self, id):
|
||||||
|
recent_medication_records = Medication.objects.filter(
|
||||||
|
principal=id
|
||||||
|
).order_by('-id')[:5]
|
||||||
|
return recent_medication_records
|
||||||
|
|
||||||
|
def get_recent_bowel(self, id):
|
||||||
|
recent_bowel_records = Bowel.objects.filter(
|
||||||
|
principal=id
|
||||||
|
).order_by('-id')[:5]
|
||||||
|
return recent_bowel_records
|
||||||
|
|
||||||
|
def get_recent_meal_symptom(self, id):
|
||||||
|
recent_meal_symptom_records = MealSymptomRecord.objects.filter(
|
||||||
|
principal=id
|
||||||
|
).order_by('-id')[:5]
|
||||||
|
|
||||||
|
|
||||||
def get(self, request, id):
|
def get(self, request, id):
|
||||||
# Retrieve the IAmPrincipal instance
|
# Retrieve the IAmPrincipal instance
|
||||||
principal_instance = get_object_or_404(IAmPrincipal, id=id)
|
principal_instance = get_object_or_404(IAmPrincipal, id=id)
|
||||||
@@ -260,8 +286,17 @@ class UserRecordView(LoginRequiredMixin, generic.View):
|
|||||||
for data in obj.chronic_data:
|
for data in obj.chronic_data:
|
||||||
print(f"data is {data.name, data.duration}")
|
print(f"data is {data.name, data.duration}")
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'page_name': self.page_name,
|
||||||
|
'obj': obj,
|
||||||
|
"recent_meal": self.get_recent_meal(id),
|
||||||
|
"recent_medication": self.get_recent_medication(id),
|
||||||
|
"recent_bowel": self.get_recent_bowel(id),
|
||||||
|
"recent_meal_symptom": self.get_recent_meal_symptom(id),
|
||||||
|
}
|
||||||
|
|
||||||
# Render the template with the principal instance and related data
|
# Render the template with the principal instance and related data
|
||||||
return render(request, self.template_name, {'obj': obj, 'page_name': self.page_name})
|
return render(request, self.template_name, context=context)
|
||||||
|
|
||||||
|
|
||||||
class UserArchiveList(LoginRequiredMixin, generic.TemplateView):
|
class UserArchiveList(LoginRequiredMixin, generic.TemplateView):
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Generated by Django 5.0.2 on 2024-03-26 22:11
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('module_cms', '0003_alter_faqs_faq_category'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='faqs',
|
||||||
|
name='answer',
|
||||||
|
field=models.TextField(default=1),
|
||||||
|
preserve_default=False,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='faqs',
|
||||||
|
name='question',
|
||||||
|
field=models.TextField(),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -43,8 +43,8 @@ class Faqs(BaseModel):
|
|||||||
faq_category = models.ForeignKey(
|
faq_category = models.ForeignKey(
|
||||||
FaqCategory, related_name="faqs_category", blank=True, null=True, on_delete=models.SET_NULL
|
FaqCategory, related_name="faqs_category", blank=True, null=True, on_delete=models.SET_NULL
|
||||||
)
|
)
|
||||||
question = models.TextField(max_length=255)
|
question = models.TextField()
|
||||||
answer = models.TextField(blank=True, null=True)
|
answer = models.TextField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "faq"
|
db_table = "faq"
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ from .iam_constant import (PRINCIPAL_SOURCE_APP, PRINCIPAL_SOURCE_APPLE,
|
|||||||
# from phonenumber_field.modelfields import PhoneNumberField
|
# from phonenumber_field.modelfields import PhoneNumberField
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class BaseModel(models.Model):
|
class BaseModel(models.Model):
|
||||||
active = models.BooleanField(default=True)
|
active = models.BooleanField(default=True)
|
||||||
deleted = models.BooleanField(default=False)
|
deleted = models.BooleanField(default=False)
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ from .models import PushNotification
|
|||||||
class PushNotificationForm(forms.ModelForm):
|
class PushNotificationForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = PushNotification
|
model = PushNotification
|
||||||
fields = ('title', 'banner_image', 'message')
|
fields = ('title', 'message')
|
||||||
@@ -195,7 +195,7 @@ REST_FRAMEWORK = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MESSAGE_TAGS = {
|
MESSAGE_TAGS = {
|
||||||
messages.DEBUG: "alert-info",
|
messages.DEBUG: "alert-primary",
|
||||||
messages.INFO: "alert-info",
|
messages.INFO: "alert-info",
|
||||||
messages.SUCCESS: "alert-success",
|
messages.SUCCESS: "alert-success",
|
||||||
messages.WARNING: "alert-warning",
|
messages.WARNING: "alert-warning",
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ class ContactUsListJson(BaseDatatableView):
|
|||||||
columns = ["id", "email_address", "subject", "message", "reply", "active"]
|
columns = ["id", "email_address", "subject", "message", "reply", "active"]
|
||||||
order_columns = ["id", "email_address", "subject", "message", "reply", "active"]
|
order_columns = ["id", "email_address", "subject", "message", "reply", "active"]
|
||||||
|
|
||||||
|
FILTER_ICONTAINS = "icontains"
|
||||||
|
|
||||||
|
def get_filter_method(self):
|
||||||
|
"""Returns preferred filter method"""
|
||||||
|
return self.FILTER_ICONTAINS
|
||||||
|
|
||||||
def get_initial_queryset(self):
|
def get_initial_queryset(self):
|
||||||
deleted_flag = self.request.GET.get('deleted_flag', None)
|
deleted_flag = self.request.GET.get('deleted_flag', None)
|
||||||
|
|
||||||
|
|||||||
54
process_food_data.py
Normal file
54
process_food_data.py
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import openpyxl
|
||||||
|
|
||||||
|
# Read existing foods from Excel file
|
||||||
|
existing_foods = set()
|
||||||
|
try:
|
||||||
|
existing_workbook = openpyxl.load_workbook('formatted_data.xlsx')
|
||||||
|
existing_sheet = existing_workbook.active
|
||||||
|
for row in existing_sheet.iter_rows(min_row=2, max_col=1, max_row=existing_sheet.max_row):
|
||||||
|
existing_foods.add(row[0].value)
|
||||||
|
except FileNotFoundError:
|
||||||
|
# If the file does not exist, there are no existing foods
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Read data from text file
|
||||||
|
with open('food_data.txt', 'r') as file:
|
||||||
|
data = file.readlines()
|
||||||
|
|
||||||
|
# Process the data
|
||||||
|
formatted_data = []
|
||||||
|
for line in data:
|
||||||
|
# Split each line by colon ':'
|
||||||
|
parts = line.strip().split(':')
|
||||||
|
# Check if there are two parts (food and ingredients)
|
||||||
|
if len(parts) == 2:
|
||||||
|
food = parts[0].strip()
|
||||||
|
ingredients = parts[1].strip()
|
||||||
|
# Check if the food is already in the existing foods set
|
||||||
|
if food not in existing_foods:
|
||||||
|
# If not, add the food to the set and to the formatted data list
|
||||||
|
existing_foods.add(food)
|
||||||
|
formatted_data.append((food, ingredients))
|
||||||
|
else:
|
||||||
|
# If only one part is present, add an empty string for ingredients
|
||||||
|
food = parts[0].strip()
|
||||||
|
if food not in existing_foods:
|
||||||
|
existing_foods.add(food)
|
||||||
|
formatted_data.append((food, ''))
|
||||||
|
|
||||||
|
# Write data to Excel file
|
||||||
|
workbook = openpyxl.Workbook()
|
||||||
|
sheet = workbook.active
|
||||||
|
|
||||||
|
# Add headers
|
||||||
|
sheet.cell(row=1, column=1).value = 'Food'
|
||||||
|
sheet.cell(row=1, column=2).value = 'Ingredients'
|
||||||
|
|
||||||
|
# Add data
|
||||||
|
for idx, entry in enumerate(formatted_data, start=2):
|
||||||
|
# Write food and ingredients to respective columns
|
||||||
|
sheet.cell(row=idx, column=1).value = entry[0]
|
||||||
|
sheet.cell(row=idx, column=2).value = entry[1]
|
||||||
|
|
||||||
|
# Save Excel file
|
||||||
|
workbook.save('formatted_data.xlsx')
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
<div class="alert {{ message.tags }} alert-dismissible messgae-alert mt-3" role="alert">
|
<div class="alert {{ message.tags }} alert-dismissible message-alert fade show border-0 m-4" role="alert">
|
||||||
{{ message }}
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"><svg> ... </svg></button>
|
||||||
</div>
|
{{ message }} </button>
|
||||||
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
{% for field in form.visible_fields %}
|
{% for field in form.visible_fields %}
|
||||||
{% comment %} <h4>{{field.errors}}</h4> {% endcomment %}
|
{% comment %} <h4>{{field.errors}}</h4> {% endcomment %}
|
||||||
|
|
||||||
{% if field.field.choices %}
|
{% if field.field.choices %}
|
||||||
<div class="form-group mb-3">
|
<div class="form-group mb-3">
|
||||||
<label for="{{ field.id_for_label }}" class="mb-2">{{ field.label }}</label>
|
<label for="{{ field.id_for_label }}" class="mb-2">{{ field.label }}</label>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
|
<!-- BEGIN GLOBAL MANDATORY SCRIPTS -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
|
||||||
<script src="{% static 'src/bootstrap/js/bootstrap.bundle.min.js' %}"></script>
|
<script src="{% static 'src/bootstrap/js/bootstrap.bundle.min.js' %}"></script>
|
||||||
<!-- END GLOBAL MANDATORY SCRIPTS -->
|
<!-- END GLOBAL MANDATORY SCRIPTS -->
|
||||||
|
|
||||||
@@ -52,8 +53,8 @@
|
|||||||
{% block javascript %}{% endblock %}
|
{% block javascript %}{% endblock %}
|
||||||
<!-- BEGIN PAGE LEVEL PLUGINS/CUSTOM SCRIPTS -->
|
<!-- BEGIN PAGE LEVEL PLUGINS/CUSTOM SCRIPTS -->
|
||||||
<script>
|
<script>
|
||||||
$(".messgae-alert").fadeTo(2000, 500).slideUp(500, function () {
|
$(".message-alert").fadeTo(2000, 500).slideUp(500, function () {
|
||||||
$(".messgae-alert").slideUp(500);
|
$(".message-alert").slideUp(500);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -81,8 +81,8 @@
|
|||||||
<script src="{% static 'src/assets/js/dashboard/dash_1.js' %}"></script>
|
<script src="{% static 'src/assets/js/dashboard/dash_1.js' %}"></script>
|
||||||
<!-- BEGIN PAGE LEVEL PLUGINS/CUSTOM SCRIPTS -->
|
<!-- BEGIN PAGE LEVEL PLUGINS/CUSTOM SCRIPTS -->
|
||||||
<script>
|
<script>
|
||||||
$(".messgae-alert").fadeTo(2000, 500).slideUp(500, function () {
|
$(".message-alert").fadeTo(2000, 500).slideUp(500, function () {
|
||||||
$(".messgae-alert").slideUp(500);
|
$(".message-alert").slideUp(500);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 layout-spacing">
|
<div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12 layout-spacing">
|
||||||
<div class="widget widget-chart-three">
|
<div class="widget widget-chart-three">
|
||||||
<div class="widget-heading">
|
<div class="widget-heading">
|
||||||
<h3>Activty Graph</h3>
|
<h3>Activity Graph</h3>
|
||||||
<select class="form-control text-center w-25" name="activity_year_select" id="activity_year_select">
|
<select class="form-control text-center w-25" name="activity_year_select" id="activity_year_select">
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h3>Meal Details</h3>
|
<h3>Bowel Details</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
<div class="col text-end">
|
||||||
{% comment %} <button class="btn btn-dark mb-2 me-4" onclick="history.back()">
|
{% comment %} <button class="btn btn-dark mb-2 me-4" onclick="history.back()">
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<p class="mb-0">Consistency :</p>
|
<p class="mb-0">Consistency :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.stool_type }}</span>
|
<span>{{ obj.stool_type }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
<p class="mb-0">Duration :</p>
|
<p class="mb-0">Duration :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.duration }}</span>
|
<span>{{ obj.duration }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
<p class="mb-0">Completeness of Evacuation :</p>
|
<p class="mb-0">Completeness of Evacuation :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.completeness_of_evacuation }}</span>
|
<span>{{ obj.completeness_of_evacuation }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
<p class="mb-0">Color :</p>
|
<p class="mb-0">Color :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.color }}</span>
|
<span>{{ obj.color }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>
|
<span>
|
||||||
{{bowel.excessive_flatulence}}
|
{{obj.excessive_flatulence}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,7 +80,7 @@
|
|||||||
<p class="mb-0">Urgency :</p>
|
<p class="mb-0">Urgency :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.urgency }}</span>
|
<span>{{ obj.urgency }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
<p class="mb-0">Smelliness :</p>
|
<p class="mb-0">Smelliness :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.smellness }}</span>
|
<span>{{ obj.smellness }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
<p class="mb-0">Pain level :</p>
|
<p class="mb-0">Pain level :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.pain_level }}</span>
|
<span>{{ obj.pain_level }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
@@ -104,7 +104,7 @@
|
|||||||
<p class="mb-0">Volume :</p>
|
<p class="mb-0">Volume :</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<span>{{ bowel.volume }}</span>
|
<span>{{ obj.volume }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
164
templates/module_activity/bowel_list.html
Normal file
164
templates/module_activity/bowel_list.html
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
{% extends 'base_structure/layout/base_template.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block stylesheet %}
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/animate_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/modal_cdn_css.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row layout-top-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col">
|
||||||
|
<a href="{% url 'module_auth:user_view' id=principal_id.id %}" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
|
arrow_back
|
||||||
|
</span><span>Bowel Record -- {{principal_id.id}} -- {{principal_id.first_name}}</span></h3>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row layout-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="statbox widget box box-shadow">
|
||||||
|
<div class="widget-content widget-content-area">
|
||||||
|
<div id="table_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="table" class="table style-3 dt-table-hover dataTable" role="grid"
|
||||||
|
aria-describedby="style-3_info">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr role="row">
|
||||||
|
<th class="sorting_asc text-center dt-no-sorting" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Sr. No</th>
|
||||||
|
<th class="sorting_asc text-center" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Record ID</th>
|
||||||
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Date</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Time</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Stool Type</th>
|
||||||
|
<th class="text-center dt-no-sorting" tabindex="5" aria-controls="style-3"
|
||||||
|
style="width: 79.7969px;">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_js.html" %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
// Define DataTable instance
|
||||||
|
var dataTableInstance;
|
||||||
|
var mainUrl = "{% url 'module_activity:bowel_list' principal_id=principal_id.id %}?deleted_flag=False"
|
||||||
|
var viewUrl = "{% url 'module_activity:bowel_detail' pk=0 %}"
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
tableName = $('#table');
|
||||||
|
dataTableInstance = initializeDataTable(tableName, mainUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function to initialize DataTable
|
||||||
|
function initializeDataTable(tableName, mainUrl) {
|
||||||
|
return tableName.DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
ajax: {
|
||||||
|
url: mainUrl,
|
||||||
|
type: "GET",
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
className: "text-center",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
// Calculate sequence number based on page, page length, and index
|
||||||
|
var sequenceNumber = meta.row + meta.settings._iDisplayStart + 1;
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ data: "id", className: "text-center" },
|
||||||
|
{ data: "date", className: "text-center" },
|
||||||
|
{ data: "time", className: "text-center" },
|
||||||
|
{ data: "stool_type", className: "text-center" },
|
||||||
|
{ data: null, className: "text-center", render: renderActions }
|
||||||
|
],
|
||||||
|
debug: true,
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: [1, 2, 3, 4],
|
||||||
|
searchable: true,
|
||||||
|
orderable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [0,-1], // Targeting the last column (action column)
|
||||||
|
searchable: false,
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||||
|
"<'table-responsive'tr>" +
|
||||||
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
|
oLanguage: {
|
||||||
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
|
sInfo: "Showing page _PAGE_ of _PAGES_",
|
||||||
|
sSearch: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||||
|
sSearchPlaceholder: "Search...",
|
||||||
|
sLengthMenu: " _MENU_",
|
||||||
|
},
|
||||||
|
stripeClasses: [],
|
||||||
|
lengthMenu: [5, 10, 20, 50],
|
||||||
|
pageLength: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to reload the DataTable
|
||||||
|
function reloadDataTable() {
|
||||||
|
dataTableInstance.ajax.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Render actions
|
||||||
|
function renderActions(data, type, row) {
|
||||||
|
return `
|
||||||
|
<a href="${viewUrl.replace('0', row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
</span><span>User Chronic conditions/diseases - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
</span><span>User Chronic conditions/diseases - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
{% comment %} <div class="col text-end">
|
||||||
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:chronic_condition_add' principal_id=principal_id.id %}">Add</a>
|
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:chronic_condition_add' principal_id=principal_id.id %}">Add</a>
|
||||||
</div>
|
</div> {% endcomment %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row layout-spacing">
|
<div class="row layout-spacing">
|
||||||
@@ -38,19 +38,12 @@
|
|||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr role="row">
|
<tr role="row">
|
||||||
<th class="checkbox-column sorting_asc text-center" tabindex="0"
|
|
||||||
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
|
||||||
#</th>
|
|
||||||
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
||||||
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
||||||
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">User Symptoms</th>
|
colspan="1" style="width: 44.2344px;">User Symptoms</th>
|
||||||
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this Symptoms</th>
|
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this Symptoms</th>
|
||||||
<th class="sorting text-center" tabindex="5" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Active</th>
|
|
||||||
<th class="sorting text-center" tabindex="6" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Action</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -89,8 +82,7 @@ var viewArchiveUrl = "{% url 'module_activity:chronic_condition_archive' princip
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
||||||
editClickEvent();
|
|
||||||
activeSwitchEventListener();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to initialize DataTable
|
// Function to initialize DataTable
|
||||||
@@ -103,38 +95,18 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, className: "text-center", render: renderCheckbox },
|
|
||||||
{ data: "id", className: "text-center" },
|
{ data: "id", className: "text-center" },
|
||||||
{ data: "name", className: "text-center" },
|
{ data: "name", className: "text-center" },
|
||||||
{ data: "duration", className: "text-center" },
|
{ data: "duration", className: "text-center" }
|
||||||
{ data: "active", className: "text-center", render: renderSwitch },
|
|
||||||
{ data: null, className: "text-center", render: renderActions }
|
|
||||||
],
|
],
|
||||||
debug: true,
|
debug: true,
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: [1, 2, 3], searchable: true, orderable: true },
|
{ targets: [1, 2, 0], searchable: true, orderable: true }
|
||||||
{ targets: [0, -1], searchable: false, orderable: false }
|
|
||||||
],
|
],
|
||||||
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
||||||
"<'table-responsive'tr>" +
|
"<'table-responsive'tr>" +
|
||||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
|
||||||
text: 'Archive',
|
|
||||||
className: "btn btn-dark buttons-archive",
|
|
||||||
action: archiveAction,
|
|
||||||
init: function(api, node, config){
|
|
||||||
$(node).hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'View Archive List',
|
|
||||||
className: "btn btn-dark ",
|
|
||||||
action: function () {
|
|
||||||
// Add your action here, e.g., redirect to archive page
|
|
||||||
window.location.href = viewArchiveUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
oLanguage: {
|
oLanguage: {
|
||||||
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
@@ -145,171 +117,7 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
},
|
},
|
||||||
stripeClasses: [],
|
stripeClasses: [],
|
||||||
lengthMenu: [5, 10, 20, 50],
|
lengthMenu: [5, 10, 20, 50],
|
||||||
pageLength: 10,
|
pageLength: 10
|
||||||
initComplete: initCompleteCallback
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to reload the DataTable
|
|
||||||
function reloadDataTable() {
|
|
||||||
dataTableInstance.ajax.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render checkbox
|
|
||||||
function renderCheckbox(data, type, row) {
|
|
||||||
var checkboxHTML = '<div class="form-check form-check-danger">';
|
|
||||||
checkboxHTML += '<input class="form-check-input archive-checkbox" type="checkbox" value="' + row.id + '" data-id="'+ row.id +'" id="checkbox-' + row.id + '">';
|
|
||||||
checkboxHTML += '</div>';
|
|
||||||
return checkboxHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render switch
|
|
||||||
function renderSwitch(data, type, row) {
|
|
||||||
console.log("data is ", data, "type is", typeof(data))
|
|
||||||
var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : '';
|
|
||||||
console.log("check attribute", + checkedAttribute)
|
|
||||||
var switchHTML = '<div class="switch form-switch-custom switch-inline form-switch-primary">';
|
|
||||||
switchHTML += '<input class="switch-input" type="checkbox" role="switch" id="form-custom-switch-checked' + row.id + '" data-id="' + row.id + '" ' + checkedAttribute + '>';
|
|
||||||
switchHTML += '</div>';
|
|
||||||
return switchHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render actions
|
|
||||||
function renderActions(data, type, row) {
|
|
||||||
return `
|
|
||||||
<div class="dropdown">
|
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback function for DataTable initialization complete event
|
|
||||||
function initCompleteCallback() {
|
|
||||||
var api = this.api();
|
|
||||||
|
|
||||||
// Add event listener for checkbox change
|
|
||||||
$('body').on('change', 'input[type="checkbox"]', function () {
|
|
||||||
var checkedCount = $('#table tbody input.archive-checkbox:checked').length;
|
|
||||||
var archiveButton = $('.buttons-archive');
|
|
||||||
archiveButton.toggle(checkedCount > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle archive action
|
|
||||||
function archiveAction() {
|
|
||||||
// Get all the checked checkboxes
|
|
||||||
var checkedCheckboxes = $('.archive-checkbox:checked');
|
|
||||||
// If no checkboxes are checked, show an error message
|
|
||||||
if (checkedCheckboxes.length === 0) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'No users selected',
|
|
||||||
text: 'Please select at least one user to archive.',
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the IDs of the checked checkboxes
|
|
||||||
var userIds = checkedCheckboxes.map(function() {
|
|
||||||
return $(this).val();
|
|
||||||
}).get();
|
|
||||||
// Perform archive action with the collected user IDs
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Are you sure?',
|
|
||||||
text: 'Once archived, you will recover it from archive list!',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: '#d33',
|
|
||||||
cancelButtonColor: '#3085d6',
|
|
||||||
confirmButtonText: 'Yes, archive it!'
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
// Perform archive action
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your archive endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "archive",
|
|
||||||
ids: userIds,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Optionally, you can reload the DataTable after successful archive
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to add event listener for switch
|
|
||||||
function activeSwitchEventListener() {
|
|
||||||
// Add event listener for switch change event
|
|
||||||
$('body').on('change', '.switch-input', function() {
|
|
||||||
var rowId = $(this).closest('tr').find('.switch-input').data('id');
|
|
||||||
var isActive = $(this).prop('checked');
|
|
||||||
console.log(rowId, isActive)
|
|
||||||
// Perform active toggle action for the current user
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your active toggle endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "active",
|
|
||||||
ids: [rowId],
|
|
||||||
active: isActive,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Reload the DataTable after successful toggle
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function to handle click event for edit button
|
|
||||||
function editClickEvent() {
|
|
||||||
$('body').on('click', '.edit', function(){
|
|
||||||
var id =$(this).data('id');
|
|
||||||
console.log('Editing user with Id:', id);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
52
templates/module_activity/food_ingredient_form.html
Normal file
52
templates/module_activity/food_ingredient_form.html
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
{% extends 'base_structure/layout/base_template.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block stylesheet %}
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row layout-top-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col">
|
||||||
|
<a href="#" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
|
arrow_back
|
||||||
|
</span><span>{{operation}} Dataset</span></h3>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row layout-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="statbox widget box box-shadow">
|
||||||
|
<div class="widget-content widget-content-area">
|
||||||
|
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{% include 'base_structure/includes/dynamic_template_form.html' with form=form %}
|
||||||
|
<div class="mt-4 mb-0">
|
||||||
|
<div class="d-grid"><button class="btn btn-primary btn-block" type="submit">Submit</button></div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
<!-- include required js cdn link through html here -->
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
</span><span>User Intolerances - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
</span><span>User Intolerances - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
{% comment %} <div class="col text-end">
|
||||||
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:intolerance_add' principal_id=principal_id.id %}">Add</a>
|
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:intolerance_add' principal_id=principal_id.id %}">Add</a>
|
||||||
</div>
|
</div> {% endcomment %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row layout-spacing">
|
<div class="row layout-spacing">
|
||||||
@@ -38,19 +38,13 @@
|
|||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr role="row">
|
<tr role="row">
|
||||||
<th class="checkbox-column sorting_asc text-center" tabindex="0"
|
|
||||||
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
|
||||||
#</th>
|
|
||||||
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
||||||
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
||||||
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">User Intolerances</th>
|
colspan="1" style="width: 44.2344px;">User Intolerances</th>
|
||||||
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this intolerance</th>
|
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this intolerance</th>
|
||||||
<th class="sorting text-center" tabindex="5" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Active</th>
|
|
||||||
<th class="sorting text-center" tabindex="6" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Action</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -103,38 +97,18 @@ function initializeDataTable(tableName, mainUrl) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, className: "text-center", render: renderCheckbox },
|
|
||||||
{ data: "id", className: "text-center" },
|
{ data: "id", className: "text-center" },
|
||||||
{ data: "name", className: "text-center" },
|
{ data: "name", className: "text-center" },
|
||||||
{ data: "duration", className: "text-center" },
|
{ data: "duration", className: "text-center" },
|
||||||
{ data: "active", className: "text-center", render: renderSwitch },
|
|
||||||
{ data: null, className: "text-center", render: renderActions }
|
|
||||||
],
|
],
|
||||||
debug: true,
|
debug: true,
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: [1, 2, 3], searchable: true, orderable: true },
|
{ targets: [0, 1, 2], searchable: true, orderable: true }
|
||||||
{ targets: [0, -1], searchable: false, orderable: false }
|
|
||||||
],
|
],
|
||||||
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
||||||
"<'table-responsive'tr>" +
|
"<'table-responsive'tr>" +
|
||||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
|
||||||
text: 'Archive',
|
|
||||||
className: "btn btn-dark buttons-archive",
|
|
||||||
action: archiveAction,
|
|
||||||
init: function(api, node, config){
|
|
||||||
$(node).hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'View Archive List',
|
|
||||||
className: "btn btn-dark ",
|
|
||||||
action: function () {
|
|
||||||
// Add your action here, e.g., redirect to archive page
|
|
||||||
window.location.href = viewArchiveUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
oLanguage: {
|
oLanguage: {
|
||||||
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
@@ -145,160 +119,7 @@ function initializeDataTable(tableName, mainUrl) {
|
|||||||
},
|
},
|
||||||
stripeClasses: [],
|
stripeClasses: [],
|
||||||
lengthMenu: [5, 10, 20, 50],
|
lengthMenu: [5, 10, 20, 50],
|
||||||
pageLength: 10,
|
pageLength: 10
|
||||||
initComplete: initCompleteCallback
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to reload the DataTable
|
|
||||||
function reloadDataTable() {
|
|
||||||
dataTableInstance.ajax.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render checkbox
|
|
||||||
function renderCheckbox(data, type, row) {
|
|
||||||
var checkboxHTML = '<div class="form-check form-check-danger">';
|
|
||||||
checkboxHTML += '<input class="form-check-input archive-checkbox" type="checkbox" value="' + row.id + '" data-id="'+ row.id +'" id="checkbox-' + row.id + '">';
|
|
||||||
checkboxHTML += '</div>';
|
|
||||||
return checkboxHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render switch
|
|
||||||
function renderSwitch(data, type, row) {
|
|
||||||
var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : '';
|
|
||||||
var switchHTML = '<div class="switch form-switch-custom switch-inline form-switch-primary">';
|
|
||||||
switchHTML += '<input class="switch-input" type="checkbox" role="switch" id="form-custom-switch-checked' + row.id + '" data-id="' + row.id + '" ' + checkedAttribute + '>';
|
|
||||||
switchHTML += '</div>';
|
|
||||||
return switchHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render actions
|
|
||||||
function renderActions(data, type, row) {
|
|
||||||
return `
|
|
||||||
<div class="dropdown">
|
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback function for DataTable initialization complete event
|
|
||||||
function initCompleteCallback() {
|
|
||||||
var api = this.api();
|
|
||||||
|
|
||||||
// Add event listener for checkbox change
|
|
||||||
$('body').on('change', 'input[type="checkbox"]', function () {
|
|
||||||
var checkedCount = $('tbody input.archive-checkbox:checked').length;
|
|
||||||
var archiveButton = $('.buttons-archive');
|
|
||||||
archiveButton.toggle(checkedCount > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle archive action
|
|
||||||
function archiveAction() {
|
|
||||||
// Get all the checked checkboxes
|
|
||||||
var checkedCheckboxes = $('.archive-checkbox:checked');
|
|
||||||
// If no checkboxes are checked, show an error message
|
|
||||||
if (checkedCheckboxes.length === 0) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'No users selected',
|
|
||||||
text: 'Please select at least one user to archive.',
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the IDs of the checked checkboxes
|
|
||||||
var ids = checkedCheckboxes.map(function() {
|
|
||||||
return $(this).val();
|
|
||||||
}).get();
|
|
||||||
// Perform archive action with the collected user IDs
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Are you sure?',
|
|
||||||
text: 'Once archived, you will recover it from archive list!',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: '#d33',
|
|
||||||
cancelButtonColor: '#3085d6',
|
|
||||||
confirmButtonText: 'Yes, archive it!'
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
// Perform archive action
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your archive endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "archive",
|
|
||||||
ids: ids,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Optionally, you can reload the DataTable after successful archive
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to add event listener for switch
|
|
||||||
function activeSwitchEventListener() {
|
|
||||||
// Add event listener for switch change event
|
|
||||||
$('body').on('change', '.switch-input', function() {
|
|
||||||
var rowId = $(this).closest('tr').find('.switch-input').data('id');
|
|
||||||
var isActive = $(this).prop('checked');
|
|
||||||
console.log(rowId, isActive)
|
|
||||||
// Perform active toggle action for the current user
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your active toggle endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "active",
|
|
||||||
ids: [rowId],
|
|
||||||
active: isActive,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Reload the DataTable after successful toggle
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,10 +101,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Download Button -->
|
|
||||||
<div class="mb-4">
|
|
||||||
<a class="btn btn-primary" href="#" role="button">Download Activity Report</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
212
templates/module_activity/meal_list.html
Normal file
212
templates/module_activity/meal_list.html
Normal file
@@ -0,0 +1,212 @@
|
|||||||
|
{% extends 'base_structure/layout/base_template.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block stylesheet %}
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/animate_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/modal_cdn_css.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row layout-top-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col">
|
||||||
|
<a href="{% url 'module_auth:user_view' id=principal_id.id %}" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
|
arrow_back
|
||||||
|
</span><span>Meal Record -- {{principal_id.id}} -- {{principal_id.first_name}}</span></h3>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row layout-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="statbox widget box box-shadow">
|
||||||
|
<div class="widget-content widget-content-area">
|
||||||
|
<div id="table_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="table" class="table style-3 dt-table-hover dataTable" role="grid"
|
||||||
|
aria-describedby="style-3_info">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr role="row">
|
||||||
|
<th class="sorting_asc text-center dt-no-sorting" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Sr. No</th>
|
||||||
|
<th class="sorting_asc text-center" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Record ID</th>
|
||||||
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Date</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Time</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Meal Type</th>
|
||||||
|
<th class="text-center dt-no-sorting" tabindex="5" aria-controls="style-3"
|
||||||
|
style="width: 79.7969px;">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- modal for View FAQ Question Answer -->
|
||||||
|
<div class="modal fade" id="faqmodal" tabindex="-1" role="dialog" aria-labelledby="faqModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content" >
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="faqModalLabel">Faq</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="card mb-2">
|
||||||
|
<div class="card-body">
|
||||||
|
<h6 class="card-title">Question</h6>
|
||||||
|
<p class="mb-0" id="questionData"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h6 class="card-title">Answer</h6>
|
||||||
|
<p class="mb-0" id="answerData"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-dark" data-bs-dismiss="modal">Discard</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_js.html" %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
// Define DataTable instance
|
||||||
|
var dataTableInstance;
|
||||||
|
var mainUrl = "{% url 'module_activity:meal_list' principal_id=principal_id.id %}?deleted_flag=False"
|
||||||
|
var viewUrl = "{% url 'module_activity:meal_detail' pk=0 %}"
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
tableName = $('#table');
|
||||||
|
dataTableInstance = initializeDataTable(tableName, mainUrl);
|
||||||
|
viewClickEvent(dataTableInstance)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function to initialize DataTable
|
||||||
|
function initializeDataTable(tableName, mainUrl) {
|
||||||
|
return tableName.DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
ajax: {
|
||||||
|
url: mainUrl,
|
||||||
|
type: "GET",
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
className: "text-center",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
// Calculate sequence number based on page, page length, and index
|
||||||
|
var sequenceNumber = meta.row + meta.settings._iDisplayStart + 1;
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ data: "id", className: "text-center" },
|
||||||
|
{ data: "date", className: "text-center" },
|
||||||
|
{ data: "time", className: "text-center" },
|
||||||
|
{ data: "meal_type", className: "text-center" },
|
||||||
|
{ data: null, className: "text-center", render: renderActions }
|
||||||
|
],
|
||||||
|
debug: true,
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: [1, 2, 3, 4],
|
||||||
|
searchable: true,
|
||||||
|
orderable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [0,-1], // Targeting the last column (action column)
|
||||||
|
searchable: false,
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||||
|
"<'table-responsive'tr>" +
|
||||||
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
|
oLanguage: {
|
||||||
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
|
sInfo: "Showing page _PAGE_ of _PAGES_",
|
||||||
|
sSearch: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||||
|
sSearchPlaceholder: "Search...",
|
||||||
|
sLengthMenu: " _MENU_",
|
||||||
|
},
|
||||||
|
stripeClasses: [],
|
||||||
|
lengthMenu: [5, 10, 20, 50],
|
||||||
|
pageLength: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to reload the DataTable
|
||||||
|
function reloadDataTable() {
|
||||||
|
dataTableInstance.ajax.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Render actions
|
||||||
|
function renderActions(data, type, row) {
|
||||||
|
return `
|
||||||
|
<a href="${viewUrl.replace('0', row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to handle archive action
|
||||||
|
|
||||||
|
// Function to handle click event for view button
|
||||||
|
function viewClickEvent(dataTableInstance) {
|
||||||
|
$('body').on('click', '.view', function(){
|
||||||
|
var id =$(this).data('id');
|
||||||
|
var rowData = dataTableInstance.row($(this).closest('tr')).data();
|
||||||
|
var question = rowData.question;
|
||||||
|
var answer = rowData.answer;
|
||||||
|
console.log(question, answer)
|
||||||
|
// Set the data in the modal content
|
||||||
|
$('#questionData').text(question);
|
||||||
|
$('#answerData').text(answer);
|
||||||
|
|
||||||
|
// Show the modal
|
||||||
|
$('#faqmodal').modal('show');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -86,10 +86,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Download Button -->
|
|
||||||
<div class="mb-4">
|
|
||||||
<a class="btn btn-primary" href="#" role="button">Download Symptom Report</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
160
templates/module_activity/meal_symptoms_list.html
Normal file
160
templates/module_activity/meal_symptoms_list.html
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
{% extends 'base_structure/layout/base_template.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block stylesheet %}
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/animate_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/modal_cdn_css.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row layout-top-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col">
|
||||||
|
<a href="{% url 'module_auth:user_view' id=principal_id.id %}" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
|
arrow_back
|
||||||
|
</span><span>Symptom Record -- {{principal_id.id}} -- {{principal_id.first_name}}</span></h3>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row layout-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="statbox widget box box-shadow">
|
||||||
|
<div class="widget-content widget-content-area">
|
||||||
|
<div id="table_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="table" class="table style-3 dt-table-hover dataTable" role="grid"
|
||||||
|
aria-describedby="style-3_info">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr role="row">
|
||||||
|
<th class="sorting_asc text-center dt-no-sorting" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Sr. No</th>
|
||||||
|
<th class="sorting_asc text-center" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Record ID</th>
|
||||||
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Date</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Time</th>
|
||||||
|
<th class="text-center dt-no-sorting" tabindex="5" aria-controls="style-3"
|
||||||
|
style="width: 79.7969px;">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_js.html" %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
// Define DataTable instance
|
||||||
|
var dataTableInstance;
|
||||||
|
var mainUrl = "{% url 'module_activity:meal_symptoms_list' principal_id=principal_id.id %}?deleted_flag=False"
|
||||||
|
var viewUrl = "{% url 'module_activity:meal_symptom_detail' pk=0 %}"
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
tableName = $('#table');
|
||||||
|
dataTableInstance = initializeDataTable(tableName, mainUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function to initialize DataTable
|
||||||
|
function initializeDataTable(tableName, mainUrl) {
|
||||||
|
return tableName.DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
ajax: {
|
||||||
|
url: mainUrl,
|
||||||
|
type: "GET",
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
className: "text-center",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
// Calculate sequence number based on page, page length, and index
|
||||||
|
var sequenceNumber = meta.row + meta.settings._iDisplayStart + 1;
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ data: "id", className: "text-center" },
|
||||||
|
{ data: "date", className: "text-center" },
|
||||||
|
{ data: "time", className: "text-center" },
|
||||||
|
{ data: null, className: "text-center", render: renderActions }
|
||||||
|
],
|
||||||
|
debug: true,
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: [1, 2, 3],
|
||||||
|
searchable: true,
|
||||||
|
orderable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [0,-1], // Targeting the last column (action column)
|
||||||
|
searchable: false,
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||||
|
"<'table-responsive'tr>" +
|
||||||
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
|
oLanguage: {
|
||||||
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
|
sInfo: "Showing page _PAGE_ of _PAGES_",
|
||||||
|
sSearch: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||||
|
sSearchPlaceholder: "Search...",
|
||||||
|
sLengthMenu: " _MENU_",
|
||||||
|
},
|
||||||
|
stripeClasses: [],
|
||||||
|
lengthMenu: [5, 10, 20, 50],
|
||||||
|
pageLength: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to reload the DataTable
|
||||||
|
function reloadDataTable() {
|
||||||
|
dataTableInstance.ajax.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Render actions
|
||||||
|
function renderActions(data, type, row) {
|
||||||
|
return `
|
||||||
|
<a href="${viewUrl.replace('0', row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -62,10 +62,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Download Button -->
|
|
||||||
<div class="mb-4">
|
|
||||||
<a class="btn btn-primary" href="#" role="button">Download Medication Report</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
160
templates/module_activity/medication_list.html
Normal file
160
templates/module_activity/medication_list.html
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
{% extends 'base_structure/layout/base_template.html' %}
|
||||||
|
{% load static %}
|
||||||
|
{% block stylesheet %}
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/animate_cdn_css.html" %}
|
||||||
|
{% include "cdn_through_html/modal_cdn_css.html" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row layout-top-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col">
|
||||||
|
<a href="{% url 'module_auth:user_view' id=principal_id.id %}" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
|
arrow_back
|
||||||
|
</span><span>Medication Record -- {{principal_id.id}} -- {{principal_id.first_name}}</span></h3>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row layout-spacing">
|
||||||
|
<div class="col-lg-12">
|
||||||
|
<div class="statbox widget box box-shadow">
|
||||||
|
<div class="widget-content widget-content-area">
|
||||||
|
<div id="table_wrapper" class="dataTables_wrapper container-fluid dt-bootstrap4 no-footer">
|
||||||
|
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="table" class="table style-3 dt-table-hover dataTable" role="grid"
|
||||||
|
aria-describedby="style-3_info">
|
||||||
|
|
||||||
|
<thead>
|
||||||
|
<tr role="row">
|
||||||
|
<th class="sorting_asc text-center dt-no-sorting" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Sr. No</th>
|
||||||
|
<th class="sorting_asc text-center" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending"
|
||||||
|
style="width: 50.2656px;">Record ID</th>
|
||||||
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Date</th>
|
||||||
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
|
colspan="1"
|
||||||
|
style="width: 44.2344px;">Time</th>
|
||||||
|
<th class="text-center dt-no-sorting" tabindex="5" aria-controls="style-3"
|
||||||
|
style="width: 79.7969px;">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock content %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
|
||||||
|
<!-- include required css cdn link through html here -->
|
||||||
|
|
||||||
|
{% include "cdn_through_html/datatable_cdn_js.html" %}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
// Define DataTable instance
|
||||||
|
var dataTableInstance;
|
||||||
|
var mainUrl = "{% url 'module_activity:medication_list' principal_id=principal_id.id %}?deleted_flag=False"
|
||||||
|
var viewUrl = "{% url 'module_activity:medication_detail' pk=0 %}"
|
||||||
|
|
||||||
|
// Entry point
|
||||||
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
tableName = $('#table');
|
||||||
|
dataTableInstance = initializeDataTable(tableName, mainUrl);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Function to initialize DataTable
|
||||||
|
function initializeDataTable(tableName, mainUrl) {
|
||||||
|
return tableName.DataTable({
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
ajax: {
|
||||||
|
url: mainUrl,
|
||||||
|
type: "GET",
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
className: "text-center",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
// Calculate sequence number based on page, page length, and index
|
||||||
|
var sequenceNumber = meta.row + meta.settings._iDisplayStart + 1;
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ data: "id", className: "text-center" },
|
||||||
|
{ data: "date", className: "text-center" },
|
||||||
|
{ data: "time", className: "text-center" },
|
||||||
|
{ data: null, className: "text-center", render: renderActions }
|
||||||
|
],
|
||||||
|
debug: true,
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: [1, 2, 3],
|
||||||
|
searchable: true,
|
||||||
|
orderable: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: [0,-1], // Targeting the last column (action column)
|
||||||
|
searchable: false,
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'f>>>" +
|
||||||
|
"<'table-responsive'tr>" +
|
||||||
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
|
oLanguage: {
|
||||||
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
|
sInfo: "Showing page _PAGE_ of _PAGES_",
|
||||||
|
sSearch: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-search"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>',
|
||||||
|
sSearchPlaceholder: "Search...",
|
||||||
|
sLengthMenu: " _MENU_",
|
||||||
|
},
|
||||||
|
stripeClasses: [],
|
||||||
|
lengthMenu: [5, 10, 20, 50],
|
||||||
|
pageLength: 10
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to reload the DataTable
|
||||||
|
function reloadDataTable() {
|
||||||
|
dataTableInstance.ajax.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Render actions
|
||||||
|
function renderActions(data, type, row) {
|
||||||
|
return `
|
||||||
|
<a href="${viewUrl.replace('0', row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
|
</a>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -21,9 +21,9 @@
|
|||||||
</span><span>User Past Treatment - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
</span><span>User Past Treatment - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
{% comment %} <div class="col text-end">
|
||||||
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:past_treatment_add' principal_id=principal_id.id%}">Add</a>
|
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:past_treatment_add' principal_id=principal_id.id%}">Add</a>
|
||||||
</div>
|
</div> {% endcomment %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row layout-spacing">
|
<div class="row layout-spacing">
|
||||||
@@ -38,19 +38,14 @@
|
|||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr role="row">
|
<tr role="row">
|
||||||
<th class="checkbox-column sorting_asc text-center" tabindex="0"
|
|
||||||
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
|
||||||
#</th>
|
|
||||||
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
||||||
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
||||||
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">User Past Treatment</th>
|
colspan="1" style="width: 44.2344px;">User Past Treatment</th>
|
||||||
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">Treatment date</th>
|
colspan="1" style="width: 44.2344px;">Treatment date</th>
|
||||||
<th class="sorting text-center" tabindex="5" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Active</th>
|
|
||||||
<th class="sorting text-center" tabindex="6" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Action</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -89,8 +84,7 @@ var viewArchiveUrl = "{% url 'module_activity:past_treatment_archive' principal_
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
||||||
editClickEvent();
|
|
||||||
activeSwitchEventListener();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to initialize DataTable
|
// Function to initialize DataTable
|
||||||
@@ -103,38 +97,18 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, className: "text-center", render: renderCheckbox },
|
|
||||||
{ data: "id", className: "text-center" },
|
{ data: "id", className: "text-center" },
|
||||||
{ data: "name", className: "text-center" },
|
{ data: "name", className: "text-center" },
|
||||||
{ data: "duration", className: "text-center" },
|
{ data: "duration", className: "text-center" },
|
||||||
{ data: "active", className: "text-center", render: renderSwitch },
|
|
||||||
{ data: null, className: "text-center", render: renderActions }
|
|
||||||
],
|
],
|
||||||
debug: true,
|
debug: true,
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: [1, 2, 3], searchable: true, orderable: true },
|
{ targets: [1, 2, 0], searchable: true, orderable: true }
|
||||||
{ targets: [0, -1], searchable: false, orderable: false }
|
|
||||||
],
|
],
|
||||||
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
||||||
"<'table-responsive'tr>" +
|
"<'table-responsive'tr>" +
|
||||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
|
||||||
text: 'Archive',
|
|
||||||
className: "btn btn-dark buttons-archive",
|
|
||||||
action: archiveAction,
|
|
||||||
init: function(api, node, config){
|
|
||||||
$(node).hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'View Archive List',
|
|
||||||
className: "btn btn-dark ",
|
|
||||||
action: function () {
|
|
||||||
// Add your action here, e.g., redirect to archive page
|
|
||||||
window.location.href = viewArchiveUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
oLanguage: {
|
oLanguage: {
|
||||||
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
@@ -145,171 +119,7 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
},
|
},
|
||||||
stripeClasses: [],
|
stripeClasses: [],
|
||||||
lengthMenu: [5, 10, 20, 50],
|
lengthMenu: [5, 10, 20, 50],
|
||||||
pageLength: 10,
|
pageLength: 10
|
||||||
initComplete: initCompleteCallback
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to reload the DataTable
|
|
||||||
function reloadDataTable() {
|
|
||||||
dataTableInstance.ajax.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render checkbox
|
|
||||||
function renderCheckbox(data, type, row) {
|
|
||||||
var checkboxHTML = '<div class="form-check form-check-danger">';
|
|
||||||
checkboxHTML += '<input class="form-check-input archive-checkbox" type="checkbox" value="' + row.id + '" data-id="'+ row.id +'" id="checkbox-' + row.id + '">';
|
|
||||||
checkboxHTML += '</div>';
|
|
||||||
return checkboxHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render switch
|
|
||||||
function renderSwitch(data, type, row) {
|
|
||||||
console.log("data is ", data, "type is", typeof(data))
|
|
||||||
var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : '';
|
|
||||||
console.log("check attribute", + checkedAttribute)
|
|
||||||
var switchHTML = '<div class="switch form-switch-custom switch-inline form-switch-primary">';
|
|
||||||
switchHTML += '<input class="switch-input" type="checkbox" role="switch" id="form-custom-switch-checked' + row.id + '" data-id="' + row.id + '" ' + checkedAttribute + '>';
|
|
||||||
switchHTML += '</div>';
|
|
||||||
return switchHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render actions
|
|
||||||
function renderActions(data, type, row) {
|
|
||||||
return `
|
|
||||||
<div class="dropdown">
|
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback function for DataTable initialization complete event
|
|
||||||
function initCompleteCallback() {
|
|
||||||
var api = this.api();
|
|
||||||
|
|
||||||
// Add event listener for checkbox change
|
|
||||||
$('body').on('change', 'input[type="checkbox"]', function () {
|
|
||||||
var checkedCount = $('#table tbody input.archive-checkbox:checked').length;
|
|
||||||
var archiveButton = $('.buttons-archive');
|
|
||||||
archiveButton.toggle(checkedCount > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle archive action
|
|
||||||
function archiveAction() {
|
|
||||||
// Get all the checked checkboxes
|
|
||||||
var checkedCheckboxes = $('.archive-checkbox:checked');
|
|
||||||
// If no checkboxes are checked, show an error message
|
|
||||||
if (checkedCheckboxes.length === 0) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'No users selected',
|
|
||||||
text: 'Please select at least one user to archive.',
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the IDs of the checked checkboxes
|
|
||||||
var userIds = checkedCheckboxes.map(function() {
|
|
||||||
return $(this).val();
|
|
||||||
}).get();
|
|
||||||
// Perform archive action with the collected user IDs
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Are you sure?',
|
|
||||||
text: 'Once archived, you will recover it from archive list!',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: '#d33',
|
|
||||||
cancelButtonColor: '#3085d6',
|
|
||||||
confirmButtonText: 'Yes, archive it!'
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
// Perform archive action
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your archive endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "archive",
|
|
||||||
ids: userIds,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Optionally, you can reload the DataTable after successful archive
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to add event listener for switch
|
|
||||||
function activeSwitchEventListener() {
|
|
||||||
// Add event listener for switch change event
|
|
||||||
$('body').on('change', '.switch-input', function() {
|
|
||||||
var rowId = $(this).closest('tr').find('.switch-input').data('id');
|
|
||||||
var isActive = $(this).prop('checked');
|
|
||||||
console.log(rowId, isActive)
|
|
||||||
// Perform active toggle action for the current user
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your active toggle endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "active",
|
|
||||||
ids: [rowId],
|
|
||||||
active: isActive,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Reload the DataTable after successful toggle
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function to handle click event for edit button
|
|
||||||
function editClickEvent() {
|
|
||||||
$('body').on('click', '.edit', function(){
|
|
||||||
var id =$(this).data('id');
|
|
||||||
console.log('Editing user with Id:', id);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
</span><span>User Symptoms - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
</span><span>User Symptoms - {{principal_id.id}} - {{principal_id.first_name}}</span></h3>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
{% comment %} <div class="col text-end">
|
||||||
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:symptoms_add' principal_id=principal_id.id %}">Add</a>
|
<a class="btn btn-primary mb-2 me-4" href="{% url 'module_activity:symptoms_add' principal_id=principal_id.id %}">Add</a>
|
||||||
</div>
|
</div> {% endcomment %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row layout-spacing">
|
<div class="row layout-spacing">
|
||||||
@@ -38,19 +38,13 @@
|
|||||||
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr role="row">
|
<tr role="row">
|
||||||
<th class="checkbox-column sorting_asc text-center" tabindex="0"
|
|
||||||
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
|
||||||
#</th>
|
|
||||||
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
||||||
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
aria-sort="ascending" style="width: 50.2656px;">#</th>
|
||||||
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">User Symptoms</th>
|
colspan="1" style="width: 44.2344px;">User Symptoms</th>
|
||||||
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this Symptoms</th>
|
colspan="1" style="width: 44.2344px;">For how long have you been experiencing this Symptoms</th>
|
||||||
<th class="sorting text-center" tabindex="5" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Active</th>
|
|
||||||
<th class="sorting text-center" tabindex="6" aria-controls="style-3"
|
|
||||||
style="width: 79.7969px;">Action</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
@@ -90,8 +84,7 @@ var viewArchiveUrl = "{% url 'module_activity:symptoms_archive' principal_id=pri
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
dataTableInstance = initializeDataTable(dataTableInstance, mainUrl);
|
||||||
editClickEvent();
|
|
||||||
activeSwitchEventListener();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to initialize DataTable
|
// Function to initialize DataTable
|
||||||
@@ -104,37 +97,18 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, className: "text-center", render: renderCheckbox },
|
|
||||||
{ data: "id", className: "text-center" },
|
{ data: "id", className: "text-center" },
|
||||||
{ data: "name", className: "text-center" },
|
{ data: "name", className: "text-center" },
|
||||||
{ data: "duration", className: "text-center" },
|
{ data: "duration", className: "text-center" }
|
||||||
{ data: "active", className: "text-center", render: renderSwitch },
|
|
||||||
{ data: null, className: "text-center", render: renderActions }
|
|
||||||
],
|
],
|
||||||
debug: true,
|
debug: true,
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: [1, 2, 3], searchable: true, orderable: true },
|
{ targets: [0, 1, 2], searchable: true, orderable: true }
|
||||||
{ targets: [0, -1], searchable: false, orderable: false }
|
|
||||||
],
|
],
|
||||||
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
||||||
"<'table-responsive'tr>" +
|
"<'table-responsive'tr>" +
|
||||||
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
"<'dt--bottom-section d-sm-flex justify-content-sm-between text-center'<'dt--pages-count mb-sm-0 mb-3'i><'dt--pagination'p>>",
|
||||||
buttons: [
|
buttons: [
|
||||||
{
|
|
||||||
text: 'Archive',
|
|
||||||
className: "btn btn-dark buttons-archive",
|
|
||||||
action: archiveAction,
|
|
||||||
init: function(api, node, config){
|
|
||||||
$(node).hide();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: 'View Archive List',
|
|
||||||
className: "btn btn-dark ",
|
|
||||||
action: function () {
|
|
||||||
window.location.href = viewArchiveUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
oLanguage: {
|
oLanguage: {
|
||||||
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
oPaginate: { "sPrevious": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>', "sNext": '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg>' },
|
||||||
@@ -145,174 +119,9 @@ function initializeDataTable(dataTableInstance, mainUrl) {
|
|||||||
},
|
},
|
||||||
stripeClasses: [],
|
stripeClasses: [],
|
||||||
lengthMenu: [5, 10, 20, 50],
|
lengthMenu: [5, 10, 20, 50],
|
||||||
pageLength: 10,
|
pageLength: 10
|
||||||
initComplete: initCompleteCallback
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to reload the DataTable
|
|
||||||
function reloadDataTable() {
|
|
||||||
dataTableInstance.ajax.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render checkbox
|
|
||||||
function renderCheckbox(data, type, row) {
|
|
||||||
var checkboxHTML = '<div class="form-check form-check-danger">';
|
|
||||||
checkboxHTML += '<input class="form-check-input archive-checkbox" type="checkbox" value="' + row.id + '" data-id="'+ row.id +'" id="checkbox-' + row.id + '">';
|
|
||||||
checkboxHTML += '</div>';
|
|
||||||
return checkboxHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render switch
|
|
||||||
function renderSwitch(data, type, row) {
|
|
||||||
console.log("data is ", data, "type is", typeof(data))
|
|
||||||
var checkedAttribute = data.toLowerCase() === 'true' ? 'checked' : '';
|
|
||||||
console.log("check attribute", + checkedAttribute)
|
|
||||||
var switchHTML = '<div class="switch form-switch-custom switch-inline form-switch-primary">';
|
|
||||||
switchHTML += '<input class="switch-input" type="checkbox" role="switch" id="form-custom-switch-checked' + row.id + '" data-id="' + row.id + '" ' + checkedAttribute + '>';
|
|
||||||
switchHTML += '</div>';
|
|
||||||
return switchHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render actions
|
|
||||||
function renderActions(data, type, row) {
|
|
||||||
return `
|
|
||||||
<div class="dropdown">
|
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
|
||||||
</div>
|
|
||||||
</div>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Callback function for DataTable initialization complete event
|
|
||||||
function initCompleteCallback() {
|
|
||||||
var api = this.api();
|
|
||||||
|
|
||||||
// Add event listener for checkbox change
|
|
||||||
$('body').on('change', 'input[type="checkbox"]', function () {
|
|
||||||
var checkedCount = $('#table tbody input.archive-checkbox:checked').length;
|
|
||||||
var archiveButton = $('.buttons-archive');
|
|
||||||
archiveButton.toggle(checkedCount > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to handle archive action
|
|
||||||
function archiveAction() {
|
|
||||||
// Get all the checked checkboxes
|
|
||||||
var checkedCheckboxes = $('.archive-checkbox:checked');
|
|
||||||
// If no checkboxes are checked, show an error message
|
|
||||||
if (checkedCheckboxes.length === 0) {
|
|
||||||
Swal.fire({
|
|
||||||
title: 'No users selected',
|
|
||||||
text: 'Please select at least one user to archive.',
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Get the IDs of the checked checkboxes
|
|
||||||
var userIds = checkedCheckboxes.map(function() {
|
|
||||||
return $(this).val();
|
|
||||||
}).get();
|
|
||||||
// Perform archive action with the collected user IDs
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Are you sure?',
|
|
||||||
text: 'Once archived, you will recover it from archive list!',
|
|
||||||
icon: 'warning',
|
|
||||||
showCancelButton: true,
|
|
||||||
confirmButtonColor: '#d33',
|
|
||||||
cancelButtonColor: '#3085d6',
|
|
||||||
confirmButtonText: 'Yes, archive it!'
|
|
||||||
}).then((result) => {
|
|
||||||
if (result.isConfirmed) {
|
|
||||||
// Perform archive action
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your archive endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "archive",
|
|
||||||
ids: userIds,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Optionally, you can reload the DataTable after successful archive
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to add event listener for switch
|
|
||||||
function activeSwitchEventListener() {
|
|
||||||
// Add event listener for switch change event
|
|
||||||
$('body').on('change', '.switch-input', function() {
|
|
||||||
var rowId = $(this).closest('tr').find('.switch-input').data('id');
|
|
||||||
var isActive = $(this).prop('checked');
|
|
||||||
console.log(rowId, isActive)
|
|
||||||
// Perform active toggle action for the current user
|
|
||||||
$.ajax({
|
|
||||||
url: actionUrl, // Replace with your active toggle endpoint
|
|
||||||
type: 'POST',
|
|
||||||
data: {
|
|
||||||
action: "active",
|
|
||||||
ids: [rowId],
|
|
||||||
active: isActive,
|
|
||||||
csrfmiddlewaretoken: '{{csrf_token}}'
|
|
||||||
},
|
|
||||||
success: function(response) {
|
|
||||||
// Show success message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Done!',
|
|
||||||
text: response.msg,
|
|
||||||
icon: 'success',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
// Reload the DataTable after successful toggle
|
|
||||||
reloadDataTable();
|
|
||||||
},
|
|
||||||
error: function(response) {
|
|
||||||
// Show error message
|
|
||||||
Swal.fire({
|
|
||||||
title: 'Error!',
|
|
||||||
text: response.message,
|
|
||||||
icon: 'error',
|
|
||||||
showConfirmButton: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Function to handle click event for edit button
|
|
||||||
function editClickEvent() {
|
|
||||||
$('body').on('click', '.edit', function(){
|
|
||||||
var id =$(this).data('id');
|
|
||||||
console.log('Editing user with Id:', id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -28,16 +28,9 @@
|
|||||||
<a href="{% url 'module_auth:users'%}" style="height: fit-content;width: fit-content;display: inline-block;">
|
<a href="{% url 'module_auth:users'%}" style="height: fit-content;width: fit-content;display: inline-block;">
|
||||||
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
<h3 class="card-title m-2 d-flex align-items-center gap-2" style="width: fit-content;"><span class="fw-bold material-symbols-outlined">
|
||||||
arrow_back
|
arrow_back
|
||||||
</span><span>User Details</span></h3>
|
</span><span>User Details -- {{obj.id}} -- {{obj.first_name}}</span></h3>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col text-end">
|
|
||||||
{% comment %} <button class="btn btn-dark mb-2 me-4" onclick="history.back()">
|
|
||||||
<i class="fa fa-arrow-left"></i>
|
|
||||||
Back
|
|
||||||
</button> {% endcomment %}
|
|
||||||
{% comment %} <a class="btn btn-success mb-2 me-4" href="{% url 'manage_cms:faq_category_add' %}">Add Category</a> {% endcomment %}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -49,9 +42,9 @@
|
|||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link active" id="pills-tab1-tab" data-bs-toggle="pill" data-bs-target="#pills-tab1" type="button" role="tab" aria-controls="pills-tab1" aria-selected="false">User</button>
|
<button class="nav-link active" id="pills-tab1-tab" data-bs-toggle="pill" data-bs-target="#pills-tab1" type="button" role="tab" aria-controls="pills-tab1" aria-selected="false">User</button>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item" role="presentation">
|
{% comment %} <li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" id="pills-tab2-tab" data-bs-toggle="pill" data-bs-target="#pills-tab2" type="button" role="tab" aria-controls="pills-tab2" aria-selected="true">Activity</button>
|
<button class="nav-link" id="pills-tab2-tab" data-bs-toggle="pill" data-bs-target="#pills-tab2" type="button" role="tab" aria-controls="pills-tab2" aria-selected="true">Activity</button>
|
||||||
</li>
|
</li> {% endcomment %}
|
||||||
<li class="nav-item" role="presentation">
|
<li class="nav-item" role="presentation">
|
||||||
<button class="nav-link" id="pills-tab3-tab" data-bs-toggle="pill" data-bs-target="#pills-tab3" type="button" role="tab" aria-controls="pills-tab3" aria-selected="true">Report</button>
|
<button class="nav-link" id="pills-tab3-tab" data-bs-toggle="pill" data-bs-target="#pills-tab3" type="button" role="tab" aria-controls="pills-tab3" aria-selected="true">Report</button>
|
||||||
</li>
|
</li>
|
||||||
@@ -100,79 +93,215 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<p>How frequently do you eat in a day? </p>
|
<p>How frequently do you eat in a day? </p>
|
||||||
<span>{{obj.health_data_principal.eat_frequency}}</span>
|
<span>--> {{obj.health_data_principal.eat_frequency}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<p>How do you rate your overall gastrointestinal functions?</p>
|
<p>How do you rate your overall gastrointestinal functions?</p>
|
||||||
<span>{{obj.health_data_principal.gastrointestinal_health}}</span>
|
<span>--> {{obj.health_data_principal.gastrointestinal_health}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<p>How much sleep do you take daily?</p>
|
<p>How much sleep do you take daily?</p>
|
||||||
<span>{{obj.health_data_principal.sleep_duration}}</span>
|
<span>--> {{obj.health_data_principal.sleep_duration}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<p>How frequently do you engage in physical activities?</p>
|
<p>How frequently do you engage in physical activities?</p>
|
||||||
<span>{{obj.health_data_principal.exercise_frequency}}</span>
|
<span>--> {{obj.health_data_principal.exercise_frequency}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr class="bdr-line">
|
<hr class="bdr-line">
|
||||||
<div class="row d-flex justify-content-between">
|
<div class="row mb-3">
|
||||||
<div class="card col-md-5 m-3 p-3 position-relative">
|
|
||||||
<div class="col-md-12 mb-3">
|
<div class="col-md-6">
|
||||||
<p>User Intolerances?</p>
|
<div class="card">
|
||||||
<span>{{ obj.intolerance_data.0.name }}</span>
|
<div class="card-body">
|
||||||
|
<p>User Intolerances?</p>
|
||||||
|
<span >{{ obj.intolerance_data.0.name }}</span>
|
||||||
|
<p>For how long have you been experiencing this intolerance?</p>
|
||||||
|
<span>{{ obj.intolerance_data.0.duration }}</span>
|
||||||
|
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:intolerance' principal_id=obj.id %}">View more</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 mb-3">
|
|
||||||
<p>For how long have you been experiencing this intolerance?</p>
|
|
||||||
<span>{{ obj.intolerance_data.0.duration }}</span>
|
|
||||||
</div>
|
|
||||||
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:intolerance' principal_id=obj.id %}">View more</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card col-md-5 m-3 p-3 position-relative">
|
<div class="col-md-6">
|
||||||
<div class="col-md-12 mb-3">
|
<div class="card">
|
||||||
<p>User Symptoms?</p>
|
<div class="card-body">
|
||||||
<span>{{ obj.symptoms_data.0.name }}</span>
|
<p>User Symptoms?</p>
|
||||||
|
<span>{{ obj.symptoms_data.0.name }}</span>
|
||||||
|
<p>For how long have you been experiencing these symptoms?</p>
|
||||||
|
<span>{{ obj.symptoms_data.0.duration }}</span>
|
||||||
|
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:symptoms' principal_id=obj.id %}">View more</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 mb-3">
|
|
||||||
<p>For how long have you been experiencing these symptoms?</p>
|
|
||||||
<span>{{ obj.symptoms_data.0.duration }}</span>
|
|
||||||
</div>
|
|
||||||
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:symptoms' principal_id=obj.id %}">View more</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<p>User Past Treatment Name?</p>
|
||||||
|
<span>{{ obj.pasttreatment_data.0.name }}</span>
|
||||||
|
<p>When did you undergo this treatment?</p>
|
||||||
|
<span>{{ obj.pasttreatment_data.0.duration }}</span>
|
||||||
|
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:past_treatment' principal_id=obj.id %}">View more</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<p>User Chronic conditions/diseases Name?</p>
|
||||||
|
<span>{{ obj.chronic_data.0 }}</span>
|
||||||
|
<p>For how long have you been experiencing this diseases?</p>
|
||||||
|
<span>{{ obj.chronic_data.0 }}</span>
|
||||||
|
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:chronic_condition' principal_id=obj.id %}">View more</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr class="bdr-line">
|
<hr class="bdr-line">
|
||||||
<div class="row d-flex justify-content-between">
|
<div class="row mb-3">
|
||||||
<div class="card col-md-5 m-3 p-3 position-relative">
|
|
||||||
<div class="col-md-12 mb-3">
|
<div class="col-md-6">
|
||||||
<p>User Past Treatment Name?</p>
|
<div class="card">
|
||||||
<span>{{ obj.pasttreatment_data.0.name }}</span>
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h5>Recent Meal Record</h5>
|
||||||
|
<a href="{% url 'module_activity:meal_view' principal_id=obj.id %}">View More</a>
|
||||||
|
</div>
|
||||||
|
<table id="meal-table" class="table dt-table-hover" style="width:100%">
|
||||||
|
<thead class="text-center">
|
||||||
|
<tr><th class="text-start">Sr no</th>
|
||||||
|
<th class="text-start">Date</th>
|
||||||
|
<th class="text-start">Time</th>
|
||||||
|
<th class="text-start">Meal Type</th>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody class="text-center">
|
||||||
|
{% if not recent_meal %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center" colspan="4"><h3>No meal has been added.</h3></td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
{% for record in recent_meal %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-start">{{ forloop.counter }}</td>
|
||||||
|
<td class="text-start">{{ record.date }}</td>
|
||||||
|
<td class="text-start">{{ record.time }}</td>
|
||||||
|
<td class="text-start">{{ record.meal_type }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 mb-3">
|
|
||||||
<p>When did you undergo this treatment?</p>
|
|
||||||
<span>{{ obj.pasttreatment_data.0.duration }}</span>
|
|
||||||
</div>
|
|
||||||
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:past_treatment' principal_id=obj.id %}">View more</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card col-md-5 m-3 p-3 position-relative">
|
<div class="col-md-6">
|
||||||
<div class="col-md-12 mb-3">
|
<div class="card">
|
||||||
<p>User Chronic conditions/diseases Name?</p>
|
<div class="card-body">
|
||||||
<span>{{ obj.chronic_data.0 }}</span>
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h5>Recent Medication Record</h5>
|
||||||
|
<a href="{% url 'module_activity:medication_view' principal_id=obj.id %}">View More</a>
|
||||||
|
</div>
|
||||||
|
<table id="medication-table" class="table dt-table-hover" style="width:100%">
|
||||||
|
<thead class="text-center">
|
||||||
|
<tr><th class="text-start">Sr no</th>
|
||||||
|
<th class="text-start">Date</th>
|
||||||
|
<th class="text-start">Time</th>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody class="text-center">
|
||||||
|
{% if not recent_medication %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center" colspan="4"><h3>No medication has been added.</h3></td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
{% for record in recent_medication %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-start">{{ forloop.counter }}</td>
|
||||||
|
<td class="text-start">{{ record.date }}</td>
|
||||||
|
<td class="text-start">{{ record.time }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12 mb-3">
|
|
||||||
<p>For how long have you been experiencing this diseases?</p>
|
|
||||||
<span>{{ obj.chronic_data.0 }}</span>
|
|
||||||
</div>
|
|
||||||
<a class="view-more-link position-absolute top-0 end-0 m-2" href="{% url 'module_activity:chronic_condition' principal_id=obj.id %}">View more</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex mb-5">
|
|
||||||
<a class="download-btn-custom mt-3" href="manage-users.php">
|
<div class="row mb-3">
|
||||||
<span>Download user profile</span>
|
|
||||||
<img src="../src/assets/img/download.svg" />
|
<div class="col-md-6">
|
||||||
</a>
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h5>Recent Bowel Record</h5>
|
||||||
|
<a href="{% url 'module_activity:bowel_view' principal_id=obj.id %}">View More</a>
|
||||||
|
</div>
|
||||||
|
<table id="bowel-table" class="table dt-table-hover" style="width:100%">
|
||||||
|
<thead class="text-center">
|
||||||
|
<tr><th class="text-start">Sr no</th>
|
||||||
|
<th class="text-start">Date</th>
|
||||||
|
<th class="text-start">Time</th>
|
||||||
|
<th class="text-start">Stool Type</th>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody class="text-center">
|
||||||
|
{% if not recent_bowel %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center" colspan="4"><h3>No bowel has been added.</h3></td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
{% for record in recent_bowel %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-start">{{ forloop.counter }}</td>
|
||||||
|
<td class="text-start">{{ record.date }}</td>
|
||||||
|
<td class="text-start">{{ record.time }}</td>
|
||||||
|
<td class="text-start">{{ record.stool_type }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<h5>Recent Symptoms Record</h5>
|
||||||
|
<a href="{% url 'module_activity:meal_symptoms_view' principal_id=obj.id %}">View More</a>
|
||||||
|
</div>
|
||||||
|
<table id="symptoms-table" class="table dt-table-hover" style="width:100%">
|
||||||
|
<thead class="text-center">
|
||||||
|
<tr><th class="text-start">Sr no</th>
|
||||||
|
<th class="text-start">Date</th>
|
||||||
|
<th class="text-start">Time</th>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody class="text-center">
|
||||||
|
{% if not recent_meal_symptom %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center" colspan="4"><h3>No symptoms has been added.</h3></td>
|
||||||
|
</tr>
|
||||||
|
{% else %}
|
||||||
|
{% for record in recent_meal_symptom %}
|
||||||
|
<tr>
|
||||||
|
<td class="text-start">{{ forloop.counter }}</td>
|
||||||
|
<td class="text-start">{{ record.date }}</td>
|
||||||
|
<td class="text-start">{{ record.time }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="pills-tab2" role="tabpanel" aria-labelledby="pills-tab2-tab" tabindex="1">
|
{% comment %} <div class="tab-pane fade" id="pills-tab2" role="tabpanel" aria-labelledby="pills-tab2-tab" tabindex="1">
|
||||||
<div class="row layout-spacing">
|
<div class="row layout-spacing">
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="statbox widget box box-shadow">
|
<div class="statbox widget box box-shadow">
|
||||||
@@ -213,7 +342,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> {% endcomment %}
|
||||||
<div class="tab-pane fade" id="pills-tab3" role="tabpanel" aria-labelledby="pills-tab3-tab" tabindex="2">
|
<div class="tab-pane fade" id="pills-tab3" role="tabpanel" aria-labelledby="pills-tab3-tab" tabindex="2">
|
||||||
<div class="d-flex justify-content-sm-end justify-content-center mb-3">
|
<div class="d-flex justify-content-sm-end justify-content-center mb-3">
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
@@ -267,12 +396,12 @@ var reportUrl = "{% url 'module_activity:report_data' principal_id=obj.id %}?dat
|
|||||||
// Entry point
|
// Entry point
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
tableName = $('#table');
|
tableName = $('#table');
|
||||||
dataTableInstance = initializeDataTable(tableName, activityMainUrl);
|
//dataTableInstance = initializeDataTable(tableName, activityMainUrl);
|
||||||
getReportData();
|
getReportData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to initialize DataTable
|
// Function to initialize DataTable
|
||||||
function initializeDataTable(tableName, activityMainUrl) {
|
/* function initializeDataTable(tableName, activityMainUrl) {
|
||||||
return tableName.DataTable({
|
return tableName.DataTable({
|
||||||
processing: true,
|
processing: true,
|
||||||
serverSide: true,
|
serverSide: true,
|
||||||
@@ -389,7 +518,7 @@ function filterActivityData(dateRange){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
function getReportData(timeRange){
|
function getReportData(timeRange){
|
||||||
@@ -403,11 +532,10 @@ function getReportData(timeRange){
|
|||||||
if (response.status == 200){
|
if (response.status == 200){
|
||||||
setReportContent(response.data)
|
setReportContent(response.data)
|
||||||
}
|
}
|
||||||
if (response.status == 204){
|
if (response.status == 202){
|
||||||
console.log(response.message)
|
|
||||||
const errorCard = $('<div class="card card-danger text-center mt-3 p-4 tab-pane-content"></div>');
|
const errorCard = $('<div class="card card-danger text-center mt-3 p-4 tab-pane-content"></div>');
|
||||||
const title = $('<h5 class="mb-3"></h5>').text('Error');
|
const title = $('<h4 class="mb-3"></h4>').text('Not Enough Records');
|
||||||
const message = $('<p></p>').text(response.message);
|
const message = $('<h5></h5>').text(response.message);
|
||||||
|
|
||||||
errorCard.append(title);
|
errorCard.append(title);
|
||||||
errorCard.append(message);
|
errorCard.append(message);
|
||||||
|
|||||||
@@ -45,8 +45,11 @@
|
|||||||
<th class="checkbox-column text-center dt-no-sorting" tabindex="0"
|
<th class="checkbox-column text-center dt-no-sorting" tabindex="0"
|
||||||
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
||||||
#</th>
|
#</th>
|
||||||
|
<th class="text-center dt-no-sorting" tabindex="0"
|
||||||
|
aria-controls="style-3" aria-sort="ascending" style="width: 50.2656px;">
|
||||||
|
Sr. No</th>
|
||||||
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
<th class="sorting_asc text-center" tabindex="0" aria-controls="style-3"
|
||||||
aria-sort="ascending" style="width: 50.2656px;">Record id</th>
|
aria-sort="ascending" style="width: 50.2656px;">User id</th>
|
||||||
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="1" aria-controls="style-3"
|
||||||
colspan="1" style="width: 44.2344px;">Name</th>
|
colspan="1" style="width: 44.2344px;">Name</th>
|
||||||
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
<th class="sorting text-center" tabindex="2" aria-controls="style-3"
|
||||||
@@ -69,20 +72,9 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% comment %} <thead id="filterboxrow">
|
|
||||||
<tr>
|
|
||||||
<th class="text-center" rowspan="1" colspan="1">id</th>
|
|
||||||
<th class="text-center" rowspan="1" colspan="1">id</th>
|
|
||||||
<th rowspan="1" colspan="1">Email</th>
|
|
||||||
<th rowspan="1" colspan="1">Name</th>
|
|
||||||
<th rowspan="1" colspan="1">Phone No.</th>
|
|
||||||
<th rowspan="1" colspan="1">Date of Birth</th>
|
|
||||||
<th class="" rowspan="1" colspan="1">Active</th>
|
|
||||||
<th class="invisible" rowspan="1" colspan="1">Action</th>
|
|
||||||
</tr>
|
|
||||||
<thead> {% endcomment %}
|
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -135,6 +127,15 @@ function initializeDataTable(tableName, mainUrl) {
|
|||||||
},
|
},
|
||||||
columns: [
|
columns: [
|
||||||
{ data: null, className: "text-center", render: renderCheckbox },
|
{ data: null, className: "text-center", render: renderCheckbox },
|
||||||
|
{
|
||||||
|
data: null,
|
||||||
|
className: "text-center",
|
||||||
|
render: function(data, type, row, meta) {
|
||||||
|
// Calculate sequence number based on page, page length, and index
|
||||||
|
var sequenceNumber = meta.row + meta.settings._iDisplayStart + 1;
|
||||||
|
return sequenceNumber;
|
||||||
|
}
|
||||||
|
},
|
||||||
{ data: "id", className: "text-center" },
|
{ data: "id", className: "text-center" },
|
||||||
{ data: "first_name", className: "text-center" },
|
{ data: "first_name", className: "text-center" },
|
||||||
{ data: "email", className: "text-center" },
|
{ data: "email", className: "text-center" },
|
||||||
@@ -144,10 +145,10 @@ function initializeDataTable(tableName, mainUrl) {
|
|||||||
{ data: null, className: "text-center", render: renderActions }
|
{ data: null, className: "text-center", render: renderActions }
|
||||||
],
|
],
|
||||||
debug: true,
|
debug: true,
|
||||||
order: [[1, 'desc']],
|
order: [[2, 'desc']],
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{ targets: [1, 2, 3, 4, 5], searchable: true, orderable: true },
|
{ targets: [2, 3, 4, 5, 6], searchable: true, orderable: true },
|
||||||
{ targets: [0, -1], searchable: false, orderable: false }
|
{ targets: [0, 1, -1], searchable: false, orderable: false }
|
||||||
],
|
],
|
||||||
orderCellsTop: true,
|
orderCellsTop: true,
|
||||||
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
dom: "<'dt--top-section'<'row'<'col-12 col-sm-6 d-flex justify-content-sm-start justify-content-center'l><'col-12 col-sm-6 d-flex justify-content-sm-end justify-content-center mt-sm-0 mt-3'Bf>>>" +
|
||||||
@@ -191,9 +192,9 @@ function initCompleteCallback() {
|
|||||||
console.log(tableId);
|
console.log(tableId);
|
||||||
|
|
||||||
// Specify the column indexes for individual searchable fields (adjust as needed)
|
// Specify the column indexes for individual searchable fields (adjust as needed)
|
||||||
var searchableColumns = [1, 2, 3, 4, 5, 6];
|
var searchableColumns = [2, 3, 4, 5, 6, 7];
|
||||||
// Specify the column indexes for select input fields (adjust as needed)
|
// Specify the column indexes for select input fields (adjust as needed)
|
||||||
var selectDropdownInputColumns = [6]
|
var selectDropdownInputColumns = [7]
|
||||||
|
|
||||||
// will use this code in future
|
// will use this code in future
|
||||||
/*
|
/*
|
||||||
@@ -288,15 +289,14 @@ function renderSwitch(data, type, row) {
|
|||||||
// Render actions
|
// Render actions
|
||||||
function renderActions(data, type, row) {
|
function renderActions(data, type, row) {
|
||||||
return `
|
return `
|
||||||
<div class="dropdown">
|
<a href="${viewUrl.replace('0', row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
</a>
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
{% comment %} <a href="${ editUrl.replace('0',row.id)}" class="bs-tooltip" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="Edit" data-bs-original-title="Edit" aria-label="Edit">
|
||||||
<a class="dropdown-item view" href="${ viewUrl.replace('0',row.id)}" data-id="${row.id}">View</a>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2 p-1 br-8 mb-1"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
|
||||||
{% comment %} <a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a> {% endcomment %}
|
</a> {% endcomment %}
|
||||||
</div>
|
`;
|
||||||
</div>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -236,15 +236,15 @@ function renderSwitch(data, type, row) {
|
|||||||
// Render actions
|
// Render actions
|
||||||
function renderActions(data, type, row) {
|
function renderActions(data, type, row) {
|
||||||
return `
|
return `
|
||||||
<div class="dropdown">
|
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a href="javascript:void(0);" role="button" data-id="${row.id}" class="bs-tooltip view" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
|
||||||
<a class="dropdown-item view" href="javascript:void(0);" data-id="${row.id}">View</a>
|
<a href="${ editUrl.replace('0',row.id)}" class="bs-tooltip edit" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="Edit" data-bs-original-title="Edit" aria-label="Edit">
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2 p-1 br-8 mb-1"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
|
||||||
</div>
|
</a>
|
||||||
</div>`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle archive action
|
// Function to handle archive action
|
||||||
|
|||||||
@@ -182,15 +182,14 @@ function renderSwitch(data, type, row) {
|
|||||||
// Render actions
|
// Render actions
|
||||||
function renderActions(data, type, row) {
|
function renderActions(data, type, row) {
|
||||||
return `
|
return `
|
||||||
<div class="dropdown">
|
<a href="${ editUrl.replace('0',row.id)}" class="bs-tooltip edit" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="Edit" data-bs-original-title="Edit" aria-label="Edit">
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2 p-1 br-8 mb-1"><path d="M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
</a>
|
||||||
</a>
|
<a href="javascript:void(0);" data-id="${row.id}" class="bs-tooltip send" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="Reply" data-bs-original-title="Reply" aria-label="Reply">
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-send"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>
|
||||||
<a class="dropdown-item edit" href="${ editUrl.replace('0',row.id)}" data-id="${row.id}">Edit</a>
|
</a>
|
||||||
<a class="dropdown-item send" href="javascript:void(0);" data-id="${row.id}">Send</a>
|
|
||||||
</div>
|
`;
|
||||||
</div>`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback function for DataTable initialization complete event
|
// Callback function for DataTable initialization complete event
|
||||||
|
|||||||
@@ -376,15 +376,15 @@ function renderSwitch(data, type, row) {
|
|||||||
// Render actions
|
// Render actions
|
||||||
function renderActions(data, type, row) {
|
function renderActions(data, type, row) {
|
||||||
return `
|
return `
|
||||||
<div class="dropdown">
|
<a href="javascript:void(0);" role="button" data-id="${row.id}" class="bs-tooltip view" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="View" data-bs-original-title="View" aria-label="View">
|
||||||
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink${row.id}" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-eye"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-more-horizontal"><circle cx="12" cy="12" r="1"></circle><circle cx="19" cy="12" r="1"></circle><circle cx="5" cy="12" r="1"></circle></svg>
|
</a>
|
||||||
</a>
|
|
||||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuLink${row.id}" style="">
|
<a href="javascript:void(0);" data-id="${row.id}" class="bs-tooltip reply" data-bs-toggle="tooltip" data-bs-placement="top" title="" data-original-title="Reply" data-bs-original-title="Reply" aria-label="Reply">
|
||||||
<a class="dropdown-item view" href="javascript:void(0);" data-id="${row.id}">View</a>
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-send"><line x1="22" y1="2" x2="11" y2="13"></line><polygon points="22 2 15 22 11 13 2 9 22 2"></polygon></svg>
|
||||||
<a class="dropdown-item reply" href="javascript:void(0)" data-id="${row.id}">Reply</a>
|
</a>
|
||||||
</div>
|
|
||||||
</div>`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function HideButton(className) {
|
function HideButton(className) {
|
||||||
|
|||||||
Reference in New Issue
Block a user