Thursday, August 25, 2022

FileUploads

import { AgGridReact } from 'ag-grid-react';

import React, { useState, useRef, useEffect, useMemo, useCallback } from 'react';
import { ApolloClient, gql, InMemoryCache } from "@apollo/client"
import { Button, getTextFieldUtilityClass, Grid, Paper, Stack, styled } from '@mui/material';
import ContentList from './ContentList';
import FileDownloadCellRenderer from './FileDownloadCellRenderer';
import FileUploadHistoryList from './FileUploadHistoryList';
import MilestoneList from './MilestoneList';
import Accordion from '@mui/material/Accordion';
import AccordionDetails from '@mui/material/AccordionDetails';
import AccordionSummary from '@mui/material/AccordionSummary';
import Typography from '@mui/material/Typography';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import * as _ from 'underscore';
import moment from 'moment';
import { Color } from 'ag-grid-community';

const GET_FILEUPLOADS =
  gql`
  query($contentId:Int) {
    fileUploads(where: {contentId:{eq:$contentId}}) {
      contentId
      fileType {
        fileTypeName
      }
      content {
          userInfo {
          longName
          }
      }
      version
      originalName
      fileName
      dateCreated
    }
  }
`;

const Item = styled(Paper)(({ theme }) => ({
  backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
  padding: theme.spacing(1),
  textAlign: 'left',
}));

const client = new ApolloClient({

  uri: process.env.REACT_APP_MAGIC_API,
  cache: new InMemoryCache(),
});

const MAGIC_API_FILES_BASE_URL ="http://localhost:8081/Files/";

const SubmissionEditor = () => {

  const gridRef = useRef(null); // Optional - for accessing Grid's API
  const [rowData, setRowData] = useState([]); // Set rowData to Array of Objects, one Object per Row // mother content
  const [fileUploadInfopPanelVisivility, SetFileUploadInfoPanelVisibility] = useState(false);
  const [expanded, setExpanded] = React.useState<string | false>(false);
  const [fileUploadData, setFileUploadData] = useState([]); //history and file uploads
  const [selectedContentId, setSelectedContentId] = useState(0);
  const [downloadURL, setDownloadURL] = useState('');  //history and file uploads
  const [mostRecentFileUploadInfo, setMostRecentFileUploadInfo] = useState({} as any);

  const handleChange =
    (panel: string) => (event: React.SyntheticEvent, isExpanded: boolean) => {
      setExpanded(isExpanded ? panel : false);
    };

  // Each Column Definition results in one Column.
  const [columnDefs, setColumnDefs] = useState([
    { field: 'fileName', filter: true },
    { field: 'version', filter: true },
    { field: 'originalName' },
    {
      headerName: "Open",
      field: "fileName",
      editable: false,
      cellRenderer: FileDownloadCellRenderer
    }

  ]);

  const onVisibilityChange = (contentId: number) => {

    setSelectedContentId(contentId);

    client
      .query({
        query: GET_FILEUPLOADS,
        variables: { "contentId": contentId }
      })
      .then((response) => {
        if (response && response.data && response.data.fileUploads && response.data.fileUploads.length) {

          setFileUploadData(response.data.fileUploads);

          let sortedList = _.sortBy(response.data.fileUploads, 'version');
          let mostRecentFile: any = sortedList.reverse()[0];

          let downloadUrl = MAGIC_API_FILES_BASE_URL + mostRecentFile.originalName;
          setDownloadURL(downloadUrl);

          setMostRecentFileUploadInfo(mostRecentFile);

          SetFileUploadInfoPanelVisibility(true);
          setExpanded('panel1');
        }
        else {
          SetFileUploadInfoPanelVisibility(false);
          setFileUploadData([]);
          setMostRecentFileUploadInfo({} as any);
          setDownloadURL('');
          setExpanded(false);
        }
      });
  }

  return (
    <div>
      <Grid container spacing={2}>
        <Grid item xs={12}>
          <p style={{ marginLeft: 5, fontSize:'20px',color:'black' }}>Submissions </p>
          <div><ContentList handleVisibility={onVisibilityChange} selectedContentId={selectedContentId} /></div>
        </Grid>
        {/*  <Grid item xs={4}>
          <p style={{ marginLeft: 5 }}>Milestones <Button variant="contained">UPdate</Button></p>

          <div className="ag-theme-alpine" style={{ height: 400 }}><MilestoneList /></div>
        </Grid> */}
        <Grid item xs={12}>
          {fileUploadInfopPanelVisivility ?
            <div>
              <Accordion expanded={expanded === 'panel1'} onChange={handleChange('panel1')}>
                <AccordionSummary
                  expandIcon={<ExpandMoreIcon />}
                  aria-controls="panel1bh-content"
                  id="panel1bh-header"
                >
                  <Typography sx={{ width: '33%', flexShrink: 0,color:'black',fontSize:'20px' }}>
                    Uploaded Files and History
                  </Typography>
                </AccordionSummary>
                <AccordionDetails>

                  <Stack spacing={1}>
                    <Item>Type : {mostRecentFileUploadInfo.fileType.fileTypeName} </Item>
                    <Item>Version : {mostRecentFileUploadInfo.version}</Item>
                    <Item>File Name : {mostRecentFileUploadInfo.fileName} &nbsp;  &nbsp; &nbsp; <a href={downloadURL}>Download</a></Item>
                    <Item>Uploaded By : {mostRecentFileUploadInfo.content.userInfo.longName}</Item>
                    <Item>Date Created : {moment(mostRecentFileUploadInfo.dateCreated).format('MM/DD/YYYY')}</Item>
                  </Stack>

                </AccordionDetails>
              </Accordion>
              <Accordion expanded={expanded === 'panel2'} onChange={handleChange('panel2')}>
                <AccordionSummary
                  expandIcon={<ExpandMoreIcon />}
                  aria-controls="panel2bh-content"
                  id="panel2bh-header"
                >
                  <Typography sx={{ width: '33%', flexShrink: 0 }}> File Upload History</Typography>
                </AccordionSummary>
                <AccordionDetails>

                </AccordionDetails>
              </Accordion>
            </div>
            : null}

        </Grid>
      </Grid>
    </div>



  );
}

export default SubmissionEditor;






ContentList

 import { ApolloClient, gql, InMemoryCache } from '@apollo/client';

import { CellClickedEvent, RowSelectedEvent } from 'ag-grid-community';
import { AgGridReact } from 'ag-grid-react';
import { AnyCnameRecord } from 'dns';
import moment from 'moment';
import React, { useEffect, useRef, useState } from 'react';

const GET_CONTENTS =
    gql`
query {
    contents {
        id
        title
        contentDescription
        feedbackComments
        dateCreated
        dateModified
      }
}
`;
export default function ContentList(props:any) {
    const gridRef = useRef(null); // Optional - for accessing Grid's API
    const [rowData, setRowData] = useState([]); // Set rowData to Array of Objects, one Object per Row
   
    const onRowSelection = (params: RowSelectedEvent) => {
        let data = params.data;
        if(data.id && props?.selectedContentId != data.id)
        {
           
            props.handleVisibility(data.id);
        }       
    };

    const client = new ApolloClient({

        uri: process.env.REACT_APP_MAGIC_API,
        cache: new InMemoryCache(),
    });
    // Each Column Definition results in one Column.
    const [columnDefs, setColumnDefs] = useState([
        { field: 'id', filter: true },
        { field: 'title', filter: true },
        { field: 'contentDescription', filter: true },
        { field: 'feedbackComments',headerName:'Approval Status',cellStyle: (params: { value: string; }) => {
            if (params.value === 'Approved') {
                return {color: '#fff', backgroundColor: 'green'};
            }
            else if (params.value === 'Rejected') {
                return {color: '#fff', backgroundColor: 'red'};
            }
            else if (params.value === 'Pending') {
                return {color: '#fff', backgroundColor: 'orange'};
            }
            return null;
        }, filter: true },        
        { field: 'dateCreated',cellRenderer: (data:any) => {
            return moment(data.dateCreated).format('MM/DD/YYYY')
        }, filter: 'agDateColumnFilter' },
        { field: 'dateModified', filter: 'agDateColumnFilter' }
    ]);

    // Example load data from sever
    useEffect(() => {
        client
            .query({
                query: GET_CONTENTS
            })
            .then((response) => setRowData(response.data.contents));
    }, []);

    return (
        <div className="ag-theme-alpine" style={{ height: 400 }}>
            <AgGridReact
                onRowClicked={onRowSelection}
                rowSelection='single'
                rowData={rowData}
                columnDefs={columnDefs}>
            </AgGridReact>
        </div>
    );
}
---------------------------------------------------------------

Wednesday, August 17, 2022

IntelReactJS

Auto React Model Generation

 src\Magic\Properties

launchSettings.json > "applicationUrl": "http://localhost:8081",


src\Magic\magicclient

.env>REACT_APP_MAGIC_API=http://localhost:8081/m5graphql


C:\Intel\FreshCopyFromGit\src\Magic\GraphQL\Queries(/MagicMutations)\MagicQueries.cs

C:\Intel\FreshCopyFromGit\src\Application\Content\Queries\GetContentsQuery.cs

C:\Intel\FreshCopyFromGit\src\Application\Content\Queries\GetContentHandler.cs

C:\Intel\FreshCopyFromGit\src\Infrastructure\Databases\M5\EntityFrameworkMagicRepository.cs


C:\Intel\Magic5_reactJS_Repository17August\src\Magic\magicclient> npm run codegen

Models will be generated in below File

https://www.apollographql.com/docs/react/

https://chillicream.com/docs/hotchocolate/get-started

https://www.howtographql.com/

https://docs.microsoft.com/en-us/shows/on-net/getting-started-with-hotchocolate#time=04m50s

C:\Intel\Magic5_reactJS_Repository17August\src\Magic\magicclient\src\graphql\schema.ts



 "DefaultConnection": "Host=postgres5746-lb-fm-in.dbaas.intel.com:5433;Database=magic5;User ID=magic5_so;Password=n2jDdUzD2WgQ5Tg"

"DefaultConnection": "Host=localhost;Database=magic5;User ID=postgres;Password=sa"

https://chillicream.com/docs/hotchocolate/get-started

https://docs.microsoft.com/en-us/shows/on-net/getting-started-with-hotchocolate#time=04m50s


Entity framework Core Update-database specific migration


162

According to EF Core Docs, correct parameter name is -Target (for EF Core 1.1) or -Migration (for EF Core 2.0)

so in your case:

update-database -target test32

or

update-database -migration test

Thursday, August 4, 2022

Interview

 SIMON HAI

University of North Texas,

Bachelor of Applied Arts and Sciences (BAAS), Applied Technology & Performance Improvement (ATPI)

Sr. Software QA Analyst/Sr. Software QA Engineer(AT&T Wireless Mobility) 

Fannie Mae 

Aug 2013 - Present · 9 yrs 11 mos

469-951-6268

br.hai902003@gmail.com

28th August,1972

Age:51

8829 CRESCENT COURT

IRVING, TEXAS 75063


Fatema Mahbuba Chowdhury

The University of Texas at Dallas  

Bachelor's Degree, Business Administration and Management, 

General 

2014 - 2018

Dallas,north Arving,valyrange

30 Sep, 1975

Carrollton Farmers Branch Independent

School District on 11/11/15

Substitute Teacher

Age:49

+1 (972) 607-6174

Ripon Bhai

15 March 1977

Age : 47

Rubol

45

shaira

The University of Texas at Dallas 

Bachelor of Science - BS, Healthcare Studies 

Aug 2019 - May 2022

enders -recruiting position

Pharmacy Technician,Dental Assistant

feb 12,2001

Shaira’s husband - Farhan,automation engineer, General Motors

Age:23

Maleha

utd

college student 

bsc finance

jan 22,2004

Age:20


Alina 

9 grade

Coppell High School

feb13 , 2009

Age:15


 Kamrun Nahar Chowdhury

Father's Name: Aziz Ullah

Mother's Name: Saleha Begum

Date of Birth: 19th of February,1958

05 SEP 2022 29 JAN 2023 TRIP TO DHAKA, BANGLADESH

Age: 66

------------------------------

Father's Surnames:

CHOWDHURY

Father's Given Names:

SHAMSUL HUDA MAHBUB

Date of Birth:

23 JANUARY 1950

--------------------------------

Monu Aunt

+1 (929) 431-8318

Age: 45

Mehedi Rezan

Cell: +1 (347) 876-8104

Email: mrezanqa@gmail.com 

Jamaica, New York, United States 

Bachelors in Computer Information System (America Bangladesh University) 2013 

UAT Lead 

RCM Life Sciences & IT client Bayada. Automation Lead

Jun 2022 - Present · 1 yr 1 mo 

United States · Remote

Application Lead 

Bank of America · Contract

1.Riya  bsc 2. Rafin bsc

Wednesday, August 3, 2022

Hot Chocolate

GraphQL is a query language and server-side runtime for application programming interfaces (APIs) that prioritizes giving clients exactly the data they request and no more. GraphQL is designed to make APIs fast, flexible, and developer-friendly.

https://www.opencodez.com/web-development/tutorial6-51-imp-graphql-interview-questions-answers.htm 

Hot Chocolate is an open-source GraphQL server built for the Microsoft .NET platform. It removes the complexity of building GraphQL APIs from scratch with built-in features for queries, mutations, and subscriptions

We’ll be building a GraphQL API backend with Hot Chocolate GraphQL 

Resolvers are functions that tell the Hot Chocolate GraphQL server how to fetch the data associated with a particular schema. In simple terms, a resolver acts as a GraphQL query handle

  • Open your browser and head over to the port your GraphQL server is listening on (ours is http://localhost:5000/graphql) to open the Hot Chocolate built-in GraphQL IDE Banana Cake Pop
  • we will use our GraphQL IDE Banana Cake Pop.
If you have setup everything correctly, you should be able to open http://localhost:5000/graphql (the port might be different for you) in your browser and be greeted by our GraphQL IDE Banana Cake Pop.

you'll learn by building a full-featured GraphQL Server with ASP.NET Core and Hot Chocolate from scratch. We'll start from File/New and build up a full-featured GraphQL server with custom middleware, filters, subscription and relay support.


 SELECT *
    FROM "Engines"  e, "Rockets"  r
    WHERE r."Id" = e."RocketId"

select        eng."Name" AS Engine_name,
              roc."Name" AS roc_name             
FROM          "Engines" eng
              INNER JOIN "Rockets" roc ON roc."Id" = eng."RocketId" 

  • run npm install  to ensure all deps are downloaded

  • Scaffold-DbContext "Host=localhost;Database=magic5;Username=postgres;Password=sa" Npgsql.EntityFrameworkCore.PostgreSQL -OutputDir Models


Apollo Client is a fully-featured caching GraphQL client with integrations for React, Angular, and more. It allows you to easily build UI components that fetch data via GraphQL.


Apollo Client :

A powerful JavaScript GraphQL client, designed to work well with React, React Native, Angular 2, or just plain JavaScript.


Apollo Client is a comprehensive state management library for JavaScript that enables you to manage both local and remote data with GraphQL. Use it to fetch, cache, and modify application data, all while automatically updating your UI.


Apollo Client is a state management library that simplifies managing remote and local data with GraphQL. Apollo Client's intelligent caching and declarative approach to data fetching can help you iterate faster while writing less code. Additionally, if you need custom functionality, you can create your dream client by building extensions on top of Apollo Client


---------------------------------------

<p id="demo"></p>  

<script>

hello = function() {

  return "Hello World!";

}

document.getElementById("demo").innerHTML = hello();

-------------------------------------------------------------

<body> 

<p id="demo"></p>

  

<script>

hello = () => {

  return "Hello World!";

}


document.getElementById("demo").innerHTML = hello();

</script>


</body>

</html>

--------------------------------

<body>  

<script>

class Car {

  constructor(name) {

    this.brand = name;

  }

  present() {

    return 'I have a ' + this.brand;

  }

}

const mycar = new Car("Ford");

mycar.present();

</script>

</body>











Driving

 https://youtube.com/shorts/5Ac2qZHrApU?si=_X-G7pJFHiZoD-s7 https://www.youtube.com/watch?v=f6pSsex87oU