getter using pinia and vue3 undefined

I have not been able to get the getters from Pinia integrate correclty into my vue3 project.
So i have a index.js, getters.js and the file file where i want to fetch the getter test.js

my index,js looks like this:

import * as actions from './actions'
import * as getters from './getters'
export const usevwoStore = defineStore('vwoStore', {
  state: () => {
    return {
      groups:[],
    }
  },
  actions: actions.actions,
  getters: getters.getters
})

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(usevwoStore, import.meta.hot))
  /*import.meta.hot.accept((newModule) => {
    if (newModule) {
      console.log('updated: count is now ', newModule.count)
    }
  })*/
}

export default usevwoStore

my getters.js looks like this:

// import { aanwezighedenSecundairHelperService } from './../../services/aanwezigheden-secundair.service.js'
import { useGlobalStore } from '@/store/store.js';
import { toRaw } from "vue";
import { usevwoStore } from './index.js';
import { restServ } from '@/services/rest.service.js';
import router from '@/router/router.js'

const dateOperations = dateOperationsMix.methods


export const getters = {

 getgroups(){
  return this.usevwoStore.groups
  // console.log('sdfsd')
}
} 

and finally where i want to fetch the getters is my test.js file

import { mapStores, mapWritableState, mapState } from 'pinia'
import { useGlobalStore } from '@/store/store.js'
import { usevwoStore } from '../../store/index.js'
import { toRaw } from "vue";
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { storeToRefs } from 'pinia'
export default {
  name: "test",
  setup() {
    const myStoreActions = toRaw(useGlobalStore())
    const myStoreState = useGlobalStore()
    const vwoStoreState = usevwoStore()
 const vwoStoreGetters = storeToRefs(usevwoStore())
    const route = useRoute();
    const currentRoute = computed(() => route.path)
    return { myStoreActions, myStoreState,vwoStoreActions,vwoStoreState,route, currentRoute,vwoStoreGetters }
  },

  data () {
    return {}
    
  },
  computed: {
    groups: {
  
      get: function () {    
        **return this.vwoStoreGetters.getgroups;**
      },
      set: function () {
        return this.vwoStoreGetters.getgroups;
      }
    }
....

i am always getting this.vwoStoreGetters.getgroups undefined..is teh logic correct what i am using? Does it have to do with the computed property?
Thanks guys!

Access Promise function in Javascript?

is it possible to retrieve the code from a Promise Object? Suppose I set up a Promise like this:

let myPromise = new Promise(function(success, error) {
                        ...
}

Can I somehow retrieve the anonymous function or the location of the anonymous function in the code file?

function(success, error) {
                        ...
}

from myPromise?

How to filter an array that has mixed data types

I have an array which is like this:

const AllFiles = [

    {name: "ExistingFile1", mimetype: "image/jpg", size: "500"},

    [ 
     File, // This is the New File itself (see File API)
     {name: "NewFile1", mimetype: "video/mp4", size: "9000"}
    ],

    {name: "ExistingFile2", mimetype: "video/mp4", size: "4000"},

    [ 
     File, // This is the New File itself (see File API)
     {name: "NewFile2", mimetype: "image/jpg", size: "500"}
    ],

 ]

As you can see the AllFiles array contains a mix of objects and arrays.

I need to filter the AllFiles array to only return items where the mimetype starts with "image/".

So I started off with the following:

const FilteredFiles = AllFiles.filter((FileItem, index) => FileItem.mimetype.startsWith("image/"))

The problem is that it only looks for the mimetype where it is in a top level object. Its does not look deeper where a New File has mimetype in the second level object within an array.

To get the mimetype of existing files you need to use: FileItem[0].mimetype

But to get the mimetype for new files you need to use: FileItem[0][1].mimetype

Because of this mismatch I am unable to filter the AllFiles array. How could this possibly be achieved?

=IMPORTXTML() not working with dynamic date selection

=IMPORTHTML("https://www.moneycontrol.com/india/fnoquote/" & A2 & "/2024-02-29/OPTSTK/CE/2700.00/true", "table", 6)

Is working fine in googlesheet to fetch data, but when i make date dynamic select from dropdown it stopped, and error #NA "Error Imported content is empty.".

I Tried using single date with same date text format date are 2024-02-29, 2024-03-28, and 2024-04-25.

This is my dynamic formula

=IMPORTHTML("https://www.moneycontrol.com/india/fnoquote/" & A2 & "/" & TEXT('OI_ANALYSIS'!D1, "yyyy-mm-dd") & "/OPTSTK/CE/2700.00/true", "table", 6)

there is a dropdown of those dates in sheet OI_ANALYSIS CELL "D1".

Can anyone help me to resolve this issue?

Asking to correct formula .

Same URL, Different Behavior

I had a ticket to modify the behavior of my company website. Some html and some js. The ticket said to make it so that when a user is on a (bootstrap) tab and clicks on Link A, it goes to the respective tab and scrolls down to the appropriate anchor. Link B should have the same behavior. Both links should navigate to the same path.

Html

// The Links
<div>
    <a name="link-a">Link A</a>
    <a name="link-b">Link B</a>
</div>

// The tab
<div class="tab-pane fade show active" id="rankings" role="tabpanel" aria-labelledby="rankings-tab">
    <h2>Rankings</h2>

    // some more code..

    <h3 class="h5 fw-700 mb-3" id="link-a-header">Link A Header</h3>

    // some more code..

    <h3 class="h5 fw-700 mb-3" id="link-b-header">Link B Header</h3>
</div>

JS

var callingClick = "";
function Init() {
    document.getElementById("rankings-tab").addEventListener("shown.bs.tab", function (e) {
        if (callingClick === "link-a" || callingClick === "link-b") {
            ScrollToAnchor(callingClick);
        }
    });

    document.querySelectorAll("a[name]").forEach(anchor => {
        anchor.addEventListener("click", function (e) {
            e.preventDefault();

            let activePanelTabId = $(".active.tab-pane")[0].getAttribute("id");
            callingClick = e.currentTarget.getAttribute("name");

            if (activePanelTabId != "rankings") {
                document.getElementById("rankings-tab").click();
            } else {
                ScrollToAnchor(callingClick);
            }
        });
    });
}
Init();

This code is deployed to our test server. When I go on the page, the page works exactly how it’s supposed to. When someone else on my team goes to the same page (same link and cleared cache and cookies), it works differently. Whereas I experience clicking the link and it navigates to the rankings tab and scrolls to the appropriate header, my teammates click on the link and are merely navigated to the tab (no scroll).

I did screenshares with them, saw that there were no console errors and verified that the js file loaded on the page was consistent with mine.

Any thoughts as to why this would be happening?

Uploading image using vue CLI front end and laravel back end

Hi guys basically what i want is to upload image using vue CLI and laravel for the back end

here is my vue code for the front end part

<script>
import axios from "@/axios";
export default {

  data: () => ({
    dialog: false,
    name:'',
    profile_path: null,

  }),

  methods: {
    onChangeProfilePath: function (event) {
      var input = event.target;
      if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = (e) => {
          this.profile_path = e.target.result;
        };
        reader.readAsDataURL(input.files[0]);
      }
    },

    add() {
      this.dialog = true;
    },
    async addData() {
      try {
        let payload = new FormData();
        payload.append("profile_path", this.profile_path);
        payload.append("name", this.name);

        const config = {
          headers: {
            "content-type": "multipart/form-data",
          },
        };

      await axios.post("/about", payload, config, {});
      } catch (error) {
        console.error("An error occured while adding", error);
      }
    },
  },
};
</script>
<template>

  <v-card class="mx-auto" max-width="100%">
    <v-card-title>
      <v-container>
        <v-row>
          <v-col cols="12" sm="12" md="6">
            <v-btn @click="add()" class="ma-2" variant="text" icon="mdi-plus-box" color="blue-lighten-2"></v-btn>
          </v-col>
        </v-row>
      </v-container>
    </v-card-title>
  </v-card>

  <v-row justify="center">
    <v-dialog v-model="dialog" persistent width="1024">

      <form @submit.prevent="addData()" enctype="multipart/form-data">
        <v-card>
          <v-card-title> Add  </v-card-title>
          <v-card-text>
            <v-container>
              <v-row>
                <v-col cols="12" sm="12" md="12">
                  <v-text-field  v-model="name" label="Name" variant="underlined" prepend-icon="mdi-file-document-outline" ></v-text-field>
                </v-col>
                <v-col cols="12" sm="12" md="12">
                  <v-card class="mx-auto" width="400" prepend-icon="mdi-image-area">
                    <template v-slot:title> Profile Image </template>
                    <v-card-text>
                      <v-row justify="center" class="mx-0">
                        <v-col cols="12" sm="12" md="12">
                          <img style="max-height: 100px" class="mb-5" contain :src="profile_path"/>
                          <input type="file" class="mb-3" @change="onChangeProfilePath" accept="image/*"/>
                        </v-col>
                      </v-row>
                    </v-card-text>
                  </v-card>
                </v-col>
              </v-row>
            </v-container>
          </v-card-text>
          <v-card-actions>
            <v-spacer></v-spacer>
            <v-btn color="blue-darken-1" variant="text" @click="dialog = false"> Close </v-btn>
            <v-btn color="blue-darken-1" variant="text" type="submit"> Add </v-btn>
          </v-card-actions>
        </v-card>
      </form>

    </v-dialog>
  </v-row>
</template>

this is my code in backend controller laravel

 public function store(Request $request)
    {
        //

            $path = public_path() . "/img/";

            $request->validate([
                'profile_path' => 'required|mimes:jpg,jpeg,png,csv,txt,xlx,xls,pdf|max:2048',
            ]);

            if (!file_exists($path)) {
                mkdir($path, 0777, true);
            } //check if the directory exists

            $profilePath = request()->file('profile_path');
            $imageProfilePath = $profilePath->getClientOriginalName();

            $profilePath->move($path . '/', $imageProfilePath);

            $img = new About;
            $img->name = $request['name'];
            $img->profile_path = '/img/' . $imageProfilePath;
            $img->save();

            
        
    }

but for some reason I am keep getting this error even if i am uploading an image file. Even if I use dd() am getting the image data in the controller.

message "The profile path field must be a file of type: jpg, jpeg, png, csv, txt, xlx, xls, pdf. (and 1 more error)"

Am hoping someone can help

thanks

Add data attribute to html (depending on screen size)

I’m looking for the simplest and short method for adding data attribute to html, depending on screen size.

Specific example:
I have some HTML:

<nav>...</nav>

And I need:

<nav data-navigation>... </nav>

*when width is < 768px

Popular example with adding a class (AddClass) – I need something like that. Thx!
I’m tryed setattribute, data, etc…

Call a function on every resize and load

I am trying to make all divs with the same class the same height when loaded and whenever the window is resized. How can I call this function on load and whenever the screen resized? I’m trying to avoid using jQuery.

(function matchHeight() {
  var getCardBodyHeight = document.getElementsByClassName("card-body-height");

  var arrayLength = getCardBodyHeight.length;
  var heights = [];

  for (var i = 0; i < arrayLength; i++) {
    heights.push(getCardBodyHeight[i].offsetHeight);
  }

  function getHighest() {
    return Math.max(...heights);
  }

  var tallest = getHighest();

  for (var i = 0; i < getCardBodyHeight.length; i++) {
    getCardBodyHeight[i].style.height = tallest + "px";
  }
})();

I’ve tried using

  window.addEventListener("resize", function () {
    for (var i = 0; i < getCardBodyHeight.length; i++) {
      getCardBodyHeight[i].style.height = tallest + "px";
    }
  });

However, this only adjusted the heights when the screen was resized once instead of everytime. It also did not work when the page loaded.

How to login using netscape cookies(not json) in puppeteer?

I’m working on automating a login process using Puppeteer for a website that utilizes Netscape cookies for authentication. I’ve obtained the necessary Netscape cookies from a previous session and now I want to use them to log in programmatically. However, I’m encountering some difficulties in implementing this process.

Could someone provide guidance or a code example on how to set Netscape cookies in Puppeteer and use them to authenticate a user session? Specifically, I need assistance with the steps to properly set the cookies and navigate through the login flow using Puppeteer.

This code is for json cookies working fine but i want to login using txt netscape cookies

const puppeteer = require('puppeteer');
const fs = require('fs');

(async () => {
const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage();

try {
// Read cookies from file (assuming cookies.json contains an array of cookie objects)
const cookiesString = fs.readFileSync('C:\Users\myuser\Desktop\webscraper\cookies.json');
const cookies = JSON.parse(cookiesString);

// Set each cookie individually
for (const cookie of cookies) {
await page.setCookie(cookie);
}

await page.goto('https://www.udemy.com');
} catch (error) {
console.error('Error setting cookies:', error);
} finally {
// Close the browser when done
// await browser.close();
  }
})();

I’ve tried setting the cookies using the page.setCookie() method and then navigating to the login page but its not working. I want to log in with Netscape cookies

Mocha test html report is not generating for all test files in visual studio code throwing an error as windows can not find the test file

Mocha test html report is not generating for all test files in visual studio code throwing an error as windows can not find the test file.(refer the attached screenshot)

Report is generating for individual test files or if I comment randomly one or two test files out of all test files.Please help me to get this issue fixed
Mocha Error

I have tried increasing the timeout property, updated the npm version and restarted system and VS Code but still no luck.

Pushing object to array results in duplication

I am trying to push an object, with values based upon an array, into another array. It seems to be going wrong on the second array.map function. Up until that point, arrValues contains an entry based on the first array.push.
By the time I make the second object and it’s values, the arrValues array has the current object inside it, not the one I created

Very confused!

let arrMap = [{
  "field_desc": "Building Name",
  "type": "string"
}]
let objFind = {
  values: [
    ["BUILDING1", "BUILDING2"],
    []
  ]
}


let arrValues = [];
let objValues = {};

objValues.row = 0;
objValues.values = arrMap.map(function(element, index, array) {
  let objFindExcel = objFind.values[0][0];
  element.field_value = objFindExcel;
  return element;
}, []);

arrValues.push(objValues);

objValues = {};

objValues.row = 1;
objValues.values = arrMap.map(function(element, index, array) {
  let objFindExcel = objFind.values[0][1];
  element.field_value = objFindExcel;
  return element;
}, []);

arrValues.push(objValues);
console.log(arrValues);

I am expecting this:

[{
  "row": 0,
  "values": [{
    "field_desc": "Building Name",
    "type": "string",
    "field_value": "BUILDING1"
  }]
}, {
  "row": 1,
  "values": [{
    "field_desc": "Building Name",
    "type": "string",
    "field_value": "BUILDING2"
  }]
}]

But I am getting this:

[{
  "row": 0,
  "values": [{
    "field_desc": "Building Name",
    "type": "string",
    "field_value": "BUILDING2"
  }]
}, {
  "row": 1,
  "values": [{
    "field_desc": "Building Name",
    "type": "string",
    "field_value": "BUILDING2"
  }]
}]

Google Noto Color Font Makes App Extremely Slow on Safari Webkit (IOS/MacOS) but not MacOS Chrome

I think this is a bug in Safari/Webkit, as I do not see this issue in Chrome/Firefox.

Minimum reproducible example:

On Safari, the website for noto color shows the IOS emojis for a few seconds for me, before actually rendering the google emojis:
https://fonts.google.com/noto/specimen/Noto+Color+Emoji. But on my app, this is not the behaviour. In my app, the app freezes before displaying the correct emojis. But then when I go onto the glyphs tab, the app even freezes in Safari, in a similar way:
https://fonts.google.com/noto/specimen/Noto+Color+Emoji/glyphs

Since I tested this on Firefox too, which afaik does not use chromium, and it worked fluidly there, I thus think this is a Safari Bug/Issue.

related to, but I made it a more concrete question:
CSS animations extremely slow, laggy, and horrible on iOS but fine on desktop

I have just made sure every single emoji that is in my app is displaying with the noto color font. But now it always freezes when I navigate to a view that uses noto color emoji.

Instead of linking a local file, I have tried using the embed approach to include the emojis. Same result. With both the <link> and import syntax.

I am also considering this approach, as linked on the IOS tab of the noto color font website:
https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app
maybe this fixes the slowness but I am not sure if it could even do this. I you know whether this could indeed help, then lmk. My app is a CapacitorJS App. So idk how one would do that with Capacitor. Maybe someone can tell me how?

The NotoColorEmoji-Regular.ttf as downloaded from here:
https://fonts.google.com/noto/specimen/Noto+Color+Emoji
is 24MB. I think the slowness might be due to this big size. And maybe it does not appear on chrome, since

Maybe there is some way of making this “preloading” happen once and for all for the app, on Safari? Not make my screen freeze every time?

I have also tried using the twemoji font, for which this did not happen on Safari. But I prefer the Noto Color font by a lot. However using twemoji with a generated subset as explained below would be a last resort for me. If really noone knows an answer, then maybe someone can provide an answer to how to generate this subset for either twemoji or Noto.

The eigth comment here lists an url with a woff2 file for twemoji:
https://issues.chromium.org/issues/40766658
I downloaded this file an linked in my app and the app ran smooth on Safari. But the file size was also only 78KB, as it was somehow compressed as discussed here:
https://github.com/talkjs/country-flag-emoji-polyfill

“This is important, because Twemoji Mozilla is 1.5MB, which is a pretty huge hit on your app perfomance. The subset is only 78kb, which is much better.”

Maybe someone could provide a guide on how to create subset font files? I would not need all of the emojis from the noto font. Not much more than are included in the 78Kb twemoji flag woff2. I tried following the guide in the github link above but I could not manage to create my own custom font

Tested on:

  • iPhone 13 Pro, IOS 17.2.1
  • iPad Pro 10.5 inch, IOS 17.2
  • Mac Apple M2 Pro, Sonoma 14.2.1 (23C71)
  • Safari, Google Chrome, Firefox. If u need the versions lmk.

Visibility of symbol and tooltip used in Chart.js

I have a chart I created using Chart.js. I also have a symbol in this chart. This symbol writes the coordinates of the position in the chart in the tooltip by drag-drop or click method within certain limits. There is an error like this: This symbol and tooltip become invisible if they are not within the specified boundaries. But in my code, if the mouse is not within the limits, the symbol is invisible and I can’t fix it.

This symbol and tooltip should always be visible if they are within valid limits and never visible if they are not.My codes are in the picture.
enter image description here