mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-08-26 06:09:23 +00:00
Automate/v2/suggested (#4257)
Suggested pipelines now work --------- Co-authored-by: Connor Yoh <connor@stirlingpdf.com> Co-authored-by: Anthony Stirling <77850077+Frooodle@users.noreply.github.com>
This commit is contained in:
parent
895bcebc7b
commit
e6f4cfb318
@ -1,6 +1,9 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import StarIcon from '@mui/icons-material/Star';
|
import StarIcon from '@mui/icons-material/Star';
|
||||||
|
import CompressIcon from '@mui/icons-material/Compress';
|
||||||
|
import SecurityIcon from '@mui/icons-material/Security';
|
||||||
|
import TextFieldsIcon from '@mui/icons-material/TextFields';
|
||||||
import { SuggestedAutomation } from '../../../types/automation';
|
import { SuggestedAutomation } from '../../../types/automation';
|
||||||
|
|
||||||
export function useSuggestedAutomations(): SuggestedAutomation[] {
|
export function useSuggestedAutomations(): SuggestedAutomation[] {
|
||||||
@ -10,37 +13,119 @@ export function useSuggestedAutomations(): SuggestedAutomation[] {
|
|||||||
const now = new Date().toISOString();
|
const now = new Date().toISOString();
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: "compress-and-merge",
|
id: "compress-and-split",
|
||||||
name: t("automation.suggested.compressAndMerge", "Compress & Merge"),
|
name: t("automation.suggested.compressAndSplit", "Compress & Split"),
|
||||||
description: t("automation.suggested.compressAndMergeDesc", "Compress PDFs and merge them into one file"),
|
description: t("automation.suggested.compressAndSplitDesc", "Compress PDFs and split them by pages"),
|
||||||
operations: [
|
operations: [
|
||||||
{ operation: "compress", parameters: {} },
|
{
|
||||||
{ operation: "merge", parameters: {} }
|
operation: "compress",
|
||||||
|
parameters: {
|
||||||
|
compressionLevel: 5,
|
||||||
|
grayscale: false,
|
||||||
|
expectedSize: '',
|
||||||
|
compressionMethod: 'quality',
|
||||||
|
fileSizeValue: '',
|
||||||
|
fileSizeUnit: 'MB',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operation: "splitPdf",
|
||||||
|
parameters: {
|
||||||
|
mode: 'bySizeOrCount',
|
||||||
|
pages: '1',
|
||||||
|
hDiv: '2',
|
||||||
|
vDiv: '2',
|
||||||
|
merge: false,
|
||||||
|
splitType: 'pages',
|
||||||
|
splitValue: '1',
|
||||||
|
bookmarkLevel: '1',
|
||||||
|
includeMetadata: false,
|
||||||
|
allowDuplicates: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
icon: StarIcon,
|
icon: CompressIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "ocr-and-convert",
|
id: "ocr-workflow",
|
||||||
name: t("automation.suggested.ocrAndConvert", "OCR & Convert"),
|
name: t("automation.suggested.ocrWorkflow", "OCR Processing"),
|
||||||
description: t("automation.suggested.ocrAndConvertDesc", "Extract text via OCR and convert to different format"),
|
description: t("automation.suggested.ocrWorkflowDesc", "Extract text from PDFs using OCR technology"),
|
||||||
operations: [
|
operations: [
|
||||||
{ operation: "ocr", parameters: {} },
|
{
|
||||||
{ operation: "convert", parameters: {} }
|
operation: "ocr",
|
||||||
|
parameters: {
|
||||||
|
languages: ['eng'],
|
||||||
|
ocrType: 'skip-text',
|
||||||
|
ocrRenderType: 'hocr',
|
||||||
|
additionalOptions: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
icon: StarIcon,
|
icon: TextFieldsIcon,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "secure-workflow",
|
id: "secure-workflow",
|
||||||
name: t("automation.suggested.secureWorkflow", "Secure Workflow"),
|
name: t("automation.suggested.secureWorkflow", "Security Workflow"),
|
||||||
description: t("automation.suggested.secureWorkflowDesc", "Sanitize, add password, and set permissions"),
|
description: t("automation.suggested.secureWorkflowDesc", "Sanitize PDFs and add password protection"),
|
||||||
operations: [
|
operations: [
|
||||||
{ operation: "sanitize", parameters: {} },
|
{
|
||||||
{ operation: "addPassword", parameters: {} },
|
operation: "sanitize",
|
||||||
{ operation: "changePermissions", parameters: {} }
|
parameters: {
|
||||||
|
removeJavaScript: true,
|
||||||
|
removeEmbeddedFiles: true,
|
||||||
|
removeXMPMetadata: false,
|
||||||
|
removeMetadata: false,
|
||||||
|
removeLinks: false,
|
||||||
|
removeFonts: false,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operation: "addPassword",
|
||||||
|
parameters: {
|
||||||
|
password: 'password',
|
||||||
|
ownerPassword: '',
|
||||||
|
keyLength: 128,
|
||||||
|
permissions: {
|
||||||
|
preventAssembly: false,
|
||||||
|
preventExtractContent: false,
|
||||||
|
preventExtractForAccessibility: false,
|
||||||
|
preventFillInForm: false,
|
||||||
|
preventModify: false,
|
||||||
|
preventModifyAnnotations: false,
|
||||||
|
preventPrinting: false,
|
||||||
|
preventPrintingFaithful: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
icon: SecurityIcon,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "optimization-workflow",
|
||||||
|
name: t("automation.suggested.optimizationWorkflow", "Optimization Workflow"),
|
||||||
|
description: t("automation.suggested.optimizationWorkflowDesc", "Repair and compress PDFs for better performance"),
|
||||||
|
operations: [
|
||||||
|
{
|
||||||
|
operation: "repair",
|
||||||
|
parameters: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operation: "compress",
|
||||||
|
parameters: {
|
||||||
|
compressionLevel: 7,
|
||||||
|
grayscale: false,
|
||||||
|
expectedSize: '',
|
||||||
|
compressionMethod: 'quality',
|
||||||
|
fileSizeValue: '',
|
||||||
|
fileSizeUnit: 'MB',
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
|
@ -33,13 +33,19 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
if (currentStep === AUTOMATION_STEPS.RUN && data.step !== AUTOMATION_STEPS.RUN) {
|
if (currentStep === AUTOMATION_STEPS.RUN && data.step !== AUTOMATION_STEPS.RUN) {
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If navigating to selection step, always clear results
|
||||||
|
if (data.step === AUTOMATION_STEPS.SELECTION) {
|
||||||
|
automateOperation.resetResults();
|
||||||
|
automateOperation.clearError();
|
||||||
|
}
|
||||||
|
|
||||||
// If navigating to run step with a different automation, reset results
|
// If navigating to run step with a different automation, reset results
|
||||||
if (data.step === AUTOMATION_STEPS.RUN && data.automation &&
|
if (data.step === AUTOMATION_STEPS.RUN && data.automation &&
|
||||||
stepData.automation && data.automation.id !== stepData.automation.id) {
|
stepData.automation && data.automation.id !== stepData.automation.id) {
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
}
|
}
|
||||||
|
|
||||||
setStepData(data);
|
setStepData(data);
|
||||||
setCurrentStep(data.step);
|
setCurrentStep(data.step);
|
||||||
};
|
};
|
||||||
@ -47,7 +53,7 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
const handleComplete = () => {
|
const handleComplete = () => {
|
||||||
// Reset automation results when completing
|
// Reset automation results when completing
|
||||||
automateOperation.resetResults();
|
automateOperation.resetResults();
|
||||||
|
|
||||||
// Reset to selection step
|
// Reset to selection step
|
||||||
setCurrentStep(AUTOMATION_STEPS.SELECTION);
|
setCurrentStep(AUTOMATION_STEPS.SELECTION);
|
||||||
setStepData({ step: AUTOMATION_STEPS.SELECTION });
|
setStepData({ step: AUTOMATION_STEPS.SELECTION });
|
||||||
@ -127,7 +133,12 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
createStep(t('automate.selection.title', 'Automation Selection'), {
|
createStep(t('automate.selection.title', 'Automation Selection'), {
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
isCollapsed: currentStep !== AUTOMATION_STEPS.SELECTION,
|
isCollapsed: currentStep !== AUTOMATION_STEPS.SELECTION,
|
||||||
onCollapsedClick: () => setCurrentStep(AUTOMATION_STEPS.SELECTION)
|
onCollapsedClick: () => {
|
||||||
|
// Clear results when clicking back to selection
|
||||||
|
automateOperation.resetResults();
|
||||||
|
setCurrentStep(AUTOMATION_STEPS.SELECTION);
|
||||||
|
setStepData({ step: AUTOMATION_STEPS.SELECTION });
|
||||||
|
}
|
||||||
}, currentStep === AUTOMATION_STEPS.SELECTION ? renderCurrentStep() : null),
|
}, currentStep === AUTOMATION_STEPS.SELECTION ? renderCurrentStep() : null),
|
||||||
|
|
||||||
createStep(stepData.mode === AutomationMode.EDIT
|
createStep(stepData.mode === AutomationMode.EDIT
|
||||||
@ -158,7 +169,7 @@ const Automate = ({ onPreviewFile, onComplete, onError }: BaseToolProps) => {
|
|||||||
},
|
},
|
||||||
steps: automationSteps,
|
steps: automationSteps,
|
||||||
review: {
|
review: {
|
||||||
isVisible: hasResults,
|
isVisible: hasResults && currentStep === AUTOMATION_STEPS.RUN,
|
||||||
operation: automateOperation,
|
operation: automateOperation,
|
||||||
title: t('automate.reviewTitle', 'Automation Results')
|
title: t('automate.reviewTitle', 'Automation Results')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user