полный рефакторинг всей системы
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:
@@ -1,124 +1,86 @@
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-col sm:flex-row justify-between w-full lg:w-auto gap-2 p-2 bg-white shadow dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-600"
|
||||
:class="{ 'opacity-50': isStatus }"
|
||||
:class="{ 'opacity-50': props.source.status }"
|
||||
>
|
||||
<div class="">
|
||||
<div class="flex-1 flex gap-2 min-w-0">
|
||||
<input
|
||||
v-model="displayUrl"
|
||||
:value="props.source.url"
|
||||
type="text"
|
||||
placeholder="URL источника"
|
||||
readonly
|
||||
class="flex-1 sm:mr-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 w-2/3 sm:min-w-0"
|
||||
class="flex-1 sm:mr-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 min-w-0"
|
||||
/>
|
||||
|
||||
<input
|
||||
v-model="displayPromt"
|
||||
:value="props.source.promt"
|
||||
type="text"
|
||||
placeholder="Промт"
|
||||
readonly
|
||||
class="flex-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 w-1/3 sm:max-w-20"
|
||||
class="h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 w-1/3 sm:max-w-20"
|
||||
/>
|
||||
</div>
|
||||
<div class="min-w-40">
|
||||
<div class="min-w-40 flex gap-1">
|
||||
<button
|
||||
type="button"
|
||||
@click="deleteParsing"
|
||||
:disabled="isDeleting"
|
||||
class="w-1/3 sm:w-9 h-11 sm:mr-1 bg-rose-600 hover:bg-rose-800 shadow text-white rounded-xl cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
class="w-1/3 sm:w-9 h-11 bg-rose-600 hover:bg-rose-800 shadow text-white rounded-xl cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
>
|
||||
X
|
||||
×
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
@click="startParsing"
|
||||
:disabled="isLoading"
|
||||
class="w-2/3 sm:w-25 h-11 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" }}
|
||||
{{ isLoading ? '...' : 'Start' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed } from "vue";
|
||||
import axios from "axios";
|
||||
import { ref } from 'vue'
|
||||
import { startSourceParsing, deleteSource } from '@/services/sourceService.js'
|
||||
|
||||
const props = defineProps({
|
||||
source: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({ url: "", promt: "", status: false}),
|
||||
default: () => ({ url: '', promt: '', status: false }),
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
const emit = defineEmits(["sourceStarted", "sourceDeleted"]);
|
||||
const emit = defineEmits(['sourceStarted', 'sourceDeleted'])
|
||||
|
||||
const isLoading = ref(false);
|
||||
const isDeleting = ref(false);
|
||||
const isStatus = ref(props.source.status);
|
||||
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;
|
||||
async function startParsing() {
|
||||
if (!props.source.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} запущен`);
|
||||
await startSourceParsing(props.source.url, props.source.promt)
|
||||
emit('sourceStarted', props.source.url)
|
||||
} catch (err) {
|
||||
console.error("Ошибка запуска парсинга:", err);
|
||||
alert("Ошибка при запуске парсинга");
|
||||
console.error('Ошибка запуска парсинга:', err)
|
||||
alert('Ошибка при запуске парсинга')
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
isLoading.value = false
|
||||
}
|
||||
};
|
||||
|
||||
const deleteParsing = async () => {
|
||||
// if (!props.source.url) {
|
||||
// alert("URL источника не указан");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (!confirm(`Вы уверены, что хотите удалить источник "${props.source.url}"?`)) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
isDeleting.value = true;
|
||||
}
|
||||
|
||||
async function deleteParsing() {
|
||||
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);
|
||||
await deleteSource(props.source.url)
|
||||
emit('sourceDeleted', props.source.url)
|
||||
} catch (error) {
|
||||
console.error("Ошибка при удалении задачи:", error);
|
||||
console.error('Ошибка при удалении источника:', error)
|
||||
} finally {
|
||||
isDeleting.value = false;
|
||||
isDeleting.value = false
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user