Skip to content

Commit

Permalink
feat: tasks template
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-d committed Jan 23, 2025
1 parent 77eebf8 commit 4762489
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="px-2 text-base font-medium">{{ 'PAC.Chat.Tasks' | translate: {Default: 'Tasks'} }}: </div>

@for (task of syncedTasks(); track task.id) {
<div class="task flex w-full rounded-2xl px-6 py-4 shadow-sm border-[0.5px] border-solid border-gray-300 hover:shadow-md"
<div class="task flex items-center w-full rounded-2xl px-6 py-4 shadow-sm border-[0.5px] border-solid border-gray-300 hover:shadow-md"
[class.deleted]="!!task.deletedAt"
[matTooltip]="task.deletedAt ? ('PAC.Chat.TaskDeleted' | translate: {Default: 'The task has been deleted'}) : null "
matTooltipPosition="above"
Expand All @@ -11,12 +11,30 @@
<div class="text-text-secondary truncate">{{task.schedule}}</div>
</div>

<div class="flex justify-center items-center rounded-full hover:bg-hover-bg"
@if (!task.deletedAt) {
@if (task.status === eXpertTaskStatus.RUNNING) {
<button type="button" class="w-8 h-8 flex justify-center items-center rounded-lg opacity-50 hover:bg-gray-50 hover:opacity-100"
[matTooltip]="'PAC.Chat.PauseTask' | translate: {Default: 'Pause the Task'}"
matTooltipPosition="above"
(click)="pause(task)">
<i class="ri-pause-circle-line text-xl"></i>
</button>
} @else if (task.status === eXpertTaskStatus.PAUSED) {
<button type="button" class="w-8 h-8 flex justify-center items-center rounded-lg opacity-50 hover:bg-gray-50 hover:opacity-100"
[matTooltip]="'PAC.Chat.ScheduleTask' | translate: {Default: 'Schedule the Task'}"
matTooltipPosition="above"
(click)="schedule(task)">
<i class="ri-play-circle-line text-xl"></i>
</button>
}
}

<button type="button" class="w-8 h-8 flex justify-center items-center rounded-full opacity-50 hover:bg-gray-50 hover:opacity-100"
[cdkMenuTriggerFor]="menu"
[cdkMenuTriggerData]="{task: task}"
>
<i class="ri-more-2-fill"></i>
</div>
</button>
</div>
} @empty {
<div class="p-4 text-text-secondary">{{'PAC.Chat.NoTasksAvailable' | translate: {Default: 'No tasks available'} }}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
:host {
@apply space-y-0.5;
@apply relative space-y-0.5;
}

.task.deleted {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,21 @@ export class ChatComponentTasksComponent {
}
})
}

schedule(task: IXpertTask) {
this.loading.set(true)
this.taskService.schedule(task.id).subscribe({
next: () => {
this.loading.set(false)
this.taskDetails.update((tasks) => [
{ ...task, status: XpertTaskStatus.RUNNING },
...(tasks?.filter((_) => _.id !== task.id) ?? [])
])
},
error: (err) => {
this.loading.set(false)
this.#toastr.error(getErrorMessage(err))
}
})
}
}
4 changes: 3 additions & 1 deletion apps/cloud/src/assets/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -1580,7 +1580,9 @@
"NoTasksAvailable": "无可用任务",
"TaskDeleted": "任务已被删除",
"TaskSuccessCount": "任务成功执行次数",
"TaskFailureCount": "任务执行失败次数"
"TaskFailureCount": "任务执行失败次数",
"PauseTask": "暂停此任务",
"ScheduleTask": "安排此任务"
},
"ChatBI": {
"Title": "ChatBI-数据分析与洞察",
Expand Down
2 changes: 1 addition & 1 deletion packages/server-ai/src/xpert-template/templates.json

Large diffs are not rendered by default.

0 comments on commit 4762489

Please sign in to comment.