Filtro de Tabela [closed]

Fala galera, tenho o código abaixo que possui funções para filtrar os dados, mas ao clicar no filtro há uma demora para abrir, as vezes abre rápido outras vezes não abre o poderia melhorar?

Interface da Aplicação: (https://i.sstatic.net/9VAOMWKN.png)

Realizar uma filtragem rápida , mas o filtro tem problemas ao ser clicado.

const { ipcRenderer } = require('electron');

document.addEventListener("DOMContentLoaded", () => {
    const fileInput = document.getElementById("fileInput");
    const processButton = document.getElementById("processButton");

    // Elementos do cabeçalho para exibir as informações do associado
    const accountName = document.getElementById("accountName");
    const accountNumber = document.getElementById("accountNumber");
    const accountAddress = document.getElementById("accountAddress");
    const bairroCep = document.getElementById("bairroCep");
    const cityState = document.getElementById("cityState");
    const saldoDisponivel = document.getElementById("saldoDisponivel");
    const limiteChequeEspecial = document.getElementById("limiteChequeEspecial");
    const limiteUtilizado = document.getElementById("limiteUtilizado");

    const progressContainer = document.querySelector('.progress-container');
    const progressText = document.getElementById('progressText');

    // Elementos dos filtros
    const dateFilter = document.getElementById('filterDateDropdown');
    const docFilter = document.getElementById('filterDocDropdown');
    const histFilter = document.getElementById('filterHistDropdown');
    const debFilter = document.getElementById('filterDebDropdown');
    const credFilter = document.getElementById('filterCredDropdown');
    const saldoFilter = document.getElementById('filterSaldoDropdown');

    let allTransactions = []; // Variável para armazenar todas as transações carregadas
    let filteredTransactions = []; // Transações filtradas
    let selectedFilters = {}; // Armazena os valores selecionados de cada filtro

    // Função para mostrar o anel de progresso
    function showProgress() {
        progressContainer.style.opacity = '1';
    }

    // Função para esconder o anel de progresso
    function hideProgress() {
        setTimeout(() => {
            progressContainer.style.opacity = '0';
        }, 1000);
    }

    // Função para atualizar o texto do progresso
    function updateProgress(percentage) {
        progressText.textContent = `${percentage}%`;
    }

    // Função para limpar as transações antes de exibir novas
    function clearTransactions() {
        const transactionsTableBody = document.getElementById('transactionsTableBody');
        transactionsTableBody.innerHTML = ''; // Limpa as linhas antigas
    }

    // Função para exibir as transações
    function displayTransactions(transactions) {
        clearTransactions(); // Limpa transações anteriores
        const transactionsTableBody = document.getElementById('transactionsTableBody');

        transactions.forEach((transaction) => {
            const row = document.createElement('tr');

            // Crie as células da tabela com base nos dados da transação
            const dateCell = document.createElement('td');
            dateCell.textContent = transaction.date;

            const docCell = document.createElement('td');
            docCell.textContent = transaction.document;

            const histCell = document.createElement('td');
            histCell.textContent = transaction.historico;

            const debCell = document.createElement('td');
            debCell.textContent = transaction.debito;

            const credCell = document.createElement('td');
            credCell.textContent = transaction.credito;

            const saldoCell = document.createElement('td');
            saldoCell.textContent = transaction.saldo;

            // Adiciona as células à linha
            row.appendChild(dateCell);
            row.appendChild(docCell);
            row.appendChild(histCell);
            row.appendChild(debCell);
            row.appendChild(credCell);
            row.appendChild(saldoCell);

            // Adiciona a linha ao corpo da tabela
            transactionsTableBody.appendChild(row);
        });
    }

    // Função para popular os filtros com os valores únicos das transações (usando checkboxes)
    function populateFilters(transactions) {
        const dates = new Set();
        const docs = new Set();
        const hists = new Set();
        const debs = new Set();
        const creds = new Set();
        const saldos = new Set();

        transactions.forEach(transaction => {
            if (transaction.date) dates.add(transaction.date);
            if (transaction.document) docs.add(transaction.document);
            if (transaction.historico) hists.add(transaction.historico);
            if (transaction.debito) debs.add(transaction.debito);
            if (transaction.credito) creds.add(transaction.credito);
            if (transaction.saldo) saldos.add(transaction.saldo);
        });

        function createFilterOptions(set, filterDropdown, filterName) {
            filterDropdown.innerHTML = ''; // Limpa o dropdown atual

            const filterContainer = document.createElement('div');
            filterContainer.classList.add('filter-container');

            const search = document.createElement('input');
            search.type = 'text';
            search.placeholder = 'Pesquisar...';
            search.classList.add('dropdown-search');
            search.onkeyup = function () {
                filterDropdown.querySelectorAll('label').forEach(label => {
                    const text = label.textContent.toLowerCase();
                    const searchValue = search.value.toLowerCase();
                    label.style.display = text.includes(searchValue) ? '' : 'none';
                });
            };
            filterContainer.appendChild(search);

            const optionList = document.createElement('div');
            optionList.classList.add('option-list');  // Contêiner para opções com rolagem interna
            set.forEach(item => {
                const label = document.createElement('label');
                const checkbox = document.createElement('input');
                checkbox.type = 'checkbox';
                checkbox.value = item;

                // Marca a caixa de seleção se o item estiver no filtro selecionado
                if (selectedFilters[filterName] && selectedFilters[filterName].includes(item)) {
                    checkbox.checked = true;
                }

                label.appendChild(checkbox);
                label.appendChild(document.createTextNode(item));
                optionList.appendChild(label);
            });
            filterContainer.appendChild(optionList);

            const clearButton = document.createElement('button');
            clearButton.textContent = 'Limpar Filtros';
            clearButton.classList.add('clear-filter-button');
            clearButton.onclick = function() {
                clearAllFilters(); // Limpa todos os filtros
            };
            filterContainer.appendChild(clearButton);

            filterDropdown.appendChild(filterContainer);

            // Adiciona os botões OK e Cancelar
            const actionsContainer = document.createElement('div');
            actionsContainer.classList.add('filter-actions');

            const applyButton = document.createElement('button');
            applyButton.textContent = 'OK';
            applyButton.classList.add('apply-filter-button');
            applyButton.onclick = function() {
                applyFilters(filterDropdown, filterName); // Aplica os filtros do dropdown específico
                closeAllDropdowns(); // Fecha o dropdown após aplicar os filtros
            };

            const cancelButton = document.createElement('button');
            cancelButton.textContent = 'Cancelar';
            cancelButton.classList.add('cancel-filter-button');
            cancelButton.onclick = function() {
                closeAllDropdowns(); // Fecha sem aplicar
            };

            actionsContainer.appendChild(applyButton);
            actionsContainer.appendChild(cancelButton);
            filterContainer.appendChild(actionsContainer);
        }

        createFilterOptions(dates, dateFilter, 'date');
        createFilterOptions(docs, docFilter, 'doc');
        createFilterOptions(hists, histFilter, 'hist');
        createFilterOptions(debs, debFilter, 'deb');
        createFilterOptions(creds, credFilter, 'cred');
        createFilterOptions(saldos, saldoFilter, 'saldo');
    }

    // Função para aplicar os filtros de checkboxes e garantir a interdependência entre colunas
    function applyFilters(filterDropdown, filterName) {
        const getCheckedValues = () => {
            const checkboxes = filterDropdown.querySelectorAll('input[type="checkbox"]');
            const checkedValues = [];
            checkboxes.forEach(checkbox => {
                if (checkbox.checked) {
                    checkedValues.push(checkbox.value);
                }
            });
            return checkedValues.length > 0 ? checkedValues : null;
        };

        selectedFilters[filterName] = getCheckedValues(); // Armazena os valores selecionados no filtro

        filteredTransactions = allTransactions.filter(transaction => {
            const dateMatch = !selectedFilters.date || selectedFilters.date.includes(transaction.date);
            const docMatch = !selectedFilters.doc || selectedFilters.doc.includes(transaction.document);
            const histMatch = !selectedFilters.hist || selectedFilters.hist.includes(transaction.historico);
            const debMatch = !selectedFilters.deb || selectedFilters.deb.includes(transaction.debito);
            const credMatch = !selectedFilters.cred || selectedFilters.cred.includes(transaction.credito);
            const saldoMatch = !selectedFilters.saldo || selectedFilters.saldo.includes(transaction.saldo);

            return dateMatch && docMatch && histMatch && debMatch && credMatch && saldoMatch;
        });

        displayTransactions(filteredTransactions);
    }

    // Função para limpar todos os filtros
    function clearAllFilters() {
        selectedFilters = {}; // Limpa todos os filtros
        filteredTransactions = [...allTransactions]; // Restaura todas as transações
        displayTransactions(filteredTransactions); // Exibe todas as transações
        populateFilters(filteredTransactions); // Restaura os filtros para os valores completos
    }

    // Processar o arquivo ao clicar no botão "Processar"
    processButton.addEventListener("click", () => {
        const file = fileInput.files[0];
        if (!file) {
            alert("Selecione um arquivo .prn.");
            return;
        }

        showProgress(); // Exibe o anel de progresso

        let progress = 0;
        const interval = setInterval(() => {
            if (progress < 100) {
                progress += 10;
                updateProgress(progress);
            } else {
                clearInterval(interval);
                hideProgress(); // Esconde o anel de progresso
            }
        }, 300);

        const reader = new FileReader();
        reader.onload = function (event) {
            const content = event.target.result;

            // Envia o conteúdo para o processo principal (main.js) para ser processado
            ipcRenderer.send('process-file', content);
        };
        reader.readAsText(file);
    });

    // Recebe a resposta do Python via o processo principal
    ipcRenderer.on('file-processed', (event, data) => {
        const headerInfo = data.header_info;
        const transactions = data.transactions;

        // Exibe o cabeçalho
        accountName.textContent = headerInfo.name;
        accountNumber.textContent = headerInfo.account_number;
        accountAddress.textContent = headerInfo.address;
        bairroCep.textContent = headerInfo.bairro_cep;
        cityState.textContent = headerInfo.city_state;
        saldoDisponivel.textContent = headerInfo.saldo_disponivel;
        limiteChequeEspecial.textContent = headerInfo.limite_cheque_especial;
        limiteUtilizado.textContent = headerInfo.limite_utilizado;

        // Exibe as transações e popula os filtros
        allTransactions = transactions;
        filteredTransactions = transactions; // Inicialmente todas as transações são exibidas
        displayTransactions(transactions);
        populateFilters(transactions);
    });
});

// Função para mostrar/ocultar o dropdown de filtro
function toggleDropdown(dropdownId) {
    const dropdown = document.getElementById(dropdownId);
    
    // Fecha todos os dropdowns abertos antes de abrir o selecionado
    closeAllDropdowns();

    // Verifica se o dropdown já está visível
    if (!dropdown.classList.contains("show")) {
        dropdown.classList.add("show");
    }
}

// Função para fechar todos os dropdowns abertos
function closeAllDropdowns() {
    const dropdowns = document.getElementsByClassName("dropdown-content");
    for (let i = 0; i < dropdowns.length; i++) {
        dropdowns[i].classList.remove("show");
    }
}

// Evitar que o dropdown feche ao clicar dentro dele
document.querySelectorAll('.dropdown-content').forEach(dropdown => {
    dropdown.addEventListener('click', function(event) {
        event.stopPropagation(); // Impede o fechamento do dropdown ao clicar em elementos internos
    });
});

// Fecha o dropdown se o usuário clicar fora dele
window.onclick = function(event) {
    if (!event.target.matches('.filter-btn') && !event.target.matches('.filter-btn img')) {
        closeAllDropdowns();
    }
}

show counter for nested loop using alphine js

I am trying to add the counter based on the provider. It should be global not service wise. I mean if there are 2 services and both of them have 2 providers, then it should show the counter like provider 1 and 2 for first service, then provider 3 and 4 for next service.

<template x-if="services !== undefined" x-for="(service,key) in services.services">
                    <template x-if="service !== undefined">
                        <tbody>
                            <tr>
                                <td>
                                    <h3 x-text="service.service_name"></h3>
                                    <div id="service-info" class="mt-3">
                                        <span class="text-left"
                                            x-html="'Booking No. '+service.booking_number "></span><br>
                                        <span class="text-left" x-html="'Start Time: '+ service.start_time "></span><br>
                                        <span class="text-left" x-html="'End Time: '+ service.end_time "></span><br>
                                        <span class="text-left"
                                            x-html="'Providers: '+ service.providers.length "></span><br>


                                    </div>

                                </td>
                                <td>

                                </td>
                                <td>

                                </td>
                            </tr>
                            <template x-for="(provider,index) in service.providers" :key="index">
                                <tr x-show="provider !== undefined && provider.check_in_status !== null">
                                    <td>

                                        <h3 x-show="details.hide_providers !== undefined && !details.hide_providers"
                                            x-text="provider.user.name"></h3>
                                        <h3 x-show="details.hide_providers !== undefined && details.hide_providers"
                                            x-text="'service-' + service.id + '-' + provider.id + 'Provider ' + providerCounter++"
                                            :id="'service-' + service.id + '-' + provider.id"></h3>

                                        <!-- Increment customCounter after each provider is rendered -->

                                        <div id="provider-info" class="mt-3">
                                            <span class="text-left"
                                                x-html="'Start Time: '+ new Date(provider.check_in_procedure_values.actual_start_timestamp).toLocaleDateString() "></span><br>
                                            <span class="text-left"
                                                x-html="'End Time: '+  new Date(provider.check_out_procedure_values.actual_end_timestamp).toLocaleDateString() "></span><br>
                                        </div>
                                    </td>
                                    <td>

                                        <div x-show=" 'total_durations_billing' in provider.billing_details ">
                                            <span
                                                x-show="!provider.service_payment_details.fixed_rate && provider.service_payment_details.day_rate "
                                                class="text-left"
                                                x-html="provider.billing_details.total_durations_billing.days == null ? '' : provider.billing_details.total_durations_billing.days+' Days '"></span>
                                            <span x-show="!provider.service_payment_details.fixed_rate"
                                                class="text-left"
                                                x-html="provider.billing_details.total_durations_billing.hours == null ? '' : provider.billing_details.total_durations_billing.hours+' Hours '"></span>
                                            <span
                                                x-show="!provider.service_payment_details.fixed_rate && !provider.service_payment_details.day_rate"
                                                class="text-left"
                                                x-html="provider.billing_details.total_durations_billing.mins == null ? '' : provider.billing_details.total_durations_billing.mins+' Mins '"></span>
                                        </div>

                                        <div x-show=" 'total_durations_billing' in provider.billing_details == false ">
                                            <span
                                                x-show="!provider.service_payment_details.fixed_rate && provider.service_payment_details.day_rate "
                                                class="text-left"
                                                x-html="service.days == null ? '' : service.days+' Days '"></span>
                                            <span x-show="!provider.service_payment_details.fixed_rate"
                                                class="text-left"
                                                x-html="service.hours == null ? '' : service.hours+' Hours '"></span>
                                            <span
                                                x-show="!provider.service_payment_details.fixed_rate && !provider.service_payment_details.day_rate"
                                                class="text-left"
                                                x-html="service.mins == null ? '' : service.mins+' Mins '"></span>
                                        </div>

                                    </td>
                                    <td>

                                        <template x-if="provider.billing_details !== undefined"
                                            x-for="(charge,charge_index) in provider.billing_details"
                                            :key="charge_index">
                                            <template x-if="charge_index == 'service_charges'">

                                                <div id="service-list" class="d-flex"
                                                    style="justify-content: space-between;">
                                                    <div class="text-left mb-2">
                                                        <p x-html="'Service Charges'"></p>
                                                    </div>
                                                    <div class="text-right mb-3">
                                                        <p x-html="charge"></p>
                                                    </div>
                                                </div>


                                            </template>
                                        </template>


                                        <template x-if="provider.billing_details !== undefined"
                                            x-for="(charge,charge_index) in provider.billing_details"
                                            :key="charge_index">
                                            <template
                                                x-if="charge_index == 'additional_charges' || charge_index == 'specialization_charges' || charge_index == 'expedited_charges'">
                                                <template x-for="(details,detail_index) in charge">
                                                    <div id="service-list" class="d-flex"
                                                        style="justify-content: space-between;">
                                                        <div class="text-left mb-2">
                                                            <p x-text="details.label"></p>
                                                        </div>
                                                        <div class="text-right mb-3">
                                                            <p x-text="details.charges"></p>
                                                        </div>
                                                    </div>
                                                </template>

                                            </template>
                                        </template>

                                        <template x-if="provider.service_payment_details.expedited_rate !== undefined">
                                            <div id="service-list" class="d-flex"
                                                style="justify-content: space-between;">
                                                <div class="text-left mb-2">
                                                    <p>Expedition Charges</p>
                                                </div>
                                                <div class="text-right mb-3">
                                                    <p x-html="provider.service_payment_details.expedited_rate"></p>
                                                </div>
                                            </div>
                                        </template>

                                        <template x-if="provider.billing_details !== undefined"
                                            x-for="(charge,charge_index) in provider.billing_details"
                                            :key="charge_index">
                                            <template x-if="charge_index == 'discounts_list'">
                                                <template x-for="(discounts,discount_index) in charge"
                                                    :key="discount_index">
                                                    <template x-if="discount_index !== undefined">
                                                        <div id="service-list" class="d-flex"
                                                            style="justify-content: space-between;">
                                                            <div class="text-left mb-2">
                                                                <p
                                                                    x-html="'<strong>Discount :</strong> ' + discounts.label">
                                                                </p>
                                                            </div>
                                                            <div class="text-right mb-3">
                                                                <p x-html="discounts.value"></p>
                                                            </div>
                                                        </div>
                                                    </template>
                                                </template>
                                            </template>
                                        </template>

                                        <div id="service-list" class="d-flex" style="justify-content: space-between;">
                                            <div class="text-left mb-2">
                                                <p><strong>Total Provider Charges</strong></p>
                                            </div>
                                            <div class="text-right mb-3">
                                                <p
                                                    x-html="services.currency + provider.billing_details.total_provider_charges">
                                                </p>
                                            </div>
                                        </div>

                                    </td>
                                </tr>

                                <!-- Increment the counter after rendering each service -->
                            </template>

I tried adding the counter but it was always returning the max count for every provider, meaning that if I had 10 providers it was showing provider 10 for each of them. Any ideas how I solve this?

How to convert web extension to safari extension using window’s

i am facing a issue i am a beginner and for me everything is right new but i love trying i am facing this issue which is this i have a window’s laptop and i am working on a extension what we want to do is to convert the extension to safari extension

the issue here is the as per the docs https://developer.apple.com/documentation/safariservices/converting-a-web-extension-for-safari

we need xcode basically i need macOS environment to run the code which is a issue for me
i want to know how can i do that create a code into my window laptop or what services i can use . Is there is a service for converting extension for other browser we have api we are able to convert the extension for other browser’s

what i need to know what i can do to convert our extension to safari extension any information might be help full for me

note : if there is any paid , free services which can help me please let me know

i tried to use creating a local macOS local environment using a virtual box but there are some compatibility issue and i am trying to find much better alternative’s

token from Google Auth not matching otplib authenticator.verify function

I’m trying to get 2fa to work on a backend project.

I have a function that created and store the secret:

import { Injectable } from '@nestjs/common';
import { authenticator } from 'otplib';
import { ClientService } from 'src/client/client.service';

@Injectable()
export class TwoFactorAuthService {
constructor(private readonly prisma: ClientService)

public async generateTwoFactorAuthSecret(loggedUserEmail: string) {
 const user = await this.prisma.users.findFirst({
   where: { email: loggedUserEmail },
 });
 const secret = authenticator.generateSecret();

 const otpAuthUrl = authenticator.keyuri(user.email, 'MyApp', secret);

 await this.prisma.users.update({
  where: {id: user.id},
  data: {2faSecret: secret}
 });

 return {otpAuthUrl}
}
}

Then with that otpAuthUrl I have the qrcode to read using google authenticator, but the thing is when I use the code provided by the auth APP it doesn’t match.

Here’s the function to verify the code:

async verifyTwoFaCode(code: string, user: Users) {
 //code = 6 number token from google auth APP
 return authenticator.verify({
   token: code,
   secret: user.2faSecret,
 });
}

The ‘authenticator.verify’ function returns false.

There’s a function that actually gives me the correct code:

const correctCode = authenticator.generate(user.2faSecret); //6 number code
 return authenticator.verify({
   token: correctCode,
   secret: user.2faSecret,
 });

If I do this it returns true, which tells me that the code provided by google auth APP is incorrect. How can I get this working properly??

react-intl intl.formatMessage does not supply placeholders with values

In react-intl since the deprecation of formatHtmlMessage api we had to substitute this functionality with custom solution, everything works well except that some of the placeholders are not being populated properly by intl.formatMessage, in one scenatio i have a translation string:

en: Hello, {firstName} {lastName}!

et: Tere, {firstName} {lastName}!

and this works, it’s properly populated and the output is

"Tere, MARY ÄNN O’CONNEŽ-ŠUSLIK TESTNUMBER!"

and this is how i use the component

        <IntlMsg
          id="customer.title"
          shouldFormat
          values={{
            firstName: authentication.firstName,
            lastName: authentication.lastName,
          }}
        />

In the second scenario i have this translation string:

en: I have read the <a target="_blank" href={termsLink}>terms and conditions</a> and the <a target="_blank" href="{euTermsLink}">EU terms</a> and do not need any further clarification.

et: Olen tutvunud <a target="_blank" href={termsLink}>lepingu tingimustega</a>, <a target="_blank" href="{euTermsLink}"> Euroopa tarbijakrediidi standardinfo teabelehega</a>

and the output is:

Olen tutvunud <a target="_blank" href={termsLink}>lepingu tingimustega</a>, <a target="_blank" href="{euTermsLink}"> Euroopa tarbijakrediidi standardinfo teabelehega</a> ja täiendavate selgituste ja hoiatustega lehel: <a target="_blank" href="https://www.creditea.com/ee/lepinguabi "> https://www.creditea.com/ee/lepinguabi </a>, nendest aru saanud ning teadlik võimalusest küsida laenuandjalt lisainfot ja selgitusi.

and this is how i use the component

<IntlMsg id="offer.submit.confirm.terms" values={{ termsLink, euTermsLink }} shouldFormat />

Can it be that this is happening because it is inside html? formatMessage does parse html in strings in other parts of application. This is the components implementation:

const IntlMessage = ({
  id,
  tagName: TagName = 'span',
  defaultMessage = '',
  description = '',
  shouldFormat = false,
  values = {},
}: Props): ReactNode => {
  const intl = useIntl();
  const msg = defineMessage({
    id,
    defaultMessage,
    description,
  });

  const message = intl.formatMessage(msg, {
    ...values,
    ...t,
    br: <br />,
  });

  const convertedMessage = (m: PrimitiveType): ReactNode =>
    convertMessage({ message: m.toString(), shouldFormat, TagName });

  const renderMessage = (content: typeof message): ReactNode => {
    if (isPrimitive(content)) {
      return convertedMessage(content);
    }
    if (isArray(content)) {
      return content.map((chunk) => (isPrimitive(chunk) ? convertedMessage(chunk) : chunk));
    }
    return content;
  };

  return <TagName key={id}>{renderMessage(message)}</TagName>;
};

Thanks for any help.

Issue with Ubuntu Files Permission while runing my project import/export tests [closed]

So whenever I run my project tests on my laptop (ubuntu version 23.10)
the tests fail when they reach the import (creating files or finding a files) tests.

I tried to chmod 777 all the directories and files in the project but still no success.

I tried all the different numbers (chmod 777, 775, 755 …)

PS: The project is placed in the desktop.

anyone can help me with that?

Chunk downloading of the big files right to the hard drive

I have this method to download files. But I want to have a possibility to download files more than 1GB. Is it possible to do it and download it chunk by chunk, because as for me it is really bad to store so much data in the clients memory.

        const list = this.selectionService.getListValue();
        const areAllSelected = this.selectionService.getIsAllSelectedValue();

        const link = document.createElement('a');

        this.loadingText = 'Exporting images...';
        this.showLoading = true;
        this.absolutePosition = true;

        await this.projectImagesService
            .downloadFilteredZip(event.imageSetId, list, areAllSelected)
            .then(response => {
                const contentDisposition = response.headers.get('Content-Disposition');
                const filename = contentDisposition
                    ? contentDisposition.split('filename=')[1]
                    : `image_set_${event.imageSetId}_${Date.now()}.zip`;

                const href = window.URL.createObjectURL(response.body);
                link.download = filename;
                link.href = href;
                document.body.appendChild(link);
                link.click();
                document.body.removeChild(link);
                this.showLoading = false;
                this.absolutePosition = false;
                this.loadingText = 'Uploading...';
            });
    }

And this is that is happening in the downloadFilteredZip

downloadFilteredZip(imageSetId: number, list: Array<string | number>, allSelected: boolean) {
        const offsetFilters = this.getOffsetFilters();
        const areAllSelected = list.includes('all');

        const url = `image-sets/${imageSetId}/archive?${this.serverApiService.rebuildObjectToQuery({
            ...this.filters,
            ...(!areAllSelected && offsetFilters),
            ...(!areAllSelected && !allSelected && { ids: list }),
        })}`;

        return this.serverApiService.get<Blob>(url, { responseType: 'blob' });
    }
}

I am using Angular, but I have some restriction from team, so I have to use thi serverApiService predefined methods

UI5 – DateTimePicker – minDate can be undershot and overwritten at the same time

I am currently using a sap.m.DateTimePicker in one of my projects.
Since I want to limit the input time range, I use the properties *minDate *and maxDate.

My UI5 version is 1.71 (yes I know, not very up-to-date).

Now to my error:
If the sap.m.DateTimePicker is opened for the first time and I change the preselected time but NOT the preselected date, it is possible to go below the minDate after confirming the selection. I have also noticed that this also overwrites the minDate, i.e. the invalid value also becomes the new minDate.

This is probably caused by the following standard method in sap.m.DateTimePicker:
method in the sap.m.DateTimePicker (UI5-version 1.71)

Here the date gets initialised with the minDate, but in JS this means that it is not a copy, but both refer to the same object. The effect of this is that when the date gets confirmed, the minDate will also be changed.
I was able to solve the whole thing as follows:
My solution

Are you aware of this error? Or am I using the sap.m.DateTimePicker incorrectly?

In the current SAPUI5 version, the error still exists ( in my understanding):
method in the sap.m.DateTimePicker (latest UI5-version)

List all IDs starting with a specified string followed by a number, remove the string, and get the biggest number value

A page contains dozens of elements with IDs that look like: <a id="msg{number}"></a> The IDs are unique and are in no particular order, for example:

<a id="msg988755"></a>
<a id="msg129"></a>
<a id="msg7756501"></a>
<a id="msg745"></a>
<a id="msg657550"></a>
<a id="msg1148"></a>
<a id="msg87905541"></a>
<a id="msg745102"></a>
<a id="msg31780"></a>
<a id="msg2657588"></a>
<a id="msg8895"></a>

My goal is to use pure JS find the ID with the biggest number (after removing the ‘msg’ part from the ID), meaning that the result of the script should be this number: 87905541

I think the script should run a query to find all IDs that start with ‘msg’, eg. document.querySelectorAll('[id^="msg"]')]; but from there I’m stuck. I read that this function could find the biggest number: Math.max(num)

Car marketplace project – send dataform to database(drizzle and neontech) [closed]

My name is Daniel and I’m start learning programming a few months ago.
I try tutorial car marketplace on YT : https://www.youtube.com/watch?v=XENGw99u4uw&t=580.

I’m in “backend” part in tutorial and my form is not save in database in drizzle.
No marked on red color in my code.
In console i have below errors:

“DropdownField.jsx:20 Warning: Each child in a list should have a unique “key” prop.”
AND
“React does not recognize the handleInputChange prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase handleinputchange instead. If you accidentally passed it from a parent component, remove it from the DOM element.
at textarea
at _c (http

third issue:
clerk.browser.js:2 Clerk: Clerk has been loaded with development keys. Development instances have strict usage limits and should not be used when deploying your application to production.

Thank for any help.

I share You print from console:
enter image description here

Does TypeScript @peculiar/asn1-schema library always wraps objects into ASN.1 SEQUENCE?

I have following class in TypeScript:

import {
    AsnSerializer
} from '@peculiar/asn1-schema';

export class Element {
    constructor(
        public value: BigInteger
    ) {}

    public ToASN1(): ArrayBuffer {
        const element = new Element();
        element.value = new Uint8Array(this.value.toByteArray()).buffer;
        try {
            return new Uint8Array(AsnSerializer.serialize(element));
        } catch (error) {
            // handle
        }
    }

And the toASN1 method returns ASN.1 output as:

output ::= SEQUENCE {
    INTEGER
}

But I don’t want that outer SEQUENCE to present and instead I only wish to have:

output ::= INTEGER

Is it achievable at all? I have found some links in the source code, but dunno is that indeed hardcoded into that library and therefore not changeable at all?

Vanilla React Navbar non-reactive upon updating local storage

I have this react App structure. Some components are hidden based on the content of a local storage.

import React from "react";
import { BrowserRouter as Router } from "react-router-dom";
import AppRoutes from "./Routes";
import NavBar from "./components/NavBar";

const App = () => {
  return (
    <Router>
      <NavBar />
      <AppRoutes />
    </Router>
  );
};

export default App;

All of my other react components are responsive except Navbar. What am I doing wrong? This is my NavBar code:

import { useEffect, useState } from "react";
function NavBar() {
  const [role, setRole] = useState("");
  
  useEffect(() => {
    setRole(localStorage.getItem("tempUserRole"));
  }, []);
    return (
        <header className="bg-white">
            <nav className="" aria-label="Global">
                {/* Links (Center-aligned) */}
                <div className="">
                    {role==='a' && <a href="/events" className="">a</a>}
                    {role==='b' && <a href="/events" className="">EveBnts</a>}
                </div>

            </nav>
        </header>
    );
}

export default NavBar;

The problem is, I have to refresh the page to see the changes take effect. How do I solve this issue?

Functionnality Search and Checkbox on vuejs3 and Vuetify 3

I need help with my application.

I want to perform a search and select the element I need.

My issue is that the search works fine, but I can’t retrieve any value after selecting a checkbox.

I have two components :

  • MyTableAnnuaire.vue and
  • add.vue

Here is my code :

MyTableAnnuaire.vue

    <v-text-field v-model="searchTerm" prepend-inner-icon="mdi-magnify" density="compact" label="Rechercher" flat
          hide-details variant="solo-filled"></v-text-field>
     
  
  
      <v-data-table class="blue-header" :headers="headers" :items="filteredItems" density="compact" hover="true"
        no-data-text="Pas de données disponibles" :fixed-header="true" :items-per-page="-1" :height="250"
        item-value="clcode" select-strategy="single" show-select
        hide-default-footer >

      </v-data-table>

add.vue

          <MyTableAnnuaire
            :headers="headers"
            :items="list"
            v-model:selected="selectedItems"
          />

enter image description here

Is it possible to display a base64 docx file in React?

I’m receiving documents from an API as a base64 string, and would like to display this in the browser.

Is anyone aware of a way to display this base64 docx file?

I’ve tried various packages to do this but they seem to only work if provided with a URL to a file that is either hosted online, or stored locally.