Skip to content

Commit

Permalink
feat: add more job updating stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
lynzrand committed Oct 15, 2020
1 parent a5744a9 commit 5bc9fff
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
13 changes: 11 additions & 2 deletions web/src/components/item-components/job-item/job-item.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Component, OnInit, Input } from '@angular/core';
import { JobItem, dashboardTypeToSlider } from 'src/models/job-items';
import {
JobItem,
dashboardTypeToSlider,
Job,
JobToJobItem,
} from 'src/models/job-items';
import { SliderItem } from 'src/components/base-components/slider-view/slider-view.component';
import { Dayjs } from 'dayjs';

Expand All @@ -9,11 +14,15 @@ import { Dayjs } from 'dayjs';
styleUrls: ['./job-item.component.styl'],
})
export class JobItemComponent implements OnInit {
@Input() item: JobItem;
@Input() job: Job;
@Input() compact: boolean = false;

constructor() {}

public get item(): JobItem {
return JobToJobItem(this.job);
}

public get slider(): SliderItem[] {
return this.item.status.map<SliderItem>((st) => {
return {
Expand Down
11 changes: 7 additions & 4 deletions web/src/services/test_suite_cacher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ export class TestSuiteAndJobCache {
job.stage = msg.stage;
}
if (msg.testResult !== undefined) {
assign(job.results, msg.testResult);
Object.assign(job.results, msg.testResult);
}
if (msg.buildOutputFile !== undefined) {
job.buildOutputFile = msg.buildOutputFile;
}
}
}
Expand Down Expand Up @@ -182,12 +185,12 @@ export class TestSuiteAndJobCache {
.pipe(
tap({
next: (jobs) => {
if (opt.tracking) {
this.startTrackingJob(...jobs.map((j) => j.id));
}
if (opt.tracking || opt.cache) {
jobs.forEach((j) => this.cacheJob(j));
}
if (opt.tracking) {
this.startTrackingJob(...jobs.map((j) => j.id));
}
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ <h2>提交评测</h2>
</app-collapse-box>
</div>
</div>
<div class="rblk" id="job-list" [@staggerLoadJobs]="items && items.length">
<div class="rblk" id="job-list" [@staggerLoadJobs]="jobs && jobs.length">
<h2>评测记录</h2>
<ng-template
[ngIf]="items === undefined || items.length === 0"
[ngIf]="jobs === undefined || jobs.length === 0"
[ngIfElse]="jobLog"
>
<div class="no-list">没有评测记录</div>
</ng-template>
<ng-template #jobLog>
<app-job-item
class="test-item"
*ngFor="let item of items; trackBy: trackBy"
[item]="item"
(click)="gotoJob(item.id)"
*ngFor="let job of jobs; trackBy: trackBy"
[job]="job"
(click)="gotoJob(job.id)"
></app-job-item>
<div
class="btn secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@ export class TestSuiteViewComponent implements OnInit {

descCollapsed: boolean = false;

get items(): JobItem[] | undefined {
return this.jobs?.map(jobToJobItem);
}
loadMore() {
if (this.jobs === undefined || this.jobs.length === 0) {
this.fetchJobs(this.id).subscribe();
Expand Down

0 comments on commit 5bc9fff

Please sign in to comment.