Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.cleaner
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RELEASE=dev
VERSION=1
BUILD=3
FIX=8
FIX=9
2 changes: 1 addition & 1 deletion .env.fileproc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RELEASE=dev
VERSION=1
BUILD=3
FIX=4
FIX=5
2 changes: 1 addition & 1 deletion .env.scrapper
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RELEASE=dev
VERSION=1
BUILD=3
FIX=7
FIX=8
2 changes: 1 addition & 1 deletion .env.search
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RELEASE=dev
VERSION=1
BUILD=3
FIX=3
FIX=4
11 changes: 11 additions & 0 deletions DSL/Ruuter/ckb/POST/source/add.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ extractRequestData:
quality_control: "${incoming.body.qualityControl != null && incoming.body.qualityControl != '' ? incoming.body.qualityControl : ''}"
extract_images: "${incoming.body.extractImages == true}"

validateUrl:
switch:
- condition: "${type == 'url_to_scrape' && !(url != null && (url.startsWith('http://') || url.startsWith('https://')))}"
next: returnInvalidUrl
next: createSource

returnInvalidUrl:
return: "Invalid URL"
status: 400
next: end

createSource:
call: http.post
args:
Expand Down
60 changes: 53 additions & 7 deletions GUI/src/pages/Agency/Agency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ const getInitialFormData = (): KnowledgeBaseFormData => ({
extractImages: false,
});

const isValidUrl = (value: string): boolean => {
try {
const parsed = new URL(value);
return parsed.protocol === 'http:' || parsed.protocol === 'https:';
} catch {
return false;
}
};

const Agency: FC = () => {
const { t } = useTranslation();
const toast = useToast();
Expand Down Expand Up @@ -108,6 +117,7 @@ const Agency: FC = () => {
const [formData, setFormData] = useState<KnowledgeBaseFormData>(
getInitialFormData()
);
const [urlError, setUrlError] = useState<string | null>(null);

// Convert sorting state to API format
const getSortingParam = (sorting: SortingState): string => {
Expand Down Expand Up @@ -472,6 +482,12 @@ const Agency: FC = () => {
return;
}

if (!isValidUrl(formData.websiteUrl)) {
setUrlError(t('knowledgeBase.invalidUrl'));
return;
}

setUrlError(null);
addUrlMutation.mutate({
agencyBaseId,
url: formData.websiteUrl,
Expand Down Expand Up @@ -564,6 +580,12 @@ const Agency: FC = () => {
return;
}

if (!isValidUrl(formData.websiteUrl)) {
setUrlError(t('knowledgeBase.invalidUrl'));
return;
}

setUrlError(null);
addUrlListMutation.mutate({
agencyBaseId,
url: formData.websiteUrl,
Expand Down Expand Up @@ -909,16 +931,22 @@ const Agency: FC = () => {
<Dialog
title={t('knowledgeBase.addUrl')}
onClose={() => {
{
setAddUrlModal(false);
setFormData(getInitialFormData());
};
setUrlError(null);
}}
footer={
<Track gap={16} justify="end">
<Button
appearance="secondary"
onClick={() => {
{
setAddUrlModal(false);
setFormData(getInitialFormData());
};
setUrlError(null);
}}
>
{t('global.cancel')}
Expand Down Expand Up @@ -955,11 +983,17 @@ const Agency: FC = () => {
label={t('knowledgeBase.url')}
name="websiteUrl"
value={formData.websiteUrl || ''}
onChange={(e) =>
setFormData((prev) => ({ ...prev, websiteUrl: e.target.value }))
}
onChange={(e) => {
setFormData((prev) => ({ ...prev, websiteUrl: e.target.value }));
if (urlError) setUrlError(null);
}}
required
/>
{urlError && (
<span style={{ color: '#AC3232', fontSize: '13px' }}>
{urlError}
</span>
)}
<div className="quality-control-options">
<span className="quality-control-options__title">
{t('knowledgeBase.imageExtraction')}
Expand Down Expand Up @@ -1072,16 +1106,22 @@ const Agency: FC = () => {
<Dialog
title={t('knowledgeBase.addUrlList')}
onClose={() => {
{
setAddUrlListModal(false);
setFormData(getInitialFormData());
};
setUrlError(null);
}}
footer={
<Track gap={16} justify="end">
<Button
appearance="secondary"
onClick={() => {
{
setAddUrlListModal(false);
setFormData(getInitialFormData());
};
setUrlError(null);
}}
>
{t('global.cancel')}
Expand Down Expand Up @@ -1120,12 +1160,18 @@ const Agency: FC = () => {
label={t('knowledgeBase.mainSourceUrl')}
name="websiteUrl"
value={formData.websiteUrl || ''}
onChange={(e) =>
setFormData((prev) => ({ ...prev, websiteUrl: e.target.value }))
}
onChange={(e) => {
setFormData((prev) => ({ ...prev, websiteUrl: e.target.value }));
if (urlError) setUrlError(null);
}}
required
/>

{urlError && (
<span style={{ color: '#AC3232', fontSize: '13px' }}>
{urlError}
</span>
)}

<div style={{ marginTop: '16px', width: '100%', textAlign: 'left', alignSelf: 'flex-start' }}>
<label style={{ display: 'block', marginBottom: '8px', fontWeight: 500 }}>
{t('knowledgeBase.uploadCsvWithUrls')}
Expand Down
1 change: 1 addition & 0 deletions GUI/translations/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@
"apiError": "Failed to add API integration",
"urlSuccess": "The URL source was successfully added",
"urlError": "Failed to add website URL",
"invalidUrl": "Please enter a valid URL",
"urlAddedSuccess": "URL added successfully",
"urlAddError": "Failed to add URL",
"urlDeleteSuccess": "URL deleted successfully",
Expand Down
1 change: 1 addition & 0 deletions GUI/translations/et/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@
"apiError": "API integratsiooni lisamine ebaõnnestus",
"urlSuccess": "Veebilehe URL lisamine õnnestus",
"urlError": "Veebilehe URL-i lisamine ebaõnnestus",
"invalidUrl": "Palun sisesta kehtiv URL",
"urlAddedSuccess": "URL lisamine õnnestus",
"urlAddError": "URL-i lisamine ebaõnnestus",
"urlDeleteSuccess": "URL kustutamine õnnestus",
Expand Down
Loading