Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <[email protected]>
  • Loading branch information
julien-nc committed Jul 15, 2024
1 parent 4aa7c11 commit 52611cb
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 44 deletions.
1 change: 0 additions & 1 deletion lib/Listener/TaskFailedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function handle(Event $event): void {
}

$task = $event->getTask();
// error_log('Task failed ' . $task->getId());
if ($task->getUserId() === null) {
return;
}
Expand Down
2 changes: 0 additions & 2 deletions lib/Listener/TaskSuccessfulListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public function handle(Event $event): void {
}

$task = $event->getTask();
// error_log('Task successful ' . $task->getId());
if ($task->getUserId() === null) {
return;
}
Expand All @@ -53,7 +52,6 @@ public function handle(Event $event): void {
$notificationActionLabel = $beforeAssistantNotificationEvent->getNotificationActionLabel();
}

error_log('SEND NOTIF');
$this->notificationService->sendNotification($task, $notificationTarget, $notificationActionLabel);
$this->taskNotificationMapper->deleteByTaskId($task->getId());
}
Expand Down
2 changes: 0 additions & 2 deletions lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function sendNotification(Task $task, ?string $customTarget = null, ?stri
'result' => $resultPreview,
];
$params['taskTypeId'] = $task->getTaskTypeId();
error_log('sendnotif-TASKTYPE:' . $task->getTaskTypeId());

$taskSuccessful = $task->getStatus() === Task::STATUS_SUCCESSFUL;

Expand All @@ -57,7 +56,6 @@ public function sendNotification(Task $task, ?string $customTarget = null, ?stri
->setSubject($subject, $params);

$manager->notify($notification);
error_log('->NOTIFY');
}

private function getDefaultTarget(Task $task): string {
Expand Down
3 changes: 0 additions & 3 deletions src/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ async function showAssistantTaskResult(taskId) {
* @return {Promise<void>}
*/
export async function openAssistantTask(task) {
console.debug('ZERO')
const { default: Vue } = await import(/* webpackChunkName: "vue-lazy" */'vue')
Vue.mixin({ methods: { t, n } })
const { showError } = await import(/* webpackChunkName: "dialogs-lazy" */'@nextcloud/dialogs')
Expand All @@ -323,7 +322,6 @@ export async function openAssistantTask(task) {
modalElement.id = modalId
document.body.append(modalElement)

console.debug('ONE')
const View = Vue.extend(AssistantTextProcessingModal)
const view = new View({
propsData: {
Expand All @@ -336,7 +334,6 @@ export async function openAssistantTask(task) {
},
}).$mount(modalElement)
let lastTask = null
console.debug('TWO')

view.$on('cancel', () => {
view.$destroy()
Expand Down
2 changes: 1 addition & 1 deletion src/components/AssistantFormInputs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default {
},
watch: {
selectedTaskType() {
console.debug('aaaa watch selectedTaskType', this.selectedTaskType, this.selectedTaskTypeId)
console.debug('[assistant] watch selectedTaskType', this.selectedTaskType, this.selectedTaskTypeId)
this.resetInputs()
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/components/AssistantTextProcessingForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default {
},
hasOptionalInputOutputShape() {
const taskType = this.selectedTaskType
console.debug('aaaaaaaaaaaa selected tt', taskType)
console.debug('[assistant] selected taskType', taskType)
if (taskType) {
return (taskType.optionalInputShape && Object.keys(taskType.optionalInputShape).length > 0)
|| (taskType.optionalOutputShape && Object.keys(taskType.optionalOutputShape.length) > 0)
Expand Down Expand Up @@ -350,7 +350,7 @@ export default {
},
mounted() {
this.getTaskTypes()
console.debug('aaaa myoutputsss', this.myOutputs)
console.debug('[assistant] form\'s myoutputs', this.myOutputs)
},
methods: {
getTaskTypes() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/AssistantTextProcessingModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export default {
},
},
mounted() {
console.debug('aaaa MODAL outputsss', this.outputs)
console.debug('[assistant] modal\'s outputs', this.outputs)
if (this.isInsideViewer) {
const elem = this.$refs.modal_content
emit('viewer:trapElements:changed', elem)
Expand Down
48 changes: 19 additions & 29 deletions src/components/TaskListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ import ImageDisplay from './fields/ImageDisplay.vue'
Vue.use(VueClipboard)
const statusIcons = {
[TASK_STATUS_STRING.successful]: CheckIcon,
[TASK_STATUS_STRING.cancelled]: CancelIcon,
[TASK_STATUS_STRING.failed]: AlertCircleOutlineIcon,
[TASK_STATUS_STRING.running]: ProgressCheckIcon,
[TASK_STATUS_STRING.scheduled]: ProgressClockIcon,
}
const statusTitles = {
[TASK_STATUS_STRING.successful]: t('assistant', 'Succeeded'),
[TASK_STATUS_STRING.cancelled]: t('assistant', 'Cancelled'),
[TASK_STATUS_STRING.failed]: t('assistant', 'Failed'),
[TASK_STATUS_STRING.running]: t('assistant', 'Running'),
[TASK_STATUS_STRING.scheduled]: t('assistant', 'Scheduled'),
}
export default {
name: 'TaskListItem',
Expand Down Expand Up @@ -156,43 +172,17 @@ export default {
return n('assistant', 'Generation of {n} image is scheduled', 'Generation of {n} images is scheduled', nbImageAsked, { n: nbImageAsked })
}
return t('assistant', 'This task is scheduled')
} else if (this.task.status === TASK_STATUS_STRING.running) {
return t('assistant', 'Running...')
} else if (this.task.status === TASK_STATUS_STRING.failed) {
return t('assistant', 'Failed')
} else if (this.task.status === TASK_STATUS_STRING.cancelled) {
return t('assistant', 'Cancelled')
}
return t('assistant', 'Unknown status')
return statusTitles[this.task.status] ?? t('assistant', 'Unknown status')
},
details() {
return moment.unix(this.task.lastUpdated).fromNow()
},
icon() {
if (this.task.status === TASK_STATUS_STRING.successful) {
return CheckIcon
} else if (this.task.status === TASK_STATUS_STRING.cancelled) {
return CancelIcon
} else if (this.task.status === TASK_STATUS_STRING.failed) {
return AlertCircleOutlineIcon
} else if (this.task.status === TASK_STATUS_STRING.running) {
return ProgressCheckIcon
} else if (this.task.status === TASK_STATUS_STRING.scheduled) {
return ProgressClockIcon
}
return ProgressQuestionIcon
return statusIcons[this.task.status] ?? ProgressQuestionIcon
},
statusTitle() {
if (this.task.status === TASK_STATUS_STRING.successful) {
return t('assistant', 'Succeeded')
} else if (this.task.status === TASK_STATUS_STRING.failed) {
return t('assistant', 'Failed')
} else if (this.task.status === TASK_STATUS_STRING.running) {
return t('assistant', 'Running')
} else if (this.task.status === TASK_STATUS_STRING.scheduled) {
return t('assistant', 'Scheduled')
}
return t('assistant', 'Unknown status')
return statusTitles[this.task.status] ?? t('assistant', 'Unknown status')
},
textInputPreview() {
const textInputs = []
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/ChooseInputFileButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {
showError(t('assistant', 'No file selected'))
return
}
console.debug('aaaaaaaaaaaaaaaaa NODE', nodes[0])
console.debug('[assistant] nodes', nodes)
this.$emit('files-chosen', this.multiple ? nodes : nodes[0])
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/ListOfMediaField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export default {
axios.post(url).then(response => {
const shareToken = response.data.ocs.data.shareToken
const shareUrl = window.location.protocol + '//' + window.location.host + generateUrl('/s/{shareToken}', { shareToken })
console.debug('aaaa share link', shareUrl)
console.debug('[assistant] generated share link', shareUrl)
const message = t('assistant', 'Output file share link copied to clipboard')
this.copyString(shareUrl, message)
}).catch(error => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/fields/MediaField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export default {
axios.post(url).then(response => {
const shareToken = response.data.ocs.data.shareToken
const shareUrl = window.location.protocol + '//' + window.location.host + generateUrl('/s/{shareToken}', { shareToken })
console.debug('aaaa share link', shareUrl)
console.debug('[assistant] generated share link', shareUrl)
const message = t('assistant', 'Output file share link copied to clipboard')
this.copyString(shareUrl, message)
}).catch(error => {
Expand Down

0 comments on commit 52611cb

Please sign in to comment.