diff --git a/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.html b/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.html
index eec0e27..742ce5e 100644
--- a/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.html
+++ b/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.html
@@ -74,7 +74,7 @@
Projects using this licence
@if (library.seeAllDirectLibraries) {
@for (directLibrary of library.directLibraries; track $index) {
- - {{directLibrary._id}}
+ - {{directLibrary._id}}@{{directLibrary.version}}
}
}
@@ -86,7 +86,7 @@ Projects using this licence
@if (library.seeAllIndirectLibraries) {
@for (indirectLibrary of library.indirectLibraries; track $index) {
- - {{indirectLibrary._id}}
+ - {{indirectLibrary._id}}@{{indirectLibrary.version}}
}
}
diff --git a/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.ts b/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.ts
index 2de2421..7716bd6 100644
--- a/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.ts
+++ b/depinder-fe/src/app/all-systems/system-info/system-dashboard/licencing-issues/licencing-issues.component.ts
@@ -2,10 +2,7 @@ import {Component, Input, OnInit} from '@angular/core';
import { CommonModule } from '@angular/common';
import {Dependency, Project} from "@core/project";
import {LibraryInfo} from "@core/library";
-import {Licence} from "@core/licence";
import {MatTableDataSource, MatTableModule} from "@angular/material/table";
-import {OperationalRiskDependencies} from "../old-dependencies-table/old-dependencies-table";
-import {LicenceRulesService} from "../../../../common/services/licence-rules.service";
import {animate, state, style, transition, trigger} from "@angular/animations";
import {OldDepDetailsComponent} from "../old-dependencies-table/old-dep-details/old-dep-details.component";
import {MatListModule} from "@angular/material/list";
@@ -49,10 +46,9 @@ export class LicencingIssuesComponent implements OnInit {
@Input() dependencies: Dependency[] = [];
@Input() licences: any[] = [];
- constructor(private licenceRules: LicenceRulesService) { }
+ constructor() { }
columns = ['licenceID', 'projects', 'libraries', 'conditions', 'limitations', 'permissions', 'issues'];
- // columns = ['licenceID', 'projects', 'libraries', 'issues'];
data: LicenceIssue[] = [];
dataSource!: MatTableDataSource;
projectIDs: string[] = [];
@@ -61,46 +57,28 @@ export class LicencingIssuesComponent implements OnInit {
ngOnInit() {
this.projectIDs = this.projects.map(project => project._id);
- this.data = this.licences
- .filter(licence => (licence.permissions ?? []).length > 0 && (licence.conditions ?? []).length > 0 && (licence.limitations ?? []).length > 0)
+ this.data = (this.licences ?? [])
+ .filter(licence => this.hasDetailedInformation(licence))
.map(licence => {
let licenceLibraries: LibraryDisplay[] = []; // Declare inside the map function
this.projects.forEach(project => {
- project.dependencies.forEach(dependency => {
- let library = this.libraries?.get(dependency.name);
- if (library !== undefined && library.licenses.some(libLicence => libLicence === licence._id)) {
+ for (let lib of licence.libraries) {
+ if (project.dependencies.find(dep => dep.name === lib.name)) {
let libraryDisplay = licenceLibraries.find(libraryDisplay => libraryDisplay.projectId === project._id);
-
if (libraryDisplay) {
- if (dependency.directDep) {
- libraryDisplay.directLibraries?.push(library);
- }
- else {
- libraryDisplay.indirectLibraries.push(library);
- }
+ lib.directDep ? libraryDisplay.directLibraries?.push(lib) : libraryDisplay.indirectLibraries.push(lib);
} else {
- if (dependency.directDep) {
- licenceLibraries.push({
- projectId: project._id,
- directLibraries: [library],
- indirectLibraries: [],
- seeAllDirectLibraries: false,
- seeAllIndirectLibraries: false
- });
- }
- else {
- licenceLibraries.push({
- projectId: project._id,
- directLibraries: [],
- indirectLibraries: [library],
- seeAllDirectLibraries: false,
- seeAllIndirectLibraries: false
- });
- }
+ licenceLibraries.push({
+ projectId: project._id,
+ directLibraries: lib.directDep ? [lib] : [],
+ indirectLibraries: !lib.directDep ? [lib] : [],
+ seeAllDirectLibraries: false,
+ seeAllIndirectLibraries: false
+ });
}
}
- });
+ }
});
return {
@@ -113,10 +91,32 @@ export class LicencingIssuesComponent implements OnInit {
}
})
+ this.data = Object.values(this.data.reduce((acc: any, cur) => {
+ if (!acc[cur.licenceID]) {
+ acc[cur.licenceID] = cur;
+ } else {
+ acc[cur.licenceID] = {
+ ...acc[cur.licenceID],
+ projects: [...(acc[cur.licenceID].projects || []), ...(cur.projects || [])].filter((project, index, self) =>
+ index === self.findIndex((t) => (
+ t.projectId === project.projectId
+ ))
+ ),
+ libraries: [...(acc[cur.licenceID].libraries || []), ...(cur.libraries || [])].filter((library, index, self) =>
+ index === self.findIndex((t) => (
+ t.licenceID === library.licenceID
+ ))
+ ),
+ permissions: cur.permissions,
+ conditions: cur.conditions,
+ limitations: cur.limitations,
+ };
+ }
+ return acc;
+ }, {}));
+
this.data = this.data.filter((licence, index, self) =>
- index === self.findIndex((t) => (
- t.licenceID === licence.licenceID
- )) && this.isCopyleft(licence)
+ this.isCopyleft(licence)
);
this.dataSource = new MatTableDataSource(this.data);
@@ -128,5 +128,7 @@ export class LicencingIssuesComponent implements OnInit {
licence.conditions?.includes('document-changes')) ?? false;
}
- protected readonly Array = Array;
+ hasDetailedInformation(licence: any) {
+ return (licence?.permissions ?? []).length > 0 && (licence?.conditions ?? []).length > 0 && (licence?.limitations ?? []).length > 0;
+ }
}
diff --git a/depinder-fe/src/app/all-systems/system-info/system-dashboard/old-dependencies-table/old-dependencies-table.ts b/depinder-fe/src/app/all-systems/system-info/system-dashboard/old-dependencies-table/old-dependencies-table.ts
index 593946a..fda569e 100644
--- a/depinder-fe/src/app/all-systems/system-info/system-dashboard/old-dependencies-table/old-dependencies-table.ts
+++ b/depinder-fe/src/app/all-systems/system-info/system-dashboard/old-dependencies-table/old-dependencies-table.ts
@@ -72,10 +72,10 @@ export class OldDependenciesTable implements OnChanges, OnChanges, AfterViewInit
}
if (this.projects !== undefined && this.libraries !== undefined) {
- this.getDependencies();
+ this.filterDependencies();
if (this.dependencies.size > 0) {
- this.dataSource = new MatTableDataSource(Array.from(this.dependencies.values()));
+ this.dataSource = new MatTableDataSource(Array.from(this.dependencies.values()).sort((a, b) => a.lastUpdated - b.lastUpdated));
}
}
}
@@ -85,7 +85,7 @@ export class OldDependenciesTable implements OnChanges, OnChanges, AfterViewInit
this.dataSource.sort = this.sort;
}
- getDependencies() {
+ filterDependencies() {
let dependencies = new Map();
this.projects!.forEach(project => {
project.dependencies.filter(dependency => {
@@ -108,11 +108,9 @@ export class OldDependenciesTable implements OnChanges, OnChanges, AfterViewInit
let savedDep = dependencies.get(dependency._id)!;
let projectDependency = savedDep.projects.findIndex(value => {
- if (value.projectId !== project._id) {
- console.log(value.projectId, project._id);
- }
return value.projectId === project._id;
});
+
if (projectDependency != -1) {
savedDep.projects[projectDependency].dependencyVersions.add(dependency.version)
}
diff --git a/depinder-fe/src/app/all-systems/system-info/system-dashboard/system-dashboard.component.ts b/depinder-fe/src/app/all-systems/system-info/system-dashboard/system-dashboard.component.ts
index dbd6f68..eb8a47a 100644
--- a/depinder-fe/src/app/all-systems/system-info/system-dashboard/system-dashboard.component.ts
+++ b/depinder-fe/src/app/all-systems/system-info/system-dashboard/system-dashboard.component.ts
@@ -8,7 +8,7 @@ import {OUT_OF_SUPPORT_MONTHS, OUTDATED_MONTHS} from "@core/constants";
import {VulnerableLibraryVersionsComponent} from "./vulnerable-library-versions/vulnerable-library-versions.component";
import {MatProgressSpinnerModule} from "@angular/material/progress-spinner";
import {MatProgressBarModule} from "@angular/material/progress-bar";
-import {concatMap, delay, finalize, from, map, Observable} from "rxjs";
+import {bufferCount, concatMap, delay, finalize, forkJoin, from, map, Observable} from "rxjs";
import {LibraryInfo, LibraryVersion} from "@core/library";
import {LibrariesService} from "../../../common/services/libraries.service";
import {LicencingIssuesComponent} from "./licencing-issues/licencing-issues.component";
@@ -43,9 +43,7 @@ export class SystemDashboardComponent implements OnChanges {
this.projects = changes['projects'].currentValue;
this.projects.forEach(project => {
- project.dependencies.forEach(dependency => {
- this.dependencies.push(dependency);
- });
+ this.dependencies.push(...project.dependencies);
});
this.totalDependencies = this.dependencies.length;
@@ -81,22 +79,30 @@ export class SystemDashboardComponent implements OnChanges {
getDependencies(): Observable