mirror of https://github.com/Chocobozzz/PeerTube
Enhance jobs list displaying on smaller screens
parent
51b34a11b2
commit
4271212172
|
@ -3,11 +3,11 @@ import { HttpClient, HttpParams } from '@angular/common/http'
|
||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { SortMeta } from 'primeng/api'
|
import { SortMeta } from 'primeng/api'
|
||||||
import { Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { JobType, ResultList } from '../../../../../../shared'
|
import { ResultList } from '../../../../../../shared'
|
||||||
import { JobState } from '../../../../../../shared/models'
|
|
||||||
import { Job } from '../../../../../../shared/models/server/job.model'
|
import { Job } from '../../../../../../shared/models/server/job.model'
|
||||||
import { environment } from '../../../../environments/environment'
|
import { environment } from '../../../../environments/environment'
|
||||||
import { RestExtractor, RestPagination, RestService } from '../../../shared'
|
import { RestExtractor, RestPagination, RestService } from '../../../shared'
|
||||||
|
import { JobStateClient } from '../../../../types/job-state-client.type'
|
||||||
import { JobTypeClient } from '../../../../types/job-type-client.type'
|
import { JobTypeClient } from '../../../../types/job-type-client.type'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -20,13 +20,13 @@ export class JobService {
|
||||||
private restExtractor: RestExtractor
|
private restExtractor: RestExtractor
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
getJobs (state: JobState, jobType: JobTypeClient, pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> {
|
getJobs (jobState: JobStateClient, jobType: JobTypeClient, pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> {
|
||||||
let params = new HttpParams()
|
let params = new HttpParams()
|
||||||
params = this.restService.addRestGetParams(params, pagination, sort)
|
params = this.restService.addRestGetParams(params, pagination, sort)
|
||||||
|
|
||||||
if (jobType !== 'all') params = params.append('jobType', jobType)
|
if (jobType !== 'all') params = params.append('jobType', jobType)
|
||||||
|
|
||||||
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
|
return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + jobState, { params })
|
||||||
.pipe(
|
.pipe(
|
||||||
map(res => {
|
map(res => {
|
||||||
return this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ])
|
return this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ])
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div i18n class="form-sub-title">Jobs list</div>
|
<div i18n class="form-sub-title">Jobs list</div>
|
||||||
|
|
||||||
<div class="select-filter-block">
|
<div class="select-filter-block">
|
||||||
<label for="jobType">Job type</label>
|
<label for="jobType" i18n>Job type</label>
|
||||||
<div class="peertube-select-container">
|
<div class="peertube-select-container">
|
||||||
<select id="jobType" name="jobType" [(ngModel)]="jobType" (ngModelChange)="onJobStateOrTypeChanged()">
|
<select id="jobType" name="jobType" [(ngModel)]="jobType" (ngModelChange)="onJobStateOrTypeChanged()">
|
||||||
<option *ngFor="let jobType of jobTypes" [value]="jobType">{{ jobType }}</option>
|
<option *ngFor="let jobType of jobTypes" [value]="jobType">{{ jobType }}</option>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="select-filter-block">
|
<div class="select-filter-block">
|
||||||
<label for="jobState">Job state</label>
|
<label for="jobState" i18n>Job state</label>
|
||||||
<div class="peertube-select-container">
|
<div class="peertube-select-container">
|
||||||
<select id="jobState" name="jobState" [(ngModel)]="jobState" (ngModelChange)="onJobStateOrTypeChanged()">
|
<select id="jobState" name="jobState" [(ngModel)]="jobState" (ngModelChange)="onJobStateOrTypeChanged()">
|
||||||
<option *ngFor="let state of jobStates" [value]="state">{{ state }}</option>
|
<option *ngFor="let state of jobStates" [value]="state">{{ state }}</option>
|
||||||
|
@ -23,43 +23,48 @@
|
||||||
<p-table
|
<p-table
|
||||||
[value]="jobs" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" dataKey="uniqId"
|
[value]="jobs" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" dataKey="uniqId"
|
||||||
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" [first]="pagination.start"
|
[sortField]="sort.field" [sortOrder]="sort.order" (onLazyLoad)="loadLazy($event)" [first]="pagination.start"
|
||||||
|
[tableStyle]="{'table-layout':'auto'}"
|
||||||
>
|
>
|
||||||
<ng-template pTemplate="header">
|
<ng-template pTemplate="header">
|
||||||
<tr>
|
<tr>
|
||||||
<th style="width: 27px"></th>
|
<th i18n style="max-width: 60px;">ID</th>
|
||||||
<th i18n style="width: 60px">ID</th>
|
<th i18n style="max-width: 120px;">Type</th>
|
||||||
<th i18n style="width: 210px">Type</th>
|
<th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
|
||||||
<th i18n style="width: 130px">State</th>
|
<th i18n>State</th>
|
||||||
<th i18n style="width: 250px" pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
|
|
||||||
<th i18n style="width: 250px">Processed on</th>
|
|
||||||
<th i18n style="width: 250px">Finished on</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template pTemplate="body" let-expanded="expanded" let-job>
|
<ng-template pTemplate="body" let-expanded="expanded" let-job>
|
||||||
<tr>
|
<tr class="expander" [pRowToggler]="job">
|
||||||
<td class="expand-cell">
|
<td style="max-width: 60px;">{{ job.id }}</td>
|
||||||
<span class="expander" [pRowToggler]="job">
|
<td style="max-width: 120px;">{{ job.type }}</td>
|
||||||
<i [ngClass]="expanded ? 'glyphicon glyphicon-menu-down' : 'glyphicon glyphicon-menu-right'"></i>
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ job.id }}</td>
|
|
||||||
<td>{{ job.type }}</td>
|
|
||||||
<td>{{ job.state }}</td>
|
|
||||||
<td>{{ job.createdAt }}</td>
|
<td>{{ job.createdAt }}</td>
|
||||||
<td>{{ job.processedOn }}</td>
|
<td *ngIf="job.state === 'delayed'" class="text-muted"><span class="glyphicon glyphicon-repeat"></span> <span i18n>Delayed.</span></td>
|
||||||
<td>{{ job.finishedOn }}</td>
|
<td *ngIf="job.state === 'waiting'" class="text-warning"><span class="glyphicon glyphicon-hourglass"></span> <span i18n>Will start soon...</span></td>
|
||||||
|
<td *ngIf="job.state === 'active'" class="text-warning"><span class="glyphicon glyphicon-cog"></span> <span i18n>Running...</span></td>
|
||||||
|
<td *ngIf="job.state === 'completed'" class="text-success"><span class="glyphicon glyphicon-ok"></span> <span i18n>Finished</span></td>
|
||||||
|
<td *ngIf="job.state === 'failed'" class="text-danger"><span class="glyphicon glyphicon-remove"></span> <span i18n>Failed</span></td>
|
||||||
</tr>
|
</tr>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template pTemplate="rowexpansion" let-job>
|
<ng-template pTemplate="rowexpansion" let-job>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="7">
|
<td colspan="4">
|
||||||
|
<pre>{{ [
|
||||||
|
'Job: ' + job.id,
|
||||||
|
'Type: ' + job.type,
|
||||||
|
'Processed on ' + (job.processedOn || '-'),
|
||||||
|
'Finished on ' + (job.finishedOn || '-')
|
||||||
|
].join('\n') }}</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
<pre>{{ job.data }}</pre>
|
<pre>{{ job.data }}</pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="job-error" *ngIf="job.error">
|
<tr class="job-error" *ngIf="job.error">
|
||||||
<td colspan="7">
|
<td colspan="4">
|
||||||
<pre>{{ job.error }}</pre>
|
<pre>{{ job.error }}</pre>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -19,6 +19,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td .glyphicon {
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import { JobState } from '../../../../../../shared/models'
|
||||||
import { RestPagination, RestTable } from '../../../shared'
|
import { RestPagination, RestTable } from '../../../shared'
|
||||||
import { JobService } from './job.service'
|
import { JobService } from './job.service'
|
||||||
import { I18n } from '@ngx-translate/i18n-polyfill'
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
||||||
|
import { JobStateClient } from '../../../../types/job-state-client.type'
|
||||||
import { JobTypeClient } from '../../../../types/job-type-client.type'
|
import { JobTypeClient } from '../../../../types/job-type-client.type'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -18,8 +19,8 @@ export class JobsComponent extends RestTable implements OnInit {
|
||||||
private static JOB_STATE_LOCAL_STORAGE_STATE = 'jobs-list-state'
|
private static JOB_STATE_LOCAL_STORAGE_STATE = 'jobs-list-state'
|
||||||
private static JOB_STATE_LOCAL_STORAGE_TYPE = 'jobs-list-type'
|
private static JOB_STATE_LOCAL_STORAGE_TYPE = 'jobs-list-type'
|
||||||
|
|
||||||
jobState: JobState = 'waiting'
|
jobState: JobStateClient = 'waiting'
|
||||||
jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
|
jobStates: JobStateClient[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
|
||||||
|
|
||||||
jobType: JobTypeClient = 'all'
|
jobType: JobTypeClient = 'all'
|
||||||
jobTypes: JobTypeClient[] = [
|
jobTypes: JobTypeClient[] = [
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { JobState } from '@shared/models'
|
||||||
|
|
||||||
|
export type JobStateClient = JobState
|
Loading…
Reference in New Issue