When I use load my flash message doesn’t disappear

I am trying to make a “widget” inside a home screen. And this “widget” will display messages depending on the user’s actions with it.

I don’t want to reload the entire page, since there may be another “widget” with user information that I haven’t finished filling in. So I’ve been getting by doing a load.

$('#user_credit .card-body #message').load(' #user_credit .card-body #message');

Now with this code the flash appears, either that it has been done correctly or if there has been an error.

The problem is that this message does not disappear automatically.

I’ve gotten it to go away using a timer in JS.

setTimeout(() => {  $("#message").attr('style', 'display:none') }, 2000);

But now it doesn’t show up again. So I had to add another timer.

setTimeout(() => {  $("#message").attr('style', 'display:block') }, 100);

In the end the code is like this:

$('#user_credit .card-body #message').load(' #user_credit .card-body #message');
setTimeout(() => {  $("#message").attr('style', 'display:block') }, 100);
setTimeout(() => {  $("#message").attr('style', 'display:none') }, 2000);

With all this it works correctly. But my question is, if reloading manually without all that code works, that is, it appears and disappears, how can I make it appear and disappear without using the timers.

Thank you very much in advance.

Excuse my English I’m using google translator

Making a JSX syntax for a MockComponent and have it typed with typescript

Wondering if anybody has some good suggestions on how to crack this. Got this test helper utils I have added some types to:

import { jest } from '@jest/globals'
import React from 'react'

// https://learn.reactnativeschool.com/courses/781007/lectures/14173979
export function mockComponent(moduleName: string, propOverrideFn = (props: Record<string, any>) => ({})) {
  const RealComponent = jest.requireActual(moduleName) as React.ComponentType<any>
  const CustomizedComponent = (props: Record<string, any>) => {
    return React.createElement(
      'CustomizedComponent',
      {
        ...props,
        ...propOverrideFn(props),
      },
      props.children
    )
  }
  CustomizedComponent.propTypes = RealComponent.propTypes

  return CustomizedComponent
}

So currently I can call it like this

jest.mock('react-native/Libraries/Components/Touchable/TouchableOpacity', () => {
  return mockComponent('react-native/Libraries/Components/Touchable/TouchableOpacity', (props) => {
    return {
      onPress: props.disabled ? () => {} : props.onPress
    }
  })
})

But I would like to be able to call it more like


jest.mock('react-native/Libraries/Components/Touchable/TouchableOpacity', () => {
  return <MockComponent 
          module='TouchableOpacity' 
          onPress={props => props.disabled ? () => {} : props.onPress}
         />
})

or

jest.mock('react-native/Libraries/Components/Touchable/TouchableOpacity', () => {
 return <MockComponent 
          module='TouchableOpacity'
          propOverride={props => ({onPress: props.disabled ? () => {} : props.onPress, ...props})}
        />
})

exports is not defined in ES module scope

I created nest js project as following.

nest new project-name

and imported following from nuxt3 which is of type module of node js with mjs file extension (type definition of import doesn’t require to write mjs).

import { ViteBuildContext, ViteOptions, bundle } from '@nuxt/vite-builder-edge';

It gives me below error.

Uncaught Error Error [ERR_REQUIRE_ESM]: require() of ES Module c:UsersuserDocumentsGitLabdiscobitenode_modules@nuxtvite-builder-edgedistindex.mjs not supported. Instead change the require of c:UsersuserDocumentsGitLabprojectnode_modules@nuxtvite-builder-edgedistindex.mjs to a dynamic import() which is available in all CommonJS modules.

So I tried adding "type": "module" in package.json so now I am getting below error.

Uncaught ReferenceError ReferenceError: exports is not defined in ES module scope This file is being treated as an ES module because it has a '.js' file extension and 'c:UsersuserDocumentsGitLabprojectpackage.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at <anonymous> (c:UsersuserDocumentsGitLabprojectdistmain.js:2:23)

How do I fix this? Error is related to typescript (or say compiled javascript) is unable to import mjs exports. What is solution to this?

Filtering in Object values is not working

I need to filter objects in the array by their value. The value comes from the input (event.target.value).

const people = [
      { firstName: "John", lastName: "Lu", age: 50, eyeColor: "green" },
      { firstName: "Mary", lastName: "Smith", age: 70, eyeColor: "blue" },
      { firstName: "Nick", lastName: "Joy", age: 45, eyeColor: "green" },
      { firstName: "Ann", lastName: "Smith", age: 10, eyeColor: "brown" },
    ];

I need to check every value in the array. If the user writes lu, the result should be (lu in blue and Lu in the lastName)

I use indexOf but get empty array.

const inputData = event.target.value;
const newResult = people.filter((obj) => Object.values(obj).indexOf(inputData !== -1));

Could you please help me. I looked through many issues but can’t solve my problem.

Imacros code is good but extraction result is override? How to store extracted text from website in a column and stored in a file using loop?

Please specifies me….what is wrong on code i am waiting for your help.

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
SET !TIMEOUT_STEP 0
SET !EXTRACT_TEST_POPUP NO
SET !ERRORIGNORE YES
SET !DATASOURCE Google.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!COL1}}

URL GOTO=https://www.google.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG
TAG POS=1 TYPE=div ATTR=class:"BNeawe UPmit AP7Wnd" EXTRACT=HTM
SAVEAS TYPE=EXTRACT FOLDER=* FILE=Data.csv

Code Working is Fine.

manipulating an array from two or more arrays in angular

I have two arrays:

1st array:

[ 0:{“useCaseId”:1036, “useCaseName”:”user”, “senderMailId”:null, “executionDate”:null, “startTime”:null, “status”:null, “endTime”:null, “totalExecutionTime”:null, “ticketId”:null, “description”:”reset password”, “createdDate”:”2022-03-15T06:19:31.832+00:00″, “active”:true},

1:{“useCaseId”:1033, “useCaseName”:”designer”, “senderMailId”:null, “executionDate”:null, “startTime”:null, “status”:null, “endTime”:null, “totalExecutionTime”:null, “ticketId”:null, “description”:”running password not”, “createdDate”:”2022-03-11T06:58:43.804+00:00″, “active”:false},… ]

2nd Array:

0: id: 1 latestMessage: “Good Morning!” latestMessageRead: true messages: Array(5) 0: {id: 1, body: ‘Hello!’, time: ‘8:21’, me: true} 1: {id: 1, body: ‘How are you?’, time: ‘8:21’, me: false} 2: {id: 3, body: ‘I am fine thanks.’, time: ‘8:21’, me: true} 3: {id: 4, body: ‘Glad to hear that’, time: ‘8:21’, me: false} 4: {id: 5, body: ‘Yes, from this side too’, time: ‘8:21’, me: true}

1: id: 2 latestMessage: “Good evening!” latestMessageRead: true messages: Array(5) 0: {id: 2, body: ‘Hello!’, time: ‘8:21’, me: true} 1: {id: 1, body: ‘How are you?’, time: ‘8:21’, me: false} 2: {id: 3, body: ‘I am fine thanks.’, time: ‘8:21’, me: true} 3: {id: 4, body: ‘Glad to hear that’, time: ‘8:21’, me: false} 4: {id: 5, body: ‘Yes, from this side too’, time: ‘8:21’, me: true}… ]

I want a third array which has:

Conversation=[ name: useCaseName (from the first array), time: createdDate (from the first array), id: 1, latestMessage: “Good Morning!”, latestMessageRead: true, messages: Array(5) 0: {id: 1, body: ‘Hello!’, time: ‘8:21’, me: true} 1: {id: 1, body: ‘How are you?’, time: ‘8:21’, me: false} 2: {id: 3, body: ‘I am fine thanks.’, time: ‘8:21’, me: true} 3: {id: 4, body: ‘Glad to hear that’, time: ‘8:21’, me: false} 4: {id: 5, body: ‘Yes, from this side too’, time: ‘8:21’, me: true},

id: 2, name: useCaseName (from the first array), time: createdDate (from the first array), latestMessage: “Good evening!”, latestMessageRead: true, messages: Array(5) 0: {id: 1, body: ‘Hello!’, time: ‘8:21’, me: true} 1: {id: 1, body: ‘How are you?’, time: ‘8:21’, me: false} 2: {id: 3, body: ‘I am fine thanks.’, time: ‘8:21’, me: true} 3: {id: 4, body: ‘Glad to hear that’, time: ‘8:21’, me: false} 4: {id: 5, body: ‘Yes, from this side too’, time: ‘8:21’, me: true}

]

I am quite new to angular,Can anyone help me out please.
Thankyou.

How to get data from many to many relationship as nested object with key in mongodb with cudebs (Mongodb BI connector)

I have many to many relationship in mongodb in collection A i have key (dynamicFieldValue) in which i story objects with id and key as you can see screen attached image
in collection B i have key as ticket_ids in which i store id tickets.
now i have to create relationship between them and get data for cubeJS

joins: {
    DynamicFields : {
      sql: `${CUBE}.dynamicFieldsValue.*._id = ${DynamicFields}._id`,
      relationship: `belongsTo`
    }
  }, 

It shows me an error

parse sql ‘SELECT
dynamic_fields.name dynamic_fields__name, count(tickets._id) tickets__count
FROM
tickeingSystem.tickets AS tickets LEFT JOIN tickeingSystem.dynamic_fields AS dynamic_fields ON
tickets.dynamicFieldsValue.*._id = dynamic_fields._id GROUP BY 1
ORDER BY 2 DESC LIMIT 5000′ error: unexpected TIMES at position 246

enter image description here
enter image description here

Check primary monitor in JavaScript with navigator.mediaDevices.getUserMedia

I want to capture the main monitor by the browser. I’m trying to do it like this:

navigator.mediaDevices.getDisplayMedia({
      video: {
        displaySurface: 'monitor',
        logicalSurface: true,
        cursor: 'always',
        frameRate: {
            ideal: 20
        }
    }
})

Next, the user chooses which screen he will broadcast. I want to check that the user has selected the main monitor (in case there are several). How i can do this? Thanks.

How to use element.scrollIntoView as a promise or observable?

I’m using

tab_element.scrollIntoView({
        behavior:'smooth',
        block: 'center',
});

to scroll the element at the center
but immediately after this, I need to call router.navigate
This is causing the scroll to be interrupted,
so my solution is to do the navigation after the scrolling is finished.
Is there a way that I can get a promise or an observable which can be used to call a function after scroll completes?

Iterate an API call for until the end is found

I have an API where it returns limited results of data
the limit value cannot be greater than 1000

> https://api.source.com?start=0&limit=1000 //first call
> https://api.source.com?start=1001&limit=1000 //second call
> https://api.source.com?start=2001&limit=1000 //third call
> https://api.source.com?start=3001&limit=1000 //fourth call

{
  "success": true,
  "message": "Verticals Returned",
  "response": {
    "start": 0,
    "limit": 1000,
    "returned": 1000,
    "total": 3230,
    "data": [
      {
        "verticalID": 3,
        "verticalName": "Galaxies",
        "status": "Active",
        "groupID": 1,
        "createdOn": "2022-03-15 05:30:06",
        "groupName": "Solar",
        "totalOffers": 0
      }
    ]
  }
}

How do it iterate this using a loop? while or any other loop is also fine.

I have tried with

limit =1000
start = 0;
total = undefined;
for(i=start;;i+=returned)
{
    y = call("https://api.source.com?start="+start+"&limit="+limit)
    total = y.total
    start = y.start
    returned = y.returned
}

How to use a Javascript library which does its own DOM manipulation in React

I am trying to use a JavaScript library in React.
The library does it does dom manipulation. e.g. when I click on a row, it adds dom elements to show the detail content of that row.

So In my React component, I did

export default class MyReactComponent extends React.Component {
  private _ref: React.RefObject<HTMLDivElement>;

  constructor(props) {
    super(props);
    this._ref = React.createRef();
  }

    componentDidMount() {
       const container = this._ref.current;
       var myJSLibrary = new JSLibrary(container);
    } 

    
  render() {
    return (
      <div>
        <div  ref={this._ref}/>
      </div>
    );
  }
}

When I run it, I do see myJSLibrary get display. But when I click it, I see this exception in my Chrome console:

Warning: render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.

Can you please tell me what am I missing so that React will let the ‘myJSLibrary’ does it own DOM manipulation.

Thank you.