группировка по папкам + удоление источников
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
122
src/components/Istochnik_section/Istochnik_one_kard.vue
Normal file
122
src/components/Istochnik_section/Istochnik_one_kard.vue
Normal file
@@ -0,0 +1,122 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-row justify-between w-full lg:w-auto gap-2 p-2 bg-gray-100 shadow dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-600"
|
||||
>
|
||||
<dev class="">
|
||||
<input
|
||||
v-model="displayUrl"
|
||||
type="text"
|
||||
placeholder="URL источника"
|
||||
readonly
|
||||
class="flex-1 m-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 min-w-0"
|
||||
/>
|
||||
|
||||
<input
|
||||
v-model="displayPromt"
|
||||
type="text"
|
||||
placeholder="Промт"
|
||||
readonly
|
||||
class="flex-1 m-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 max-w-20"
|
||||
/>
|
||||
</dev>
|
||||
<div class="">
|
||||
<button
|
||||
@click="deleteParsing"
|
||||
:disabled="isDeleting"
|
||||
class="w-9 h-11 m-1 bg-rose-600 hover:bg-rose-800 shadow text-white rounded-xl cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
X
|
||||
</button>
|
||||
<button
|
||||
@click="startParsing"
|
||||
:disabled="isLoading"
|
||||
class="w-25 h-11 m-1 dark:bg-orange-500 hover:dark:bg-orange-600 shadow text-white bg-sky-700 hover:bg-sky-900 rounded-xl px-2 cursor-pointer whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
{{ isLoading ? "..." : "Start" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import axios from "axios";
|
||||
|
||||
const props = defineProps({
|
||||
source: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({ url: "", promt: "" }),
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["sourceStarted", "sourceDeleted"]);
|
||||
|
||||
const isLoading = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
|
||||
const displayUrl = computed({
|
||||
get: () => props.source.url || "",
|
||||
set: (val) => {
|
||||
// Только для чтения
|
||||
},
|
||||
});
|
||||
|
||||
const displayPromt = computed({
|
||||
get: () => props.source.promt || "",
|
||||
set: (val) => {
|
||||
// Только для чтения
|
||||
},
|
||||
});
|
||||
|
||||
const startParsing = async () => {
|
||||
if (!props.source.url) {
|
||||
// alert("URL источника не указан");
|
||||
return;
|
||||
}
|
||||
|
||||
isLoading.value = true;
|
||||
|
||||
try {
|
||||
await axios.post("https://allowlgroup.ru/api/8001/parser_all", {
|
||||
// await axios.post("http://127.0.0.1:8001/parser_all", {
|
||||
url: props.source.url,
|
||||
promt: props.source.promt,
|
||||
});
|
||||
|
||||
emit("sourceStarted", props.source.url);
|
||||
// alert(`Парсинг для ${props.source.url} запущен`);
|
||||
} catch (err) {
|
||||
console.error("Ошибка запуска парсинга:", err);
|
||||
alert("Ошибка при запуске парсинга");
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteParsing = async () => {
|
||||
// if (!props.source.url) {
|
||||
// alert("URL источника не указан");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!confirm(`Вы уверены, что хотите удалить источник "${props.source.url}"?`)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
isDeleting.value = true;
|
||||
|
||||
try {
|
||||
await axios.delete(
|
||||
// "https://allowlgroup.ru/api/8001/delete_sources",
|
||||
"http://127.0.0.1:8001/delete_sources",
|
||||
{ params: { url: props.source.url } }
|
||||
);
|
||||
emit("sourceDeleted", props.source.url);
|
||||
} catch (error) {
|
||||
console.error("Ошибка при удалении задачи:", error);
|
||||
} finally {
|
||||
isDeleting.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user