Skip to content

Commit

Permalink
license backend integration and UI customization.
Browse files Browse the repository at this point in the history
Signed-off-by: lanrekkeeg <[email protected]>
  • Loading branch information
lanrekkeeg committed Mar 15, 2023
1 parent 69b3a8a commit bd7bf84
Show file tree
Hide file tree
Showing 7 changed files with 552 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { BehaviorSubject } from 'rxjs/BehaviorSubject';

/*******************************************************************************
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
Expand All @@ -23,6 +25,18 @@ export interface Software {
licensesAll: Array<string>;
}

export class LicenseTree {
name: string;
files?: LicenseTree[];
ismarktodelte: boolean;
}

export class LicenseTreeFlatNode {
expandable: boolean;
name: string;
level: number;
}

export enum Status {
QUEUED = 'QUEUED',
UPLOADING = 'UPLOADING',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class LicenseEngineService {

getCompatibleLicenses(): Observable<string[]> {
const headers = new HttpHeaders({ 'content-type': 'application/json', 'Accept': 'application/json' });
return this.http.get(this.licenseEngineUrl + '/software/' + this.software.id + '/recommended-licenses', {
return this.http.get(this.licenseEngineUrl + '/software/' + this.software.id + '/compatible-licenses', {
headers: headers
}).map(
(data) => {
Expand Down Expand Up @@ -169,4 +169,35 @@ export class LicenseEngineService {
return this.software.licensesEffective;
}

getLicensewithFiles(id: String): any {
const headers = new HttpHeaders({ 'Accept': 'application/json' });
return this.http.get(this.licenseEngineUrl + '/software/' + id + '/licenses?effective=false', {
headers: headers
});
}

excludeFile(filename: String[]) {

const headers = new HttpHeaders({ 'content-type': 'application/json' });
headers.append('Access-Control-Request-Method', 'DELETE');
return this.http.put(this.licenseEngineUrl + '/software/' + this.software.id + '/files-excluded', filename, {
headers: headers, observe: 'response'
}).map((response) => {
return response.status === 200;
});
}

deleteExcludedFile() {
const headers = new HttpHeaders({ 'content-type': 'application/json' });
headers.append('Access-Control-Request-Method', 'DELETE');
return this.http.delete(this.licenseEngineUrl + '/software/' + this.software.id + '/files-excluded', {
headers: headers, observe: 'response'
}).map((response) => {
return response.status === 204;
});




}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,19 @@ input {
font: normal 12px/100% Verdana, Tahoma, sans-serif;
width: 100%;
}

#s1 {
height: 40px;
width: 600px;
overflow-x: scroll;/* Remove this if you want the user to resize the textarea */
}

#s2 {
height: 40px;
width: 600px;
overflow-x: scroll;/* Remove this if you want the user to resize the textarea */
}

.emphasized {
font-size: small;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

<textarea [(ngModel)]="currentLicenseText" *ngIf="!showForm"></textarea>

<div *ngIf="showForm" style="clear: both">
<div class="emphasized" *ngIf="showForm" style="clear: both">
<mat-horizontal-stepper [linear]="true" #stepper>
<mat-step completed="false">
<form [formGroup]="firstFormGroup">
Expand Down Expand Up @@ -117,7 +117,93 @@
<form [formGroup]="secondFormGroup">
<ng-template matStepLabel>Check Compatibility</ng-template>
<br>
<mat-label style="font-size: 15px">{{foundLicenses}}</mat-label>
<mat-accordion>
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>

<h5><u>Files with found licenses</u></h5>
</mat-panel-title>
</mat-expansion-panel-header>

<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
<!-- This is the tree node template for leaf nodes -->
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
<!-- use a disabled button to provide padding for tree leaf -->
<button mat-icon-button disabled></button>
{{node.name}}
</mat-tree-node>
<!-- This is the tree node template for expandable nodes -->
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>

<p id="s1" *ngIf="!checkNode(node)"><b>{{node.name}}</b>
</p>

<p id="s2" *ngIf="checkNode(node)">
<del>
<b> {{node.name}} </b>
</del>
</p>

<button mat-icon-button (click)="deleteItem(node)">
<mat-icon>block</mat-icon>
</button>

<button mat-icon-button (click)="undoDelteItemd(node)">
<mat-icon>undo</mat-icon>
</button>
</mat-tree-node>

</mat-tree>
</mat-expansion-panel>
<div *ngIf="unknowLicense.length!=0">
<mat-expansion-panel>

<mat-expansion-panel-header>
<mat-panel-title>
<h5><u>Files which may contain possible licences</u></h5>

</mat-panel-title>

</mat-expansion-panel-header>
<mat-list>
<mat-list-item class="emphasized" *ngFor="let file of unknowLicense">
<b>{{file}}</b>
</mat-list-item>


</mat-list>
</mat-expansion-panel>

</div>

<div *ngIf="nullLicense.length!=0">
<mat-expansion-panel>

<mat-expansion-panel-header>
<mat-panel-title>
<h5><u>Files which do not contain any licences</u></h5>

</mat-panel-title>

</mat-expansion-panel-header>
<mat-list>
<mat-list-item class="emphasized" *ngFor="let file of nullLicense">
<b>{{file}}</b>
</mat-list-item>


</mat-list>
</mat-expansion-panel>

</div>
</mat-accordion>
<br><br>
<div *ngIf="loadingbar">
<mat-progress-bar mode="indeterminate"
Expand All @@ -131,10 +217,12 @@
<div>
<button class="btn btn-primary" matStepperPrevious (click)="back()">Back</button>
<button style="margin-left: 12px" class="btn btn-primary"
(click)="onSubmitCheckCompatibility()" [disabled]="loadingbar">Next
(click)="deleteFromBackend();onSubmitCheckCompatibility()" [disabled]="loadingbar">
Next
</button>
</div>
</form>

</mat-step>
<mat-step>
<ng-template matStepLabel>Select License</ng-template>
Expand Down
Loading

0 comments on commit bd7bf84

Please sign in to comment.