mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-31 23:59:32 +01:00
Merge pull request #11907 from AllForNothing/log-replication
Fix duration and log bugs for replication task UI
This commit is contained in:
commit
d355bac376
@ -112,7 +112,7 @@
|
||||
<clr-dg-cell>{{t.start_time | date: 'short'}}</clr-dg-cell>
|
||||
<clr-dg-cell>{{t.end_time && t.end_time != '0001-01-01T00:00:00Z' ? (t.end_time | date: 'short') : "-"}}</clr-dg-cell>
|
||||
<clr-dg-cell>
|
||||
<a target="_blank" [href]="viewLog(t.id)">
|
||||
<a target="_blank" [href]="viewLog(t.id)" *ngIf="t.status !== 'Initialized'">
|
||||
<clr-icon shape="list"></clr-icon>
|
||||
</a>
|
||||
</clr-dg-cell>
|
||||
|
@ -286,4 +286,38 @@ describe('Replication Component (inline template)', () => {
|
||||
expect(el.textContent.trim()).toEqual('library/nginx');
|
||||
});
|
||||
}));
|
||||
|
||||
it('function "getDuration" should work', () => {
|
||||
// ms level
|
||||
const item: ReplicationJobItem = {
|
||||
start_time: 1589340503637,
|
||||
end_time: 1589340503638,
|
||||
id: 3,
|
||||
status: "stopped",
|
||||
policy_id: 2,
|
||||
trigger: "Manual",
|
||||
total: 1,
|
||||
failed: 1,
|
||||
succeed: 0,
|
||||
in_progress: 0,
|
||||
stopped: 0
|
||||
};
|
||||
expect(comp.getDuration(item)).toEqual('1ms');
|
||||
// sec level
|
||||
item.start_time = 1589340503637;
|
||||
item.end_time = 1589340504638;
|
||||
expect(comp.getDuration(item)).toEqual('1s');
|
||||
// min level
|
||||
item.start_time = 1589340503637;
|
||||
item.end_time = 1589340564638;
|
||||
expect(comp.getDuration(item)).toEqual('1m1s');
|
||||
// hour level
|
||||
item.start_time = 1589340503637;
|
||||
item.end_time = 1589344164638;
|
||||
expect(comp.getDuration(item)).toEqual('61m1s');
|
||||
// day level
|
||||
item.start_time = "5/8/20,11:20 AM";
|
||||
item.end_time = "5/9/20,11:24 AM";
|
||||
expect(comp.getDuration(item)).toEqual('1444m');
|
||||
});
|
||||
});
|
||||
|
@ -499,9 +499,12 @@ export class ReplicationComponent implements OnInit, OnDestroy {
|
||||
let end_time = new Date(j.end_time).getTime();
|
||||
let timesDiff = end_time - start_time;
|
||||
let timesDiffSeconds = timesDiff / 1000;
|
||||
let minutes = Math.floor(((timesDiffSeconds % ONE_DAY_SECONDS) % ONE_HOUR_SECONDS) / ONE_MINUTE_SECONDS);
|
||||
let minutes = Math.floor(timesDiffSeconds / ONE_MINUTE_SECONDS);
|
||||
let seconds = Math.floor(timesDiffSeconds % ONE_MINUTE_SECONDS);
|
||||
if (minutes > 0) {
|
||||
if (seconds === 0) {
|
||||
return minutes + "m";
|
||||
}
|
||||
return minutes + "m" + seconds + "s";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user