What is Amazon Nova Act AI?

Image
  What is Amazon Nova Act AI? Okay so, let me tell you about something super cool Amazon made. It's called Nova Act , and it's like a super smart robot brain that can use the internet just like we do! You know how we open websites, click stuff, type in boxes, and buy things online? Nova Act can do all that ... by itself! 1. It’s an AI Agent for Browsing the Internet So this Nova Act thing is like a robot helper that knows how to use a browser (like Chrome or Safari). It can go to websites, click buttons, fill forms, buy stuff, and even follow hard instructions without us telling it every little thing. Like imagine you said, "Hey Nova, go buy me a red t-shirt from Amazon." And guess what? It actually can go and do it all by itself! How crazy is that! 2. It Works on Its Own! One of the coolest thing about Nova Act is, once you give it a job, you don’t have to sit and watch it or tell it every step. It just knows what to do next, and it finish the task for you. Li...

How to create a Full-Stack Billing System with JavaScript, Node.js, Express, MySQL, and Semantic UI (1.5)


 About The EJS Template Structure

This HTML template is part of an inventory management system that allows users to view stock summaries and filter stock by brand or category. It utilizes several technologies:

  • Bootstrap and Semantic-UI for responsive layout and styling.
  • A vertical navigation bar on the left with links to various pages like Dashboard, Billing, Orders, and Stock management.
  • The page content displays a stock summary table where the user can filter stocks based on selected brands or categories.
  • Form inputs are provided to choose filtering criteria, with corresponding tables dynamically populated with stock data using server-side templating (EJS).
  • The stock data includes details like Item ID, Item Name, Category, Brand, Size, and Quantity, fetched from the database and displayed in tables with filtering functionality.

viewstocks.ejs file

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--Custom CSS-->
    <link rel="stylesheet" href="/css/style.css">
    <!--Semantic-UI CSS-->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.css">
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">

    <title>View Stocks</title>
  </head>
  <body>
     <!--Vertical Navbar-->
  <div class="vertical-nav bg-white" id="sidebar">
    <div class="py-4 px-3 mb-4" style="background: linear-gradient(to top, #90EE90 0%, #FFB385 68%);">
      <div class="media d-flex align-items-center"><img src="/css/admin.svg" alt="..." width="65" class="mr-3 rounded-circle img-thumbnail shadow-sm">
        &emsp;<div class="media-body">
          <h4 class="m-0"><p class="text-white">Hubuk Garments</h4>
            <p class="font-weight-light text-white mb-0"></p>
        </div>
      </div>
    </div>
    <form action="/logout?_method=DELETE" method="POST">
      <center><button type="submit" class="btn btn-danger" ><p class="text-white">Log Out</p></button></center>
    </form>
    <h5 class="ui horizontal divider header text-primary">
      MAIN
    </h5>
 
    <ul class="nav flex-column bg-white mb-0">
      <li class="nav-item">
        <a href="/" class="nav-link text-dark font-italic">
                  <i class="home icon"></i>
                  Dashboard
              </a>
      </li>
      <li class="nav-item">
        <a href="/bill" class="nav-link text-dark font-italic">
          <i class="rupee sign icon"></i>
                  Bill
              </a>
      </li>
      <li class="nav-item">
        <a href="/orders" class="nav-link text-dark font-italic">
          <i class="eye icon"></i>
                  View Orders
              </a>
      </li>
      <li class="nav-item">
        <a href="/viewstocks" class="nav-link text-dark font-italic" style="background: linear-gradient(to right, #90EE90 0%, #FFB385 68%);">
          <p class="text-white"><i class="tags icon"></i>
                  View Stocks
                  </p>
              </a>
      </li>
      <li class="nav-item">
        <a href="/stocks" class="nav-link text-dark font-italic">
          <i class="plus circle icon"></i>
                  Add Stock
              </a>
      </li>
    </ul>
 
    <h5 class="ui horizontal divider header text-primary">
      CUSTOMIZE
    </h5>
 
    <ul class="nav flex-column bg-white mb-0">
      <li class="nav-item">
        <a href="/brands" class="nav-link text-dark font-italic">
          <i class="yelp icon"></i>
                  Brand
              </a>
      </li>
      <li class="nav-item">
        <a href="/categories" class="nav-link text-dark font-italic">
          <i class="bookmark icon"></i>
                  Category
              </a>
      </li>
      <li class="nav-item">
        <a href="/sizes" class="nav-link text-dark font-italic">
          <i class="check square icon"></i>
                  Size
              </a>
      </li>
    </ul>

    <h5 class="ui horizontal divider header text-primary">
      FILTERS
    </h5>
 
    <ul class="nav flex-column bg-white mb-0">
      <li class="nav-item">
        <a href="/sales_filter" class="nav-link text-dark font-italic">
          <i class="yelp icon"></i>
                  Sales
              </a>
      </li>
      <li class="nav-item">
        <a href="/stock_filter" class="nav-link text-dark font-italic">
          <i class="bookmark icon"></i>
                  Stock
              </a>
      </li>
    </ul>
  </div>
  <!-- End vertical navbar -->
 
  <!-- Page content holder -->
  <div class="page-content p-5" id="content" style="background: linear-gradient(to right, #90EE90 47%, #FFB385 68%);">
    <!-- Toggle button -->
    <button id="sidebarCollapse" type="button" class="btn btn-light bg-white rounded-pill shadow-sm px-4 mb-4"><i class="align justify icon"></i><small class="text-uppercase font-weight-bold">Menu</small></button>
 
    <!-- Page content -->
    <h1>Stocks Summary</h1>
    <br>
    <center><img class="ui medium rounded image" src="/css/stock.svg"></center>
    <br>
    <form action="/viewstocks/stocks_query" method="POST">
      <div class="ui four column grid">
        <div class="row">
        <div class="column">
        <h3>View Stock By</h3>
        </div>
       
        <div class="column">
        <div class="form-check form-check-inline form-switch">
             <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios2" value="brand" oninput="myFunction()">
            <label class="form-check-label" for="exampleRadios2">
                Brand
            </label>
        </div>
        <div class="form-check form-check-inline form-switch">
            <input class="form-check-input" type="radio" name="exampleRadios" id="exampleRadios3" value="category" oninput="myFunction()">
            <label class="form-check-label" for="exampleRadios3">
                Category
            </label>
        </div>
        </div>
        <div class="column">
            <select class="form-select" aria-label="Disabled select example" id="brand" name="Brand" disabled>
                <option selected>Select Brand</option>
                <% brands.forEach(function(order){ %>
                  <option value="<%= order.Brand %>"><%= order.Brand %></option>
                  <% }); %>
              </select>
        </div>
        <div class="column">
            <select class="form-select" aria-label="Disabled select example" id="category" name="Category" disabled>
                <option selected>Select Category</option>
                <% categories.forEach(function(order){ %>
                  <option name="<%= order.Category %>" value="<%= order.Category %>"><%= order.Category %></option>
                <% }); %>
              </select>
        </div>
        </div>
        </div>
        <br>
        <center>
          <div class="ui left corner labeled action input">
            <button class="ui teal button" type="submit">Search &emsp;</button>
            <div class="ui corner label">
              <i class="search icon"></i>
            </div>
          </div>
        </center>
      </form>
    <% if(filter_type == 'None') { %>  
      <table class="ui inverted table table-bordered" style="background-color: #A52A2A; color: white;">
        <thead>
        <tr>
            <th>Item ID</th>
            <th>Item Name</th>
            <th>Category</th>
            <th>Brand Name</th>
            <th>Size</th>
            <th>Amount</th>
            <th>Quantity</th>
            <th>Date Entered</th>
            <th>Time Entered</th>
        </tr>
    </thead>
    <tbody>
        <% all_stocks.forEach(function(order){ %>
            <tr style="background: linear-gradient(to left, #66CDAA 0%, #CD5C5C 68%);">
                <td><%= order.ItemID %>
                <td><%= order.ItemName %></td>
                <td><%= order.Category %></td>
                <td><%= order.Brand %></td>
                <td><%= order.Size %></td>
                <td><%= order.Amount %></td>
                <td><%= order.quantity %></td>
                <td><%= order.StockDate %></td>
                <td><%= order.StockTime %>&emsp;<form action="/viewstocks/deletestock" method="POST"><input type="hidden" name="deleteid" value="<%= order.ItemID %>"><button type="submit" class="btn btn-danger btn-sm">Delete</button></form></td>
                <!-- <form action="/deleteitem" method="POST"><input type="hidden" name="deleteid" value="<%= order.TransactionID %>"><button type="submit" class="btn btn-danger btn-sm">Delete</button></form> -->
            </tr>
        <% }); %>
    </tbody>
    </table>
    <% } %>

    <% if(filter_type == 'brand') { %>
      <br>  
      <h2 class="text-primary">Showing Stocks for <%= filter_name %>  </h2>
      <br>
      <table class="ui inverted violet table table-bordered">
          <thead>
          <tr>
              <th>Item ID</th>
              <th>Item Name</th>
              <th>Category</th>
              <th>Brand Name</th>
              <th>Size</th>
              <th>Amount</th>
              <th>Quantity</th>
              <th>Date Entered</th>
              <th>Time Entered</th>
          </tr>
      </thead>
      <tbody>
          <% display_content.forEach(function(order){ %>
              <tr style="background: linear-gradient(to left, #0066eb 0%, #ff8ab3 68%);">
                  <td><%= order.ItemID %>
                  <td><%= order.ItemName %></td>
                  <td><%= order.Category %></td>
                  <td><%= order.Brand %></td>
                  <td><%= order.Size %></td>
                  <td><%= order.Amount %></td>
                  <td><%= order.quantity %></td>
                  <td><%= order.StockDate %></td>
                  <td><%= order.StockTime %>&emsp;<form action="/viewstocks/deletestock" method="POST"><input type="hidden" name="deleteid" value="<%= order.ItemID %>"><button type="submit" class="btn btn-danger btn-sm">Delete</button></form></td>
                  <!-- <form action="/deleteitem" method="POST"><input type="hidden" name="deleteid" value="<%= order.TransactionID %>"><button type="submit" class="btn btn-danger btn-sm">Delete</button></form> -->
              </tr>
          <% }); %>
      </tbody>
      </table>
      <% } %>

      <% if(filter_type == 'category') { %>
        <br>  
        <h2 class="text-primary">Showing Stocks for <%= filter_name %>  </h2>
        <br>
        <table class="ui inverted violet table table-bordered">
            <thead>
            <tr>
                <th>Item ID</th>
                <th>Item Name</th>
                <th>Category</th>
                <th>Brand Name</th>
                <th>Size</th>
                <th>Amount</th>
                <th>Quantity</th>
                <th>Date Entered</th>
                <th>Time Entered</th>
            </tr>
        </thead>
        <tbody>
            <% display_content.forEach(function(order){ %>
                <tr style="background: linear-gradient(to left, #0066eb 0%, #ff8ab3 68%);">
                    <td><%= order.ItemID %>
                    <td><%= order.ItemName %></td>
                    <td><%= order.Category %></td>
                    <td><%= order.Brand %></td>
                    <td><%= order.Size %></td>
                    <td><%= order.Amount %></td>
                    <td><%= order.quantity %></td>
                    <td><%= order.StockDate %></td>
                    <td><%= order.StockTime %>&emsp;<form action="/viewstocks/deletestock" method="POST"><input type="hidden" name="deleteid" value="<%= order.ItemID %>"><button type="submit" class="btn btn-danger btn-sm">Delete</button></form></td>
                   
                </tr>
            <% }); %>
        </tbody>
        </table>
        <% } %>

    </div>
   
    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
    <!-- Semnatic-UI Scripts -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.2.13/semantic.min.js"></script>

    <script>
      $(function() {
    // Sidebar toggle behavior
    $('#sidebarCollapse').on('click', function() {
      $('#sidebar, #content').toggleClass('active');
    });
  });
 

  function myFunction(){
    if (document.getElementById('exampleRadios2').checked == true){
      document.getElementById("brand").disabled = false;
      document.getElementById("category").disabled = true;
    }
    if (document.getElementById('exampleRadios3').checked == true){
      document.getElementById("brand").disabled = true;
      document.getElementById("category").disabled = false;
    }
  }
</script>
  </body>
</html>

viewstocks.js router file

const express = require('express');
const router = express.Router();
const { viewstocksControllers } = require('../controllers/viewstocksControllers');

// Define a route for fetching stock data
router.get('/', viewstocksControllers.getViews);

// Define a POST route for deleting stock
router.post('/deletestock', viewstocksControllers.deleteViews);

// Define a POST route for filtering stocks by brand or category
router.post('/stocks_query', viewstocksControllers.filterViews);

module.exports = router;


viewstocksControllers.js controller file

const db = require('../db/connect.js');

const viewstocksControllers = {
 
getViews:(req, res) => {
    // Query to fetch all stocks
    const stockQuery = `SELECT * FROM add_stock`;

    // Query to fetch data from brands and categories tables
    const brandsQuery = `SELECT * FROM brands`;
    const categoryQuery = `SELECT * FROM categories`;

    // Execute all queries using Promise.all to ensure data is fetched before rendering
    Promise.all([
      new Promise((resolve, reject) => {
        db.query(stockQuery, (err, stockResults) => {
          if (err) reject(err);
          resolve(stockResults);
        });
      }),
      new Promise((resolve, reject) => {
        db.query(brandsQuery, (err, brandResults) => {
          if (err) reject(err);
          resolve(brandResults);
        });
      }),
      new Promise((resolve, reject) => {
        db.query(categoryQuery, (err, categoryResults) => {
          if (err) reject(err);
          resolve(categoryResults);
        });
      })
    ])
    .then(([stockResults, brandResults, categoryResults]) => {
      // Render the viewstocks page and pass the results and brands/categories to the EJS template
      res.render('viewstocks', {
        title: 'View Stocks',
        all_stocks: stockResults,
        brands: brandResults,
        categories: categoryResults,
        filter_type: req.query.filter_type || 'None'
      });
    })
    .catch((err) => {
      console.error('Error fetching data: ', err);
      res.status(500).send('Error fetching data');
    });
  },
  deleteViews:(req, res) => {
    const { deleteid } = req.body;
    const deleteQuery = 'DELETE FROM add_stock WHERE ItemID = ?';
 
    db.query(deleteQuery, [deleteid], (err, result) => {
      if (err) {
        console.error('Failed to delete stock: ', err);
        return res.status(500).send('Failed to delete stock');
      }
 
      console.log('Stock deleted successfully:', result);
      // Redirect or send a success response
      res.redirect('/viewstocks');
    });
  },

  filterViews: (req, res) => {
    const { Brand, Category } = req.body;

    let filterQuery = `SELECT * FROM add_stock`;
    let filterParams = [];

    if (Brand) {
      filterQuery += ` WHERE Brand = ?`;
      filterParams.push(Brand);
    } else if (Category) {
      filterQuery += ` WHERE Category = ?`;
      filterParams.push(Category);
    }

    db.query(filterQuery, filterParams, (err, results) => {
      if (err) {
        console.error('Error filtering stocks: ', err);
        return res.status(500).send('Error filtering stocks');
      }

      // Render the filtered stocks on the viewstocks page
      res.render('viewstocks', {
        title: 'Filtered Stocks',
        all_stocks: results, // Ensure `all_stocks` is passed
        brands: [],  // If you need to pass brands/categories, update this
        categories: [],  // Same here
        filter_type: Brand ? 'brand' : 'category',
        filter_name: Brand || Category,
        display_content: results // Adjusted for filtered display
      });
    });
  }

 
};



module.exports = { viewstocksControllers};




Comments

Popular posts from this blog

What Is an API?

How to Turn Your Photos into Studio Ghibli-Style Art for Free!

What is Amazon Nova Act AI?