Enhance TabPiyangoKatilimciListesi component by adding conditional rendering for job completion statistics, including inserted and duplicate counts. Implement toast notifications for handling upload conflicts and ensure proper cleanup of upload handlers on component unmount. This improves user feedback and data management during file uploads.
This commit is contained in:
@ -86,6 +86,10 @@
|
|||||||
<span class="history-file">{{ job.fileName }}</span>
|
<span class="history-file">{{ job.fileName }}</span>
|
||||||
<span :class="['history-status', 'status-' + job.status?.toLowerCase()]">{{ statusText(job.status) }}</span>
|
<span :class="['history-status', 'status-' + job.status?.toLowerCase()]">{{ statusText(job.status) }}</span>
|
||||||
<span class="history-progress">{{ job.progress }}%</span>
|
<span class="history-progress">{{ job.progress }}%</span>
|
||||||
|
<span v-if="job.status?.toLowerCase() === 'completed'" class="history-stats">
|
||||||
|
+{{ job.insertedCount ?? 0 }}
|
||||||
|
<template v-if="(job.duplicateCount ?? 0) > 0"> / {{ job.duplicateCount }} dpl</template>
|
||||||
|
</span>
|
||||||
<span class="history-date">{{ formatDate(job.createdAt) }}</span>
|
<span class="history-date">{{ formatDate(job.createdAt) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -164,13 +168,16 @@
|
|||||||
import { useDialogStore } from '@/components/global/dialogStore'
|
import { useDialogStore } from '@/components/global/dialogStore'
|
||||||
|
|
||||||
const dialogStore = useDialogStore()
|
const dialogStore = useDialogStore()
|
||||||
|
const toastStore = useToastStore()
|
||||||
|
|
||||||
import { usePiyangoOnayStore } from '../stores/piyangoOnayStore'
|
import { usePiyangoOnayStore } from '../stores/piyangoOnayStore'
|
||||||
const piyangoOnayStore = usePiyangoOnayStore()
|
const piyangoOnayStore = usePiyangoOnayStore()
|
||||||
import { usePiyangoOnayService } from '../service/piyangoOnayService'
|
import { usePiyangoOnayService } from '../service/piyangoOnayService'
|
||||||
const piyangoOnayService = usePiyangoOnayService()
|
const piyangoOnayService = usePiyangoOnayService()
|
||||||
|
|
||||||
import { connectToHub, onProgress, onInsertProgress, onCompleted, onError } from '../service/signalrService'
|
import { onUnmounted } from 'vue'
|
||||||
|
import { connectToHub, onProgress, onInsertProgress, onCompleted, onError, removeUploadHandlers } from '../service/signalrService'
|
||||||
|
import { useToastStore } from '@/components/global/toastStore'
|
||||||
|
|
||||||
const uploadProgressValue = ref(0)
|
const uploadProgressValue = ref(0)
|
||||||
const uploadProgressPanel = ref(false)
|
const uploadProgressPanel = ref(false)
|
||||||
@ -299,6 +306,7 @@
|
|||||||
uploadJobs.value = cekilisId !== null ? await piyangoKatilimciService.GetUploadJobs(cekilisId) : []
|
uploadJobs.value = cekilisId !== null ? await piyangoKatilimciService.GetUploadJobs(cekilisId) : []
|
||||||
uploadJobsLoading.value = false
|
uploadJobsLoading.value = false
|
||||||
|
|
||||||
|
removeUploadHandlers()
|
||||||
// İşleniyor durumundaki job varsa SignalR ile abone ol (gerçek zamanlı progress almak için)
|
// İşleniyor durumundaki job varsa SignalR ile abone ol (gerçek zamanlı progress almak için)
|
||||||
const processingJob = uploadJobs.value.find(
|
const processingJob = uploadJobs.value.find(
|
||||||
(j: Record<string, any>) => j.status?.toLowerCase() === 'processing'
|
(j: Record<string, any>) => j.status?.toLowerCase() === 'processing'
|
||||||
@ -361,6 +369,7 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeUploadHandlers()
|
||||||
uploadProgressValue.value = 0
|
uploadProgressValue.value = 0
|
||||||
uploadProgressPanel.value = true
|
uploadProgressPanel.value = true
|
||||||
|
|
||||||
@ -389,10 +398,22 @@
|
|||||||
`Katilimci/ExcelleYukle/${piyangoStore.selectedLottery}?connectionId=${connId}`,
|
`Katilimci/ExcelleYukle/${piyangoStore.selectedLottery}?connectionId=${connId}`,
|
||||||
{
|
{
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: { 'Content-Type': 'multipart/form-data' }
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
skipErrorForStatuses: [409]
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (response?._error && response.status === 409) {
|
||||||
|
uploadProgressPanel.value = false
|
||||||
|
const msg = response.data?.message || 'Bu çekiliş için zaten devam eden bir Excel yükleme işlemi var.'
|
||||||
|
toastStore.AddToast(msg, 'alert', 6000)
|
||||||
|
if (response.data?.existingJobId) {
|
||||||
|
refreshUploadJobsAndPollProcessing()
|
||||||
|
OpenUploadDetail(response.data.existingJobId)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (response !== 'errorfalse' && response?.jobId) {
|
if (response !== 'errorfalse' && response?.jobId) {
|
||||||
startPolling(response.jobId)
|
startPolling(response.jobId)
|
||||||
} else {
|
} else {
|
||||||
@ -511,6 +532,11 @@
|
|||||||
startPollingForExistingJob(processingJob.guid)
|
startPollingForExistingJob(processingJob.guid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
|
stopPolling()
|
||||||
|
removeUploadHandlers()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.progress-bar {
|
.progress-bar {
|
||||||
|
|||||||
Reference in New Issue
Block a user