ResourceContextProvider doesn’t work react-admin

AdminPanel.tsx

<Resource
        options={{ label: 'Transactions' }}
        icon={WorkIcon}
        name={path}
        list={TransactionsList}
      />

TransactionsList.tsx

const PostList = () => (
<ResourceContextProvider value={path}>
  
  <List syncWithLocation {...props}>
   <Datagrid  >
  <FullNameUserField label="User" source="userFirstName" />
    <TextField label="Goal Type" source="savingGoalType" />
    <TextField label="Goal name" source="savingGoalName" />
   
    <TextField label="Target Amount" source="targetAmount" />
    <SavingGoalCreationDateField label="Goal creation date" source="savingGoalCreationDate" />
    <TextField label="Strategy Name" source="strategyName" />
    <SavingGoalCreationDateField label="Target Date" source="targetDate" />
    <TextField label="Status" source="savingGoalStatus" />
  </Datagrid>
  </List>
</ResourceContextProvider>)



 <Tab label="comments" path="comments">
               <PostLisst />
 </Tab>

enter image description here

enter image description here
i can’t display request’s result, why?

How to do a tag labelling option with HTML JS

Actually i want to do a tag management module like git lab tag management option in issues

How can i do with dynamic tags

enter image description here

sample Code

  <select class="form-control" id="label"  name="label">
    <option value="value" style="background-color:green" >Green</option>
 <option value="value" style="background-color:red" >red</option>
   </select>

How to automatically trigger click event with shepherd tour

I have set up a page tour using a Shepherd tour. I am trying to apply click events whenever the tour reaches a specific section. However, I am not able to trigger click events automatically.

buildPageTour() {
        let tour = this.tour;
        
        const step1 = tour.addStep({
            id: 'guidedDashboard1',
            text: '<h5>Hello!</h5>',
            buttons: [
                {
                    text: 'Skip',
                    action: tour.cancel,
                    secondary: true
                },
                {
                    text: 'Next',
                    action: tour.next
                }
            ]
        });
        const step2 = tour.addStep({
            id: 'guidedDashboard2',
            text: 'Page tour 2',
            attachTo: {
                element: '.orientationStepArea',
                on: 'bottom'
            },
            buttons: [
                {
                    text: 'Skip',
                    action: tour.cancel, 
                    secondary: true
                },
                {
                    text: 'Back',
                    classes: 'backBt',
                    action: tour.back
                },
                {
                    text: 'Next',
                    action: tour.next
                }
            ]
        });
   }

<!-- begin snippet: js hide: false console: true babel: false -->

So now when the page tour reaches the 2nd section, I want to trigger a click event for my toggle menu so that the page tour appears on the correct icon.

<div class="helpMenu" data-bind="css: {expanded: showMenu()}">
        <div class="wrapper">
            <!-- ko if: hasPageTour() -->
            <div class="item" data-bind="click: launchPageTour, clickBubble: false">
                <svg class="ico"><use xlink:href="Content/icons/icons.svg#infoBaloon" /></svg>
                <span class="label">Page Tour</span>
            </div>
            <!-- /ko -->
            <!-- ko if: realTimeFeedbackEnabled() -->
            <div class="item" id="vFooterShareFeedback" data-bind="click: launchRealTimeFeedbackSurvey, clickBubble: false">
                <svg class="ico"><use xlink:href="Content/icons/icons.svg#notes" /></svg>
                <span class="label">Share Feedback</span>
            </div>
            <!-- /ko -->
            <div class="item" data-bind="click: openDialog, clickBubble: false">
                <svg class="ico"><use xlink:href="Content/icons/icons.svg#email" /></svg>
                <span class="label">Contact Support</span>
            </div>
            <div class="item -close" data-bind="click: hideHelpMenu, clickBubble: false">
                <svg class="ico"><use xlink:href="Content/icons/icons.svg#close" /></svg>
                <span class="label">CLOSE</span>
            </div>
        </div>
    </div>

formdata.entries() not a function in react native

i am adding a key and value to formdata, and when i try to console.log() it says data.entries not a function. i tried consoling it directly it shows like this

{
"_parts": [
    [
        "referral_product[0]",
        "rgvsrh_09"
    ]
]

}

here is my code

 var formdata= new FormData();
  formdata.append('referral_product[0]', `${props.Refferel}_${props.product_id}`);
  for (var pair of formdata.entries()) {
    console.log(pair[0]+ ', ' + pair[1]); 
}

Uncaught TypeError: Cannot read properties of undefined (reading ‘msie’)

The code below is just expected to alert users on lower versions than IE 10 of Internet Explorer. The line if (($.browser.msie) && ($.browser.version == '10.0')) { is causing an error. Could you please help fix it.

<script type="text/javascript">
    jQuery(document).ready(function($) {
    // Detect if the browser is IE and find out the version.
    // Alert user if the version is less than IE 11
    var div = document.createElement("div");
    div.innerHTML = "<!--[if lt IE 11]><i></i><![endif]-->";
    // true if it is lower than IE11
    var isIeLessThan11 = (div.getElementsByTagName("i").length == 1);

    // According to wikipedia, conditional comments are not supported in IE10 and above.
    // So find out if the version is IE 10.
    var isIe10 = false;
    if (($.browser.msie) && ($.browser.version == '10.0')) {
      isIe10 = true;
    }

    if ((isIe10) || (isIeLessThan11) ) {
      alert("Your web browser is out of date. Please complete this form using an approved browser, such as Edge, Chrome, Safari, or Firefox.");
    } else {
      alert("Your browser is supported");
    }
  });
</script>

How to find that array is a cyclic or not?

How to find whether the array is Cyclic or not ?

Example 1 A1=[‘a’,’b’,’c’,’d’]

A2 = [‘a:b’, ‘c:d’]

Output : not cyclic because ([‘b’,’a’,’d’,’c’] is the order for that)

Example 2

A1=[‘a’,’b’,’c’,’d’]

A2 = [‘a:b’, ‘b:a’]

Output : It is cyclic because it is looping a to b , b to a and again

click anywhere in Card on a Antd radio button wrapped inside a Card to change border and background on select

I have a antd radio button that I wrapped it around a card to make it more custom. What I am trying to do is be able to click anywhere and make the radio button selectable as well as change the card border-color and background color when selected
Here is my code.

  <Card hoverable style={{ borderRadius: '10px', borderColor: 'lightgray'}} bordered>
    <Meta
      style={{float: 'left'}}
      avatar={<Avatar shape="square" src='/resources/images/document.png' />}
    />
    <Radio value="Subscription Docs">Subscription Docs</Radio>
  </Card>

any ideas on the best approach?

Microphone access on Safari / MacOs when window is in the background

Since the last two major updates on Mac (BigSur, Monterey) i’m having this issue where Safari microhone capture via getUserMedia does only work when the Safari window is visible on the screen (1px is sufficient). Whenever Safari is moved to the background the microphone stops transmitting sound, as if it was muted by a hardware button. For the web-application this is not transparent afaik.

Is there a setting or even a documentation or blog post for this? I wasn’t able to find any info on how or why this is happening (even though i can imagine why).

This behaviour is especially inconvenient for multi user web-apps using webrtc, where microphone input can be used together with screen sharing (getDisplayMedia). Users usually assume that they can be heared when sharing their entire screen, even if safari is not in the foreground / visible. It feels inconsistent to on the one hand allow screen sharing when the safari window is not visible, but on the other hand block microphone transmission.

I would be grateful for information on why this is happening and if there is a plan from apple to change this in the future.

How to schedule cron job to run only once at a specific date (with year) using node-cron?

I’m new to cron and actually not sure if node-cron is the right npm package for me.
Basically, I just want to create a scheduled post feature in my app. Where I can set a time to post my content in the future.

So I discovered node-cron and was able to play around with it. I can get it to work, but I noticed this kind of scheduling in node-cron is about setting intervals, and your function is set to repeat again and again. Correct me if I’m wrong.

But let’s say I’d like to console.log("Hello World") on Feb, 24, 2023 and run it only once. If I set that on the cron string(not sure what you call it), then I guess I would set it like this:

    cron.schedule("* * * 24 Feb *", ()=>{
        console.log("Hello World")
    })

There is no option to specify a year as I read on the documentation, so where I can I specify the year? My code above will run every second on every Feb, 24 in any year right? Don’t mind “the every second run” on my code above, but what I wanted to do is to specify the exact date and year for it to run, within that specific date only.

I’ve read about node-schedule package where you can pass dates as the schedule, but it seems node-schedule only runs when the script is running?

AG Grid not showing total no of rows in the footer

I am using ag-grid for the representation of data in tabular format in my angular application and for some reason the footer is just showing the data for the first page i.e. if I select 100 rows via some external dropdown It shows only 100 rows and Page 1 of 1 whereas there is almost 17K rows of data that is available and since it shows only page 1 of 1 I cant click on the next page to retrieve further data. Does anyone knows what’s the issue ? Am I missing some property that I have to pass ?

<app-ag-grid-wrapper #agGrid id="Job-List-View-Sales-Rep" [rowData]="gridData" [columnDefs]="cols" [sizeToContent]="true"
          (selectionChanged)="onRowSelection($event)" [gridOptions]="gridOptions" (gridReady)="onGridReady($event)"
          [excelStyles]="excelStyles" [masterDetail]="true" [groupDefaultExpanded]= "0" [groupIncludeFooter]="false"
          [groupIncludeTotalFooter]="true"  [rowGroupPanelShow]="false">
  </app-ag-grid-wrapper>
  <div class="custom-page-size">
    <p-dropdown [options]="pageSize" [(ngModel)]="selectedPageSize" (onChange)="onPageSizeChanged()">
    </p-dropdown>
  </div>

enter image description here

I am trying to retrieve the posts via ajax call but WordPress Ajax gives server error 500

When i click on pagination link (page number) it gives me post_type, taxonomy, term_name. I passed the variables with JQuery Variables to Ajax wordpress function. The Ajax function is receiving the vaiables. But WP_Query loop does not work with the passed data.

JavaScript Code:

`<script>
 $(".category--pagination").on("click", "a", function (e) {
    e.preventDefault();
    var link = $(this).attr("href");
    if (link.indexOf("/page/") >= 0) {
      brands_page = parseInt(link.substr(link.indexOf("/page/") + 6, 4));
    } else {
      brands_page = 1;
    }
    mzm_filter_taxonomy();
  });

  //  mzm_filter_tax

  function mzm_filter_taxonomy() {
    $("#brandCategoryItemDisplay").addClass("loading");
    var post_type = $("#post_type").val();
    var taxonomy = $("#taxonomy").val();
    var term_slug = $("#term_slug").val();
    var term_name = $("#term_name").val();
    //console.log(post_type);
   // console.log(taxonomy);
   // console.log(term_name);
   if (brands_page == undefined) {
    brands_page = 1;
  }
    var data = {
      action: "mzm_filter_taxonomy",
      post_type: post_type,
      taxonomy:taxonomy,
      term_slug:term_slug,
      term_name:term_name,
      page:brands_page,

    };

    $.post(mzm_filter.ajax_url, data, function (response, textStatus, jqXHR) {
      if (response.success) {
        console.log("executed success");
        $("#brandCategoryItemDisplay").removeClass("loading");
        $("#brandCategoryItemDisplay").html(response.data.items);

        $(".category--pagination").html(response.data.pagination);
        //$("#taxonomy_pagination").html(response.data.pagination);
      }
    });
  }
</script>`

WordPress Ajax Function:

`function mzm_filter_taxonomy()
{
    $post_type   = isset($_POST['post_type']) ? filter_var(trim($_POST['post_type']), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
    $taxonomy   = isset($_POST['taxonomy']) ? filter_var(trim($_POST['taxonomy']), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
    $term_slug   = isset($_POST['term_slug']) ? filter_var(trim($_POST['term_slug']), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
    $term_name   = isset($_POST['term_name']) ? filter_var(trim($_POST['term_name']), FILTER_SANITIZE_FULL_SPECIAL_CHARS) : null;
    $perpage  = mzm_brand_perpage();
    $paged    = (isset($_POST['page']) && intval($_POST['page'])) ? intval($_POST['page']) : 1;
    // $sort     = ( isset( $_POST['sort'] ) && intval( $_POST['sort'] ) ) ? intval( $_POST['sort'] ) : 1;
   // $sort     = (isset($_POST['sort'])) ? intval($_POST['sort']) : 1;
    // $args     = array(
    //     'post_type'      => $post_type,
    //     'hide_empty'     => false,
    //     'posts_per_page' => $perpage,
    //     'paged'          => $paged,
    //     'post_status' => 'publish',
    //     'tax_query' => array(
    //         array (
    //             'taxonomy' => $taxonomy,
    //             'field' => 'slug',
    //             'terms' => $term_slug,
    //         )
    //     ),
    // );
    $the_query = new WP_Query( array(
        'post_type' => $post_type,
        'tax_query' => array(
            array (
                'taxonomy' => $taxonomy,
                'field' => 'slug',
                'terms' => $term_slug,
            )
        ),
    ) );
   // $the_query = new WP_Query($args);
    ob_start();
    // echo $post_type . '<br>';
    // echo $taxonomy . '<br>';
    // echo $term_name . '<br>';
    // echo $term_slug . '<br>';
    if ($the_query->have_posts()) {
        while ($the_query->have_posts()) {
            the_post();
           // echo mzm_render_single_brand_card();
           echo the_title();
        }
        wp_reset_postdata();
    } else {
        echo '<div class="no-criteria-search">Sorry, no posts matched your criteria.</div>';
    }
    $html = ob_get_clean();
    $result = array(
        'items' => $html,
        'pagination' => 'mzm_render_pagination($the_query)',
    );
    wp_send_json_success($result);
}
add_action('wp_ajax_nopriv_mzm_filter_taxonomy', 'mzm_filter_taxonomy');
add_action('wp_ajax_mzm_filter_taxonomy', 'mzm_filter_taxonomy');`

enter image description here

I am trying paginate via Ajax request. Other all scripts are working. But this is a single taxonomy page. On this page the loop doesn’t executes. It gives server error 500.

Ajax doesn’t get a success response back after file upload

I just started with Ajax and also tried to find a solution for this.

Here is the problem:

I upload a .csv to a server. This works just fine. But after the upload “success” in the ajax call won’t respond. Neither does complete or error. It shows nothing. Not even an empty alert. Just nothing. I also didn’t find anything in the logs.

When I click the upload button without chosing a file to upload I get a response from success…

Here is the code:

upload.php

<?php
header('Content-type: application/json');
$target_dir = 'uploads/';
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$response[] ='';

  if(move_uploaded_file($_FILES["file"]["tmp_name"],$target_file))
  { 
    //$response['message'] = "File was uploaded!";
    $response['message'] = csvToJson($target_file);
  }
  else
  { 
    $response['message'] = 'Sorry, there was an error uploading your file.'; 
  }

echo json_encode($response);


function csvToJson($file) 
{
    // open csv file
    if (!($fp = fopen($file, 'r'))) {
        die("Can't open file...");
    }
    
    //read csv headers
    $key = fgetcsv($fp,"1024",";");
    
    // parse csv rows into array
    $json = array();
        while ($row = fgetcsv($fp,"1024",";")) {
        $json[] = array_combine($key, $row);
    }
    
    // release file handle
    fclose($fp);
    
    // encode array to json
    return $json;
}
?>

upload.js

$(document).ready(function(e)
{
    // Submit form data via Ajax
    $("#form").on('submit', function(e)
    {
        var form_data = new FormData($(this)[0]);  
        $.ajax({    
            type: 'POST',
            url: 'upload.php',
            data: form_data,
            contentType: false,
            cache: false,
            processData:false,
            success: function(response)
            { 
                //var json = $.parseJSON(response)
                alert(response);
            },
            error: function(error){
                console.log("Error:");
                console.log(error);
           }, 
           complete: function(response){
            alert(response);
           }

        });
    });
});

the form in index.php

<form id=form enctype="multipart/form-data">
        <input type="file" name="file" id="file">
        <input type="submit" value="Upload Excel" name="submit">
</form>

In the end I want a json back with the content of the uploaded file. But right now there is zero output if the file is uploaded.

Thanks for any advice!

Pushing unique element in an 2D array from another 2D array

I am trying to do this challenge in FCC, inventory update.

Only problem I am facing is that, when I want to push the new element from the new array to the old array, it is giving me timeout. Adding the numbers if the element matches works fine though.
Here is what I have done so far.

//sorting the 2D array
function sortingArray(a,b){
    if (a[1] === b[1]) {
        return 0;
    }
    else {
        return (a[1] < b[1]) ? -1 : 1;
    }
}

function updateInventory(arr1, arr2) {
    if (arr1.length === 0) {
        return arr2.sort(sortingArray)
    }
    if (arr2.length === 0) {
        return arr1.sort(sortingArray)
    }
    for (let i = 0; i < arr2.length; i++) {
        for (let j = 0; j < arr1.length; j++) {
            if (arr2[i][1] === arr1[j][1]) {
                arr1[j][0] = arr1[j][0] + arr2[i][0] //adding the numbers if it matches
            }
            if(arr2[i][1] != arr1[j][1]){
                arr1.push(arr2[i]) //pushing the unique element
            }
            
        }
    }
    console.log(arr1)
    return arr1.sort(sortingArray);
}

// Example inventory lists
var curInv = [[21, "Bowling Ball"], [2, "Dirty Sock"], [1, "Hair Pin"], [5, "Microphone"]];

var newInv = [[2, "Hair Pin"], [3, "Half-Eaten Apple"], [67, "Bowling Ball"], [7, "Toothpaste"]];

updateInventory(curInv, newInv);