Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 1x 1x 1x 1x 1x 1x 1x 14x 1x 1x 1x 1x 3x 1x 1x 1x 1x 1x 1x 1x | import { Component, effect, OnDestroy, OnInit, Signal } from '@angular/core'; import { debounceTime, Observable, Subject } from 'rxjs'; import { AsyncPipe, KeyValuePipe } from '@angular/common'; import { MatPaginatorIntl, MatPaginatorModule, PageEvent } from '@angular/material/paginator'; import { MatCardModule } from '@angular/material/card'; import { Page } from '../../../core/model/page.interface'; import { Job, JobStatus } from '../../../core/model/job.interface'; import { JobService } from '../../../core/services/job.service'; import { ModalService } from '../../../core/services/modal.service'; import { StatusLabelPipe } from '../../../core/pipe/status-label.pipe'; import { MatButton } from '@angular/material/button'; import { NotificationService } from '../../../core/services/notification.service'; import { FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms'; import { MatRippleModule } from '@angular/material/core'; import { MatMenuModule } from '@angular/material/menu'; import { JobMetadata } from '../../../core/model/job-metadata.interface'; import { CustomPaginatorIntl } from '../../../core/services/custom-paginator-intl'; import { User } from '../../../core/model/user.interface'; import { UserService } from '../../../core/services/user.service'; import { MatIcon } from '@angular/material/icon'; import { JobSummaryComponent } from '../job-summary/job-summary.component'; import { ComponentInputDomainData } from '../../../core/model/component-input-data.interface'; import { UserSummary } from '@app/core/model/user-summary.interface'; import { StatusMetaLabelPipe } from '@app/core/pipe/status-meta-label.pipe'; import { JobsListOptions } from '@app/core/model/jobs-list-options'; import { JobsListOptionsService } from '@app/core/services/jobs-list-options.service'; import { MatFormField, MatInput } from "@angular/material/input"; @Component({ selector: 'app-jobs', imports: [AsyncPipe, KeyValuePipe, MatMenuModule, MatRippleModule, MatFormField, MatInput, MatCardModule, MatPaginatorModule, MatIcon, JobSummaryComponent, StatusLabelPipe, StatusMetaLabelPipe, MatButton, FormsModule, ReactiveFormsModule, MatInput], providers: [{ provide: MatPaginatorIntl, useClass: CustomPaginatorIntl }], templateUrl: './jobs.component.html', styleUrl: './jobs.component.scss' }) export class JobsComponent implements OnDestroy { private readonly destroy$: Subject<boolean> = new Subject<boolean>(); statusKeys: string[] = []; public jobs$!: Observable<Page<Job>>; protected user$: Observable<User>; // make user's summary available to template protected userSummary!: Signal<UserSummary | null | false>; // make options available to the template protected jobsOptions!: Signal<JobsListOptions | null>; searchControl = new FormControl(''); private queryFieldInit: boolean = false; constructor( private readonly userService: UserService, private readonly jobService: JobService, private readonly jobsListOptionsService: JobsListOptionsService, private readonly modalService: ModalService, private readonly notificationService: NotificationService) { this.statusKeys = Object.keys(JobStatus); this.user$ = this.userService.getUser(); // make summary available to template this.userSummary = userService.getUserSummary(); this.jobsOptions = this.jobsListOptionsService.getJobsListOptions(); effect(() => { const options = this.jobsOptions(); Iif(options === null) { return; } // initialize search control value and subscription only once if(!this.queryFieldInit) { this.searchControl.setValue(options.getQuery()); this.searchControl.valueChanges .pipe(debounceTime(500)) .subscribe(value => { this.query(value); }); this.queryFieldInit = true; } this.jobs$ = this.jobService.getAllJobs(options); }) } ngOnDestroy(): void { this.destroy$.next(true); } sortBy(sort: string): void { this.jobsListOptionsService.sort(sort); } query(query: string | null): void { this.jobsListOptionsService.query(query); } filter(status: string | null, statusMeta: string | null): void { this.jobsListOptionsService.filter(status, statusMeta); } handlePageEvent(event: PageEvent) { this.jobsListOptionsService.changePagination(event.pageIndex, event.pageSize); } onJobChanged(job: Job): void { this.reloadJobs(); } reloadJobs(): void { // reloading user summary will trigger options and jobs loading this.userService.reloadUserSummary(); } createJobWithUrl(): void { this.modalService.openCreateJobWithUrlModal((data: ComponentInputDomainData) => this.createJobWithMetadata(data.metadata.jobMetadata)); } createJobWithMetadata(metadata: JobMetadata): void { this.modalService.openJobStepperModal(() => this.reloadJobs(), { jobMetadata: metadata }); } createJob(): void { this.modalService.openJobStepperModal(() => {this.reloadJobs()}); } onDelete(job: Job) :void { this.reloadJobs(); this.notificationService.confirmation($localize`:@@job.deleted:Job successfully deleted.`); } manageAttachments(event: Event, job: Job): void { // prevent routing to job detail event.stopPropagation(); // don't reload list; as the edited job is replaced after update directly by the service this.modalService.openJobModal('attachments', job, () => { }); } } |