Compare commits
11 Commits
openspendi
...
878-how-to
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11144758ca | ||
|
|
f443dab92c | ||
|
|
d9be7d0f5b | ||
|
|
7c21993b92 | ||
|
|
3f06aa3f01 | ||
|
|
d191178ecf | ||
|
|
a0eb06ee19 | ||
|
|
539fd6c77e | ||
|
|
8fa930b3f4 | ||
|
|
3be88f1cdb | ||
|
|
d0ee06e8d0 |
@@ -1,138 +0,0 @@
|
||||
import { expect, test } from 'vitest';
|
||||
import { getAllProjectsFromOrg, getProjectDataPackage } from '../lib/project';
|
||||
import { loadDataPackage } from '../lib/loader';
|
||||
import { getProjectMetadata } from '../lib/project';
|
||||
import { getCsv, parseCsv } from '../components/Table';
|
||||
|
||||
test(
|
||||
'Test OS-Data',
|
||||
async () => {
|
||||
const repos = await getAllProjectsFromOrg(
|
||||
'os-data',
|
||||
'main',
|
||||
process.env.VITE_GITHUB_PAT
|
||||
);
|
||||
if (repos.failed.length > 0) console.log(repos.failed);
|
||||
expect(repos.failed.length).toBe(0);
|
||||
},
|
||||
{ timeout: 100000 }
|
||||
);
|
||||
|
||||
test(
|
||||
'Test Gift-Data',
|
||||
async () => {
|
||||
const repos = await getAllProjectsFromOrg(
|
||||
'gift-data',
|
||||
'main',
|
||||
process.env.VITE_GITHUB_PAT
|
||||
);
|
||||
if (repos.failed.length > 0) console.log(repos.failed);
|
||||
expect(repos.failed.length).toBe(0);
|
||||
},
|
||||
{ timeout: 100000 }
|
||||
);
|
||||
|
||||
test(
|
||||
'Test getting one dataset from github',
|
||||
async () => {
|
||||
const datapackage = await getProjectDataPackage(
|
||||
'os-data',
|
||||
'berlin-berlin',
|
||||
'main',
|
||||
process.env.VITE_GITHUB_PAT
|
||||
);
|
||||
const repo = await getProjectMetadata(
|
||||
'os-data',
|
||||
'berlin-berlin',
|
||||
process.env.VITE_GITHUB_PAT
|
||||
);
|
||||
const project = loadDataPackage(datapackage, repo);
|
||||
delete project['datapackage'];
|
||||
delete project.files[0]['dialect'];
|
||||
delete project.files[0]['schema'];
|
||||
expect(project).toStrictEqual({
|
||||
name: 'berlin-berlin',
|
||||
title: 'Berlin-Berlin',
|
||||
description: null,
|
||||
owner: {
|
||||
name: 'os-data',
|
||||
logo: 'https://avatars.githubusercontent.com/u/13695166?v=4',
|
||||
title: 'os-data',
|
||||
},
|
||||
repo: {
|
||||
name: 'berlin-berlin',
|
||||
full_name: 'os-data/berlin-berlin',
|
||||
url: 'https://github.com/os-data/berlin-berlin',
|
||||
},
|
||||
files: [
|
||||
{
|
||||
name: 'berlin-gesamt',
|
||||
format: 'csv',
|
||||
path: 'https://storage.openspending.org/berlin-berlin/berlin-gesamt.csv',
|
||||
mediatype: 'text/csv',
|
||||
bytes: 81128743,
|
||||
encoding: 'utf-8',
|
||||
},
|
||||
],
|
||||
author: 'Michael Peters <michael.peters@okfn.de>',
|
||||
cityCode: 'Berlin',
|
||||
countryCode: 'DE',
|
||||
fiscalPeriod: { start: '2014-01-01', end: '2019-12-31' },
|
||||
readme: '',
|
||||
});
|
||||
},
|
||||
{ timeout: 100000 }
|
||||
);
|
||||
|
||||
test(
|
||||
'Test getting one section of csv from R2',
|
||||
async () => {
|
||||
const rawCsv = await getCsv(
|
||||
'https://storage.openspending.org/state-of-minas-gerais-brazil-planned-budget/__os_imported__br-mg-ppagloc.csv'
|
||||
);
|
||||
const parsedCsv = await parseCsv(rawCsv);
|
||||
expect(parsedCsv.errors.length).toBe(1);
|
||||
expect(parsedCsv.data.length).toBe(10165);
|
||||
expect(parsedCsv.meta.fields).toStrictEqual([
|
||||
'function_name',
|
||||
'function_label',
|
||||
'product_name',
|
||||
'product_label',
|
||||
'area_name',
|
||||
'area_label',
|
||||
'subaction_name',
|
||||
'subaction_label',
|
||||
'region_label_map',
|
||||
'region_reg_map',
|
||||
'region_name',
|
||||
'region_label',
|
||||
'municipality_map_id',
|
||||
'municipality_name',
|
||||
'municipality_map_code',
|
||||
'municipality_label',
|
||||
'municipality_map_name_simple',
|
||||
'municipality_map_name',
|
||||
'cofog1_label_en',
|
||||
'cofog1_name',
|
||||
'cofog1_label',
|
||||
'amount',
|
||||
'subprogramme_name',
|
||||
'subprogramme_label',
|
||||
'time_name',
|
||||
'time_year',
|
||||
'time_month',
|
||||
'time_day',
|
||||
'time_week',
|
||||
'time_yearmonth',
|
||||
'time_quarter',
|
||||
'time',
|
||||
'action_name',
|
||||
'action_label',
|
||||
'subfunction_name',
|
||||
'subfunction_label',
|
||||
'programme_name',
|
||||
'programme_label',
|
||||
]);
|
||||
},
|
||||
{ timeout: 100000 }
|
||||
);
|
||||
@@ -1,15 +1,15 @@
|
||||
import Link from 'next/link';
|
||||
import clsx from 'clsx';
|
||||
import Link from 'next/link'
|
||||
import clsx from 'clsx'
|
||||
|
||||
export function Button({ href, className = '', ...props }) {
|
||||
export function Button({ href, className = "", ...props }) {
|
||||
className = clsx(
|
||||
'inline-flex justify-center rounded-2xl bg-emerald-600 p-4 text-base font-semibold text-white hover:bg-emerald-500 focus:outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-emerald-500 active:text-white/70',
|
||||
className
|
||||
);
|
||||
)
|
||||
|
||||
return href ? (
|
||||
<Link scroll={false} href={href} className={className} {...props} />
|
||||
<Link href={href} className={className} {...props} />
|
||||
) : (
|
||||
<button className={className} {...props} />
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
import Link from 'next/link';
|
||||
import { Project } from '../lib/project.interface';
|
||||
import ExternalLinkIcon from './icons/ExternalLinkIcon';
|
||||
|
||||
export default function DatasetCard({ dataset }: { dataset: Project }) {
|
||||
return (
|
||||
<div
|
||||
key={dataset.name}
|
||||
className="overflow-hidden rounded-xl border border-gray-200"
|
||||
>
|
||||
<Link
|
||||
href={`/@${dataset.owner.name}/${dataset.repo.name}`}
|
||||
className="flex items-center gap-x-4 border-b border-gray-900/5 bg-gray-50 p-6"
|
||||
>
|
||||
<img
|
||||
src={dataset.owner.logo || '/assets/org-icon.svg'}
|
||||
alt={dataset.owner.name}
|
||||
className="h-12 w-12 flex-none rounded-lg bg-white object-cover ring-1 ring-gray-900/10 p-2"
|
||||
/>
|
||||
<div className="text-sm font-medium leading-6">
|
||||
<div className="text-gray-900 line-clamp-1">{dataset.title}</div>
|
||||
<div className="text-gray-500 line-clamp-1">
|
||||
{dataset.owner.title}
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
<dl className="-my-3 divide-y divide-gray-100 px-6 py-4 text-sm leading-6">
|
||||
<div className="flex justify-between gap-x-4 py-3">
|
||||
<dt className="text-gray-500">Name</dt>
|
||||
<dd className="flex items-start gap-x-2">
|
||||
<div className="font-medium text-gray-900 line-clamp-1">
|
||||
{dataset.name}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex justify-between gap-x-4 py-3">
|
||||
<dt className="text-gray-500">Country</dt>
|
||||
<dd className="flex items-start gap-x-2">
|
||||
<div className="font-medium text-gray-900">
|
||||
{dataset.countryCode}
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex justify-between gap-x-4 py-3">
|
||||
<dt className="text-gray-500">Fiscal Period</dt>
|
||||
<dd className="text-gray-700">
|
||||
{dataset.fiscalPeriod?.start &&
|
||||
new Date(dataset.fiscalPeriod.start).getFullYear()}
|
||||
{dataset.fiscalPeriod?.end &&
|
||||
dataset.fiscalPeriod?.start !== dataset.fiscalPeriod?.end && (
|
||||
<>
|
||||
{' - '}
|
||||
{new Date(dataset.fiscalPeriod.end).getFullYear()}
|
||||
</>
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex justify-between gap-x-4 py-3">
|
||||
<dt className="text-gray-500">Metadata</dt>
|
||||
<dd className="flex items-start gap-x-2">
|
||||
<div className="font-medium text-gray-900">
|
||||
<Link
|
||||
// TODO: this link may be incorrect for some datasets
|
||||
href={`https://github.com/${dataset.owner.name}/${dataset.repo.name}/blob/main/datapackage.json`}
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-gray-700"
|
||||
>
|
||||
datapackage.json <ExternalLinkIcon className="ml-1" />
|
||||
</Link>
|
||||
</div>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { Project } from '../lib/project.interface';
|
||||
import DatasetCard from './DatasetCard';
|
||||
|
||||
export default function DatasetsGrid({ datasets }: { datasets: Project[] }) {
|
||||
return (
|
||||
<ul
|
||||
className="grid gap-x-6 gap-y-8 grid-cols-1 sm:grid-cols-2 md:grid-cols-3"
|
||||
role="list"
|
||||
>
|
||||
{datasets.map((dataset, idx) => {
|
||||
return (
|
||||
<li key={`datasets-grid-item-${idx}`}>
|
||||
<DatasetCard dataset={dataset} />
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
import { useForm } from 'react-hook-form';
|
||||
import DatasetsGrid from './DatasetsGrid';
|
||||
import { Project } from '../lib/project.interface';
|
||||
import { Index } from 'flexsearch';
|
||||
import {
|
||||
ChevronDoubleLeftIcon,
|
||||
ChevronDoubleRightIcon,
|
||||
ChevronLeftIcon,
|
||||
ChevronRightIcon,
|
||||
} from '@heroicons/react/24/solid';
|
||||
import { useState } from 'react';
|
||||
|
||||
export default function DatasetsSearch({
|
||||
datasets,
|
||||
availableCountries,
|
||||
}: {
|
||||
datasets: Project[];
|
||||
availableCountries;
|
||||
}) {
|
||||
const itemsPerPage = 6;
|
||||
const [page, setPage] = useState(1);
|
||||
|
||||
const index = new Index({ tokenize: 'full' });
|
||||
|
||||
datasets.forEach((dataset: Project) =>
|
||||
index.add(
|
||||
dataset.name,
|
||||
`${dataset.repo} ${dataset.name} ${dataset.title} ${dataset.author} ${dataset.title} ${dataset.cityCode} ${dataset.fiscalPeriod?.start} ${dataset.fiscalPeriod?.end}`
|
||||
)
|
||||
);
|
||||
|
||||
const { register, watch, handleSubmit, reset, resetField } = useForm({
|
||||
defaultValues: {
|
||||
searchTerm: '',
|
||||
country: '',
|
||||
minDate: '',
|
||||
maxDate: '',
|
||||
},
|
||||
});
|
||||
|
||||
const filteredDatasets = datasets
|
||||
.filter((dataset: Project) =>
|
||||
watch().searchTerm && watch().searchTerm !== ''
|
||||
? index.search(watch().searchTerm).includes(dataset.name)
|
||||
: true
|
||||
)
|
||||
.filter((dataset) =>
|
||||
watch().country && watch().country !== ''
|
||||
? dataset.countryCode === watch().country
|
||||
: true
|
||||
)
|
||||
.filter((dataset) => {
|
||||
const filterMinDate = watch().minDate;
|
||||
const filterMaxDate = watch().maxDate;
|
||||
|
||||
const datasetMinDate = dataset.fiscalPeriod?.start;
|
||||
const datasetMaxDate = dataset.fiscalPeriod?.end;
|
||||
|
||||
let datasetStartOverlaps = false;
|
||||
if (datasetMinDate) {
|
||||
datasetStartOverlaps =
|
||||
datasetMinDate >= filterMinDate && datasetMinDate <= filterMaxDate;
|
||||
}
|
||||
|
||||
let datasetEndOverlaps = false;
|
||||
if (datasetMaxDate) {
|
||||
datasetEndOverlaps =
|
||||
datasetMaxDate >= filterMinDate && datasetMaxDate <= filterMaxDate;
|
||||
}
|
||||
|
||||
if (filterMinDate && filterMaxDate) {
|
||||
return datasetStartOverlaps || datasetEndOverlaps;
|
||||
} else if (filterMinDate) {
|
||||
return datasetMinDate >= filterMinDate;
|
||||
} else if (filterMaxDate) {
|
||||
return datasetMinDate <= filterMaxDate;
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
const paginatedDatasets = filteredDatasets.slice(
|
||||
(page - 1) * itemsPerPage,
|
||||
(page - 1) * itemsPerPage + itemsPerPage
|
||||
);
|
||||
|
||||
const pageCount = Math.ceil(filteredDatasets.length / itemsPerPage) || 1;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex flex-col gap-3 sm:flex-row">
|
||||
<div className="min-w-0 flex-auto">
|
||||
<br />
|
||||
<div className="relative">
|
||||
<input
|
||||
placeholder="Search datasets"
|
||||
aria-label="Search datasets"
|
||||
{...register('searchTerm', { onChange: () => setPage(1) })}
|
||||
className="h-[3em] relative w-full rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-emerald-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-emerald-400 sm:text-sm"
|
||||
/>
|
||||
{watch().searchTerm !== '' && (
|
||||
<button
|
||||
onClick={() => resetField('searchTerm')}
|
||||
className="absolute right-3 top-1/2 -translate-y-1/2 text-gray-500"
|
||||
>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="sm:basis-1/6">
|
||||
{/* TODO: nicer select e.g. headlessui example */}
|
||||
<label className="text-sm text-gray-600 font-medium">Country</label>
|
||||
<select
|
||||
className="h-[3em] w-full rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-emerald-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-emerald-400 sm:text-sm"
|
||||
{...register('country', { onChange: () => setPage(1) })}
|
||||
>
|
||||
<option value="">All</option>
|
||||
{availableCountries.map((country) => {
|
||||
return (
|
||||
<option key={country.code} value={country.code}>
|
||||
{country.title}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
</div>
|
||||
<div className="sm:basis-1/6">
|
||||
<label className="text-sm text-gray-600 font-medium">
|
||||
Fiscal Period Start
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
aria-label="Min. date"
|
||||
type="date"
|
||||
{...register('minDate', { onChange: () => setPage(1) })}
|
||||
className="h-[3em] w-full rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-emerald-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-emerald-400 sm:text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="sm:basis-1/6">
|
||||
<label className="text-sm text-gray-600 font-medium">
|
||||
Fiscal Period End
|
||||
</label>
|
||||
<div className="relative">
|
||||
<input
|
||||
aria-label="Max. date"
|
||||
type="date"
|
||||
{...register('maxDate', { onChange: () => setPage(1) })}
|
||||
className="h-[3em] w-full rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-emerald-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-emerald-400 sm:text-sm"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-5 mb-5">
|
||||
<span className="text-lg font-medium">
|
||||
{filteredDatasets.length} datasets found
|
||||
</span>
|
||||
</div>
|
||||
<div className="min-w-full align-middle">
|
||||
<DatasetsGrid datasets={paginatedDatasets} />
|
||||
<div className="w-full flex justify-center mt-10">
|
||||
<button
|
||||
onClick={() => setPage(1)}
|
||||
disabled={page <= 1}
|
||||
className="disabled:text-gray-400"
|
||||
>
|
||||
<ChevronDoubleLeftIcon className="w-6 h-6" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (page > 1) setPage((prev) => --prev);
|
||||
}}
|
||||
disabled={page <= 1}
|
||||
className="disabled:text-gray-400"
|
||||
>
|
||||
<ChevronLeftIcon className="w-6 h-6" />
|
||||
</button>
|
||||
<span className="mx-5">
|
||||
Page {page} of {pageCount}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (page < pageCount) setPage((prev) => ++prev);
|
||||
}}
|
||||
disabled={page >= pageCount}
|
||||
className="disabled:text-gray-400"
|
||||
>
|
||||
<ChevronRightIcon className="w-6 h-6" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setPage(pageCount)}
|
||||
disabled={page >= pageCount}
|
||||
className="disabled:text-gray-400"
|
||||
>
|
||||
<ChevronDoubleRightIcon className="w-6 h-6" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const CloseIcon = () => {
|
||||
return (
|
||||
<svg
|
||||
width={20}
|
||||
height={20}
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<g id="Menu / Close_MD">
|
||||
<path
|
||||
id="Vector"
|
||||
d="M18 18L12 12M12 12L6 6M12 12L18 6M12 12L6 18"
|
||||
stroke="currentColor"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</g>
|
||||
</svg>
|
||||
);
|
||||
};
|
||||
@@ -1,94 +0,0 @@
|
||||
import {
|
||||
QueryClient,
|
||||
QueryClientProvider,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
} from 'react-query';
|
||||
import Papa from 'papaparse';
|
||||
import { Grid } from '@githubocto/flat-ui';
|
||||
|
||||
const queryClient = new QueryClient();
|
||||
|
||||
export async function getCsv(url: string) {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Range: 'bytes=0-5132288',
|
||||
},
|
||||
});
|
||||
const data = await response.text();
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function parseCsv(file: string): Promise<any> {
|
||||
return new Promise((resolve, reject) => {
|
||||
Papa.parse(file, {
|
||||
header: true,
|
||||
dynamicTyping: true,
|
||||
skipEmptyLines: true,
|
||||
transform: (value: string): string => {
|
||||
return value.trim();
|
||||
},
|
||||
complete: (results: any) => {
|
||||
return resolve(results);
|
||||
},
|
||||
error: (error: any) => {
|
||||
return reject(error);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const Spinning = () => {
|
||||
return (
|
||||
<div role="status w-fit mx-auto">
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
className="w-8 h-8 mr-2 text-gray-200 animate-spin dark:text-gray-600 fill-emerald-600"
|
||||
viewBox="0 0 100 101"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
/>
|
||||
</svg>
|
||||
<span className="sr-only">Loading...</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const FlatUiTable: React.FC<{ url: string }> = ({ url }) => {
|
||||
return (
|
||||
// Provide the client to your App
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TableInner url={url} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
};
|
||||
|
||||
const TableInner: React.FC<{ url: string }> = ({ url }) => {
|
||||
const { data: csvString, isLoading: isDownloadingCSV } = useQuery(
|
||||
['dataCsv', url],
|
||||
() => getCsv(url)
|
||||
);
|
||||
const { data: parsedData, isLoading: isParsing } = useQuery(
|
||||
['dataPreview', csvString],
|
||||
() => parseCsv(csvString),
|
||||
{ enabled: !!csvString }
|
||||
);
|
||||
if (isParsing || isDownloadingCSV)
|
||||
<div className="w-full">
|
||||
<Spinning />
|
||||
</div>;
|
||||
if (parsedData)
|
||||
return (
|
||||
<div className="h-[500px] w-full">
|
||||
<Grid data={parsedData.data} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,82 +1,54 @@
|
||||
import Image from 'next/image';
|
||||
import { Container } from './Container';
|
||||
import logo from '../public/logo.svg';
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
import { Bars3Icon } from '@heroicons/react/24/outline';
|
||||
import { useState } from 'react';
|
||||
import Image from 'next/image'
|
||||
import { Button } from './Button'
|
||||
import { Container } from './Container'
|
||||
import logo from "../public/logo.svg"
|
||||
import Link from 'next/link'
|
||||
import { useRouter } from 'next/router'
|
||||
|
||||
export function Header() {
|
||||
const [menuOpen, setMenuOpen] = useState<boolean>(false);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const isActive = (navLink) => {
|
||||
return router.asPath.split('?')[0] == navLink.href;
|
||||
};
|
||||
return router.asPath.split("?")[0] == navLink.href;
|
||||
}
|
||||
|
||||
const navLinks = [
|
||||
{
|
||||
title: 'Home',
|
||||
href: '/',
|
||||
title: "Home",
|
||||
href: "/#header"
|
||||
},
|
||||
{
|
||||
title: 'Datasets',
|
||||
href: '/#datasets',
|
||||
title: "Datasets",
|
||||
href: "/#datasets"
|
||||
},
|
||||
// {
|
||||
// title: "Community",
|
||||
// href: "https://community.openspending.org/"
|
||||
// }
|
||||
];
|
||||
{
|
||||
title: "Community",
|
||||
href: "https://community.openspending.org/"
|
||||
}
|
||||
]
|
||||
|
||||
return (
|
||||
<header className="relative z-50 pb-11 lg:pt-11">
|
||||
<Container className="flex flex-wrap items-center justify-between lg:flex-nowrap mt-10 lg:mt-0">
|
||||
<Link href="/" className="lg:mt-0 lg:grow lg:basis-0 flex items-center">
|
||||
<header className="z-50 pb-5 lg:pt-11 sticky top-0 backdrop-blur" id="header">
|
||||
<Container className="flex flex-wrap items-center justify-center sm:justify-between lg:flex-nowrap">
|
||||
<div className="mt-10 lg:mt-0 lg:grow lg:basis-0 flex items-center">
|
||||
<Image src={logo} alt="OpenSpending" className="h-12 w-auto" />
|
||||
</Link>
|
||||
<ul className="hidden list-none sm:flex gap-x-5 text-base font-medium">
|
||||
</div>
|
||||
<ul className='list-none flex gap-x-5 text-base font-medium'>
|
||||
{navLinks.map((link, i) => (
|
||||
<li key={`nav-link-${i}`}>
|
||||
<Link
|
||||
className={`text-emerald-900 hover:text-emerald-600 ${
|
||||
isActive(link) ? 'text-emerald-600' : ''
|
||||
}`}
|
||||
className={`text-emerald-900 hover:text-emerald-600 ${isActive(link) ? "text-emerald-600" : ""}`}
|
||||
href={link.href}
|
||||
scroll={false}
|
||||
>
|
||||
{link.title}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</li>))}
|
||||
</ul>
|
||||
<div className="hidden xl:block xl:grow"></div>
|
||||
<div className="sm:hidden sm:mt-10 lg:mt-0 lg:grow lg:basis-0 lg:justify-end">
|
||||
<button onClick={() => setMenuOpen(!menuOpen)}>
|
||||
<Bars3Icon className="w-8 h-8" />
|
||||
</button>
|
||||
<div className="hidden sm:mt-10 sm:flex lg:mt-0 lg:grow lg:basis-0 lg:justify-end">
|
||||
<Button href="#">View on GitHub</Button>
|
||||
</div>
|
||||
{menuOpen && (
|
||||
<div className={`sm:hidden basis-full mt-5 text-center`}>
|
||||
<ul className="gap-x-5 text-base font-medium">
|
||||
{navLinks.map((link, i) => (
|
||||
<li key={`nav-link-${i}`}>
|
||||
<Link
|
||||
className={`text-emerald-900 hover:text-emerald-600 ${
|
||||
isActive(link) ? 'text-emerald-600' : ''
|
||||
}`}
|
||||
href={link.href}
|
||||
scroll={false}
|
||||
>
|
||||
{link.title}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</Container>
|
||||
</header>
|
||||
);
|
||||
</header >
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Button } from './Button';
|
||||
import { Container } from './Container';
|
||||
import { Button } from './Button'
|
||||
import { Container } from './Container'
|
||||
|
||||
export function Hero({ countriesCount, datasetsCount, filesCount }) {
|
||||
export function Hero() {
|
||||
return (
|
||||
<div className="relative pb-20 pt-10 sm:py-40" id="hero">
|
||||
<div className="relative pb-20 pt-10 sm:py-40">
|
||||
<div className="absolute inset-x-0 -bottom-14 -top-48 overflow-hidden bg-green-50 bg-opacity-50">
|
||||
<div className="absolute inset-x-0 top-0 h-40 bg-gradient-to-b from-white" />
|
||||
<div className="absolute inset-x-0 bottom-0 h-40 bg-gradient-to-t from-white" />
|
||||
@@ -15,25 +15,22 @@ export function Hero({ countriesCount, datasetsCount, filesCount }) {
|
||||
</h1>
|
||||
<div className="mt-6 space-y-6 font-display text-2xl tracking-tight text-emerald-900">
|
||||
<p>
|
||||
By understanding how governments spend money in our name can we
|
||||
have a say in how that money will affect our own lives. The
|
||||
journey starts here.
|
||||
By understanding how governments spend money in our name can we have a say
|
||||
in how that money will affect our own lives. The journey starts here.
|
||||
</p>
|
||||
<p>
|
||||
OpenSpending is a free, open and global platform to search,
|
||||
visualise and analyse fiscal data in the public sphere.
|
||||
OpenSpending is a free, open and global platform to search, visualise and analyse
|
||||
fiscal data in the public sphere.
|
||||
</p>
|
||||
</div>
|
||||
<Button href="#datasets" className="mt-10">
|
||||
Search datasets
|
||||
<Button href="#" className="mt-10 w-full sm:hidden">
|
||||
View on GitHub
|
||||
</Button>
|
||||
<dl className="mt-10 grid grid-cols-2 gap-x-10 gap-y-6 sm:mt-16 sm:gap-x-16 sm:gap-y-10 sm:text-center lg:auto-cols-auto lg:grid-flow-col lg:grid-cols-none lg:justify-start lg:text-left">
|
||||
{[
|
||||
// Added the plus sign because some datasets do not
|
||||
// contain defined countries
|
||||
['Countries', '+' + countriesCount],
|
||||
['Datasets', datasetsCount],
|
||||
['Files', filesCount],
|
||||
['Countries', '75'],
|
||||
['Datasets', '2091'],
|
||||
['Files', '9230'],
|
||||
].map(([name, value]) => (
|
||||
<div key={name}>
|
||||
<dt className="font-mono text-sm text-emerald-600">{name}</dt>
|
||||
@@ -46,5 +43,5 @@ export function Hero({ countriesCount, datasetsCount, filesCount }) {
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { Header } from '../Header';
|
||||
|
||||
export default function Layout({ children }) {
|
||||
return (
|
||||
<div className="bg-white min-h-screen pb-32">
|
||||
<Header />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
25
examples/openspending/datasets.json
Normal file
25
examples/openspending/datasets.json
Normal file
@@ -0,0 +1,25 @@
|
||||
[
|
||||
{
|
||||
"owner": "os-data",
|
||||
"branch": "main",
|
||||
"repo": "mongolia-budget-2016-2017",
|
||||
"files": [
|
||||
"data/mongolia-2017.csv",
|
||||
"data/mongolia-2017__2017.csv"
|
||||
]
|
||||
},
|
||||
{
|
||||
"owner": "os-data",
|
||||
"branch": "main",
|
||||
"repo": "gb-country-regional-analysis",
|
||||
"files": [
|
||||
"data/cofog.csv",
|
||||
"data/cofog_dejargonise.csv",
|
||||
"data/cra.csv",
|
||||
"data/departments.csv",
|
||||
"data/nuts_pop.csv",
|
||||
"data/pogs.csv"
|
||||
],
|
||||
"readme": "README.md"
|
||||
}
|
||||
]
|
||||
@@ -1,289 +0,0 @@
|
||||
/**
|
||||
* Fiscal Data Package is a simple specification for data access and delivery of fiscal data.
|
||||
*/
|
||||
export type FiscalDataPackage = TabularDataPackage & {
|
||||
countryCode?: ISO31661Alpha2CountryCode
|
||||
regionCode?: string
|
||||
cityCode?: string
|
||||
author?: string
|
||||
readme?: string
|
||||
granularity?: GranularityOfResources
|
||||
fiscalPeriod?: FiscalPeriodForTheBudget
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* The profile of this descriptor.
|
||||
*/
|
||||
export type Profile = "tabular-data-package"
|
||||
/**
|
||||
* An identifier string. Lower case characters with `.`, `_`, `-` and `/` are allowed.
|
||||
*/
|
||||
export type Name = string
|
||||
/**
|
||||
* A property reserved for globally unique identifiers. Examples of identifiers that are unique include UUIDs and DOIs.
|
||||
*/
|
||||
export type ID = string
|
||||
/**
|
||||
* A human-readable title.
|
||||
*/
|
||||
export type Title = string
|
||||
/**
|
||||
* A text description. Markdown is encouraged.
|
||||
*/
|
||||
export type Description = string
|
||||
/**
|
||||
* The home on the web that is related to this data package.
|
||||
*/
|
||||
export type HomePage = string
|
||||
/**
|
||||
* The datetime on which this descriptor was created.
|
||||
*/
|
||||
export type Created = string
|
||||
/**
|
||||
* The contributors to this descriptor.
|
||||
*/
|
||||
export type Contributors = [Contributor, ...Contributor[]]
|
||||
/**
|
||||
* A human-readable title.
|
||||
*/
|
||||
export type Title1 = string
|
||||
/**
|
||||
* A fully qualified URL, or a POSIX file path.
|
||||
*/
|
||||
export type Path = string
|
||||
/**
|
||||
* An email address.
|
||||
*/
|
||||
export type Email = string
|
||||
/**
|
||||
* An organizational affiliation for this contributor.
|
||||
*/
|
||||
export type Organization = string
|
||||
/**
|
||||
* A list of keywords that describe this package.
|
||||
*/
|
||||
export type Keywords = [string, ...string[]]
|
||||
/**
|
||||
* A image to represent this package.
|
||||
*/
|
||||
export type Image = string
|
||||
/**
|
||||
* The license(s) under which this package is published.
|
||||
*/
|
||||
export type Licenses = [License, ...License[]]
|
||||
/**
|
||||
* A license for this descriptor.
|
||||
*/
|
||||
export type License =
|
||||
| {
|
||||
[k: string]: unknown
|
||||
}
|
||||
| {
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* An `array` of Tabular Data Resource objects, each compliant with the [Tabular Data Resource](/tabular-data-resource/) specification.
|
||||
*
|
||||
/**
|
||||
* A Tabular Data Resource.
|
||||
*/
|
||||
export interface TabularDataResource {
|
||||
format?: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
title?: string;
|
||||
schema?: Schema;
|
||||
sample?: any[];
|
||||
profile?: string;
|
||||
key?: string;
|
||||
path?: string;
|
||||
size?: number;
|
||||
bytes?: number;
|
||||
}
|
||||
|
||||
export interface Field {
|
||||
name: string;
|
||||
type: FieldType;
|
||||
}
|
||||
|
||||
export interface Schema {
|
||||
fields: Field[];
|
||||
}
|
||||
|
||||
export const OptionsFields = [
|
||||
"any",
|
||||
"array",
|
||||
"boolean",
|
||||
"date",
|
||||
"datetime",
|
||||
"duration",
|
||||
"geojson",
|
||||
"geopoint",
|
||||
"integer",
|
||||
"number",
|
||||
"object",
|
||||
"string",
|
||||
"time",
|
||||
"year",
|
||||
"yearmonth",
|
||||
] as const;
|
||||
|
||||
type FieldType = typeof OptionsFields[number];
|
||||
/**
|
||||
* A human-readable title.
|
||||
*/
|
||||
export type Title2 = string
|
||||
/**
|
||||
* A fully qualified URL, or a POSIX file path.
|
||||
*/
|
||||
export type Path1 = string
|
||||
/**
|
||||
* An email address.
|
||||
*/
|
||||
export type Email1 = string
|
||||
/**
|
||||
* The raw sources for this resource.
|
||||
*/
|
||||
export type Sources = Source[]
|
||||
|
||||
/**
|
||||
* A keyword that represents the direction of the spend, either expenditure or revenue.
|
||||
*/
|
||||
export type DirectionOfTheSpending = "expenditure" | "revenue"
|
||||
/**
|
||||
* A keyword that represents the phase of the data, can be proposed for a budget proposal, approved for an approved budget, adjusted for modified budget or executed for the enacted budget
|
||||
*/
|
||||
export type BudgetPhase = "proposed" | "approved" | "adjusted" | "executed"
|
||||
/**
|
||||
* Either an array of strings corresponding to the name attributes in a set of field objects in the fields array or a single string corresponding to one of these names. The value of primaryKey indicates the primary key or primary keys for the dimension.
|
||||
*/
|
||||
export type PrimaryKey = string | [string, ...string[]]
|
||||
/**
|
||||
* Describes what kind of a dimension it is.
|
||||
*/
|
||||
export type DimensionType =
|
||||
| "datetime"
|
||||
| "entity"
|
||||
| "classification"
|
||||
| "activity"
|
||||
| "fact"
|
||||
| "location"
|
||||
| "other"
|
||||
/**
|
||||
* The type of the classification.
|
||||
*/
|
||||
export type ClassificationType = "functional" | "administrative" | "economic"
|
||||
/**
|
||||
* A valid 2-digit ISO country code (ISO 3166-1 alpha-2), or, an array of valid ISO codes.
|
||||
*/
|
||||
export type ISO31661Alpha2CountryCode = string | [string, ...string[]]
|
||||
/**
|
||||
* A keyword that represents the type of spend data, eiter aggregated or transactional
|
||||
*/
|
||||
export type GranularityOfResources = "aggregated" | "transactional"
|
||||
|
||||
/**
|
||||
* Tabular Data Package
|
||||
*/
|
||||
export interface TabularDataPackage {
|
||||
profile: Profile
|
||||
name?: Name
|
||||
id?: ID
|
||||
title?: Title
|
||||
description?: Description
|
||||
homepage?: HomePage
|
||||
created?: Created
|
||||
contributors?: Contributors
|
||||
keywords?: Keywords
|
||||
image?: Image
|
||||
licenses?: Licenses
|
||||
resources: TabularDataResource[]
|
||||
sources?: Sources
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* A contributor to this descriptor.
|
||||
*/
|
||||
export interface Contributor {
|
||||
title: Title1
|
||||
path?: Path
|
||||
email?: Email
|
||||
organization?: Organization
|
||||
role?: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* A source file.
|
||||
*/
|
||||
export interface Source {
|
||||
title: Title2
|
||||
path?: Path1
|
||||
email?: Email1
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* Measures are numerical and correspond to financial amounts in the source data.
|
||||
*/
|
||||
export interface Measures {
|
||||
[k: string]: Measure
|
||||
}
|
||||
/**
|
||||
* Measure.
|
||||
*
|
||||
* This interface was referenced by `Measures`'s JSON-Schema definition
|
||||
* via the `patternProperty` "^\w+".
|
||||
*/
|
||||
export interface Measure {
|
||||
source: string
|
||||
resource?: string
|
||||
currency: string
|
||||
factor?: number
|
||||
direction?: DirectionOfTheSpending
|
||||
phase?: BudgetPhase
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* Dimensions are groups of related fields. Dimensions cover all items other than the measure.
|
||||
*/
|
||||
export interface Dimensions {
|
||||
[k: string]: Dimension
|
||||
}
|
||||
/**
|
||||
* Dimension.
|
||||
*
|
||||
* This interface was referenced by `Dimensions`'s JSON-Schema definition
|
||||
* via the `patternProperty` "^\w+".
|
||||
*/
|
||||
export interface Dimension {
|
||||
attributes: Attributes
|
||||
primaryKey: PrimaryKey
|
||||
dimensionType?: DimensionType
|
||||
classificationType?: ClassificationType
|
||||
[k: string]: unknown
|
||||
}
|
||||
/**
|
||||
* Attribute objects that make up the dimension
|
||||
*/
|
||||
export interface Attributes {
|
||||
/**
|
||||
* This interface was referenced by `Attributes`'s JSON-Schema definition
|
||||
* via the `patternProperty` "^\w+".
|
||||
*/
|
||||
[k: string]: {
|
||||
source: string
|
||||
resource?: string
|
||||
constant?: string | number
|
||||
parent?: string
|
||||
labelfor?: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The fiscal period of the dataset
|
||||
*/
|
||||
export interface FiscalPeriodForTheBudget {
|
||||
start: string
|
||||
end?: string
|
||||
[k: string]: unknown
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import { FiscalDataPackage } from './datapackage.interface';
|
||||
import { Project } from './project.interface';
|
||||
|
||||
export function loadDataPackage(datapackage: FiscalDataPackage, repo): Project {
|
||||
return {
|
||||
name: datapackage.name,
|
||||
title: datapackage.title,
|
||||
description: datapackage.description || null,
|
||||
owner: {
|
||||
name: repo.owner.login,
|
||||
logo: repo.owner.avatar_url,
|
||||
// TODO: make this title work
|
||||
title: repo.owner.login,
|
||||
},
|
||||
repo: { name: repo.name, full_name: repo.full_name, url: repo.html_url },
|
||||
files: datapackage.resources,
|
||||
author: datapackage.author ? datapackage.author : null,
|
||||
cityCode: datapackage.cityCode ? datapackage.cityCode : null,
|
||||
countryCode: datapackage.countryCode
|
||||
? (datapackage.countryCode as string)
|
||||
: null,
|
||||
fiscalPeriod: datapackage.fiscalPeriod
|
||||
? {
|
||||
start: datapackage.fiscalPeriod.start
|
||||
? datapackage.fiscalPeriod.start
|
||||
: null,
|
||||
end: datapackage.fiscalPeriod.end
|
||||
? datapackage.fiscalPeriod.end
|
||||
: null,
|
||||
}
|
||||
: null,
|
||||
readme: datapackage.readme ? datapackage.readme : '',
|
||||
datapackage,
|
||||
};
|
||||
}
|
||||
@@ -13,7 +13,8 @@ export interface GithubProject {
|
||||
export async function getProjectReadme(
|
||||
owner: string,
|
||||
repo: string,
|
||||
branch: string = 'main',
|
||||
branch: string,
|
||||
readme: string,
|
||||
github_pat?: string
|
||||
) {
|
||||
const octokit = new Octokit({ auth: github_pat });
|
||||
@@ -21,7 +22,7 @@ export async function getProjectReadme(
|
||||
const response = await octokit.rest.repos.getContent({
|
||||
owner,
|
||||
repo,
|
||||
path: 'README.md',
|
||||
path: readme,
|
||||
ref: branch,
|
||||
});
|
||||
const data = response.data as { content?: string };
|
||||
@@ -124,6 +125,7 @@ export async function getProject(project: GithubProject, github_pat?: string) {
|
||||
project.owner,
|
||||
project.repo,
|
||||
project.branch,
|
||||
project.readme,
|
||||
github_pat
|
||||
);
|
||||
|
||||
@@ -138,8 +140,7 @@ export async function getProject(project: GithubProject, github_pat?: string) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let projectBase = '',
|
||||
last_updated = '';
|
||||
let projectBase = "", last_updated = "";
|
||||
if (projectReadme) {
|
||||
projectBase =
|
||||
project.readme.split('/').length > 1
|
||||
@@ -161,65 +162,3 @@ export async function getProject(project: GithubProject, github_pat?: string) {
|
||||
base_path: projectBase,
|
||||
};
|
||||
}
|
||||
|
||||
export async function getProjectDataPackage(
|
||||
owner: string,
|
||||
repo: string,
|
||||
branch: string,
|
||||
github_pat?: string
|
||||
) {
|
||||
const octokit = new Octokit({ auth: github_pat });
|
||||
try {
|
||||
const response = await octokit.rest.repos.getContent({
|
||||
owner,
|
||||
repo,
|
||||
path: 'datapackage.json',
|
||||
ref: branch,
|
||||
});
|
||||
const data = response.data as { content?: string };
|
||||
const fileContent = data.content ? data.content : '';
|
||||
if (fileContent === '') {
|
||||
return null;
|
||||
}
|
||||
const decodedContent = Buffer.from(fileContent, 'base64').toString();
|
||||
const datapackage = JSON.parse(decodedContent);
|
||||
|
||||
return { ...datapackage, repo };
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getAllProjectsFromOrg(
|
||||
org: string,
|
||||
branch?: string,
|
||||
github_pat?: string
|
||||
) {
|
||||
const octokit = new Octokit({ auth: github_pat });
|
||||
const repos = await octokit.rest.repos.listForOrg({
|
||||
org,
|
||||
type: 'public',
|
||||
per_page: 100,
|
||||
});
|
||||
let failedProjects = [];
|
||||
const projects = await Promise.all(
|
||||
repos.data.map(async (_repo) => {
|
||||
const project = await getProjectDataPackage(
|
||||
org,
|
||||
_repo.name,
|
||||
branch ? branch : 'main',
|
||||
github_pat
|
||||
);
|
||||
if (!project) {
|
||||
failedProjects.push(_repo.name);
|
||||
return null;
|
||||
}
|
||||
|
||||
return { datapackage: project, repo: _repo };
|
||||
})
|
||||
);
|
||||
return {
|
||||
results: projects.filter((item) => item !== null),
|
||||
failed: failedProjects,
|
||||
};
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
import {
|
||||
FiscalDataPackage,
|
||||
TabularDataResource,
|
||||
} from './datapackage.interface';
|
||||
|
||||
export interface Project {
|
||||
owner: { name: string; logo?: string; title?: string }; // Info about the owner of the data repo
|
||||
repo: { name: string; full_name: string; url: string }; // Info about the the data repo
|
||||
files: TabularDataResource[];
|
||||
name: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
author?: string;
|
||||
cityCode?: string;
|
||||
countryCode?: string;
|
||||
fiscalPeriod?: {
|
||||
start: string;
|
||||
end: string;
|
||||
};
|
||||
readme?: string;
|
||||
datapackage: FiscalDataPackage;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
[
|
||||
"os-data"
|
||||
]
|
||||
3981
examples/openspending/package-lock.json
generated
3981
examples/openspending/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,42 +6,30 @@
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"test": "vitest"
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@githubocto/flat-ui": "^0.14.1",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@octokit/plugin-throttling": "^5.2.2",
|
||||
"@types/flexsearch": "^0.7.3",
|
||||
"@types/node": "18.16.0",
|
||||
"@types/react": "18.0.38",
|
||||
"@types/react-dom": "18.0.11",
|
||||
"@vitejs/plugin-react": "^4.0.0",
|
||||
"clsx": "^1.2.1",
|
||||
"eslint": "8.39.0",
|
||||
"eslint-config-next": "13.3.1",
|
||||
"flexsearch": "0.7.21",
|
||||
"next": "13.3.1",
|
||||
"next-seo": "^6.0.0",
|
||||
"octokit": "^2.0.14",
|
||||
"papaparse": "^5.4.1",
|
||||
"prettier": "^2.8.8",
|
||||
"react": "18.2.0",
|
||||
"react-dom": "18.2.0",
|
||||
"react-hook-form": "^7.43.9",
|
||||
"react-markdown": "^8.0.7",
|
||||
"react-query": "^3.39.3",
|
||||
"react-timeago": "^7.1.0",
|
||||
"remark-gfm": "^3.0.1",
|
||||
"typescript": "5.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/typography": "^0.5.9",
|
||||
"@types/papaparse": "^5.3.7",
|
||||
"autoprefixer": "^10.4.14",
|
||||
"postcss": "^8.4.23",
|
||||
"tailwindcss": "^3.3.1",
|
||||
"vitest": "^0.31.0"
|
||||
"tailwindcss": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
126
examples/openspending/pages/@org/[org]/[...path].tsx
Normal file
126
examples/openspending/pages/@org/[org]/[...path].tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
import { NextSeo } from 'next-seo';
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
import getConfig from 'next/config';
|
||||
import { getProject, GithubProject } from '../../../lib/octokit';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import Breadcrumbs from '../../../components/_shared/Breadcrumbs';
|
||||
|
||||
export default function ProjectPage({ project }) {
|
||||
const repoId = `@${project.repo_config.owner}/${project.repo_config.repo}`
|
||||
|
||||
return (
|
||||
<>
|
||||
<NextSeo title={`${repoId}${project.base_path !== '/' ? '/' + project.base_path : ''} - GitHub Datasets`} />
|
||||
<main className="prose mx-auto my-8">
|
||||
<Breadcrumbs links={[{ title: repoId, href: "" }]} />
|
||||
<h1 className="mb-0 mt-16">{project.repo_config.name || repoId}</h1>
|
||||
<p className='mb-8'><span className='font-semibold'>Repository:</span> <a target="_blank" href={project.html_url}>{project.html_url}</a></p>
|
||||
|
||||
<h2 className="mb-0 mt-10">Files</h2>
|
||||
<div className="inline-block min-w-full py-2 align-middle">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Name
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Size
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
{project.files.map((file) => (
|
||||
<tr key={file.download_url}>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<a href={file.download_url}>{file.name}</a>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{file.size} Bytes
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{project.readmeContent && <>
|
||||
<hr />
|
||||
|
||||
<h2 className='uppercase font-black'>Readme</h2>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>
|
||||
{project.readmeContent}
|
||||
</ReactMarkdown>
|
||||
</>}
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// Generates `/posts/1` and `/posts/2`
|
||||
export async function getStaticPaths() {
|
||||
const jsonDirectory = path.join(
|
||||
process.cwd(),
|
||||
'datasets.json'
|
||||
);
|
||||
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
||||
|
||||
return {
|
||||
paths: JSON.parse(repos).map((repo) => {
|
||||
const projectPath =
|
||||
repo.readme && repo.readme.split('/').length > 1
|
||||
? repo.readme.split('/').slice(0, -1)
|
||||
: null;
|
||||
let path = [repo.repo];
|
||||
if (projectPath) {
|
||||
projectPath.forEach((element) => {
|
||||
path.push(element);
|
||||
});
|
||||
}
|
||||
return {
|
||||
params: { org: repo.owner, path },
|
||||
};
|
||||
}),
|
||||
fallback: false, // can also be true or 'blocking'
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticProps({ params }) {
|
||||
const jsonDirectory = path.join(
|
||||
process.cwd(),
|
||||
'datasets.json'
|
||||
);
|
||||
const reposFile = await fs.readFile(jsonDirectory, 'utf8');
|
||||
const repos: GithubProject[] = JSON.parse(reposFile);
|
||||
const repo = repos.find((_repo) => {
|
||||
const projectPath =
|
||||
_repo.readme && _repo.readme.split('/').length > 1
|
||||
? _repo.readme.split('/').slice(0, -1)
|
||||
: null;
|
||||
let path = [_repo.repo];
|
||||
if (projectPath) {
|
||||
projectPath.forEach((element) => {
|
||||
path.push(element);
|
||||
});
|
||||
}
|
||||
return (
|
||||
_repo.owner == params.org &&
|
||||
JSON.stringify(path) === JSON.stringify(params.path)
|
||||
);
|
||||
});
|
||||
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
||||
const project = await getProject(repo, github_pat);
|
||||
return {
|
||||
props: {
|
||||
project: { ...project, repo_config: repo },
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,275 +0,0 @@
|
||||
import { NextSeo } from 'next-seo';
|
||||
import getConfig from 'next/config';
|
||||
import {
|
||||
getAllProjectsFromOrg,
|
||||
getProjectDataPackage,
|
||||
getProjectMetadata,
|
||||
getProjectReadme,
|
||||
} from '../../../lib/project';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import { loadDataPackage } from '../../../lib/loader';
|
||||
import Layout from '../../../components/_shared/Layout';
|
||||
import Link from 'next/link';
|
||||
import { Project } from '../../../lib/project.interface';
|
||||
import ExternalLinkIcon from '../../../components/icons/ExternalLinkIcon';
|
||||
import { FlatUiTable } from '@/components/FlatUiTable';
|
||||
|
||||
export default function ProjectPage({
|
||||
project,
|
||||
readme,
|
||||
}: {
|
||||
project: Project;
|
||||
readme: string;
|
||||
}) {
|
||||
// Get description from datapackage or calculate
|
||||
// excerpt from README by getting all the content
|
||||
// up to the first dot.
|
||||
const description =
|
||||
project.description || (readme && readme.slice(0, readme.indexOf('.') + 1));
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<NextSeo title={`${project.title} - OpenSpending`} />
|
||||
<main className="prose mx-auto my-8">
|
||||
<h1 className="mb-1 mt-16">{project.title || project.name}</h1>
|
||||
<Link target="_blank" href={project.repo.url}>
|
||||
@{project.repo.full_name}
|
||||
</Link>
|
||||
|
||||
{description && (
|
||||
<div className="inline-block min-w-full py-2 align-middle mt-5">
|
||||
{description}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="inline-block min-w-full py-2 align-middle">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Name
|
||||
</th>
|
||||
{project.datapackage.countryCode && (
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Country
|
||||
</th>
|
||||
)}
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Metadata
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
<tr>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{project.name}
|
||||
</td>
|
||||
{project.datapackage.countryCode && (
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{project.datapackage.countryCode}
|
||||
</td>
|
||||
)}
|
||||
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<Link
|
||||
// TODO: this link may be incorrect for some datasets
|
||||
href={`https://github.com/${project.owner.name}/${project.repo.name}/blob/main/datapackage.json`}
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-gray-700"
|
||||
>
|
||||
datapackage.json <ExternalLinkIcon className="ml-1" />
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<h3 className="mb-1 mt-10">Data files</h3>
|
||||
<p>
|
||||
This dataset contains {project.files.length} file
|
||||
{project.files.length == 1 ? '' : 's'}
|
||||
</p>
|
||||
<div className="inline-block min-w-full py-2 align-middle">
|
||||
<table className="mt-0 min-w-full divide-y divide-gray-300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Name
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Format
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Size
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
{project.files?.map((file) => {
|
||||
let size: number | string = file.size;
|
||||
|
||||
if (!size) {
|
||||
if (file.bytes) {
|
||||
if (file.bytes > 1000000) {
|
||||
size = (file.bytes / 1000000).toFixed(2) + ' MB';
|
||||
} else {
|
||||
size = (file.bytes / 1000).toFixed(2) + ' kB';
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<tr key={file.name}>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{file.name}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{file.format}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
{size}
|
||||
</td>
|
||||
|
||||
<td className="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
||||
<Link
|
||||
target="_blank"
|
||||
href={
|
||||
file.path.startsWith('http')
|
||||
? file.path
|
||||
: `https://raw.githubusercontent.com/${project.owner.name}/${project.repo.name}/main/${file.path}`
|
||||
}
|
||||
>
|
||||
Download
|
||||
</Link>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-y-16 ">
|
||||
{project.files?.map((file) => {
|
||||
let size: number | string = file.size;
|
||||
|
||||
if (!size) {
|
||||
if (file.bytes) {
|
||||
if (file.bytes > 1000000) {
|
||||
size = (file.bytes / 1000000).toFixed(2) + ' MB';
|
||||
} else {
|
||||
size = (file.bytes / 1000).toFixed(2) + ' kB';
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<div key={file.name}>
|
||||
{file.path && (
|
||||
<>
|
||||
<h4>
|
||||
{file.name}
|
||||
{file.format ? `.${file.format}` : ''}
|
||||
</h4>
|
||||
{file.bytes >= 5132288 && (
|
||||
<span>Previewing 5MB out of {size}</span>
|
||||
)}
|
||||
<FlatUiTable
|
||||
url={
|
||||
file.path.startsWith('http')
|
||||
? file.path
|
||||
: `https://raw.githubusercontent.com/${project.owner.name}/${project.repo.name}/main/${file.path}`
|
||||
}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{readme && (
|
||||
<>
|
||||
<hr />
|
||||
|
||||
<h2 className="uppercase font-black">Readme</h2>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{readme}</ReactMarkdown>
|
||||
</>
|
||||
)}
|
||||
</main>
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
// Generates `/posts/1` and `/posts/2`
|
||||
export async function getStaticPaths() {
|
||||
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
||||
|
||||
const allProjects = await getAllProjectsFromOrg(
|
||||
'os-data',
|
||||
'main',
|
||||
github_pat
|
||||
);
|
||||
|
||||
const paths = allProjects.results.map((project) => ({
|
||||
params: {
|
||||
// TODO: dynamize the org
|
||||
org: 'os-data',
|
||||
project: project.repo.name,
|
||||
},
|
||||
}));
|
||||
|
||||
return {
|
||||
paths,
|
||||
fallback: false, // can also be true or 'blocking'
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticProps({ params }) {
|
||||
const { org: orgName, project: projectName } = params;
|
||||
|
||||
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
||||
const datapackage = await getProjectDataPackage(
|
||||
orgName,
|
||||
projectName,
|
||||
'main',
|
||||
github_pat
|
||||
);
|
||||
|
||||
const repo = await getProjectMetadata(orgName, projectName, github_pat);
|
||||
|
||||
const project = loadDataPackage(datapackage, repo);
|
||||
|
||||
// TODO: should this be moved to the loader?
|
||||
const readme = await getProjectReadme(
|
||||
orgName,
|
||||
projectName,
|
||||
'main',
|
||||
github_pat
|
||||
);
|
||||
|
||||
return {
|
||||
props: {
|
||||
project,
|
||||
readme,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
import { AppProps } from 'next/app';
|
||||
import Head from 'next/head';
|
||||
import './styles.css';
|
||||
import { NextSeo } from 'next-seo';
|
||||
|
||||
function CustomApp({ Component, pageProps }: AppProps) {
|
||||
return (
|
||||
<>
|
||||
<NextSeo title="OpenSpending" />
|
||||
<Head>
|
||||
<title>GitHub Datasets</title>
|
||||
</Head>
|
||||
<main className="app">
|
||||
<Component {...pageProps} />
|
||||
</main>
|
||||
|
||||
@@ -1,59 +1,44 @@
|
||||
import { getAllProjectsFromOrg } from '../lib/project';
|
||||
import { promises as fs } from 'fs';
|
||||
import path from 'path';
|
||||
import { getProject } from '../lib/octokit';
|
||||
import getConfig from 'next/config';
|
||||
import ExternalLinkIcon from '../components/icons/ExternalLinkIcon';
|
||||
import TimeAgo from 'react-timeago';
|
||||
import Link from 'next/link';
|
||||
import { Hero } from '../components/Hero';
|
||||
import { Header } from '../components/Header';
|
||||
import { Container } from '../components/Container';
|
||||
import { FiscalDataPackage } from '../lib/datapackage.interface';
|
||||
import { loadDataPackage } from '../lib/loader';
|
||||
import DatasetsSearch from '../components/DatasetsSearch';
|
||||
import Layout from '../components/_shared/Layout';
|
||||
|
||||
export async function getStaticProps() {
|
||||
// TODO: support other orgs
|
||||
// const orgsListPath = path.join(process.cwd(), '/orgs.json');
|
||||
// const orgs = await fs.readFile(orgsListPath, 'utf8');
|
||||
|
||||
const jsonDirectory = path.join(
|
||||
process.cwd(),
|
||||
'/datasets.json'
|
||||
);
|
||||
const repos = await fs.readFile(jsonDirectory, 'utf8');
|
||||
const github_pat = getConfig().serverRuntimeConfig.github_pat;
|
||||
|
||||
const allProjects = await getAllProjectsFromOrg(
|
||||
'os-data',
|
||||
'main',
|
||||
github_pat
|
||||
const projects = await Promise.all(
|
||||
(JSON.parse(repos)).map(async (repo) => {
|
||||
const project = await getProject(repo, github_pat);
|
||||
return { ...project, repo_config: repo };
|
||||
})
|
||||
);
|
||||
|
||||
const projects = allProjects.results.map(
|
||||
(item: { datapackage: FiscalDataPackage & { repo: string }; repo: any }) =>
|
||||
loadDataPackage(item.datapackage, item.repo)
|
||||
);
|
||||
|
||||
const availableCountries = projects
|
||||
.map((item) => item.countryCode)
|
||||
.filter((v) => v) // Filters false values
|
||||
.filter((v, i, a) => a.indexOf(v) === i) // Remove duplicates
|
||||
// TODO: title should be the full name
|
||||
.map((code) => ({ code, title: code }));
|
||||
|
||||
return {
|
||||
props: {
|
||||
projects: JSON.stringify(projects),
|
||||
availableCountries,
|
||||
projects,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function Home({ projects, availableCountries }) {
|
||||
projects = JSON.parse(projects);
|
||||
|
||||
export function Datasets({ projects }) {
|
||||
return (
|
||||
<Layout>
|
||||
<Hero
|
||||
countriesCount={availableCountries.length}
|
||||
datasetsCount={projects.length}
|
||||
filesCount={projects.reduce(
|
||||
(partialSum, a) => partialSum + a.files.length,
|
||||
0
|
||||
)}
|
||||
/>
|
||||
<section className="py-20 sm:py-32">
|
||||
<div className="bg-white min-h-screen">
|
||||
<Header />
|
||||
<Hero />
|
||||
<section
|
||||
className="py-20 sm:py-32"
|
||||
>
|
||||
<Container>
|
||||
<div className="mx-auto max-w-2xl lg:mx-0">
|
||||
<h2
|
||||
@@ -66,16 +51,80 @@ export function Home({ projects, availableCountries }) {
|
||||
Find spending data about countries all around the world.
|
||||
</p>
|
||||
</div>
|
||||
<div className="mt-10">
|
||||
<DatasetsSearch
|
||||
datasets={projects}
|
||||
availableCountries={availableCountries}
|
||||
/>
|
||||
<div className="mt-5">
|
||||
<div className="-mx-4 -my-2 overflow-x-auto sm:-mx-6 lg:-mx-8">
|
||||
<div className="inline-block min-w-full py-2 align-middle sm:px-6 lg:px-8">
|
||||
<table className="min-w-full divide-y divide-gray-300">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Name
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Repository
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Description
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="px-3 py-3.5 text-left text-sm font-semibold text-gray-900"
|
||||
>
|
||||
Last updated
|
||||
</th>
|
||||
<th
|
||||
scope="col"
|
||||
className="relative py-3.5 pl-3 pr-4 sm:pr-0"
|
||||
></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
{projects.map((project) => (
|
||||
<tr key={project.id}>
|
||||
<td className="whitespace-nowrap px-3 py-6 text-sm text-gray-500">
|
||||
{project.repo_config.name
|
||||
? project.repo_config.name
|
||||
: project.full_name + (project.base_path === '/' ? '' : '/' + project.base_path)}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-6 text-sm group text-gray-500 hover:text-gray-900 transition-all duration-250">
|
||||
<a href={project.html_url} target="_blank" className='flex items-center'>@{project.full_name} <ExternalLinkIcon className='ml-1' /></a>
|
||||
</td>
|
||||
<td className="px-3 py-4 text-sm text-gray-500">
|
||||
{project.repo_config.description
|
||||
? project.repo_config.description
|
||||
: project.description}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-3 py-6 text-sm text-gray-500">
|
||||
<TimeAgo date={new Date(project.last_updated)} />
|
||||
</td>
|
||||
<td className="relative whitespace-nowrap py-6 pl-3 pr-4 text-right text-sm font-medium sm:pr-0">
|
||||
<a
|
||||
href={`/@${project.repo_config.owner}/${project.repo_config.repo}/${project.base_path === '/' ? '' : project.base_path}`}
|
||||
className='border border-gray-900 text-gray-900 px-4 py-2 transition-all hover:bg-gray-900 hover:text-white'
|
||||
>
|
||||
info
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</section>
|
||||
</Layout>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Home;
|
||||
export default Datasets;
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg fill="#000000" version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800px" height="800px" viewBox="0 0 120 120" enable-background="new 0 0 120 120" xml:space="preserve">
|
||||
<rect x="2" y="108.1" width="116" height="11.9"/>
|
||||
<rect x="6.744" y="96.582" width="104.979" height="6.543"/>
|
||||
<rect x="15.288" y="38.532" width="17.639" height="52.925"/>
|
||||
<rect x="50.484" y="38.532" width="17.639" height="52.925"/>
|
||||
<rect x="84.33" y="38.532" width="17.639" height="52.925"/>
|
||||
<polygon points="0,26.96 60,0 120,26.96 119.946,33.912 0,34.01 "/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 818 B |
@@ -13,10 +13,7 @@
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
"incremental": true
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
||||
"exclude": ["node_modules"]
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
test: {
|
||||
environment: 'jsdom',
|
||||
},
|
||||
})
|
||||
@@ -21,7 +21,6 @@ const config = {
|
||||
{ name: "Blog", href: "/blog" },
|
||||
{ name: "Showcases", href: "/#showcases" },
|
||||
{ name: "Examples", href: "https://github.com/datopian/portaljs/tree/main/examples", target: "_blank" },
|
||||
{ name: "Components", href: "https://storybook.portaljs.org", target: "_blank" },
|
||||
// { name: "DL Demo", href: "/data-literate/demo" },
|
||||
// { name: "Excel Viewer", href: "/excel-viewer" },
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user