display history of indexed jobs
This commit is contained in:
parent
f6a98e0e7e
commit
51de258d6e
17 changed files with 658 additions and 190 deletions
|
@ -17,7 +17,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@sentry/nextjs": "^7.43.0",
|
"@sentry/nextjs": "^7.43.0",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mailchimp/mailchimp_marketing": "^3.0.80",
|
"@mailchimp/mailchimp_marketing": "^3.0.80",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "0.8.0-pre.84",
|
"@saleor/macaw-ui": "0.8.0-pre.84",
|
||||||
"@sentry/nextjs": "^7.52.1",
|
"@sentry/nextjs": "^7.52.1",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@sentry/nextjs": "^7.39.0",
|
"@sentry/nextjs": "^7.39.0",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.1.0",
|
"@hookform/resolvers": "^3.1.0",
|
||||||
"@monaco-editor/react": "^4.4.6",
|
"@monaco-editor/react": "^4.4.6",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/apps-ui": "workspace:*",
|
"@saleor/apps-ui": "workspace:*",
|
||||||
"@saleor/macaw-ui": "0.8.0-pre.84",
|
"@saleor/macaw-ui": "0.8.0-pre.84",
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.1.0",
|
"@hookform/resolvers": "^3.1.0",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "0.8.0-pre.84",
|
"@saleor/macaw-ui": "0.8.0-pre.84",
|
||||||
"@sentry/nextjs": "^7.36.0",
|
"@sentry/nextjs": "^7.36.0",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@sentry/nextjs": "^7.36.0",
|
"@sentry/nextjs": "^7.36.0",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@urql/exchange-auth": "^1.0.0",
|
"@urql/exchange-auth": "^1.0.0",
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "^3.332.0",
|
"@aws-sdk/client-s3": "^3.332.0",
|
||||||
"@hookform/resolvers": "^3.1.0",
|
"@hookform/resolvers": "^3.1.0",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/apps-ui": "workspace:*",
|
"@saleor/apps-ui": "workspace:*",
|
||||||
"@saleor/macaw-ui": "0.8.0-pre.84",
|
"@saleor/macaw-ui": "0.8.0-pre.84",
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.1.0",
|
"@hookform/resolvers": "^3.1.0",
|
||||||
"@prisma/client": "^4.15.0",
|
"@prisma/client": "^4.15.0",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/apps-ui": "workspace:*",
|
"@saleor/apps-ui": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.8.0-pre.84",
|
"@saleor/macaw-ui": "^0.8.0-pre.84",
|
||||||
|
|
52
apps/search/src/components/ImportHistory.tsx
Normal file
52
apps/search/src/components/ImportHistory.tsx
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
import React from "react";
|
||||||
|
import { Prisma } from "@prisma/client";
|
||||||
|
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
|
||||||
|
import { useQuery } from "react-query";
|
||||||
|
import { Box, Text } from "@saleor/macaw-ui/next";
|
||||||
|
|
||||||
|
const fetchJobs = (fetch: typeof window.fetch) =>
|
||||||
|
fetch("/api/jobs").then((r: any) => r.json() as Prisma.IndexJob[]);
|
||||||
|
|
||||||
|
export const ImportHistory = () => {
|
||||||
|
const fetch = useAuthenticatedFetch();
|
||||||
|
|
||||||
|
const { data } = useQuery<Prisma.IndexJob[]>({
|
||||||
|
queryFn: () => fetchJobs(fetch),
|
||||||
|
refetchInterval: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box marginTop={8} as={"table"} width={"100%"}>
|
||||||
|
<Box as={"thead"}>
|
||||||
|
<td>
|
||||||
|
<Text>Job ID</Text>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Text>Created at</Text>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Text>Createdy by</Text>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<Text>Status</Text>
|
||||||
|
</td>
|
||||||
|
</Box>
|
||||||
|
{data.map((job) => (
|
||||||
|
<tr key={job.jobId}>
|
||||||
|
<td>{job.jobId}</td>
|
||||||
|
<td>
|
||||||
|
{Intl.DateTimeFormat(["en"], { timeStyle: "medium", dateStyle: "medium" }).format(
|
||||||
|
new Date(job.createdAt)
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>{job.createdBy}</td>
|
||||||
|
<td>{job.status}</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
};
|
|
@ -3,6 +3,7 @@ import React, { useEffect, useMemo, useState } from "react";
|
||||||
import { AlgoliaSearchProvider } from "../lib/algolia/algoliaSearchProvider";
|
import { AlgoliaSearchProvider } from "../lib/algolia/algoliaSearchProvider";
|
||||||
import { useConfiguration } from "../lib/configuration";
|
import { useConfiguration } from "../lib/configuration";
|
||||||
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
|
import { useAuthenticatedFetch } from "@saleor/app-sdk/app-bridge";
|
||||||
|
import { ImportHistory } from "./ImportHistory";
|
||||||
|
|
||||||
export const ImportProductsToAlgolia = () => {
|
export const ImportProductsToAlgolia = () => {
|
||||||
const fetch = useAuthenticatedFetch();
|
const fetch = useAuthenticatedFetch();
|
||||||
|
@ -48,17 +49,6 @@ export const ImportProductsToAlgolia = () => {
|
||||||
</Text>
|
</Text>
|
||||||
<Box display={"flex"} justifyContent={"flex-end"} marginTop={13}>
|
<Box display={"flex"} justifyContent={"flex-end"} marginTop={13}>
|
||||||
<Button onClick={() => fetch("/api/index-products")}>Start importing</Button>
|
<Button onClick={() => fetch("/api/index-products")}>Start importing</Button>
|
||||||
<Button
|
|
||||||
onClick={() =>
|
|
||||||
fetch("/api/jobs")
|
|
||||||
.then((r: any) => r.json())
|
|
||||||
.then((jobs: unknown) => {
|
|
||||||
console.log(jobs);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Check status
|
|
||||||
</Button>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
) : (
|
) : (
|
||||||
|
@ -69,6 +59,7 @@ export const ImportProductsToAlgolia = () => {
|
||||||
<Text>Configure Algolia first</Text>
|
<Text>Configure Algolia first</Text>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
<ImportHistory />
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,7 +14,7 @@ export default createProtectedHandler(
|
||||||
|
|
||||||
await indexingJobRepository.createPendingJob(ctx.authData.saleorApiUrl, {
|
await indexingJobRepository.createPendingJob(ctx.authData.saleorApiUrl, {
|
||||||
jobId: Number(job.id),
|
jobId: Number(job.id),
|
||||||
createdByEmail: "some-name-todo", // todo add to sdk
|
createdByEmail: ctx.user.email,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).end();
|
return res.status(200).end();
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@sentry/nextjs": "^7.30.0",
|
"@sentry/nextjs": "^7.30.0",
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/apps-shared": "workspace:*",
|
"@saleor/apps-shared": "workspace:*",
|
||||||
"@saleor/apps-ui": "workspace:*",
|
"@saleor/apps-ui": "workspace:*",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
"@material-ui/core": "^4.12.4",
|
"@material-ui/core": "^4.12.4",
|
||||||
"@material-ui/icons": "^4.11.3",
|
"@material-ui/icons": "^4.11.3",
|
||||||
"@material-ui/lab": "4.0.0-alpha.61",
|
"@material-ui/lab": "4.0.0-alpha.61",
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/macaw-ui": "^0.7.2",
|
"@saleor/macaw-ui": "^0.7.2",
|
||||||
"@types/react": "^18.0.27",
|
"@types/react": "^18.0.27",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
"typescript": "5.1.3"
|
"typescript": "5.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@saleor/app-sdk": "0.39.1",
|
"@saleor/app-sdk": "0.41.0",
|
||||||
"@saleor/macaw-ui": "0.8.0-pre.84",
|
"@saleor/macaw-ui": "0.8.0-pre.84",
|
||||||
"@types/react": "^18.0.27",
|
"@types/react": "^18.0.27",
|
||||||
"@types/react-dom": "^18.0.10",
|
"@types/react-dom": "^18.0.10",
|
||||||
|
|
755
pnpm-lock.yaml
755
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue