c# dotnet SSE Server do answer, but the Browser do not display the messages. Why?

I have an SSE Server that has the following settings/requirements:

  • C# dotnet 8
  • Non Blocking Communication
  • No ASP
  • No Extention
  • Allow CORS

On the other side (client) I have an Browser with JavaScript

The Problem:

I can see the communication from the client to the server.
The Server accepts the request and send packets back to the client.
I can see the received packets with wireshark, but the javascript do not responds to the received packets.

If I try to use curl, then I receive the header. Then after a short period of time the cached packets (many packets). But I think the cache is full and I see the cache.

Here is the c# SSE Server code:

using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Timers;

class Program
{
    private static readonly List<HttpListenerContext> clients = new List<HttpListenerContext>();
    private static readonly object lockObject = new object();
    private static System.Timers.Timer? messageTimer;

    static async Task Main(string[] args)
    {
        string url = "http://+:5000/";
        HttpListener listener = new HttpListener();
        listener.Prefixes.Add(url);
        listener.Start();
        Console.WriteLine($"Server runs on {url}");

        // Timer
        messageTimer = new System.Timers.Timer(1000);
        messageTimer.Elapsed += SendPeriodicMessages;
        messageTimer.AutoReset = true;
        messageTimer.Enabled = true;

        while (true)
        {
            HttpListenerContext context = await listener.GetContextAsync();
            HandleClient(context);
        }
    }

    private static void HandleClient(HttpListenerContext context)
    {
        HttpListenerRequest request = context.Request;
        HttpListenerResponse response = context.Response;

        response.Headers.Add("Access-Control-Allow-Origin", "*");
        response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS");
        response.Headers.Add("Access-Control-Allow-Headers", "Content-Type");

        if (request.HttpMethod == "OPTIONS")
        {
            response.Headers.Add("Access-Control-Allow-Origin", "*");
            response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS");
            response.Headers.Add("Access-Control-Allow-Headers", "Content-Type");
            response.StatusCode = (int)HttpStatusCode.OK;
            response.OutputStream.Close();
            return;
        }

        response.Headers.Add("Content-Type", "text/event-stream");
        response.Headers.Add("Cache-Control", "no-cache");
        response.Headers.Add("Connection", "keep-alive");

        AddClient(context);
    }

    private static void AddClient(HttpListenerContext context)
    {
        lock (lockObject)
        {
            clients.Add(context);

            var clientIp = context.Request.RemoteEndPoint.Address.ToString();
            var clientPort = context.Request.RemoteEndPoint.Port;
            Console.WriteLine($"Client connected: IP = {clientIp}, Port = {clientPort}");
        }
    }

    static int TimerCounter = 0;
    private static void SendPeriodicMessages(object? sender, ElapsedEventArgs e)
    {
        Console.WriteLine("TimerTick " + TimerCounter);
        SendMessagesToClients("data: " + TimerCounter++ + "\n\n");
    }

    private static void SendMessagesToClients(string message)
    {
        Task.Run(async () =>
        {
            byte[] buffer = Encoding.UTF8.GetBytes(message);

            List<Task> sendTasks = new List<Task>();
            List<HttpListenerContext> removeList = new ();

            lock (lockObject)
            {
                Console.WriteLine("Number of Clients: " + clients.Count);
                foreach (var client in clients)
                {
                    sendTasks.Add(Task.Run(() =>
                    {
                        try
                        {
                            HttpListenerRequest request = client.Request;
                            HttpListenerResponse response = client.Response;

                            var clientIp = client.Request.RemoteEndPoint.Address.ToString();
                            var clientPort = client.Request.RemoteEndPoint.Port;
                            Console.WriteLine($"Sending Data ({buffer.Length}) to {clientIp}:{clientPort}");

                            response.OutputStream.Write(buffer, 0, buffer.Length);
                            response.OutputStream.Flush();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine($"Error - Cant send data to Client: {ex.Message}");
                            removeList.Add(client);
                        }
                    }));
                }
            }

            await Task.WhenAll(sendTasks);

            lock (lockObject)
            {
                while (removeList.Count > 0)
                {
                    clients.Remove(removeList.First());
                    removeList.RemoveAt(0);   
                }
            }
        });
    }
}

And the JavaCode:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TEST</title>
</head>
<body>
    <h1>
        Server Send Event
    </h1>
    <div id="messages"></div>
    <script>
        const eventSource = new EventSource('http://192.168.56.245:5000/');

        eventSource.onmessage = function(event) {
            const messagesDiv = document.getElementById('messages');
            messagesDiv.innerHTML += `<p>${event.data}</p>`;
            console.log(event.data);
        };

        eventSource.onerror = function(event) {
            console.error("Error receiving messages from SSE:", event);
            eventSource.close();
        };
    </script>
</body>
</html>

how do I pass a URL with multiple parameters in javascript code? [duplicate]

I want to run jasper report from oracle APEX and I used javascript code to run the report URL

I need to run the URL and pass 3 parameters

This is the code I used :

var company_id = $v('P53_COMPANY');
var sample_id = $v('P53_SAMPLE');
var program_id = $v('P53_PROGRAM');

if (company_id && sample_id && program_id) {
    var url = 'http://maxapex:8090/JasperReportsIntegration/report?_repName=785/Companyrep&_repFormat=pdf&standAlone=true&_dataSource=2064&company_id=' + company_id;
    window.open(url, '_blank'); // Opens the URL in a new tab
} else {
    alert('Select company and sample and program before print');
}

the code with one parameter its working but I need to pass also sample_id and program_id
at the end of var url ,

I don’t know the correct syntax ?
Thank you in advance

Change CSS property after transition

I have a button to toggle opening and closing of a dropdown menu with CSS transition. Suppose I have this HTML for a dropdown menu and a toggle button:

<button type="button" id="main-nav-collapse-button" aria-label="Click to expand or collapse the main navigation menu" >☰</button>
...
<nav role="navigation" id="main-nav"><ul>
  <li>...</li>
  <li>...</li>
  <li>...</li>
</ul></nav>

Instead of opening/closing the nav dropdown with JS, I have minimal JS to just add/remove a class .expanded to/from the <ul>.

I have transition in the CSS so that the opening/closing is animated:

#main-nav>ul {
  display:none;
  max-height:0;
  overflow:hidden;
  transition: height 0.5s linear;
}
#main-nav>ul.expanded {
  display:block;
  max-height: 100vh;
}

The problem with the above code is that the opening/closing do not transition/animate because I have display CSS property specified in both states. display cannot be transition/animated and it is toggled straight away when the class is added/removed.

In contrast, if I remove the display properties in the CSS, it does animate. The only problem is that the menu is only hidden from users (height=0) but not preventing the menu from being accessed. When users use keyboard-navigation by tapping , the menu items in the menu are still focusable even they are visibly ‘hidden’. I haven’t found a solution to disable the focus with CSS.

I am hoping there is a way to apply the display property change before/after the CSS transition. I haven’t got a pure CSS approach. My current fallback is to apply the change of display property before/after the class-toggle with a delay using JS, but I just feel that this approach is more like a patch to the problem rather than a proper solution.

It will be great if there is a non-JS solution.

Side note: I could have made the class-toggling part non-JS-dependent too, but unfortunately the button and the nav don’t share the same parent in DOM. Making the dropdown to appear/hide on hover without JS would be extremely difficult.

Flatpickr in Brave / Safari needs two clicks to open

I have tried literally everything I (and chatgpt) could think of but I cannot fix it.
I have a simple form using Flatpickr. It works like a charm but in Safari and Brave (the latter both on Android and iOs) the date picker needs two clicks to open the datepicker.

This is my code:

<!-- Flatpickr CSS & JS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>

<form id="booking-form" style="
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  background-color: #2F4D47;
  border-radius: 10px;
  padding: 10px;
">
  <!-- Location select -->
  <select id="location" style="
    flex: 1 1 auto;
    min-width: 150px;
    background-color: #FFFFFF;
    border: none;
    border-radius: 5px;
    padding: 12px 40px 12px 15px;
    font-size: 16px;
    color: #1f1f1f;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg fill='%231f1f1f' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
  ">
    <option value="">Alle locaties</option>
    <option value="811720" selected>Kedichem</option>
    <option value="811721">Dorst</option>
  </select>

  <!-- Date range -->
<input type="text" id="date-range" placeholder="Selecteer periode" readonly style="
  flex: 1 1 auto;
  min-width: 200px;
  background-color: #FFFFFF;
  border: none;
  border-radius: 5px;
  padding: 12px 15px; /* GEEN extra padding rechts */
  font-size: 16px;
  color: #1f1f1f;
  text-align: left;
  width: 100%;
">

  <!-- Number of people -->
  <select id="people" style="
    flex: 1 1 auto;
    min-width: 100px;
    background-color: #FFFFFF;
    border: none;
    border-radius: 5px;
    padding: 12px 40px 12px 15px;
    font-size: 16px;
    color: #1f1f1f;
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg fill='%231f1f1f' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
  ">
    <option value="1">1</option>
    <option value="2" selected>2</option>
    <option value="3">3</option>
  </select>

  <!-- Submit button -->
  <button type="submit" style="
    flex: 1 1 auto;
    min-width: 120px;
    background-color: #dfa16f;
    color: #1f1f1f;
    border: none;
    border-radius: 25px;
    padding: 12px 15px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
                font-weight: 400;
            font-family: 'gitan-latin';
  ">Zoeken</button>
</form>

<script>
    const input = document.getElementById("date-range");

  const fp = flatpickr(input, {
    mode: "range",
    minDate: "today",
    dateFormat: "Y-m-d",
    clickOpens: false,
    allowInput: false,
  });

  function openPicker(e) {
    e.preventDefault();
    setTimeout(() => {
      input.blur(); // force blur to reset state
      input.focus(); // ensure input is active again
      fp.open();
    }, 0);
  }

  ["click", "focus", "touchstart", "mousedown"].forEach(event => {
    input.addEventListener(event, openPicker, { passive: false });
  });
  // Form logic
  document.getElementById("booking-form").addEventListener("submit", function (event) {
    event.preventDefault();

    const location = document.getElementById("location").value;
    const range = document.getElementById("date-range").value;
    const people = document.getElementById("people").value;

    const [startDate, endDate] = range.split(" to ");

    const currentLocale = window.location.href.includes("/en/") ? "en" : "nl";
    const baseUrl = currentLocale === "en"
      ? "https://reserveren.rostig.nl/en/book"
      : "https://reserveren.rostig.nl/reserveren";

    const url = `${baseUrl}?period%5Bstart_date%5D=${startDate}&period%5Bend_date%5D=${endDate}&guest_group%5Badults%5D=${people}&tag_ids%5B%5D=${location}`;

    const newWindow = window.open(url, "_blank");
    if (!newWindow) {
      window.location.href = url;
    }
  });

</script>

<style>
  /* Responsive layout */
  @media (max-width: 768px) {
    #booking-form {
      flex-wrap: wrap !important;
    }
    #booking-form > * {
      flex: 1 1 100% !important;
      max-width: 100% !important;
    }
  }

  input::placeholder {
    color: #999999;
    opacity: 1;
  }
</style>

The code is live on https://rostig.nl/nl/kedichem/ so you can test the behavior there.

It is a WordPress website build with Avada themebuilder. I have added this code with a code block.

Does anyone have any idea how to solve this?

I have a JSON script which changes the pickerInput in my shiny app, however the dropdown list closes every time I click the group I want to select

I have this JSON script to make the pickerInput in my shiny app select all individuals by their respective groups, however the dropdown list closes every-time I select a group. I have tried to add evt.stopPropagation(); but this did not work. I want to avoid using other packages aside from shiny, shinyWidgets, and tidyr if possible. If there is a better workaround that achieves my goal but uses the included packages, I would be open to it. enter image description here

Here is my current code

library(shiny)
library(shinyWidgets)

    js <- HTML("
    $(document).ready(function() {
      let clickCounter = 0;
      
      function attachClickHandlers() {
    
      $('.dropdown-header').off('click.groupSelect');
    
        $('.dropdown-header').on('click.groupSelect', function(evt) {
          let groupName = $(this).find('span').text().trim();
          clickCounter++;
          Shiny.setInputValue('group_select', groupName + '_' + clickCounter, {priority: 'event'});
        }).css('cursor', 'pointer'); 
      }
      function waitForPicker() {
        if ($('.dropdown-header').length > 0) {
          attachClickHandlers();
        } else {
          setTimeout(waitForPicker, 100);
        }
      }
      
      setTimeout(waitForPicker, 500);
      
      // reattach when dropdown is opened
      $(document).on('shown.bs.dropdown', function() {
        setTimeout(attachClickHandlers, 50);
      });
    })
    ")
    
    choices <- list("A" = c(1, 2, 3, 4, 5), "B" = c(6, 7, 8, 9, 10))
    
    ui <- fluidPage(
      tags$head(tags$script(js)),
      pickerInput("test", choices = choices, multiple = TRUE),
      textOutput("testOutput")
    )
    
    server <- function(input, output, session) {
      output$testOutput <- renderText({
        if(length(input$test) > 0) {
          paste("Selected:", paste(input$test, collapse = ", "))
        } else {
          "No selection"
        }
      })
      
      
      observeEvent(input$group_select, {
        req(input$group_select)
        
        group_name <- gsub("_[0-9]+$", "", input$group_select)
        
        current_selected <- input$test
        if(is.null(current_selected)) current_selected <- c()
        
        group_values <- choices[[group_name]]
        
        if (is.null(group_values)) return()
        
        # select vs. deselect
        if (length(current_selected) > 0 && all(group_values %in% current_selected)) {
          new_selected <- setdiff(current_selected, group_values)
          
        } else {
          
          new_selected <- unique(c(current_selected, group_values))
        }
        
        updatePickerInput(session, "test", selected = new_selected)
      })
    }
    
    shinyApp(ui = ui, server = server)

Odoo12 Point of Sale: Make sure RPC call is ended before printing the receipt

I need to include some information on the point of sale receipt that should actually be obtained via RPC.

I am using Odoo 12, and I found some problems in my code.
Code is working and I can connect to backend and get the desired data via RPC;

Problem is, receit is being printed before the RPC call is ended and thus, I cannot print the information in receipt.

I have tried to extend the PaymentScreenWidget to force RPC before ticket is printed but no luck.

(I believe problem is on this extend as per my coments in point 4.1)

What I have done:

  • My .js file

“””
odoo.define(‘mymodule.sincronize_receitp’, function (require) {
“use strict”;

var models = require('point_of_sale.models');
var screens = require('point_of_sale.screens');
var rpc = require('web.rpc');
var core = require('web.core');
var _t = core._t;

// 1. Using this approach because having some this._super.apply(this, arguments) errors on functions
var originalOrderInitialize = models.Order.prototype.initialize;
var originalOrderExportForPrinting = models.Order.prototype.export_for_printing;
var originalPushOrder = models.PosModel.prototype.push_order;


// 2. Extend original method for controlling RPC state
models.Order = models.Order.extend({
    initialize: function() {
        //this._super.apply(this, arguments); --- having some errors using this approach
        // Calling the original method by using var creates above
        if (originalOrderInitialize) {
            originalOrderInitialize.apply(this, arguments);
        }
        this.rpc_completed = false;
        this.rpc_data = {};
        this.print_callbacks = [];
    },
    
    //Trying to use callbacks to garantee ticket is printed when all callbacks are ended
    add_print_callback: function(callback) {
        if (this.rpc_completed) {
            callback();
        } else {
            this.print_callbacks.push(callback);
        }
    },
    
    export_for_printing: function() {
        //var receipt = this._super.apply(this, arguments);
        var receipt = originalOrderExportForPrinting ? 
            originalOrderExportForPrinting.apply(this, arguments) : 
            {};
            
        console.log('EXPORT FOR PRINTING');
        
        receipt.rpc_data = this.rpc_completed ? this.rpc_data : { status: 'loading' };
        return receipt;
    }
});

// 3. RPC Call added in push_order
models.PosModel = models.PosModel.extend({
    push_order: function(order) {
        var self = this;
        
        if (!order) {
            return Promise.resolve();
        }

        // Set RPC as pending
        order.rpc_state = 'pending';
        order.rpc_data = { status: 'loading' };

        // First call the original method
        return (originalPushOrder ? originalPushOrder.apply(this, arguments) : Promise.resolve())
            .then(function() {
                // RPC Call
                console.log('START RPC');
                
                return rpc.query({
                    model: 'pos.order',
                    method: 'get_data_rpc',
                    args: [order.unique_id],
                }).then(function(response) {
                    order.rpc_data = response || {};
                    order.rpc_state = 'completed';
                    
                    console.log('RPC ENDED:', response);
                    
                })/*
                    I am having errors using .catch() function but this is not the problem since I can see the RPC call is sucessfull
                    .catch(function(error) {
                    console.error('RPC Error:', error);
                    order.rpc_data = { 
                        error: error.message || 'Erro de comunicação',
                        details: error.data ? error.data.message : ''
                    };
                    order.rpc_state = 'failed';
                });*/
            });
    }
});

// 4. Extend PaymentScreen. I was expecting this is only executed after RPC is ended
screens.PaymentScreenWidget.include({
    validate_order: function(force_validate) {
        var self = this;
        var order = this.pos.get_order();
        
        if (!order || order.is_empty()) {
            return this._super(force_validate);
        }
        
        // 4.1. First, validate the payment normally
        // When I run the code, after validate the order, first I get an error in console for this line, after that, receipt is printed before RPC call
        return this._super(force_validate).then(function() {
            
            // 4.2. Send the order and wait for RPC
            return self.pos.push_order(order).then(function() {
                // 3. At last, print the receipt
                return self.pos.proxy('print_receipt', order.export_for_printing());
            });
        });
    }
});

});

“””

Can anyone help me fix this?

Thank you in advance

is there any conditions for excel file upload using javascript (eg cell b5 contains numerical value)? [closed]

not encountering any error scenario is add conditional statement in below script while uploading excel it should check the particular cell contains numeric and if not numeric no upload and show error in uploading.

const express = require("express");
const fileUpload = require("express-fileupload");
const path = require("path");
const filesPayloadExists = require('./middleware/filesPayloadExists');
const fileExtLimiter = require('./middleware/fileExtLimiter');
const fileSizeLimiter = require('./middleware/fileSizeLimiter');
const PORT = process.env.PORT || 3000;
const app = express();
app.get("/", (req, res) => {
    res.sendFile(path.join(__dirname, "index.html"));
});
app.post('/upload', fileUpload({
    createParentPath: true
}), filesPayloadExists, fileExtLimiter(['.xlsx', '.xlsm']), fileSizeLimiter, (req, res) => {
    const files = req.files console.log(files) Object.keys(files).forEach(key => {
        const filepath = path.join(__dirname, 'files', files[key].name) files[key].mv(filepath, (err) => {
            if (err) return res.status(500).json({
                status: "error",
                message: err
            })
        })
    }) return res.json({
        status: 'success',
        message: Object.keys(files).toString()
    })
}) app.listen(PORT, () => console.log(Server running on port $ {
    PORT
}));

is there any conditions for excel file upload using java script ( ex. cell b5 contains be numerical value)?

here is the code is there anything to be change

i was expecting the excel file should meet cell b5 in numeric while uploading if not met no upload and should show error

const express = require(“express”);const fileUpload = require(“express-fileupload”);const path = require(“path”);const filesPayloadExists = require(‘./middleware/filesPayloadExists’);
const fileExtLimiter = require(‘./middleware/fileExtLimiter’);const fileSizeLimiter = require(‘./middleware/fileSizeLimiter’);const PORT = process.env.PORT || 3000;const app = express();app.get(“/”, (req, res) => {res.sendFile(path.join(__dirname, “index.html”));
});app.post(‘/upload’,fileUpload({ createParentPath: true }),filesPayloadExists,fileExtLimiter([‘.xlsx’,’.xlsm’]),
fileSizeLimiter,(req, res) => {const files = req.files
console.log(files) Object.keys(files).forEach(key => { const filepath = path.join(__dirname, ‘files’, files[key].name)
files[key].mv(filepath, (err) => {
if (err) return res.status(500).json({ status: “error”, message: err }) }) }) return res.json({ status: ‘success’, message: Object.keys(files).toString() })})app.listen(PORT, () => console.log(Server running on port ${PORT}));

Convert HTML to PDF from frontENd, when download it then format of complaint and opposite poarty changes

Frontend Notice
Under the Consumer Protection Act, 2019
Email:  
FIRST APPEAL NO. G.MANI S/O. GOVINDASAMY….Petitioner/ AppellantVersusCENTRAL BANK OF INDIA…..Opposite Party/ Respondent(s)To,Complainant / Petitioner / Appellant Name:G.MANI S/O. GOVINDASAMYFARIDABAD HARYANA 1220011A. G.MANI S/O. GOVINDASAMYALSO AT: NEW DELHI DELHI 1100921B. G.MANI S/O. GOVINDASAMYALSO AT: NO 1/56B, PILLAYAR KOIL STREET, ANNANGUDI VILLAGE, KATPADI TALUK, VELLORE DISTRICT, TAMIL NADU AMBALA HARYANA 122001TMT. PUSHPA W/O. G. MANINO 1/56B, PILLAYAR KOIL STREET, ANNANGUDI VILLAGE, KATPADI TALUK, VELLORE DISTRICT, TAMIL NADUM. MANOJ KUMAR S/O. G.MANINO 1/56B, PILLAYAR KOIL STREET, ANNANGUDI VILLAGE, KATPADI TALUK, VELLORE DISTRICT, TAMIL NADUM. REKHA D/O. G.MANINO 1/56B, PILLAYAR KOIL STREET, ANNANGUDI VILLAGE, KATPADI TALUK, VELLORE DISTRICT, TAMIL NADUM. HARI KRISHNAN S/O. G.MANINO 1/56B, PILLAYAR KOIL STREET, ANNANGUDI VILLAGE, KATPADI TALUK, VELLORE DISTRICT, TAMIL NADUComplainant / Petitioner / Appellant Advocate Name:MAHIMAI ANTONI JEYAM MA-1/140 Kishangarh, vasanth kunj katti roll opposite SOUTH DELHI 110070Opposite Party / Respondent Name:CENTRAL BANK OF INDIAJHAJJAR HARYANA 1220021A. CENTRAL BANK OF INDIAALSO AT: REP. BY ITS CHAIRMAN AND MANAGING DIRECTOR, CHANDER MUKHI, NARIMAN POINT, MUMBAI-400021, MAHARASHTRA BHIWANI HARYANA 122003THE BRANCH MANAGERCENTRAL BANK OF INDIA, LATHERI BRANCH, VELLORE, VELLORE DISTRICT, TAMIL NADUTHE REGIONAL MANAGER, THE CENTRAL BANK OF INDIANO. 48/49, MONTEITH ROAD, EGMORE, CHENNAI-600068, TAMIL NADUTHE BANKING OMBUDSMAN C/O RESERVE BANK OF INDIAPORT GLASIES, CHENNAI-600001, TAMIL NADU
    

How to Properly Use Separate CSS/JS Assets for Frontend and Admin Layouts in a Single Vue 3 App?

I’m working on a Vue 3 app where I have both a public frontend and an admin panel, each with totally different designs. So, I need to load different CSS/JS files for each one.

I’ve created separate layouts and route groups for frontend and admin, but I’m running into these issues:

Frontend CSS is still active when I visit admin routes.

If I import admin JS/CSS inside the layout, sometimes the page goes blank.

It’s not clear where the best place is to import layout-specific assets.

My questions:
What’s the best practice for separating frontend and admin assets?

Where should I put these files (src/assets/…)? And how should I import them?

Should I consider creating two separate apps?

I’m using Vue 3 with Vue Router and Vite.

Would really appreciate some guidance or examples!

Playwright(JS): Issue with afterAll when timeout error in test

when test1 fails in test suite it executes afterEach and afterAll even though it did not finish executing test2. Especially when test1 fails due to timeout error

    const { test, expect } = require('@playwright/test');
    class TimeoutError extends Error {
        constructor(message) {
            super(message);
            this.name = 'TimeoutError';
        }
   }


    test('test1 - timeout intentionally', async () => {
        console.log('executing test1');
        throw new TimeoutError('Simulated TimeoutError in test2-here after this test   it runs afterEach(Expected) and afterAll(not expected, it should be running after all tests in this suite');
    });

    test('test2 - should still run', async () => {
        console.log('executing test2');
    });

    test.afterEach(async ({ }, testInfo) => {
        console.log('In AFTER_EACH');
    });

    test.afterAll(async () => {
        console.log('In AFTER_ALL');
    });


Expected: AfterAll should run before executing all my tests in the test suite.
Actual: If any test in the suite fails due to timedOut error it is running afterAll without completing the execution of remining cases in the suite

“Why is my React navbar wider than the viewport, causing horizontal scroll?”

“I’m building a React app that includes a Navbar component. The navbar seems to extend beyond the width of the screen, causing a horizontal scroll (x-axis). I tried applying CSS fixes but nothing worked. However, when I recreated the layout in plain HTML and CSS without React, the output was exactly as expected with no horizontal scroll. Why does this happen in React but not in plain HTML/CSS?”

    import "bootstrap/dist/css/bootstrap.min.css";
import "bootstrap/dist/js/bootstrap.bundle.min.js";
import { FaBars } from "react-icons/fa";
import { useEffect, useState } from "react";

import "./Navbar.css";
const Navbar = () => {
  const [hover, setHover] = useState(false);

  const setHoverFunction = () => {
    setHover(true);
    console.log(hover);
  };
  const setHoverFunctionOut = () => {
    setHover(false);
    console.log(hover);
  };

  useEffect(() => {
    document.querySelector(".DropdowN").classList.toggle("show");
  }, [hover]);

  const handleList = () => {
    document.querySelector(".Navbar_links").classList.toggle("show");
  };
  return (
    <nav className="d-block">
    <div className="Navbar_i ">
      <div className="nav-header">

            <div className="Navbar_logo ">SHOP-PAKK</div>
            <button className="nav-toggle" onClick={handleList}>
            <FaBars />
            </button>
            
      </div>

      <ul className="Navbar_links ">
        <li>
          <a href="#home">Home</a>
        </li>
        <li>
          <a href="#about">About</a>
        </li>
        <li
          className="item-down"
          onMouseEnter={setHoverFunction}
          onMouseLeave={setHoverFunctionOut}
        >
          <a href="#services">Services</a>
          <ul className="DropdowN">
            <li className="D-item">
              <a href="#services">Web Development</a>
            </li>
            <li className="D-item">
              <a href="#services">Mobile Development</a>
            </li>
            <li className="D-item">
              <a href="#services">Desktop Apps</a>
            </li>
            <li className="D-item">
              <a href="#services">Embedded System</a>
            </li>
            <li className="D-item">
              <a href="#services">Cyper Secuirity</a>
            </li>
          </ul>
        </li>
        <li>
          <a href="#contact">Contact</a>
        </li>
        <li>
          <a href="#blog">Blog</a>
        </li>
      </ul>
    </div>
    </nav>
  );
};

export default Navbar;

and CSS Code

    *,
*::before,
*::after{

    margin: 0;
    padding: 0;
    box-sizing: border-box;
   
}
ul{
    padding: 0;
    margin: 0;
}
html, body, #root {
    /* width: 100%; */
    /* height: 100%; */
    /* position: fixed; */
    /* left: 0px; */
    /* top: 0px; */


    margin: 0;
    padding: 0 ;
    /* max-width: none; */
  }
/* nav{
    width: 100%;
    height: 100px;
    background-color: #252525;
    position: relative;
} */
.Navbar_i {
    /* width: 100% ; */
    height: 100px;
    background-color: #252525;
    /* position: fixed; */
    top: 10px;
    left: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
  }
  
.Navbar_logo{
    
    font-size: 35px;
    font-weight: 600;
    color: #e6e6e6;
    /* margin-left: 100px; */
}
.Navbar_links{
    
    height: 100%;
    list-style: none;
   
    /* margin: 0 20px; */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}
.Navbar_links li{
    
    
    list-style: none;
    height: 100%;
    display: flex;
    align-items: center;
   
  
}

.Navbar_links li a{
    text-decoration: none;
    color: #e6e6e6;
    font-size: 24px;
    font-weight: 500;
    
    height: 100%;
    display: flex;
    align-items: center;
} 

.Navbar_links li a:hover{
    color: #c15c35;
    transition: 0.3s;
}
.item-down{

    position: relative;

}
.DropdowN{
    background-color: transparent;
    width: 250px;
    position: absolute;
    top: 100px;
    right: -50px;
    margin: 0;

    height: auto;
    /* border: 1px solid #c15c35; */
   
    display: none;
   
}
.show{
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 1;
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease-in-out;
}
.DropdowN li{
    display: block;
    width: 100%;

   
}
.DropdowN li a{
    color: rgba(255, 255, 255, 0.75);
    padding: 4px 10px;
    border-bottom: #c15c35 solid 1px;
    width: 100%;
    background-color: transparent;
}
.DropdowN li a:hover{
    color: #c15c35;
    background-color: #252525;
    transition: 0.3s;
    

}

.nav-toggle{
    display: none;
}

/* @media screen and (max-width: 768px) {
.nav-toggle{
    background-color: transparent;
    font-size: 40px;
    border: none;
    color: #e6e6e6;
    display: block;
}
.nav-toggle:hover{
    color: #c15c35;
    transition: 0.8s;
    transform: rotate(90deg);
}
.Navbar_links{
    display: none ;
}
.Navbar_i{
    display: block;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}
.nav-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    /* padding: 0 20px; */
/* } */
/*
.show{
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* top: 100px; */
    /* left: 0; */
    /* width: 100%;
    height: 400px;
    background-color: #252525;
    padding: 20px 0;

} */
/* .show li{
    width: 100%;
    text-align: center;

    background-color: tomato;
}
.DropdowN{
    display: none;
}} */ 

Bootstrap 5 vertical alignment of table cells does not work

I’m using Bootstrap 5 to create a responsive table. I want the content of the table cells to be vertically centered, so I applied the align-middle class to the element. However, the content still appears aligned to the top. Here’s a snippet of my code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Employee Table</title>
  <!-- Bootstrap 5 CSS -->
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container my-5">
  <h2 class="text-center mb-4">Employee List</h2>
  <div class="table-responsive">
    <table class="table table-bordered table-striped table-hover align-middle mx-auto" style="width: 80%;">
      <thead class="table-dark text-center">
        <tr>
          <th>Name</th>
          <th>Age</th>
          <th class="text-end">Salary</th>
          <th>Department</th>
          <th>Active</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td class="text-start">Anna Kovács</td>
          <td class="text-center">28</td>
          <td class="text-end">450,000</td>
          <td class="text-center">Marketing</td>
          <td class="text-center">*</td>
        </tr>
        <!-- Additional rows... -->
      </tbody>
    </table>
  </div>
</div>

<!-- Bootstrap 5 JS (optional) -->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

</body>
</html>