How to save ManyToMany relations in TypeORM?

I need to create relations ManyToMany with using third table. Below is my code:

Account.ts

    @OneToMany(() => WorkspaceAccount, workspaceAccount => workspaceAccount.accountId, {
        cascade: true,
    })
    workspaces: WorkspaceAccount[];

Workspace.ts

    @OneToMany(() => WorkspaceAccount, workspaceAccount => workspaceAccount.workspaceId, {
        onUpdate: 'CASCADE', onDelete: 'CASCADE'
    })
    members: WorkspaceAccount[];

WorkspaceAccount.ts

    @ManyToOne(() => Account, {
        nullable: false,
        onUpdate: 'CASCADE',
        onDelete: 'CASCADE',
        primary: true,
    })
    @JoinColumn({
        name: 'accountId',
    })
    accountId: Account;

    @ManyToOne(() => Workspace, {
        nullable: false,
        onUpdate: 'CASCADE',
        onDelete: 'CASCADE',
        primary: true,
    })
    @JoinColumn({
        name: 'workspaceId',
    })
    workspaceId: Workspace;

And now I have a question, how to save this relations, in this way, that when I create new Workspace then automatically will be created object in WorkspaceAccount table?

Thanks for any help

I want to track the distance i walk and i couldn’t make that i’m trying to do that with react native so anyone could help me

i’m trying to make an app that count steps and distance and time and i couldn’t find way to get distance in the counter (realtime) so i want any one to help me how to that .

import {useEffect, useState` } from “react”;
import * as Location from “expo-location”;enter code here

export default `useLocation` = () => {
  const [location, `setLocation`] = `useState`();

  const `getLocation` = async () => {
    try {
      const { granted } = await `Location`.`requestForegroundPermissionsAsync`();
      if (!granted) return;
      const {
        `coords`: { latitude, longitude },
      } = await `Location.getCurrentPositionAsync`();

      console.log(latitude, latitude);
      setLocation({ latitude, longitude });
    } catch (error) {
      console.log(error);
    }
  };

  const `updateLocation` = async () => {
    try {
  await `Locationx.startLocationUpdatesAsync();`

    } catch (error) {
      console.log(error);
    }
  };

  `useEffect`   (  ()   => {

    `getLocation`();

  }, []);
  return location;
};

    enter code here

`

Display X and Y coordinates in Chart.js

I have a robot in my project that I get X and Y coordinates from when I start it. I want to show these coordinates that make the robot move in a diagram. Like a car to see where you’re going.

I get the data from the robot in the main.js file and call it in the index.html file using id = “posX” and id = “posY”

enter image description here

How can I pass the value shown above to the chart?

const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
    type: 'line',
    data: {
        datasets: [{
            label: 'GOKART MOVING',
            data: [document.getElementById(posX),document.getElementById(posY)],    
        }],
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero: true,
                    suggestedMax: 20,
                }
            }]
        }
    }
});

What is the standard way of using selenium in production?

I have written some tests for my website using selenium and javascript. I want to know the standard way of using this script in production. Locally I’m running chrome driver and testing my script. What I have tried is in start of my package.json I run my test node test.js && react-scripts start.What is the standard way of doing the same in production?

How to smooth out the trails of the particles in a p5js simulation

I want to turn this halting, discontinuous trails in the particle on this simulation

enter image description here

to something worth staring at as in this beautiful field flow in here (not my work, but I don’t remember where I got it from).

I have tried different permutations of the code in the accomplished field flow without getting anything remotely close to the smoothness in the transitions that I was aiming for. I suspect I am mishandling the updates or the placement of the black rectangle that seems to circumvent the need for a black background, which would erase the wake of the particles.

const scl = 45;
var cols, rows;
var particles = [];
var flowfield;

function setup() {

    createCanvas(750, 750);
    cols = ceil( width / scl );
    rows = ceil( height / scl );


    flowfield = new Array( cols * rows );

    for (var i = 0; i < 1000; i ++ ) {
        particles[i] = new Particle();
    }
}

function draw() {
    
    translate(height / 2, height / 2); //moves the origin to center
    scale( 1, - 1 ); //flips the y values so y increases "up"

    rect(-width,-height,2*width,2*height);
    for ( var y = 0; y < rows; y ++ ) { 
        for ( var x = 0; x < cols; x ++ ) { 
      
      var index = x + y * cols;

      let vX = x * 2 - cols;
      let vY = y * 2 - rows;
                
     
      var v = createVector( vY, -vX );
      v.normalize();
          
      flowfield[index] = v;
      
      // The following push() / pull() affects only the arrows     
      push();
      translate(x*scl-width/2,y*scl-height/2);

      fill(255);
      stroke(255);
      rotate(v.heading());
      line(0,0,0.5*scl,0);
      let arrowSize = 7;
      translate(0.5*scl - arrowSize, 0);
      triangle(0, arrowSize / 2, 0, -arrowSize / 2, arrowSize, 0);
      pop();
// The preceding push() / pull() affects only the arrows     
    }// Closes inner loop
  }// Closes outer loop to create vectors and index.
  
//This next loop actually creates the desired particles:
    for (var i = 0; i < particles.length; i++) {
    particles[i].follow(flowfield);
    particles[i].update();
    particles[i].edges();
    particles[i].show();
  }
} // End of the function draw

class Particle {

    constructor() {


        // changed startpostion. Since the origin is in the center of the canvas,
        // the x goes from -width/2 to width/2
        // the y goes from -height/2 to height/2
        // i also changed this in this.edges().

        this.pos = createVector( random( - width / 2, width / 2 ),
            random( - height / 2, height / 2 ) );
        this.vel = createVector( 0, 0 );
        this.acc = createVector( 0, 0 );
        this.maxspeed = 4;
        this.steerStrength = 30;
        this.prevPos = this.pos.copy();
        this.size = 2;

    }

    update() {

        this.vel.add( this.acc );
        this.vel.limit( this.maxspeed );
        this.pos.add( this.vel );
        this.acc.mult( 0 );
        fill(255)
        circle( this.pos.x, this.pos.y, this.size );
      

    }

    follow( vectors ) {

        var x = floor( map( this.pos.x, - width / 2, width / 2, 0, cols - 1, true ) );
        var y = floor( map( this.pos.y, - height / 2, height / 2, 0, rows - 1, true ) );
        var index = ( y * cols ) + x;

        var force = vectors[ index ].copy();
        force.mult( this.steerStrength );
        this.applyForce( force );

    }

    applyForce( force ) {

        this.acc.add( force );

    }

    show() {


        noStroke();
        fill(0,5)
        // you can just draw on the position.


        this.updatePrev();


    }

    updatePrev() {

        this.prevPos.x = this.pos.x;
        this.prevPos.y = this.pos.y;

    }

    edges() {

        //clamp between -width/2 and width/2. -height/2 and height/2
        if ( this.pos.x > width / 2 ) {

            this.pos.x = - width / 2;
            this.updatePrev();

        }
        if ( this.pos.x < - width / 2 ) {

            this.pos.x = width / 2;
            this.updatePrev();

        }
        if ( this.pos.y > height / 2 ) {

            this.pos.y = - height / 2;
            this.updatePrev();

        }
        if ( this.pos.y < - height / 2 ) {

            this.pos.y = height / 2;
            this.updatePrev();

        }
    }
}

Showing a red alert text near an input if the input does not match what we want

So basically I want to display some red text in a website if the content of an input is not what I want the person to put
I know how to check for that with jquery, but to show the red text I was thinking of having it already in the html with a hidden class and then removing the hidden class when the input is not correct, but it seems a bit dirty ? Is there a better way to make some text appear in that case ?

3 progress bar in one html file using js

How to display 3 progress bar that have different data using js and html.
First of all, sorry for my poor English, I hope you will understand me after all
I want 3 same circle to show 3 different data.
When I add 3 of the same js codes in which I change the “radialprogress” ID, I always see one progress bar.
I have this code

Html:

<div class="row">
<div>
<div style="width: 160px;float: left;margin-right: 0px;" id="radialprogress" ></div>
</div>
<div>
<div style="width: 160px;float: left;margin-right: 0px;" id="radialprogress" ></div>
</div>
<div>
<div style="width: 160px;float: left;margin-right: 0px;" id="radialprogress" ></div>
</div>
</div>

JS code which I also put in html:

    <script>
    var svg ;

function drawProgress(end){ 
d3.select("svg").remove() 
  if(svg){
  svg.selectAll("*").remove();
  
}
var wrapper = document.getElementById('radialprogress');
var start = 0;
 
var colours = {
  fill: '#12ea8d',
  track: '#555555',
  text: '#00C0FF',
  stroke: '#172b4d',
}

var radius = 80;
var border = 12;
var strokeSpacing = 4;
var endAngle = Math.PI * 2;
var formatText = d3.format('.0%');
var boxSize = radius * 2;
var count = end;
var progress = start;
var step = end < start ? -0.01 : 0.01;

//Define the circle
var circle = d3.svg.arc()
  .startAngle(0)
  .innerRadius(radius)
  .outerRadius(radius - border);

//setup SVG wrapper
svg = d3.select(wrapper)
  .append('svg')
  .attr('width', boxSize)
  .attr('height', boxSize);

  
// ADD Group container
var g = svg.append('g')
  .attr('transform', 'translate(' + boxSize / 2 + ',' + boxSize / 2 + ')');

//Setup track
var track = g.append('g').attr('class', 'radial-progress');
track.append('path')
  .attr('fill', colours.track)
  .attr('stroke', colours.stroke)
  .attr('stroke-width', strokeSpacing + 'px')
  .attr('d', circle.endAngle(endAngle));

//Add colour fill
var value = track.append('path')
  .attr('fill', colours.fill)
  .attr('stroke', colours.stroke)
  .attr('stroke-width', strokeSpacing + 'px');

//Add text value
var numberText = track.append('text')
  .attr('fill', colours.text)
  .attr('text-anchor', 'middle')
  .attr('dy', '.5rem'); 

  //update position of endAngle
  value.attr('d', circle.endAngle(endAngle * end));
  //update text value
  numberText.text(formatText(end));
  
}
 
drawProgress(14/100)
</script>

Thank You

NTLM in CYPress

I want to access a link that is protected with username and password through a windows authentication popup.

I read that this requires an NTLM plugin for CYPRESS. I want to access a form link https://etc.domain.com/dirlisting/notifications and here i want to login

 it('loginpopup', () => {
    cy.ntlm(["https://etc.domain.com/dirlisting/notifications"], "Administrator", "password");
    cy.visit("https://etc.domain.com/dirlisting/notifications");
  })

I tried this code but i have error: “Invalid host [https://etc.domain.com/dirlisting/notifications ] in ntlmHosts, must be one of: 1) a hostname or FQDN, wildcards accepted. 2) hostname or FQDN with port, wildcards not accepted (localhost:8080 or www.google.com or *.acme.com are ok, https://www.google.com:443/search is not ok).

I tried also without https

I tried cy.visit('https://username:[email protected]') but isn’t work

Rewrite vanilla JS forEach into jQuery Each()

I am trying to keep my code consistent as I’m using jQuery for my project, however, I’m a bit confused about the each() method of jQuery.

let cells=$(".cell").toArray();

my Vanilla JS code is here:

cells.forEach(function(cell,index){
    cell.addEventListener('click',function(){
        console.log(cell,index);
    })
})

my jQuery is here:

cells.each(function(index,cell){
    cell.click(function(){
        console.log(cell,index);
    })
})

I know the code is wrong, as the console shows Uncaught TypeError: cells.each is not a function but I checked the jQuery Document, it says the each method is the forEach method in JS, I am really confused now.

display input value in div

I have an input with values and I want to add a value to a div every time I select it.

so that I can add more than one value

Thanks in advance.

HTML

<div [formGroup]="form">
 <select name="test id="test">
   <option value="one">One</option>
   <option value="two">Two</option>
 </select>
</div>

// i want display the input value here

<div> {{this.form.value}} </div> // this way does not work

JavaScripts read an array that was sent from PHP

Hello I am starting to use JavaScript, I explain my problem, i send array to give from PHP to my JavaScript but when I want to read my array in JavaScript, it reads letter by letter and not words by words.

erreur image

function update(json)
{

    console.log(json);
    var result = JSON.stringify(json);
    console.log(result);

    for (let i =0;i< result.length;i++)
    {
        chart.data.datasets[0].data[i]=result[i];
        console.log(result[i]);
    }
    chart.update();
}
<button data-values="<?php  echo preg_replace('/"/',"'", preg_replace("/'/","'", json_encode($tab[$row]))); ?>" onclick="update(this.getAttribute('data-values'))"><?php echo $worksheet->getCell('A'.$row)->getValue(); ?></button>

How do you fetch data from an API and inject that same data into a link that points to another API (JavaScript)

The movie.imdbID return a string of IDs which is then used as an argument for the getMovieIMDBID function. In my code when the element is created, it looks fine as the id looks to be properly inserted like so

a onclick=”getMovieIMDBID(tt4853102)”>Batman: The Killing Joke

yet on the console it tells me ReferenceError: tt4853102 is not defined when i click on the UI.

and if I ctrl+click the link i get this error message in a pop up window

{“Response”:”False”,”Error”:”Conversion from string “${movieID}” to type ‘Double’ is not valid.”}

let movies = movieItems.map(function (movie) {
   return `  <a onclick="getMovieIMDBID(${movie.imdbID})">${movie.Title}</a> 
                <img src="${movie.Poster}">

              `;
    });

function getMovieIMDBID(movieID) {
  let movieInfo = new XMLHttpRequest();
  movieInfo.addEventListener("load", function () {
    let movieInfoParsed = JSON.parse(this.responseText);
    let movieInfoItems = movieInfoParsed.map(function (data) {
      return `<h1>${data.Title}</h1>`;
    });
    movieInfoContainer.innerHTML = movieInfoItems;
  });
  movieInfo.open(
    "GET",
    `https://www.omdbapi.com/?i=${movieID}&apikey=564727fa`
  );
  movieInfo.send();
}

Delete only div containers inside a container

The aim is to delete all div containers within a container and leave two anhchor tags untouched.

<div id="container">
  <div id="wrapper" class="slider">

    <div><img src=""></div>
    <div><img src=""></div>
    <div><img src=""></div>

    <!-- Next and previous buttons -->
    <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
    <a class="next" onclick="plusSlides(1)">&#10095;</a>

  </div>
</div>

expected / goal

<div id="container">
  <div id="wrapper" class="slider">
    <!-- Next and previous buttons -->
    <a class="prev" onclick="plusSlides(-1)">&#10094;</a>
    <a class="next" onclick="plusSlides(1)">&#10095;</a>

  </div>
</div>

With innerHTML everything is deleted and therefore also the a tags. Is there an elegant and simple solution?

HTML input type=’range’ not moving

I have an Options component containing a slider input.
I don’t understand why the thumb of the slider doesn’t move if I set the “value” parameter, but i need it.

Here the code:

interface Props {
    value?: number
}

const Options: React.FC<Props> = ({ value }) => {

    return (
        <div className='options'>
            <span className='boh'>CUSTOMIZE YOUR PASSWORD</span>
            <div className='slider-container'>
                <input type="range" id="slider" min="1" max="100" value={value} />
                <label htmlFor="slider">Length</label>
            </div>
        </div>
    )
}

export default Options

I thank anyone who gives me a hand

Splitting sheet text using an array to mantain unique ID

I’m using this: How to transpose and split in Google Apps Script?

Which works great in the first part (I use it to copy data an split it) but then I would need to redo it since I have 2 different separators, first time “;” second time “,”.

The issue and I’m guessing it’s more JS related than anything else, is that if I use the same for it splits the 2nd column vertically. I’ll post examples.

Column A has the ID, Column B has the comma separated text

If I use it again to reformat it gives this:

enter image description here

I would like it to be split into Column B and C.

I figured it was because the for loop only pushes 2 rows, but I can’t solve adding a third.