From 86d3b258612500648561f38ac5944d2ee77ead16 Mon Sep 17 00:00:00 2001 From: Raj Gupta <150777419+Raj-G07@users.noreply.github.com> Date: Sat, 27 Sep 2025 23:32:37 +0530 Subject: [PATCH] Feature/add sorting to job queue table (#5560) * Add sorting to job queue table * Update changelog --- CHANGELOG.md | 1 + .../admin-jobs/admin-jobs.component.ts | 10 +++- .../app/components/admin-jobs/admin-jobs.html | 58 ++++++++++++++++--- 3 files changed, 60 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc95d387..d2f0363b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added support for column sorting to the queue jobs table in the admin control panel - Added a blog post: _Hacktoberfest 2025_ ### Changed diff --git a/apps/client/src/app/components/admin-jobs/admin-jobs.component.ts b/apps/client/src/app/components/admin-jobs/admin-jobs.component.ts index d28749b9c..8ed72445f 100644 --- a/apps/client/src/app/components/admin-jobs/admin-jobs.component.ts +++ b/apps/client/src/app/components/admin-jobs/admin-jobs.component.ts @@ -16,7 +16,8 @@ import { ChangeDetectorRef, Component, OnDestroy, - OnInit + OnInit, + ViewChild } from '@angular/core'; import { FormBuilder, @@ -27,6 +28,7 @@ import { import { MatButtonModule } from '@angular/material/button'; import { MatMenuModule } from '@angular/material/menu'; import { MatSelectModule } from '@angular/material/select'; +import { MatSort, MatSortModule } from '@angular/material/sort'; import { MatTableDataSource, MatTableModule } from '@angular/material/table'; import { IonIcon } from '@ionic/angular/standalone'; import { JobStatus } from 'bull'; @@ -44,6 +46,7 @@ import { removeCircleOutline, timeOutline } from 'ionicons/icons'; +import { get } from 'lodash'; import { NgxSkeletonLoaderModule } from 'ngx-skeleton-loader'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -57,6 +60,7 @@ import { takeUntil } from 'rxjs/operators'; MatButtonModule, MatMenuModule, MatSelectModule, + MatSortModule, MatTableModule, NgxSkeletonLoaderModule, ReactiveFormsModule @@ -66,6 +70,8 @@ import { takeUntil } from 'rxjs/operators'; templateUrl: './admin-jobs.html' }) export class GfAdminJobsComponent implements OnDestroy, OnInit { + @ViewChild(MatSort) sort: MatSort; + public DATA_GATHERING_QUEUE_PRIORITY_LOW = DATA_GATHERING_QUEUE_PRIORITY_LOW; public DATA_GATHERING_QUEUE_PRIORITY_HIGH = DATA_GATHERING_QUEUE_PRIORITY_HIGH; @@ -196,6 +202,8 @@ export class GfAdminJobsComponent implements OnDestroy, OnInit { .pipe(takeUntil(this.unsubscribeSubject)) .subscribe(({ jobs }) => { this.dataSource = new MatTableDataSource(jobs); + this.dataSource.sort = this.sort; + this.dataSource.sortingDataAccessor = get; this.isLoading = false; diff --git a/apps/client/src/app/components/admin-jobs/admin-jobs.html b/apps/client/src/app/components/admin-jobs/admin-jobs.html index f2bfaa931..14f1b211b 100644 --- a/apps/client/src/app/components/admin-jobs/admin-jobs.html +++ b/apps/client/src/app/components/admin-jobs/admin-jobs.html @@ -16,9 +16,21 @@ -
+ |
|
@@ -27,7 +39,12 @@
+ |
|
@@ -42,7 +59,12 @@
|
+ |
|
@@ -51,7 +73,12 @@
|
+ |
|
@@ -60,7 +87,12 @@
|
+ |
|
@@ -79,7 +111,12 @@
|
+ |
|
@@ -88,7 +125,12 @@
|
+ |
|
| |
---|