From c138cc535279683aaf8d6cad29ec3319bd68d4d7 Mon Sep 17 00:00:00 2001 From: Richard Abrich Date: Mon, 17 Jun 2024 14:08:56 -0400 Subject: [PATCH 1/2] wip --- components/Developers.js | 299 ------------------------------- components/Developers.module.css | 19 -- components/DownloadGraph.js | 39 ++-- pages/index.js | 4 +- 4 files changed, 26 insertions(+), 335 deletions(-) delete mode 100644 components/Developers.js delete mode 100644 components/Developers.module.css diff --git a/components/Developers.js b/components/Developers.js deleted file mode 100644 index 61ee5c8..0000000 --- a/components/Developers.js +++ /dev/null @@ -1,299 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faWindows, faApple } from '@fortawesome/free-brands-svg-icons'; -import Link from 'next/link'; -import styles from './Developers.module.css'; -import { getReleasesDownloadCount } from 'utils/githubStats'; -import EmailForm from '@components/EmailForm'; -import { Bounties } from '@components/Bounties'; -import DownloadGraph from './DownloadGraph'; - -export default function Developers() { - const [latestRelease, setLatestRelease] = useState({ version: null, date: null }); - const [downloadCount, setDownloadCount] = useState({ windows: 0, mac: 0 }); - const [showBuildWarning, setShowBuildWarning] = useState(false); - const macURL = latestRelease.version - ? `https://github.com/OpenAdaptAI/OpenAdapt/releases/download/${latestRelease.version}/OpenAdapt-${latestRelease.version}.app.zip` - : ''; - const windowsURL = latestRelease.version - ? `https://github.com/OpenAdaptAI/OpenAdapt/releases/download/${latestRelease.version}/OpenAdapt-${latestRelease.version}.zip` - : ''; - - useEffect(() => { - // Fetch the latest release information - fetch('https://api.github.com/repos/OpenAdaptAI/OpenAdapt/releases/latest') - .then(response => response.json()) - .then(data => { - const releaseDate = new Date(data.published_at).toLocaleString('en-US', { - year: 'numeric', month: 'numeric', day: 'numeric', - hour: '2-digit', minute: '2-digit', second: '2-digit', - hour12: false, timeZoneName: 'short' - }); - setLatestRelease({ - version: data.name, - date: releaseDate - }); - }); - - // Fetch download counts - getReleasesDownloadCount().then(({ windowsDownloadCount, macDownloadCount }) => { - setDownloadCount({ - windows: windowsDownloadCount, - mac: macDownloadCount, - }); - }); - - // Check for issues labeled "main-broken" - fetch('https://api.github.com/repos/OpenAdaptAI/OpenAdapt/issues?state=open&labels=main-broken') - .then(response => response.json()) - .then(issues => { - if (issues.length > 0) { - setShowBuildWarning(true); - } else { - setShowBuildWarning(false); - } - }); - }, []); - - const handleDownloadClick = (os, url) => { - const fileName = url.split('/').pop(); - window.gtag('event', 'download_start', { - event_category: 'Software Downloads', - event_action: `Download Initiated ${os}`, - event_label: fileName, - value: 1 - }); - downloadFile(url, os, fileName); - } - - const downloadFile = async (url, os, fileName) => { - try { - const response = await fetch(url); - if (response.ok) { - window.gtag('event', 'download_success', { - event_category: 'Software Downloads', - event_action: `Download Successful ${os}`, - event_label: fileName, - value: 1 - }); - } else { - throw new Error('Network response was not ok.'); - } - } catch (error) { - console.error('Download failed:', error); - window.gtag('event', 'download_failure', { - event_category: 'Software Downloads', - event_action: `Download Failed ${os}`, - event_label: fileName, - value: 0 - }); - } - } - - return ( -
-
-
- {showBuildWarning && ( -
- Warning: The current version has a known issue and may not function as expected. Please check back later for updates. -
- )} -

- Getting Started -

-

- Note: OpenAdapt is Alpha software. This means it is in - the early stages of development and may contain bugs, - incomplete features, and other issues. Users should - exercise caution and understand that the software is - provided "as-is" without any guarantees or warranties. - We appreciate your feedback and contributions to help - improve the project. For more information and to support - our development, please visit our{' '} - - GitHub sponsors page. - -

- {latestRelease.version && ( -
-

Current Version: {latestRelease.version}

-

Released on: {latestRelease.date}

-
- )} -
- handleDownloadClick('Windows', windowsURL)} - > - - - Download for Windows - - {downloadCount.windows > 0 && ( - - {downloadCount.windows} downloads - - )} - - handleDownloadClick('MacOS', macURL)} - > - - Download for MacOS - {downloadCount.mac > 0 && ( - - {downloadCount.mac} downloads - - )} - -
- - -

What's Next?

- -

- Troubleshooting -

- -

Comfortable on the command line? Read on:

- -

- Getting Started for Developers -

-

- Note: If you run into trouble with the scripted - installation described here, please refer to{' '} - - Manual Setup - {' '} - instructions. -

-

- - Windows -

-
    -
  • - Press Windows Key, type "powershell", and press - Enter -
  • -
  • - Copy and paste the following command into the - terminal, and press Enter (If Prompted for `User - Account Control`, click 'Yes'): -
  • -
-
-                        Start-Process powershell -Verb RunAs -ArgumentList
-                        '-NoExit', '-ExecutionPolicy', 'Bypass', '-Command',
-                        "iwr -UseBasicParsing -Uri
-                        'https://raw.githubusercontent.com/OpenAdaptAI/OpenAdapt/main/install/install_openadapt.ps1'
-                        | Invoke-Expression"
-                    
-

- - MacOS -

-
    -
  • - Press Command+Space, type "terminal", and press - Enter -
  • -
  • - Copy and paste the following command into the - terminal, and press Enter: -
  • -
-
-                        /bin/bash -c "$(curl -fsSL
-                        https://raw.githubusercontent.com/OpenAdaptAI/OpenAdapt/HEAD/install/install_openadapt.sh)"
-                    
-
-
-
- ) -} diff --git a/components/Developers.module.css b/components/Developers.module.css deleted file mode 100644 index 9d4477c..0000000 --- a/components/Developers.module.css +++ /dev/null @@ -1,19 +0,0 @@ -.row { - display: flex; - flex-wrap: wrap; - justify-content: center; - padding-top: 50px; - padding-bottom: 50px; - background-color: rgba(0, 0, 30, 1); - color: white; -} -.p { - padding: 20px; - font-size: 18px; - text-align: center; - color: rgb(204, 194, 194); -} -.no-bullets { - list-style-type: none; /* Removes bullet points */ - padding-left: 0; /* Removes default padding */ -} diff --git a/components/DownloadGraph.js b/components/DownloadGraph.js index bfc12e9..7900e3f 100644 --- a/components/DownloadGraph.js +++ b/components/DownloadGraph.js @@ -1,10 +1,10 @@ import React, { useState, useEffect } from 'react'; import { Line } from 'react-chartjs-2'; import 'chart.js/auto'; +import 'chartjs-adapter-date-fns'; const DownloadGraph = () => { const [chartData, setChartData] = useState({ - labels: [], datasets: [ { label: 'Release Downloads', @@ -24,7 +24,25 @@ const DownloadGraph = () => { const options = { responsive: true, maintainAspectRatio: false, - aspectRatio: 1.5, // Lower ratio to make the chart taller + scales: { + x: { + type: 'time', + time: { + unit: 'day' + }, + title: { + display: true, + text: 'Date' + } + }, + y: { + beginAtZero: true, + title: { + display: true, + text: 'Number of Downloads' + } + } + } }; const fetchReleaseData = async (page = 1) => { @@ -51,29 +69,21 @@ const DownloadGraph = () => { // Sort releases by published date allReleases.sort((a, b) => new Date(a.published_at) - new Date(b.published_at)); - const labels = []; const dailyDownloads = []; const cumulativeDownloads = []; allReleases.forEach(release => { - const date = new Date(release.published_at).toLocaleDateString(); - const label = `${release.name} : ${date}`; // Combine release name with date - labels.push(label); - + const date = new Date(release.published_at); const dailyTotalDownloads = release.assets.reduce((acc, asset) => { - if (asset.name.endsWith('.zip')) { - return acc + asset.download_count; - } - return acc; + return acc + (asset.name.endsWith('.zip') ? asset.download_count : 0); }, 0); cumulativeTotalDownloads += dailyTotalDownloads; - dailyDownloads.push(dailyTotalDownloads); - cumulativeDownloads.push(cumulativeTotalDownloads); + dailyDownloads.push({ x: date, y: dailyTotalDownloads }); + cumulativeDownloads.push({ x: date, y: cumulativeTotalDownloads }); }); setChartData({ - labels, datasets: [ { ...chartData.datasets[0], data: dailyDownloads }, { ...chartData.datasets[1], data: cumulativeDownloads }, @@ -94,4 +104,3 @@ const DownloadGraph = () => { }; export default DownloadGraph; - diff --git a/pages/index.js b/pages/index.js index 7ecf49f..58ecbf2 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,6 +1,6 @@ import { useRef, useState } from 'react' -import Developers from '@components/Developers' +import Start from '@components/Start' import FeedbackForm from '@components/FeedbackForm' import Footer from '@components/Footer' import IndustriesGrid from '@components/IndustriesGrid' @@ -22,7 +22,7 @@ export default function Home() { setFeedbackData={setFeedbackData} sectionRef={sectionRef} /> - +