upload future report bid product
This commit is contained in:
parent
4f9edf80d0
commit
5f1c7c793c
|
|
@ -16,7 +16,10 @@ export const createScrapConfig = async (
|
||||||
url: "scrap-configs",
|
url: "scrap-configs",
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: newData,
|
data: {
|
||||||
|
...newData,
|
||||||
|
enable: newData.enable === "1",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
handleSuccess(data);
|
handleSuccess(data);
|
||||||
|
|
@ -28,14 +31,14 @@ export const createScrapConfig = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateScrapConfig = async (scrapConfig: Partial<IScrapConfig>) => {
|
export const updateScrapConfig = async (scrapConfig: Partial<IScrapConfig>) => {
|
||||||
const { search_url, keywords, id } = removeFalsyValues(scrapConfig);
|
const { search_url, keywords, id, enable } = removeFalsyValues(scrapConfig);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await axios({
|
const { data } = await axios({
|
||||||
url: "scrap-configs/" + id,
|
url: "scrap-configs/" + id,
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
data: { search_url, keywords },
|
data: { search_url, keywords, enable: enable === "1" },
|
||||||
});
|
});
|
||||||
|
|
||||||
handleSuccess(data);
|
handleSuccess(data);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
LoadingOverlay,
|
LoadingOverlay,
|
||||||
Modal,
|
Modal,
|
||||||
ModalProps,
|
ModalProps,
|
||||||
|
Select,
|
||||||
Textarea,
|
Textarea,
|
||||||
TextInput,
|
TextInput,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
|
|
@ -28,6 +29,7 @@ const schema = z.object({
|
||||||
.string({ message: "Keyword is required" })
|
.string({ message: "Keyword is required" })
|
||||||
.min(1, { message: "Keyword is required" })
|
.min(1, { message: "Keyword is required" })
|
||||||
.optional(),
|
.optional(),
|
||||||
|
enable: z.enum(["1", "0"], { required_error: "Enable is required" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default function ScrapConfigModal({
|
export default function ScrapConfigModal({
|
||||||
|
|
@ -93,9 +95,18 @@ export default function ScrapConfigModal({
|
||||||
form.reset();
|
form.reset();
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
form.setValues(data.scrap_config);
|
const values = {
|
||||||
|
...data.scrap_config,
|
||||||
|
enable: (data.scrap_config?.enable === undefined
|
||||||
|
? "1"
|
||||||
|
: data.scrap_config.enable
|
||||||
|
? "1"
|
||||||
|
: "0") as "0" | "1",
|
||||||
|
};
|
||||||
|
|
||||||
prevData.current = data.scrap_config;
|
form.setValues(values);
|
||||||
|
|
||||||
|
prevData.current = values;
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
|
|
@ -121,6 +132,23 @@ export default function ScrapConfigModal({
|
||||||
onSubmit={form.onSubmit(handleSubmit)}
|
onSubmit={form.onSubmit(handleSubmit)}
|
||||||
className="grid grid-cols-2 gap-2.5"
|
className="grid grid-cols-2 gap-2.5"
|
||||||
>
|
>
|
||||||
|
<Select
|
||||||
|
className="col-span-2"
|
||||||
|
label="Enable scrape"
|
||||||
|
defaultChecked={true}
|
||||||
|
defaultValue={"1"}
|
||||||
|
data={[
|
||||||
|
{
|
||||||
|
label: "Enbale",
|
||||||
|
value: "1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Disable",
|
||||||
|
value: "0",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
{...form.getInputProps("enable")}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
className="col-span-2"
|
className="col-span-2"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ export interface IScrapConfig extends ITimestamp {
|
||||||
id: number;
|
id: number;
|
||||||
search_url: string;
|
search_url: string;
|
||||||
keywords: string;
|
keywords: string;
|
||||||
|
enable: boolean | "0" | "1";
|
||||||
scrap_items: IScrapItem[];
|
scrap_items: IScrapItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
import { IsNumber, IsOptional, IsString, IsUrl } from 'class-validator';
|
import {
|
||||||
|
IsBoolean,
|
||||||
|
IsNumber,
|
||||||
|
IsOptional,
|
||||||
|
IsString,
|
||||||
|
IsUrl,
|
||||||
|
} from 'class-validator';
|
||||||
|
|
||||||
export class CreateScrapConfigDto {
|
export class CreateScrapConfigDto {
|
||||||
@IsUrl()
|
@IsUrl()
|
||||||
search_url: string;
|
search_url: string;
|
||||||
|
|
||||||
|
@IsBoolean()
|
||||||
|
@IsOptional()
|
||||||
|
enable: boolean;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
keywords: string;
|
keywords: string;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ export class ScrapConfig extends Timestamp {
|
||||||
@Column({ default: 'cisco' })
|
@Column({ default: 'cisco' })
|
||||||
keywords: string;
|
keywords: string;
|
||||||
|
|
||||||
|
@Column({ default: true })
|
||||||
|
enable: boolean;
|
||||||
|
|
||||||
@OneToOne(() => WebBid, (web) => web.scrap_config, { onDelete: 'CASCADE' })
|
@OneToOne(() => WebBid, (web) => web.scrap_config, { onDelete: 'CASCADE' })
|
||||||
@JoinColumn()
|
@JoinColumn()
|
||||||
web_bid: WebBid;
|
web_bid: WebBid;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,11 @@ export class ScrapConfigsService {
|
||||||
|
|
||||||
async clientGetScrapeConfigs() {
|
async clientGetScrapeConfigs() {
|
||||||
const data = await this.scrapConfigRepo.find({
|
const data = await this.scrapConfigRepo.find({
|
||||||
where: { search_url: Not(IsNull()), keywords: Not(IsNull()) },
|
where: {
|
||||||
|
search_url: Not(IsNull()),
|
||||||
|
keywords: Not(IsNull()),
|
||||||
|
enable: true,
|
||||||
|
},
|
||||||
relations: {
|
relations: {
|
||||||
web_bid: true,
|
web_bid: true,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,6 @@ export class TasksService {
|
||||||
private readonly logger = new Logger(TasksService.name);
|
private readonly logger = new Logger(TasksService.name);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly scrapConfigsService: ScrapConfigsService,
|
|
||||||
private readonly scrapItemsService: ScrapItemsService,
|
private readonly scrapItemsService: ScrapItemsService,
|
||||||
private readonly mailsService: MailsService,
|
private readonly mailsService: MailsService,
|
||||||
private readonly configsSerivce: ConfigsService,
|
private readonly configsSerivce: ConfigsService,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue