mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-14 11:41:31 +01:00
Merge pull request #10980 from AllForNothing/scan-bug
Fix a bug for scanning
This commit is contained in:
commit
cb370f8dd9
src/portal/src/app/project/repository
artifact/artifact-additions/artifact-vulnerabilities
vulnerability-scanning
@ -1,4 +1,4 @@
|
||||
import { Component, Input, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, Input, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||
import { AdditionsService } from "../additions.service";
|
||||
import { ClrDatagridComparatorInterface, ClrLoadingState } from "@clr/angular";
|
||||
import { finalize } from "rxjs/operators";
|
||||
@ -18,13 +18,14 @@ import {
|
||||
} from "../../../../../../lib/utils/utils";
|
||||
import { ChannelService } from "../../../../../../lib/services/channel.service";
|
||||
import { ResultBarChartComponent } from "../../../vulnerability-scanning/result-bar-chart.component";
|
||||
import { Subscription } from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'hbr-artifact-vulnerabilities',
|
||||
templateUrl: './artifact-vulnerabilities.component.html',
|
||||
styleUrls: ['./artifact-vulnerabilities.component.scss']
|
||||
})
|
||||
export class ArtifactVulnerabilitiesComponent implements OnInit {
|
||||
export class ArtifactVulnerabilitiesComponent implements OnInit, OnDestroy {
|
||||
@Input()
|
||||
vulnerabilitiesLink: AdditionLink;
|
||||
@Input()
|
||||
@ -48,6 +49,7 @@ export class ArtifactVulnerabilitiesComponent implements OnInit {
|
||||
hasShowLoading: boolean = false;
|
||||
@ViewChild(ResultBarChartComponent, {static: false})
|
||||
resultBarChartComponent: ResultBarChartComponent;
|
||||
sub: Subscription;
|
||||
constructor(
|
||||
private errorHandler: ErrorHandler,
|
||||
private additionsService: AdditionsService,
|
||||
@ -67,9 +69,17 @@ export class ArtifactVulnerabilitiesComponent implements OnInit {
|
||||
this.getVulnerabilities();
|
||||
this.getScanningPermission();
|
||||
this.getProjectScanner();
|
||||
this.channel.ArtifactDetail$.subscribe(tag => {
|
||||
this.getVulnerabilities();
|
||||
});
|
||||
if (!this.sub) {
|
||||
this.sub = this.channel.ArtifactDetail$.subscribe(tag => {
|
||||
this.getVulnerabilities();
|
||||
});
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
|
||||
getVulnerabilities() {
|
||||
|
@ -147,8 +147,6 @@ export class ResultBarChartComponent implements OnInit, OnDestroy {
|
||||
if (!this.repoName || !this.artifactDigest) {
|
||||
return;
|
||||
}
|
||||
|
||||
// this.tagService.getTag(this.repoName, this.artifactId)
|
||||
this.artifactService.getArtifact({
|
||||
projectName: this.projectName,
|
||||
repositoryName: this.repoName,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { forkJoin } from "rxjs";
|
||||
import { Component, OnInit, Input, OnDestroy } from '@angular/core';
|
||||
import { forkJoin, Subscription } from "rxjs";
|
||||
import { finalize } from "rxjs/operators";
|
||||
import { ClrDatagridComparatorInterface, ClrLoadingState } from "@clr/angular";
|
||||
import {
|
||||
@ -17,7 +17,7 @@ import { DEFAULT_SUPPORTED_MIME_TYPE, SEVERITY_LEVEL_MAP, VULNERABILITY_SEVERITY
|
||||
templateUrl: './result-grid.component.html',
|
||||
styleUrls: ['./scanning.scss']
|
||||
})
|
||||
export class ResultGridComponent implements OnInit {
|
||||
export class ResultGridComponent implements OnInit, OnDestroy {
|
||||
scanningResults: VulnerabilityItem[] = [];
|
||||
dataCache: VulnerabilityItem[] = [];
|
||||
loading: boolean = false;
|
||||
@ -29,6 +29,7 @@ export class ResultGridComponent implements OnInit {
|
||||
hasEnabledScanner: boolean = false;
|
||||
scanBtnState: ClrLoadingState = ClrLoadingState.DEFAULT;
|
||||
severitySort: ClrDatagridComparatorInterface<VulnerabilityItem>;
|
||||
sub: Subscription;
|
||||
constructor(
|
||||
private scanningService: ScanningResultService,
|
||||
private channel: ChannelService,
|
||||
@ -46,9 +47,17 @@ export class ResultGridComponent implements OnInit {
|
||||
ngOnInit(): void {
|
||||
this.loadResults(this.repositoryId, this.tagId);
|
||||
this.getScanPermissions(this.projectId);
|
||||
this.channel.ArtifactDetail$.subscribe(tag => {
|
||||
this.loadResults(this.repositoryId, this.tagId);
|
||||
});
|
||||
if (!this.sub) {
|
||||
this.channel.ArtifactDetail$.subscribe(tag => {
|
||||
this.loadResults(this.repositoryId, this.tagId);
|
||||
});
|
||||
}
|
||||
}
|
||||
ngOnDestroy() {
|
||||
if (this.sub) {
|
||||
this.sub.unsubscribe();
|
||||
this.sub = null;
|
||||
}
|
||||
}
|
||||
getLevel(v: VulnerabilityItem): number {
|
||||
if (v && v.severity && SEVERITY_LEVEL_MAP[v.severity]) {
|
||||
|
Loading…
Reference in New Issue
Block a user