mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
Update Darwin Core export metadata
This commit is contained in:
@@ -6,18 +6,29 @@ import { useUser } from '@/hooks/user'
|
||||
import { Role } from '@/shared/types'
|
||||
import { currentDateAsString } from '@/shared/currentDateAsString'
|
||||
import { downloadExportFileWithProgress } from '@/util/exportProgress'
|
||||
import { usePageContext } from '../Page'
|
||||
|
||||
export const LocalityDwcExportMenuItem = ({ handleClose }: { handleClose: () => void }) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { notify, setMessage: setNotificationMessage } = useNotify()
|
||||
const user = useUser()
|
||||
const { idList } = usePageContext()
|
||||
|
||||
if (user.role !== Role.Admin) {
|
||||
return null
|
||||
}
|
||||
|
||||
const fetchOptions = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filename = `now_dwc_localities_test_export_${currentDateAsString()}.zip`
|
||||
const fetchOptions: RequestInit = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filteredFetchOptions: RequestInit = {
|
||||
...fetchOptions,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(fetchOptions.headers as Record<string, string> | undefined),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ ids: idList }),
|
||||
}
|
||||
const filename = `now_dwc_localities_export_${currentDateAsString()}.zip`
|
||||
|
||||
const fetchZipFile = async () => {
|
||||
setLoading(true)
|
||||
@@ -26,7 +37,7 @@ export const LocalityDwcExportMenuItem = ({ handleClose }: { handleClose: () =>
|
||||
await downloadExportFileWithProgress({
|
||||
url: `${BACKEND_URL}/locality/export/dwc-archive`,
|
||||
filename,
|
||||
fetchOptions,
|
||||
fetchOptions: filteredFetchOptions,
|
||||
notify,
|
||||
setNotificationMessage,
|
||||
startMessage: 'Generating DwC-A locality ZIP export...',
|
||||
|
||||
@@ -6,18 +6,29 @@ import { useUser } from '@/hooks/user'
|
||||
import { Role } from '@/shared/types'
|
||||
import { currentDateAsString } from '@/shared/currentDateAsString'
|
||||
import { downloadExportFileWithProgress } from '@/util/exportProgress'
|
||||
import { usePageContext } from '../Page'
|
||||
|
||||
export const OccurrenceDwcDpExportMenuItem = ({ handleClose }: { handleClose: () => void }) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { notify, setMessage: setNotificationMessage } = useNotify()
|
||||
const user = useUser()
|
||||
const { sqlColumnFilters, sqlOrderBy } = usePageContext()
|
||||
|
||||
if (user.role !== Role.Admin) {
|
||||
return null
|
||||
}
|
||||
|
||||
const fetchOptions = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filename = `now_dwc_dp_test_export_${currentDateAsString()}.zip`
|
||||
const fetchOptions: RequestInit = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filteredFetchOptions: RequestInit = {
|
||||
...fetchOptions,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(fetchOptions.headers as Record<string, string> | undefined),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ columnFilters: sqlColumnFilters, sorting: sqlOrderBy }),
|
||||
}
|
||||
const filename = `now_dwc_dp_export_${currentDateAsString()}.zip`
|
||||
|
||||
const fetchZipFile = async () => {
|
||||
setLoading(true)
|
||||
@@ -26,7 +37,7 @@ export const OccurrenceDwcDpExportMenuItem = ({ handleClose }: { handleClose: ()
|
||||
await downloadExportFileWithProgress({
|
||||
url: `${BACKEND_URL}/occurrence/export/dwc-data-package`,
|
||||
filename,
|
||||
fetchOptions,
|
||||
fetchOptions: filteredFetchOptions,
|
||||
notify,
|
||||
setNotificationMessage,
|
||||
startMessage: 'Generating DwC-DP ZIP export...',
|
||||
|
||||
@@ -6,18 +6,29 @@ import { useUser } from '@/hooks/user'
|
||||
import { Role } from '@/shared/types'
|
||||
import { currentDateAsString } from '@/shared/currentDateAsString'
|
||||
import { createExportId, downloadExportFileWithProgress } from '@/util/exportProgress'
|
||||
import { usePageContext } from '../Page'
|
||||
|
||||
export const OccurrenceDwcExportMenuItem = ({ handleClose }: { handleClose: () => void }) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { notify, setMessage: setNotificationMessage } = useNotify()
|
||||
const user = useUser()
|
||||
const { sqlColumnFilters, sqlOrderBy } = usePageContext()
|
||||
|
||||
if (user.role !== Role.Admin) {
|
||||
return null
|
||||
}
|
||||
|
||||
const fetchOptions = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filename = `now_dwc_occurrences_test_export_${currentDateAsString()}.zip`
|
||||
const fetchOptions: RequestInit = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filteredFetchOptions: RequestInit = {
|
||||
...fetchOptions,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(fetchOptions.headers as Record<string, string> | undefined),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ columnFilters: sqlColumnFilters, sorting: sqlOrderBy }),
|
||||
}
|
||||
const filename = `now_dwc_occurrences_export_${currentDateAsString()}.zip`
|
||||
|
||||
const fetchZipFile = async () => {
|
||||
setLoading(true)
|
||||
@@ -27,7 +38,7 @@ export const OccurrenceDwcExportMenuItem = ({ handleClose }: { handleClose: () =
|
||||
url: `${BACKEND_URL}/occurrence/export/dwc-archive?${new URLSearchParams({ exportId })}`,
|
||||
progressUrl: `${BACKEND_URL}/occurrence/export/dwc-archive/progress/${exportId}`,
|
||||
filename,
|
||||
fetchOptions,
|
||||
fetchOptions: filteredFetchOptions,
|
||||
notify,
|
||||
setNotificationMessage,
|
||||
startMessage: 'Generating DwC-A occurrence ZIP export...',
|
||||
|
||||
@@ -6,18 +6,29 @@ import { useUser } from '@/hooks/user'
|
||||
import { Role } from '@/shared/types'
|
||||
import { currentDateAsString } from '@/shared/currentDateAsString'
|
||||
import { downloadExportFileWithProgress } from '@/util/exportProgress'
|
||||
import { usePageContext } from '../Page'
|
||||
|
||||
export const OccurrenceFullDarwinCoreExportMenuItem = ({ handleClose }: { handleClose: () => void }) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { notify, setMessage: setNotificationMessage } = useNotify()
|
||||
const user = useUser()
|
||||
const { sqlColumnFilters, sqlOrderBy } = usePageContext()
|
||||
|
||||
if (user.role !== Role.Admin) {
|
||||
return null
|
||||
}
|
||||
|
||||
const fetchOptions = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filename = `now_dwc_full_test_export_${currentDateAsString()}.zip`
|
||||
const fetchOptions: RequestInit = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filteredFetchOptions: RequestInit = {
|
||||
...fetchOptions,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(fetchOptions.headers as Record<string, string> | undefined),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ columnFilters: sqlColumnFilters, sorting: sqlOrderBy }),
|
||||
}
|
||||
const filename = `now_dwc_full_export_${currentDateAsString()}.zip`
|
||||
|
||||
const fetchZipFile = async () => {
|
||||
setLoading(true)
|
||||
@@ -26,7 +37,7 @@ export const OccurrenceFullDarwinCoreExportMenuItem = ({ handleClose }: { handle
|
||||
await downloadExportFileWithProgress({
|
||||
url: `${BACKEND_URL}/occurrence/export/dwc-full-package`,
|
||||
filename,
|
||||
fetchOptions,
|
||||
fetchOptions: filteredFetchOptions,
|
||||
notify,
|
||||
setNotificationMessage,
|
||||
startMessage: 'Generating full Darwin Core ZIP export...',
|
||||
|
||||
@@ -6,18 +6,29 @@ import { useUser } from '@/hooks/user'
|
||||
import { Role } from '@/shared/types'
|
||||
import { currentDateAsString } from '@/shared/currentDateAsString'
|
||||
import { downloadExportFileWithProgress } from '@/util/exportProgress'
|
||||
import { usePageContext } from '../Page'
|
||||
|
||||
export const SpeciesDwcExportMenuItem = ({ handleClose }: { handleClose: () => void }) => {
|
||||
const [loading, setLoading] = useState(false)
|
||||
const { notify, setMessage: setNotificationMessage } = useNotify()
|
||||
const user = useUser()
|
||||
const { idList } = usePageContext()
|
||||
|
||||
if (user.role !== Role.Admin) {
|
||||
return null
|
||||
}
|
||||
|
||||
const fetchOptions = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filename = `now_dwc_test_export_${currentDateAsString()}.zip`
|
||||
const fetchOptions: RequestInit = user.token ? { headers: { Authorization: `Bearer ${user.token}` } } : {}
|
||||
const filteredFetchOptions: RequestInit = {
|
||||
...fetchOptions,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...(fetchOptions.headers as Record<string, string> | undefined),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ ids: idList }),
|
||||
}
|
||||
const filename = `now_dwc_export_${currentDateAsString()}.zip`
|
||||
|
||||
const fetchZipFile = async () => {
|
||||
setLoading(true)
|
||||
@@ -26,7 +37,7 @@ export const SpeciesDwcExportMenuItem = ({ handleClose }: { handleClose: () => v
|
||||
await downloadExportFileWithProgress({
|
||||
url: `${BACKEND_URL}/species/export/dwc-archive`,
|
||||
filename,
|
||||
fetchOptions,
|
||||
fetchOptions: filteredFetchOptions,
|
||||
notify,
|
||||
setNotificationMessage,
|
||||
startMessage: 'Generating DwC-A taxon ZIP export...',
|
||||
|
||||
Reference in New Issue
Block a user