-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin-ui): Display background jobs in UI
Relates to #111
- Loading branch information
1 parent
a83945a
commit 59d8312
Showing
14 changed files
with
339 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
admin-ui/src/app/core/components/job-list/job-list.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<vdr-dropdown *ngIf="(activeJobs$ | async) as jobs"> | ||
<button | ||
type="button" | ||
class="btn btn-link btn-sm job-button" | ||
[class.hidden]="jobs.length === 0" | ||
vdrDropdownTrigger | ||
> | ||
<clr-icon shape="hourglass" class="has-badge"></clr-icon> | ||
{{ 'common.jobs-in-progress' | translate: { count: jobs.length } }} | ||
</button> | ||
<vdr-dropdown-menu vdrPosition="top-right"> | ||
<div *ngFor="let job of (activeJobs$ | async); trackBy: trackById" class="job-row"> | ||
{{ getJobName(job) | translate }} | ||
<div class="progress labeled"> | ||
<progress max="100" [value]="job.progress" data-displayval="0%"></progress> | ||
<span>{{ job.progress }}%</span> | ||
</div> | ||
</div> | ||
</vdr-dropdown-menu> | ||
</vdr-dropdown> |
25 changes: 25 additions & 0 deletions
25
admin-ui/src/app/core/components/job-list/job-list.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
@import "variables"; | ||
|
||
:host { | ||
position: fixed; | ||
bottom: 12px; | ||
left: 12px; | ||
z-index: 5; | ||
} | ||
|
||
.job-button { | ||
background-color: $color-grey-200; | ||
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.2); | ||
&.hidden { | ||
display: none; | ||
} | ||
} | ||
|
||
.job-row { | ||
padding: 0 60px 0 12px; | ||
width: 90vw; | ||
max-width: 360px; | ||
@media screen and (min-width: $breakpoint-small){ | ||
max-width: 400px; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
admin-ui/src/app/core/components/job-list/job-list.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { JobInfoFragment } from '../../../common/generated-types'; | ||
import { _ } from '../../providers/i18n/mark-for-extraction'; | ||
import { JobQueueService } from '../../providers/job-queue/job-queue.service'; | ||
|
||
@Component({ | ||
selector: 'vdr-job-list', | ||
templateUrl: './job-list.component.html', | ||
styleUrls: ['./job-list.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class JobListComponent implements OnInit { | ||
activeJobs$: Observable<JobInfoFragment[]>; | ||
|
||
constructor(private jobQueueService: JobQueueService) {} | ||
|
||
ngOnInit() { | ||
this.activeJobs$ = this.jobQueueService.activeJobs$; | ||
} | ||
|
||
getJobName(job: JobInfoFragment): string { | ||
switch (job.name) { | ||
case 'reindex': | ||
return _('job.reindex'); | ||
default: | ||
return job.name; | ||
} | ||
} | ||
|
||
trackById(index: number, item: JobInfoFragment) { | ||
return item.id; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.