-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/admin forth/1281/let's add hard limit to transl #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yaroslav8765
merged 12 commits into
main
from
feature/AdminForth/1281/let's-add-hard-limit-to-transl
Mar 3, 2026
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8d83ec6
feat: add p-limit dependency and implement token length management fo…
yaroslav8765 6a6fed2
chore: remove debug logs
yaroslav8765 b29fccc
feat: enhance translation error handling and reporting in bulk transl…
yaroslav8765 27a4dd2
feat!: add background jobs for transtations
yaroslav8765 a2e951a
feat: add TranslationJobViewComponent and integrate with background j…
yaroslav8765 8c1a52e
chore: remove debug logs
yaroslav8765 15cfb0d
feat: enhance TranslationJobViewComponent layout and improve token di…
yaroslav8765 c7769e7
feat: enhance BulkActionButton and TranslationJobViewComponent for im…
yaroslav8765 b9c2ea8
feat: update TranslationJobViewComponent for improved pagination hand…
yaroslav8765 9ae4f8f
feat: open job popup after a successfull job start
yaroslav8765 4692ef7
fix: correct region detection in prompt
yaroslav8765 17657cb
fix: use record id as a key for the object of token costs per string
yaroslav8765 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
|
|
||
| <template> | ||
| <div class="grid grid-cols-1 sm:grid-cols-2 gap-4 my-3"> | ||
| <div class="flex items-center space-x-1"> | ||
| <span class=" text-gray-500">{{ t('Total tokens will be used for translation:') }}</span> | ||
| <span class="text-lg font-semibold text-gray-900 dark:text-gray-100">{{ new Number(props.job.state?.totalTranslationTokenCost).toLocaleString() || 0 }}</span> | ||
| </div> | ||
| <div class="flex items-center space-x-1"> | ||
| <span class=" text-gray-500">{{ t('Total translation token used:') }}</span> | ||
| <span class="text-lg font-semibold text-gray-900 dark:text-gray-100">{{ new Number(props.job.state?.totalUsedTokens).toLocaleString() || 0 }}</span> | ||
|
yaroslav8765 marked this conversation as resolved.
|
||
| </div> | ||
| </div> | ||
| <div class="grid grid-cols-3 gap-2"> | ||
| <div class="bg-gray-50 hover:bg-gray-100 transition-all px-2 py-2 rounded-md border max-w-64 w-full flex items-center gap-2" v-for="(task, index) in translationTasks" :key="index"> | ||
| {{ task.state?.taskName }} to | ||
| <span class="flag-icon" | ||
| :class="`flag-icon-${getCountryCodeFromLangCode(task.state?.lang)}`" | ||
| ></span> | ||
| <component | ||
| :is="getCustomComponent({file: '@@/plugins/BackgroundJobsPlugin/StateToIcon.vue'})" | ||
| :status="task.status" | ||
| /> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
|
|
||
| <script setup lang="ts"> | ||
| import { AdminForthComponentDeclarationFull } from 'adminforth'; | ||
| import { useI18n } from 'vue-i18n' | ||
| import { onMounted, onUnmounted, ref } from 'vue'; | ||
| import websocket from '@/websocket'; | ||
| import { getCountryCodeFromLangCode } from './langCommon'; | ||
| import { getCustomComponent } from '@/utils'; | ||
|
|
||
| const { t } = useI18n(); | ||
|
|
||
| const translationTasks = ref<{state: Record<string, any>, status: string}[]>([]); | ||
| const currentPaginationWindow = ref({limit: 25, offset: 0}); | ||
|
|
||
| const props = defineProps<{ | ||
| meta: any; | ||
| getJobTasks: (limit?: number, offset?: number) => Promise< | ||
| {tasks: {state: Record<string, any>, status: string}[], total: number}>; | ||
| job: { | ||
| id: string; | ||
| name: string; | ||
| status: 'IN_PROGRESS' | 'DONE' | 'DONE_WITH_ERRORS' | 'CANCELLED'; | ||
| state: { | ||
| totalTranslationTokenCost: number; | ||
| totalUsedTokens: number; | ||
| }; | ||
| progress: number; // 0 to 100 | ||
| createdAt: Date; | ||
| customComponent?: AdminForthComponentDeclarationFull; | ||
| }; | ||
| }>(); | ||
|
|
||
| onMounted(async () => { | ||
| const {tasks, total} = await props.getJobTasks(currentPaginationWindow.value.limit, currentPaginationWindow.value.offset); | ||
| translationTasks.value = tasks; | ||
|
|
||
| websocket.subscribe(`/background-jobs-task-update/${props.job.id}`, (data: { taskIndex: number, status?: string, state?: Record<string, any> }) => { | ||
| if ( data.taskIndex <= currentPaginationWindow.value.offset + currentPaginationWindow.value.limit && data.taskIndex >= currentPaginationWindow.value.offset ) { | ||
| if (data.state) { | ||
| translationTasks.value[data.taskIndex].state = data.state; | ||
| } | ||
| if (data.status) { | ||
| translationTasks.value[data.taskIndex].status = data.status; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
|
|
||
| }); | ||
|
|
||
| onUnmounted(() => { | ||
| websocket.unsubscribe(`/background-jobs-task-update/${props.job.id}`); | ||
| }); | ||
|
|
||
|
|
||
| </script> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.