how can i pass query string parameter in payload with jason data using javascript ajax post call

Every time a user searches, I have to send a request. So I’m utilizing kendo multi-select and implementing it using an ajax post call.

var payload ={
  "vFilters": [
    {
      "field": "DistLocationIds",
      "values": [
        "2787"
      ]
    },
    {
      "field": "VdistLocationIds",
      "values": []
    },
    {
      "field": "createdByLocationLevelId",
      "values": []
    },
    {
      "field": "taskLevelId",
      "values": [
        "118"
      ]
    }
  ],
  "rangeFilters": [
    {
      "greaterThanOrEqual": "2022-06-11",
      "field": "startDate"
    },
    {
      "lessThanOrEqual": "2022-07-11",
      "field": "endDate"
    }
  ],
  "sorts": [],
  "limit": 50,
  "q": "s"
};


var new1 = new kendo.data.DataSource({
  transport: {
                    read: function(options) {
                        $.ajax({
                             delay: 350, // wait 250 milliseconds before triggering the request
                             url: "https://tasklist",
                             type: "post",
                             data: JSON.stringify(payload),
                             dataType: 'json',
                             contentType: "application/json"
                        });
                    },
                    
                    contentType: "application/json",
                    beforeSend: function(req) {
           req.setRequestHeader('Authorization', "Bearer @Session.AuthToken~");
       },
        processResults: function (data) {   
                //console.log("results: "+data.results.length);
                var res = [];
                if(data && data.results){
                    for(var i  = 0 ; i < data.results.length; i++) {
                        res.push({id: data.results[i].objectId, text: data.results[i].title});
                    }
                }
                return {
                    results: res
                }
            },
            complete: function(){
            }
                }
});
$("#islTasks").kendoMultiSelect({
        placeholder: "Select Tasks...",
        filter: "contains",
        autoBind: false,
    dataValueField: "objectId",
    dataTextField : "title",
    dataSource : new1
});

I’ve tried several techniques, but none of them have worked. Anyone have any ideas on how to pass json data in an array plus a query string parameter in a payload request using a post ajax call?

Now I have to pass the query string parameter in the variable I made which is payload data. Could someone kindly help me with this?

How to fetch data into Victory Native Charts

I am using victory native chart to render area chart and i dont know how to fetch data from api to the chart, meaning x will hold “usia” and y will hold “indeks_massa”. anyone good people can help me to solve this? 🙁

this is my code:

const data = listHistory.map((usia, indeks_massa) => {
    return { x: usia, y: indeks_massa }
})
<VictoryLine style={{ data: { stroke: "blue" }, }}
             data={data}
/>

Datatables – Export different data to what is shown in the table?

I have a script which adds an export to Excel button to my datatables:

$(document).ready(function() {
    
      $('#table_id').DataTable( {
        dom: 'Brtip',
        buttons: [
            {
              extend: 'excel',
          filename: function(){
                    var today = new Date();
            var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
            var time = today.getHours() +':'+ today.getMinutes()+':'+today.getSeconds();
            var dateTime = date+' '+time;                
            return 'Query ' + dateTime;
                },
              customize: function ( xlsx ) {
                var sheet = xlsx.xl.worksheets['sheet1.xml'];
                $('c[r=A1] t', sheet).text( '{{foo_query}}' );
            $('c[r=A2] t', sheet).text( '' );
                $('row:first c', sheet).attr( 's', '2' ); // first row is bold
              }
            }
        ]
      } );
    
    });

This works fine:

enter image description here

However, I am only showing the top 200 hits in the datatable, as the actual dataframe is 35,000+ and takes too long to load.

When I click the Excel button it sends the data that is in the table, but ideally I want it to export the original data which I hold as a global variable called 'dataHold'

Is there any way do do this?

Facing error while using materisl-ui icons in react app

I have used the commands npm install @material-ui/core and npm install @material-ui/icons in my react app and want to use the FileUploadIcon. I am importing it by using

import { FileUploadIcon } from '@material-ui/icons/FileUpload';

and later

<input type= "file" id = "file" onChange={checkJSON}/>
<label for = "file">
<FileUploadIcon />
    Choose a JSON file
</label>'

I am getting the error

Module not found: Can't resolve '@material-ui/icons/FileUpload' in 'F:ProfileDesktopNewUIreact-jwt-auth-mastersrccomponents'

My package.json has these dependencies

"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",

Mapping over an array – Return of map is undefined

I’m still quite new to JS and don’t understand why this function returns undefined. What am I not seeing?

const people = [
{ name: 'Ben', year: 1980 },
{ name: 'John', year: 1985 },
{ name: 'Bob', year: 1971 }
];

and my function:

const myFunction = () => {
people.map((person) => {
    return person.year;
});
};

console.log(myFunction());

Thanks y’all

CSS: Hide box-shadow only when div is getting overflowed

I have a navigation bar with a box shadow. My navigation bar is visible on every page of my website. However, on my Home page, I have a hero section overflowing the Navigation bar. I want the box shadow to disappear there.

Navigation bar on the home page

Navigation bar everywhere else

I tried to give a higher z-index to the content of the Navigation bar but it did not work. If someone could help me out I would be very grateful.

Part of the code for my navigation bar:

header {
    background-color: transparent;
    padding: 0 25px;
    z-index: 1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);


    .link {
        font-weight: 500;
        font-size: 14px;
        padding: 0 2px;
        transition: 0.3s color ease;
        z-index: 110;
        &:hover {
            color: #1eb8b8;
        }
    }
}

Part of the code for my hero section:

.hero-section {
  z-index: 100;
  display: flex;
  justify-content: center;
  background-image: url(../assets/hero.jpg);
  margin-top: -145px;
  height: 115vh;
  width: 100%; 
  background-repeat:no-repeat;
  background-size:cover;
  background-position:center;
  align-items: center;
}

Thank you very much in advance!

Code/Algorithm for Logical Expression Simplifier

I’m building a logical expression from multiple inputs and combining them with an OR, so my expression becomes something like below

(1 AND 2 AND 3 AND 4 AND (50 OR 51) AND 7 AND 8)
OR
(1 AND 2 AND 3 AND 41 AND (50 OR 51) AND 71)

There are many repetitive elements in it which can be combined to build the optimal & final logical expression as

(1 AND 2 AND 3 AND (4 OR 41) AND (50 OR 51) AND ((7 AND 8) OR 71))

Is there any way by which this can be done? I’m currently building this as a string into javascript but any generic algorithm would help which I can apply to trim my logical expression

When I add “addEventListener”, console does not show it

I am new to the JS and I am coding a vanilla project which is a counter. When I add “addEventListener”, this method does not work. Here is my html file:

<!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">
    <link rel="stylesheet" href="style.css">
    <script src="script.js" async></script>
    <title>Counter</title>
</head>
<body>
    
    <h2 class="title">Counter</h2>
    <span id="value">0</span>

    <div class="container">
        
        <button class="btn increase" type="button">Increase</button>
        
        <button class="btn decrease" type="button">Decrease</button>
        
        <button class="btn reset" type="button">Reset</button>
    </div>

</body>
</html>

Here is my JS file:

let counter = 0

const btns = document.getElementsByClassName("btn")
const value = document.getElementById("value")

function getButton() {
    for (let i = 0; i < btns.length; i++) {
        getBtn = btns[i]
        getBtn.addEventListener("click", function (event) {
            console.log("clicked")

            // let buttonClicked = event.target
            // if (buttonClicked.classList.contains("increase")) {
            //     counter++
            // }
            // value.innerText = counter
        })
    }
}

The problem when I click the button, console.log(“clicked”) is not showed on the console.
Also, I got an issue from console:

Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform
A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.
Note that for performance reasons, only the first access to one of the properties is shown.
1 source
content-script-utils.js:1
Learn more: User-Agent String Reduction

I searched a little bit but I dont know whether it is related with my JS file.

Is there a way to view all custom marker icons in the Google maps javascript API?

The Issue:

I’ve viewed the tutorial on the Google Maps API documentation on how to change the icon of a marker. Here’s a screenshot of that:
Google Maps tutorial

In this tutorial though, they don’t actually elaborate on how they got the link to that icon. And I would like to know if there’s anyway to view all the available icons and their corresponding links.

What I’ve tried

  1. I tried going directly to the link: “https://maps.google.com/mapfiles/kml/shapes/”, but that returns a 404 error.
  2. After doing some research, I found this: http://econym.org.uk/gmap/geicons.htm …This should work, but the icons are a bit outdated and don’t really fit with what I’m going for.

Any help will be greatly appreciated. 🙂

Security issues in neb and underscore

this is my first question and I hope I am not coming up with something totally stupid.

I am new to JS and Node.js. I can solve easy issues on my own, but with this pollution report I need some advice.

I received the following report:

Severity: high
Prototype Pollution - https://github.com/advisories/GHSA-339j-hqgx-qrrx
Depends on vulnerable versions of binary-search-tree
Depends on vulnerable versions of underscore
No fix available
node_modules/nedb

underscore  1.3.2 - 1.12.0
Severity: high
Arbitrary Code Execution in underscore - https://github.com/advisories/GHSA-cf4h-3jhx-xvhq
No fix available
node_modules/underscore
  binary-search-tree  *
  Depends on vulnerable versions of underscore
  node_modules/binary-search-tree```

For nedb there seems to be absoutly no solution beside not using it. With underscore there is a patch available which seems to solve the problem.

However:
1. I have no clue whether nedb will still be working in I update the dependency underscore

2. I have no clue how to update the dependency underscore

So community kindly advice on using nedb in general and question 1 and 2.

Many thanks
Klaus 


Unable to send email nodemailer / office365

Im unable to use nodemailer to send emails through office365 using following code:

var transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
port: '587',
auth: {
    user: '[email protected]',
    pass: 'userpassword',
},
});

I have tried with different flags for nodemailer but nothing works:

secureConnection: false,
port: 587,
tls: {
ciphers:'SSLv3'

I have setup app-password in office 365 and can send email with following pyhton code:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

username = "[email protected]"
password = "userpassword"
mail_from = "[email protected]"
mail_to = "[email protected]"
mail_subject = "Test Subject"
mail_body = "This is a test message"
mimemsg = MIMEMultipart()
mimemsg['From']=mail_from
mimemsg['To']=mail_to
mimemsg['Subject']=mail_subject
mimemsg.attach(MIMEText(mail_body, 'plain'))
connection = smtplib.SMTP(host='smtp.office365.com', port=587)
connection.starttls()
connection.login(username,password)
connection.send_message(mimemsg)
connection.quit()

Konva text getting overflow outside the lable

We have integrated Konva in our project and we are facing issue with Label and Text. Text getting overflow outside the Label.
Expected behaviour
enter image description here

Current Behavior:
enter image description here

Please find the code snippet :

 self.label = new Konva.Label({
        id: ASSET_LABEL + assetData.properties._id,
        x: assetData.properties.labelCoordinates.x,
        y: assetData.properties.labelCoordinates.y,
        draggable: true
      });
      
       self.tag = new Konva.Tag({
        fill: config.color || Color.DARK_YELLOW,
        stroke: Color.BLACK,
        strokeWidth: LABEL_STROKE_WIDTH,
        cornerRadius: CORNER_RADIUS,
        shadowBlur: SHADOW_BLUR,
        shadowColor: Color.BLUE,
        shadowOpacity: SHADOW_OPACITY
      });
      
      self.text = new Konva.Text({
        padding: 5,
        fill: Color.BLACK,
        align: DEFAULT_TEXT_ALIGNMENT,
        fontFamily: config.fontFamily || DEFAULT_FONT_FAMILY,
        fontSize: config.fontSize || DEFAULT_FONT_SIZE,
        text: displayText
      });
      
       self.label.add(self.tag).add(self.text);
      
      

Please help me with this issue.

Thanks
Sanjeev