From 85ae4067767cd9b4c931948c6bf290ce34804a80 Mon Sep 17 00:00:00 2001 From: Drew Blokzyl Date: Thu, 28 May 2026 12:10:56 -0400 Subject: [PATCH] feat(supertasks): add "skip completed pretasks" option to apply-hashlist form Adds a skipCompleted checkbox to the apply-supertask form that passes the flag to the createSupertask helper and surfaces meta.skippedPretasks from the response (info toast for skipped pretasks, plus the all-skipped / taskWrapperId=null case). Defaults off, so existing behavior is unchanged. --- .../supertasks/applyhashlist.component.html | 5 ++ .../supertasks/applyhashlist.component.ts | 46 +++++++++++++++---- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/src/app/tasks/supertasks/applyhashlist.component.html b/src/app/tasks/supertasks/applyhashlist.component.html index 55b5c1e54..49b6915be 100644 --- a/src/app/tasks/supertasks/applyhashlist.component.html +++ b/src/app/tasks/supertasks/applyhashlist.component.html @@ -38,6 +38,11 @@ > + diff --git a/src/app/tasks/supertasks/applyhashlist.component.ts b/src/app/tasks/supertasks/applyhashlist.component.ts index 1ab06cd6f..516dae6fa 100644 --- a/src/app/tasks/supertasks/applyhashlist.component.ts +++ b/src/app/tasks/supertasks/applyhashlist.component.ts @@ -30,6 +30,17 @@ export interface ApplyHashlistForm { hashlistId: FormControl; crackerBinaryId: FormControl; crackerBinaryTypeId: FormControl; + skipCompleted: FormControl; +} + +interface SkippedPretask { + pretaskId: number; + matchingTaskId: number; +} + +interface CreateSupertaskMeta { + taskWrapperId: number | null; + skippedPretasks?: SkippedPretask[]; } /** @@ -119,7 +130,8 @@ export class ApplyHashlistComponent implements OnInit, OnDestroy { supertaskTemplateId: new FormControl(null), hashlistId: new FormControl(null), crackerBinaryId: new FormControl(null), - crackerBinaryTypeId: new FormControl(null) + crackerBinaryTypeId: new FormControl(null), + skipCompleted: new FormControl(false, { nonNullable: true }) }); } @@ -135,7 +147,8 @@ export class ApplyHashlistComponent implements OnInit, OnDestroy { supertaskTemplateId: new FormControl(this.editedIndex), hashlistId: new FormControl(null), crackerBinaryId: new FormControl(1), - crackerBinaryTypeId: new FormControl(null) + crackerBinaryTypeId: new FormControl(null), + skipCompleted: new FormControl(false, { nonNullable: true }) }); //subscribe to changes to handle select cracker binary @@ -252,13 +265,30 @@ export class ApplyHashlistComponent implements OnInit, OnDestroy { const adaptedFormValue = { supertaskTemplateId: formValue.supertaskTemplateId, hashlistId: formValue.hashlistId, - crackerVersionId: formValue.crackerBinaryTypeId + crackerVersionId: formValue.crackerBinaryTypeId, + skipCompleted: formValue.skipCompleted }; - const onSubmitSubscription$ = this.gs.chelper(SERV.HELPER, 'createSupertask', adaptedFormValue).subscribe(() => { - this.alert.showSuccessMessage('New SuperTask created'); - this.router.navigate(['tasks/show-tasks']); - this.isCreatingLoading = false; - }); + const onSubmitSubscription$ = this.gs + .chelper>(SERV.HELPER, 'createSupertask', adaptedFormValue) + .subscribe({ + next: (response) => { + const skipped = response?.meta?.skippedPretasks ?? []; + const allSkipped = response?.meta?.taskWrapperId == null; + if (skipped.length) { + this.alert.showInfoMessage(`Skipped ${skipped.length} pretask(s) already completed for this hashlist.`); + } + this.alert.showSuccessMessage( + allSkipped ? 'All pretasks already completed - no new SuperTask created.' : 'New SuperTask created' + ); + this.router.navigate(['tasks/show-tasks']); + }, + error: () => { + this.isCreatingLoading = false; + }, + complete: () => { + this.isCreatingLoading = false; + } + }); this.unsubscribeService.add(onSubmitSubscription$); } else { this.form.markAllAsTouched();