diff --git a/.vscode/settings.json b/.vscode/settings.json index c3d22a03..00b8e43f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,7 +2,7 @@ "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.codeActionsOnSave": { - "source.fixAll.eslint": true, - "source.fixAll.format": true + "source.fixAll.eslint": "explicit", + "source.fixAll.format": "explicit" } } diff --git a/package-lock.json b/package-lock.json index 9f7b6065..aa9f2ef7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,8 +8,10 @@ "name": "mf-open-source", "version": "0.1.0", "dependencies": { + "@headlessui/react": "^1.7.18", "clsx": "^2.0.0", "i": "^0.3.7", + "moment": "^2.30.1", "next": "13.5.4", "npm": "^10.2.0", "react": "^18", @@ -611,6 +613,22 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/@headlessui/react": { + "version": "1.7.18", + "resolved": "https://registry.npmjs.org/@headlessui/react/-/react-1.7.18.tgz", + "integrity": "sha512-4i5DOrzwN4qSgNsL4Si61VMkUcWbcSKueUV7sFhpHzQcSShdlHENE5+QBntMSRvHt8NyoFO2AGG8si9lq+w4zQ==", + "dependencies": { + "@tanstack/react-virtual": "^3.0.0-beta.60", + "client-only": "^0.0.1" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "react": "^16 || ^17 || ^18", + "react-dom": "^16 || ^17 || ^18" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.13", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", @@ -890,6 +908,31 @@ "tslib": "^2.4.0" } }, + "node_modules/@tanstack/react-virtual": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@tanstack/react-virtual/-/react-virtual-3.2.0.tgz", + "integrity": "sha512-OEdMByf2hEfDa6XDbGlZN8qO6bTjlNKqjM3im9JG+u3mCL8jALy0T/67oDI001raUUPh1Bdmfn4ZvPOV5knpcg==", + "dependencies": { + "@tanstack/virtual-core": "3.2.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@tanstack/virtual-core": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@tanstack/virtual-core/-/virtual-core-3.2.0.tgz", + "integrity": "sha512-P5XgYoAw/vfW65byBbJQCw+cagdXDT/qH6wmABiLt4v4YBT2q2vqCOhihe+D1Nt325F/S/0Tkv6C5z0Lv+VBQQ==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/tannerlinsley" + } + }, "node_modules/@types/debug": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.9.tgz", @@ -5562,6 +5605,14 @@ "node": ">=0.10.0" } }, + "node_modules/moment": { + "version": "2.30.1", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", + "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", + "engines": { + "node": "*" + } + }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", diff --git a/package.json b/package.json index 761c6b05..6e15185e 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,10 @@ "update-projects": "node updateProject.mjs" }, "dependencies": { + "@headlessui/react": "^1.7.18", "clsx": "^2.0.0", "i": "^0.3.7", + "moment": "^2.30.1", "next": "13.5.4", "npm": "^10.2.0", "react": "^18", diff --git a/public/images/bxl-github.svg b/public/images/bxl-github.svg new file mode 100644 index 00000000..905bdd3a --- /dev/null +++ b/public/images/bxl-github.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/images/bxs-download.svg b/public/images/bxs-download.svg new file mode 100644 index 00000000..416efdf4 --- /dev/null +++ b/public/images/bxs-download.svg @@ -0,0 +1 @@ + diff --git a/public/images/social-media/bx-filter-alt.svg b/public/images/social-media/bx-filter-alt.svg new file mode 100644 index 00000000..f31c1a05 --- /dev/null +++ b/public/images/social-media/bx-filter-alt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/images/social-media/expand-wide-svgrepo-com.svg b/public/images/social-media/expand-wide-svgrepo-com.svg new file mode 100644 index 00000000..4357c10c --- /dev/null +++ b/public/images/social-media/expand-wide-svgrepo-com.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/public/images/social-media/npm-svgrepo-com.svg b/public/images/social-media/npm-svgrepo-com.svg new file mode 100644 index 00000000..9502e11f --- /dev/null +++ b/public/images/social-media/npm-svgrepo-com.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/app/packages/page.tsx b/src/app/packages/page.tsx new file mode 100644 index 00000000..2b92c800 --- /dev/null +++ b/src/app/packages/page.tsx @@ -0,0 +1,518 @@ +"use client"; + +import React, { useEffect, useState, Fragment } from "react"; +import statsList from "../projects/assets/stats.json"; +import Link from "next/link"; +import npm from "../../../public/images/social-media/npm-svgrepo-com.svg"; +import filter from "../../../public/images/social-media/bx-filter-alt.svg"; +import download from "../../../public/images/bxs-download.svg"; +import github from "../../../public/images/bxl-github.svg"; +import Image from "next/image"; +import { Dialog, Transition } from "@headlessui/react"; +import moment from "moment"; + +type stats = { + downloads: download[]; +}; + +type download = { + downloads: number; + day: string; +}; + +const Stats = () => { + const [startDate, setStartDate] = useState(moment().format("YYYY-MM-DD")); + const [endDate, setEndDate] = useState(moment().format("YYYY-MM-DD")); + + const [count, setCount] = useState(0); + const [selectedRange, setSelectedRange] = useState(false); + const [isOpen, setIsOpen] = useState(false); + const [npmPackage, setNpmPackage] = useState({ + name: "fmdapi-node-weaver", + day: 0, + week: 3, + year: 70, + total: 70, + }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [packages, setPackages] = useState(statsList); + // const [allPackage, setAllPackage] = useState(packageList); + + function closeModal() { + setIsOpen(false); + setCount(0); + setSelectedRange(false); + } + + function openModal() { + setIsOpen(true); + } + + // Function to fetch download statistics for a given package and period + async function fetchDownloadStats(packageName: string, period: string) { + const url = `https://api.npmjs.org/downloads/range/${period}/@mindfiredigital/${packageName}`; + const response = await fetch(url); + + if (!response.ok) { + console.log( + `Failed to fetch download stats for ${packageName} (${period}): ${response.statusText}` + ); + } + + const data = await response.json(); + return data; + } + + function calculateDownloads(stats: stats): number { + if (!stats || !stats.downloads) { + return 0; // Return 0 if stats or stats.downloads is undefined + } + return stats.downloads.reduce( + (accumulator, download) => accumulator + download.downloads, + 0 + ); + } + + // Function to fetch and process statistics for a package and period + async function getStats(packageName: string, period: string) { + try { + // Fetch download statistics + const stats = await fetchDownloadStats(packageName, period); + + // Check if stats exist + if (!stats || !stats.package) return 0; + + // Calculate average downloads + return stats; + } catch (error) { + // Log and handle errors + console.error(`${packageName} not present`); + return 0; + } + } + function handleChange( + event: React.ChangeEvent, + _package: { + name: string; + day: number; + week: number; + year: number; + total: number; + } + ) { + const range: { start: string; end: string } = getDateRange( + event.target.value as string + ); + getStats(_package.name, `${range?.start}:${range?.end}`).then((res) => { + const count = calculateDownloads(res); + // console.log(count); + + packages.map((npmPackage) => { + if (npmPackage.name === _package.name) { + setCount(count); + } + return npmPackage; + }); + }); + } + + function formatDate(date: Date) { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + return `${year}-${month}-${day}`; + } + + function getDateRange(range: string) { + const currentDate = new Date(); + const currentYear = currentDate.getFullYear(); + const currentMonth = currentDate.getMonth(); + const currentDay = currentDate.getDate(); + + switch (range.toLowerCase()) { + case "today": { + setSelectedRange(false); + return { + start: formatDate(new Date(currentYear, currentMonth, currentDay)), + end: formatDate(new Date(currentYear, currentMonth, currentDay)), + }; + } + case "yesterday": { + setSelectedRange(false); + const yesterdayDate = new Date( + currentYear, + currentMonth, + currentDay - 1 + ); + return { + start: formatDate(yesterdayDate), + end: formatDate(yesterdayDate), + }; + } + case "last month": { + setSelectedRange(false); + const lastMonthStartDate = new Date(currentYear, currentMonth - 1, 1); + const lastMonthEndDate = new Date(currentYear, currentMonth, 0); + return { + start: formatDate(lastMonthStartDate), + end: formatDate(lastMonthEndDate), + }; + } + case "last quarter": { + setSelectedRange(false); + const quarterStartMonth = Math.floor(currentMonth / 3) * 3; // Get the start month of the current quarter + const lastQuarterStartDate = new Date( + currentYear, + quarterStartMonth - 3, + 1 + ); + const lastQuarterEndDate = new Date(currentYear, quarterStartMonth, 0); + return { + start: formatDate(lastQuarterStartDate), + end: formatDate(lastQuarterEndDate), + }; + } + case "this year": { + setSelectedRange(false); + const thisYearStartDate = new Date(currentYear, 0, 1); + return { + start: formatDate(thisYearStartDate), + end: formatDate(currentDate), + }; + } + case "this month": { + setSelectedRange(false); + const thisMonthStartDate = new Date(currentYear, currentMonth, 1); + return { + start: formatDate(thisMonthStartDate), + end: formatDate(currentDate), + }; + } + case "custom": { + setSelectedRange(true); + setCount(0); + return { + start: formatDate(new Date(currentYear, currentMonth, currentDay)), + end: formatDate(new Date(currentYear, currentMonth, currentDay)), + }; + } + default: + setSelectedRange(false); + return { + start: "1000-01-01", + end: "3000-01-01", + }; + } + } + + const generateChart = async () => { + const stats = await fetchDownloadStats( + npmPackage.name, + `${startDate}:${endDate}` + ); + setCount(calculateDownloads(stats)); + }; + + useEffect(() => { + generateChart(); + }, [startDate, endDate]); + + return ( +
+

Download Statistics

+
+ {packages.map((package_list) => ( +
+
+
+

+ {package_list.name.replaceAll("-", " ")} +

+
+
+
+ +
+
+
+
+
+
+
+ expand_img +
+
+ {package_list.total} +
+
+
+
+

Downloads

+
+
+
+
+
+ + npm_img + +
+
+ + npm_img + +
+
+
+
+ ))} +
+ + + + +
+ + +
+
+ + +
+ +
+ + {npmPackage.name.replaceAll("-", " ")} + +
+
+

+ Select +

+
+ +
+ + + +
+
+
+ +
+ {selectedRange === true ? ( +
+
+
+ + setStartDate(e.target.value)} + /> +
+
+ + setEndDate(e.target.value)} + /> +
+
+
+
+
+
+ expand_img +
+
+ {count} +
+
+
+
+

+ Downloads +

+
+
+
+
+
+ ) : ( +
+
+
+
+ expand_img +
+
+ {count} +
+
+
+
+

+ Downloads +

+
+
+
+
+ )} +
+
+
+
+
+
+
+
+
+ ); +}; + +export default Stats; diff --git a/src/app/projects/assets/contributors.json b/src/app/projects/assets/contributors.json index 160dbf26..037e40d8 100644 --- a/src/app/projects/assets/contributors.json +++ b/src/app/projects/assets/contributors.json @@ -1,9 +1,184 @@ -{ - "lakinmindfire": { +[ + { + "id": 116242186, + "contributions": 273, + "html_url": "https://github.com/ashutosh-jena-mindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/116242186?v=4", + "login": "ashutosh-jena-mindfire" + }, + { "id": 80667930, - "contributions": 116, + "contributions": 188, "html_url": "https://github.com/lakinmindfire", "avatar_url": "https://avatars.githubusercontent.com/u/80667930?v=4", "login": "lakinmindfire" + }, + { + "id": 120394376, + "contributions": 126, + "html_url": "https://github.com/Bhupesh-MS", + "avatar_url": "https://avatars.githubusercontent.com/u/120394376?v=4", + "login": "Bhupesh-MS" + }, + { + "id": 7521181, + "contributions": 121, + "html_url": "https://github.com/ssswagatss", + "avatar_url": "https://avatars.githubusercontent.com/u/7521181?v=4", + "login": "ssswagatss" + }, + { + "id": 63102290, + "contributions": 57, + "html_url": "https://github.com/VershalaTandon", + "avatar_url": "https://avatars.githubusercontent.com/u/63102290?v=4", + "login": "VershalaTandon" + }, + { + "id": 31609471, + "contributions": 29, + "html_url": "https://github.com/soumyadeep589", + "avatar_url": "https://avatars.githubusercontent.com/u/31609471?v=4", + "login": "soumyadeep589" + }, + { + "id": 64151314, + "contributions": 26, + "html_url": "https://github.com/BasudevBharatBhushan", + "avatar_url": "https://avatars.githubusercontent.com/u/64151314?v=4", + "login": "BasudevBharatBhushan" + }, + { + "id": 103591425, + "contributions": 25, + "html_url": "https://github.com/ArnabKMindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/103591425?v=4", + "login": "ArnabKMindfire" + }, + { + "id": 148045555, + "contributions": 18, + "html_url": "https://github.com/prashant-mindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/148045555?v=4", + "login": "prashant-mindfire" + }, + { + "id": 11457501, + "contributions": 17, + "html_url": "https://github.com/lakinmohapatra", + "avatar_url": "https://avatars.githubusercontent.com/u/11457501?v=4", + "login": "lakinmohapatra" + }, + { + "id": 85334692, + "contributions": 16, + "html_url": "https://github.com/hemant-sudhanshu", + "avatar_url": "https://avatars.githubusercontent.com/u/85334692?v=4", + "login": "hemant-sudhanshu" + }, + { + "id": 118360815, + "contributions": 15, + "html_url": "https://github.com/asishmindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/118360815?v=4", + "login": "asishmindfire" + }, + { + "id": 5602062, + "contributions": 15, + "html_url": "https://github.com/debabratapatra", + "avatar_url": "https://avatars.githubusercontent.com/u/5602062?v=4", + "login": "debabratapatra" + }, + { + "id": 29296038, + "contributions": 13, + "html_url": "https://github.com/aryanxorian", + "avatar_url": "https://avatars.githubusercontent.com/u/29296038?v=4", + "login": "aryanxorian" + }, + { + "id": 134675427, + "contributions": 13, + "html_url": "https://github.com/VershalaT", + "avatar_url": "https://avatars.githubusercontent.com/u/134675427?v=4", + "login": "VershalaT" + }, + { + "id": 160819069, + "contributions": 11, + "html_url": "https://github.com/konark-mindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/160819069?v=4", + "login": "konark-mindfire" + }, + { + "id": 138189810, + "contributions": 10, + "html_url": "https://github.com/Satyam-Mindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/138189810?v=4", + "login": "Satyam-Mindfire" + }, + { + "id": 84971366, + "contributions": 8, + "html_url": "https://github.com/Harshita-mindfire", + "avatar_url": "https://avatars.githubusercontent.com/u/84971366?v=4", + "login": "Harshita-mindfire" + }, + { + "id": 123073226, + "contributions": 7, + "html_url": "https://github.com/avishekthapamindfire0822", + "avatar_url": "https://avatars.githubusercontent.com/u/123073226?v=4", + "login": "avishekthapamindfire0822" + }, + { + "id": 137804674, + "contributions": 7, + "html_url": "https://github.com/Bhupesh-mfsi", + "avatar_url": "https://avatars.githubusercontent.com/u/137804674?v=4", + "login": "Bhupesh-mfsi" + }, + { + "id": 87860388, + "contributions": 6, + "html_url": "https://github.com/iabhishekkumarms", + "avatar_url": "https://avatars.githubusercontent.com/u/87860388?v=4", + "login": "iabhishekkumarms" + }, + { + "id": 10649999, + "contributions": 6, + "html_url": "https://github.com/chaudharyvivek", + "avatar_url": "https://avatars.githubusercontent.com/u/10649999?v=4", + "login": "chaudharyvivek" + }, + { + "id": 42381761, + "contributions": 3, + "html_url": "https://github.com/praliptarajoo", + "avatar_url": "https://avatars.githubusercontent.com/u/42381761?v=4", + "login": "praliptarajoo" + }, + { + "id": 11786875, + "contributions": 3, + "html_url": "https://github.com/taditdash", + "avatar_url": "https://avatars.githubusercontent.com/u/11786875?v=4", + "login": "taditdash" + }, + { + "id": 87357401, + "contributions": 2, + "html_url": "https://github.com/jagannathmfs", + "avatar_url": "https://avatars.githubusercontent.com/u/87357401?v=4", + "login": "jagannathmfs" + }, + { + "id": 20682504, + "contributions": 1, + "html_url": "https://github.com/divyarbehera", + "avatar_url": "https://avatars.githubusercontent.com/u/20682504?v=4", + "login": "divyarbehera" } -} +] diff --git a/src/app/projects/assets/projects.json b/src/app/projects/assets/projects.json index ac3027d5..5071d2ac 100644 --- a/src/app/projects/assets/projects.json +++ b/src/app/projects/assets/projects.json @@ -1,32 +1,114 @@ [ { - "title": "react canvas editor", + "id": 1, + "title": "React Canvas Editor", + "short_description": "Multipage document editing in React with Canvas.", + "github_repository_link": "https://github.com/mindfiredigital/react-canvas-editor", + "documentation_link": "https://mindfiredigital.github.io/react-canvas-editor/", + "project_type": "current", + "date_created": "2023-12-20T10:32:42.000Z", + "date_updated": null, + "status": "published", "shortDescription": "Multipage document editing in React with Canvas.", "githubUrl": "https://github.com/mindfiredigital/react-canvas-editor", - "documentationUrl": "https://mindfiredigital.github.io/react-canvas-editor" + "documentationUrl": "https://mindfiredigital.github.io/react-canvas-editor/" }, { - "title": "canvas editor", + "id": 2, + "title": "Canvas Editor", + "short_description": "Multipage document editor based on HTML5 canvas.", + "github_repository_link": "https://github.com/mindfiredigital/canvas-editor", + "documentation_link": "https://mindfiredigital.github.io/canvas-editor", + "project_type": "current", + "date_created": "2023-12-20T10:35:03.000Z", + "date_updated": null, + "status": "published", "shortDescription": "Multipage document editor based on HTML5 canvas.", "githubUrl": "https://github.com/mindfiredigital/canvas-editor", "documentationUrl": "https://mindfiredigital.github.io/canvas-editor" }, { - "title": "NFT marketplace", + "id": 3, + "title": "NFT Marketplace", + "short_description": "A multi-chain platform for fans to connect with their favorite celebrities.", + "github_repository_link": "https://github.com/mindfiredigital/nft-marketplace", + "documentation_link": "https://github.com/mindfiredigital/nft-marketplace", + "project_type": "current", + "date_created": "2023-12-20T10:36:13.000Z", + "date_updated": null, + "status": "published", "shortDescription": "A multi-chain platform for fans to connect with their favorite celebrities.", "githubUrl": "https://github.com/mindfiredigital/nft-marketplace", "documentationUrl": "https://github.com/mindfiredigital/nft-marketplace" }, { + "id": 4, "title": "FMDAPI Node Weaver", + "short_description": "Seamless frontend integration with Filemaker Database.", + "github_repository_link": "https://github.com/mindfiredigital/fmdapi-node-weaver", + "documentation_link": "https://github.com/mindfiredigital/fmdapi-node-weaver", + "project_type": "current", + "date_created": "2023-12-20T10:37:14.000Z", + "date_updated": null, + "status": "published", "shortDescription": "Seamless frontend integration with Filemaker Database.", "githubUrl": "https://github.com/mindfiredigital/fmdapi-node-weaver", "documentationUrl": "https://github.com/mindfiredigital/fmdapi-node-weaver" }, { + "id": 5, "title": "Extension Methods", + "short_description": "C# utility library with 300+ NuGet extension methods.", + "github_repository_link": "https://github.com/mindfiredigital/extension-methods", + "documentation_link": "https://github.com/mindfiredigital/extension-methods", + "project_type": "current", + "date_created": "2023-12-20T10:38:02.000Z", + "date_updated": null, + "status": "published", "shortDescription": "C# utility library with 300+ NuGet extension methods.", "githubUrl": "https://github.com/mindfiredigital/extension-methods", "documentationUrl": "https://github.com/mindfiredigital/extension-methods" + }, + { + "id": 6, + "title": "FireKubeX", + "short_description": "Simplifies Kubernetes, easing app deployment for developers.", + "github_repository_link": "https://github.com/mindfiredigital/FireKubeX", + "documentation_link": "https://github.com/mindfiredigital/FireKubeX", + "project_type": "current", + "date_created": "2023-12-20T10:39:23.000Z", + "date_updated": null, + "status": "published", + "shortDescription": "Simplifies Kubernetes, easing app deployment for developers.", + "githubUrl": "https://github.com/mindfiredigital/FireKubeX", + "documentationUrl": "https://github.com/mindfiredigital/FireKubeX" + }, + { + "id": 12, + "title": "MobileQuickLaunchKit-iOS", + "short_description": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "github_repository_link": "https://github.com/mindfiredigital/MobileQuickLaunchKit-iOS", + "documentation_link": "https://github.com/mindfiredigital/MobileQuickLaunchKit-iOS", + "project_type": "current", + "date_created": "2024-01-30T08:48:28.000Z", + "date_updated": null, + "status": "published", + "shortDescription": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "githubUrl": "https://github.com/mindfiredigital/MobileQuickLaunchKit-iOS", + "documentationUrl": "https://github.com/mindfiredigital/MobileQuickLaunchKit-iOS" + }, + { + "id": 13, + "title": "MobileQuickLaunchKit-Android", + "short_description": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "github_repository_link": "https://github.com/mindfiredigital/MobileQuickLaunchKit-Android", + "documentation_link": "https://github.com/mindfiredigital/MobileQuickLaunchKit-Android", + "project_type": "current", + "date_created": "2024-01-30T08:49:12.000Z", + "date_updated": null, + "status": "published", + "shortDescription": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "githubUrl": "https://github.com/mindfiredigital/MobileQuickLaunchKit-Android", + "documentationUrl": "https://github.com/mindfiredigital/MobileQuickLaunchKit-Android" } ] diff --git a/src/app/projects/assets/stats.json b/src/app/projects/assets/stats.json new file mode 100644 index 00000000..e03009ca --- /dev/null +++ b/src/app/projects/assets/stats.json @@ -0,0 +1,23 @@ +[ + { + "name": "fmdapi-node-weaver", + "day": 0, + "week": 3, + "year": 70, + "total": 70 + }, + { + "name": "react-canvas-editor", + "day": 1, + "week": 22, + "year": 947, + "total": 947 + }, + { + "name": "canvas-editor", + "day": 0, + "week": 7, + "year": 1063, + "total": 1063 + } +] diff --git a/src/app/projects/assets/upcomingProjects.json b/src/app/projects/assets/upcomingProjects.json index 1bfc37ca..7f7f82bb 100644 --- a/src/app/projects/assets/upcomingProjects.json +++ b/src/app/projects/assets/upcomingProjects.json @@ -1,38 +1,86 @@ [ { - "id": 1, - "title": "FireKubeX", - "shortDescription": "Simplifies Kubernetes, easing app deployment for developers.", - "Summary": "This script simplifies the deployment process for developers by abstracting the complexities of Kubernetes. By providing the necessary configuration in the config.yaml file, developers can quickly deploy their applications to a Kubernetes cluster with ease without the need for in-depth Kubernetes knowledge. It also supports starting and stopping services, along with options for development (dev) and production (prod) modes. The config.yaml is intended for individual microservices. It aims to enhance the efficiency of deploying and scaling microservices by providing a flexible and customizable solution.", - "project_type": "Developer Tools and Utilities", - "contributors": ["jagannathmfs", "amitshr6779"], - "project_goal": "The script is designed to handle multiple services, making it scalable for diverse microservices architectures. Additionally, it can be extended easily to incorporate additional features or adapt to evolving Kubernetes best practices.", - "target_users": "Targeted users will be the developers who needs to deploy their applications in a kubernetes cluster on their own local system or in any cloud kubernetes like (EKS,AKS,GKE).", - "risk": "Potential risks related to conflicting with proprietary IP or current customer work if any: None" - }, - { - "id": 2, + "id": 7, "title": "SSR Guide", - "shortDescription": "The ultimate guide for SSR implementation" + "short_description": "The ultimate guide for SSR implementation", + "github_repository_link": "NA", + "documentation_link": "NA", + "project_type": "upcoming", + "date_created": "2023-12-20T10:39:55.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "The ultimate guide for SSR implementation", + "githubUrl": "NA", + "documentationUrl": "NA" }, { - "id": 3, + "id": 8, "title": "IframeVsWebComponent", - "shortDescription": "Benchmarking performance with iframes and web components" + "short_description": "Benchmarking performance with iframes and web components", + "github_repository_link": "https://github.com/mindfiredigital/IframeVsWebComponents", + "documentation_link": "https://github.com/mindfiredigital/IframeVsWebComponents", + "project_type": "upcoming", + "date_created": "2023-12-20T10:40:36.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "Benchmarking performance with iframes and web components", + "githubUrl": "https://github.com/mindfiredigital/IframeVsWebComponents", + "documentationUrl": "https://github.com/mindfiredigital/IframeVsWebComponents" }, { - "id": 4, + "id": 9, "title": "FMDAPI Python Weaver", - "shortDescription": "Seamless frontend integration with Filemaker Database" + "short_description": "Seamless frontend integration with Filemaker Database", + "github_repository_link": "NA", + "documentation_link": "NA", + "project_type": "upcoming", + "date_created": "2023-12-20T10:41:05.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "Seamless frontend integration with Filemaker Database", + "githubUrl": "NA", + "documentationUrl": "NA" }, { - "id": 5, + "id": 10, "title": "Angular Canvas Editor", - "shortDescription": "Multipage document editing in Angular with Canvas" + "short_description": "Multipage document editing in Angular with Canvas", + "github_repository_link": "NA", + "documentation_link": "NA", + "project_type": "upcoming", + "date_created": "2023-12-20T10:41:28.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "Multipage document editing in Angular with Canvas", + "githubUrl": "NA", + "documentationUrl": "NA" }, { - "id": 6, + "id": 11, "title": "EHRConnect", - "shortDescription": "Seamlessly connect with any EHR" + "short_description": "Seamlessly connect with any EHR", + "github_repository_link": "NA", + "documentation_link": "NA", + "project_type": "upcoming", + "date_created": "2023-12-20T10:42:02.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "Seamlessly connect with any EHR", + "githubUrl": "NA", + "documentationUrl": "NA" + }, + { + "id": 14, + "title": "QuickLaunchReactNativeKit", + "short_description": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "github_repository_link": "https://github.com/mindfiredigital/QuickLaunchReactNativeKit", + "documentation_link": "https://github.com/mindfiredigital/QuickLaunchReactNativeKit", + "project_type": "upcoming", + "date_created": "2024-02-29T10:55:14.000Z", + "date_updated": null, + "status": "draft", + "shortDescription": "Simplifies mobile development with pre-built features like login, signup, and settings. Developers integrate efficiently, leveraging diverse themes.", + "githubUrl": "https://github.com/mindfiredigital/QuickLaunchReactNativeKit", + "documentationUrl": "https://github.com/mindfiredigital/QuickLaunchReactNativeKit" } ] diff --git a/src/constants/index.ts b/src/constants/index.ts index 3bf3c226..19274bc4 100644 --- a/src/constants/index.ts +++ b/src/constants/index.ts @@ -26,6 +26,10 @@ const navigations: Navigation[] = [ name: "Contributors", path: ["/contributors"], }, + { + name: "Packages", + path: ["/packages"], + }, { name: "GitHub", path: ["https://github.com/mindfiredigital"], diff --git a/updateProject.mjs b/updateProject.mjs index fc27f251..40569664 100644 --- a/updateProject.mjs +++ b/updateProject.mjs @@ -1,3 +1,4 @@ +/* eslint-disable no-undef */ // updateProjects.mjs import fs from "fs"; import path from "path"; @@ -156,6 +157,7 @@ async function updateProjects() { const contributionsMap = {}; for (const repo in contributorsObject) { + // eslint-disable-next-line no-prototype-builtins if (contributorsObject.hasOwnProperty(repo)) { contributorsObject[repo].forEach((contributor) => { if (contributor.login === "github-actions[bot]") { @@ -186,10 +188,100 @@ async function updateProjects() { JSON.stringify(sortedContributions, null, 2) ); console.log("Contributors list updated successfully."); + + getAllStats(repoNames) + .then((statsMap) => { + fs.writeFileSync( + path.join(__dirname, "src/app/projects/assets/stats.json"), + JSON.stringify(statsMap, null, 2) + ); + + console.log("Status list updated successfully."); + }) + .catch((error) => { + console.error("Error fetching stats:", error); + }); } catch (error) { console.error("An error occurred:", error); } } +// Function to fetch download statistics for a given package and period +async function fetchDownloadStats(packageName, period) { + const url = `https://api.npmjs.org/downloads/range/${period}/@mindfiredigital/${packageName}`; + const response = await fetch(url); + + if (!response.ok) { + console.log( + `Failed to fetch download stats for ${packageName} (${period}): ${response.statusText}` + ); + } + + const data = await response.json(); + return data; +} + +// Function to calculate average downloads from the statistics +function calculateAverageDownloads(stats) { + return stats.downloads.reduce( + (accumulator, download) => accumulator + download.downloads, + 0 + ); +} + +// Function to fetch and process statistics for a package and period +async function getStats(packageName, period) { + try { + // Fetch download statistics + const stats = await fetchDownloadStats(packageName, period); + + // Check if stats exist + if (!stats || !stats.package) return 0; + + // Calculate average downloads + return calculateAverageDownloads(stats); + } catch (error) { + // Log and handle errors + console.error(`${packageName} not present`); + return null; + } +} + +// Function to fetch and aggregate statistics for all packages and periods +async function getAllStats(npmPackages) { + const statsMap = []; + + // Fetch stats for each package and period + await Promise.all( + npmPackages.map(async (packageName) => { + try { + // Fetch stats for different periods + const [dayStats, weekStats, yearStats, totalStats] = await Promise.all([ + getStats(packageName, "last-day"), + getStats(packageName, "last-week"), + getStats(packageName, "last-year"), + getStats(packageName, "1000-01-01:3000-01-01"), + ]); + + // If any stats exist, add to the map + if (dayStats !== 0 || weekStats !== 0 || yearStats !== 0) { + statsMap.push({ + name: packageName, + day: dayStats, + week: weekStats, + year: yearStats, + total: totalStats, + }); + } + } catch (error) { + // Log and handle errors + console.error(`Error fetching stats for ${packageName}:`, error); + } + }) + ); + + return statsMap; +} + // Call the main function updateProjects();