Skip to content

Commit bd7bf84

Browse files
committed
license backend integration and UI customization.
Signed-off-by: lanrekkeeg <p156058@nu.edu.pk>
1 parent 69b3a8a commit bd7bf84

File tree

7 files changed

+552
-13
lines changed

7 files changed

+552
-13
lines changed

org.eclipse.winery.frontends/app/tosca-management/src/app/wineryLicenseModule/LicenseEngineApiData.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
2+
13
/*******************************************************************************
24
* Copyright (c) 2022 Contributors to the Eclipse Foundation
35
*
@@ -23,6 +25,18 @@ export interface Software {
2325
licensesAll: Array<string>;
2426
}
2527

28+
export class LicenseTree {
29+
name: string;
30+
files?: LicenseTree[];
31+
ismarktodelte: boolean;
32+
}
33+
34+
export class LicenseTreeFlatNode {
35+
expandable: boolean;
36+
name: string;
37+
level: number;
38+
}
39+
2640
export enum Status {
2741
QUEUED = 'QUEUED',
2842
UPLOADING = 'UPLOADING',

org.eclipse.winery.frontends/app/tosca-management/src/app/wineryLicenseModule/licenseEngine.service.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export class LicenseEngineService {
9898

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

172+
getLicensewithFiles(id: String): any {
173+
const headers = new HttpHeaders({ 'Accept': 'application/json' });
174+
return this.http.get(this.licenseEngineUrl + '/software/' + id + '/licenses?effective=false', {
175+
headers: headers
176+
});
177+
}
178+
179+
excludeFile(filename: String[]) {
180+
181+
const headers = new HttpHeaders({ 'content-type': 'application/json' });
182+
headers.append('Access-Control-Request-Method', 'DELETE');
183+
return this.http.put(this.licenseEngineUrl + '/software/' + this.software.id + '/files-excluded', filename, {
184+
headers: headers, observe: 'response'
185+
}).map((response) => {
186+
return response.status === 200;
187+
});
188+
}
189+
190+
deleteExcludedFile() {
191+
const headers = new HttpHeaders({ 'content-type': 'application/json' });
192+
headers.append('Access-Control-Request-Method', 'DELETE');
193+
return this.http.delete(this.licenseEngineUrl + '/software/' + this.software.id + '/files-excluded', {
194+
headers: headers, observe: 'response'
195+
}).map((response) => {
196+
return response.status === 204;
197+
});
198+
199+
200+
201+
202+
}
172203
}

org.eclipse.winery.frontends/app/tosca-management/src/app/wineryLicenseModule/wineryLicense.component.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,19 @@ input {
7676
font: normal 12px/100% Verdana, Tahoma, sans-serif;
7777
width: 100%;
7878
}
79+
80+
#s1 {
81+
height: 40px;
82+
width: 600px;
83+
overflow-x: scroll;/* Remove this if you want the user to resize the textarea */
84+
}
85+
86+
#s2 {
87+
height: 40px;
88+
width: 600px;
89+
overflow-x: scroll;/* Remove this if you want the user to resize the textarea */
90+
}
91+
92+
.emphasized {
93+
font-size: small;
94+
}

org.eclipse.winery.frontends/app/tosca-management/src/app/wineryLicenseModule/wineryLicense.component.html

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

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

81-
<div *ngIf="showForm" style="clear: both">
81+
<div class="emphasized" *ngIf="showForm" style="clear: both">
8282
<mat-horizontal-stepper [linear]="true" #stepper>
8383
<mat-step completed="false">
8484
<form [formGroup]="firstFormGroup">
@@ -117,7 +117,93 @@
117117
<form [formGroup]="secondFormGroup">
118118
<ng-template matStepLabel>Check Compatibility</ng-template>
119119
<br>
120-
<mat-label style="font-size: 15px">{{foundLicenses}}</mat-label>
120+
<mat-accordion>
121+
<mat-expansion-panel>
122+
<mat-expansion-panel-header>
123+
<mat-panel-title>
124+
125+
<h5><u>Files with found licenses</u></h5>
126+
</mat-panel-title>
127+
</mat-expansion-panel-header>
128+
129+
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl">
130+
<!-- This is the tree node template for leaf nodes -->
131+
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding>
132+
<!-- use a disabled button to provide padding for tree leaf -->
133+
<button mat-icon-button disabled></button>
134+
{{node.name}}
135+
</mat-tree-node>
136+
<!-- This is the tree node template for expandable nodes -->
137+
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
138+
<button mat-icon-button matTreeNodeToggle
139+
[attr.aria-label]="'toggle ' + node.name">
140+
<mat-icon class="mat-icon-rtl-mirror">
141+
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
142+
</mat-icon>
143+
</button>
144+
145+
<p id="s1" *ngIf="!checkNode(node)"><b>{{node.name}}</b>
146+
</p>
147+
148+
<p id="s2" *ngIf="checkNode(node)">
149+
<del>
150+
<b> {{node.name}} </b>
151+
</del>
152+
</p>
153+
154+
<button mat-icon-button (click)="deleteItem(node)">
155+
<mat-icon>block</mat-icon>
156+
</button>
157+
158+
<button mat-icon-button (click)="undoDelteItemd(node)">
159+
<mat-icon>undo</mat-icon>
160+
</button>
161+
</mat-tree-node>
162+
163+
</mat-tree>
164+
</mat-expansion-panel>
165+
<div *ngIf="unknowLicense.length!=0">
166+
<mat-expansion-panel>
167+
168+
<mat-expansion-panel-header>
169+
<mat-panel-title>
170+
<h5><u>Files which may contain possible licences</u></h5>
171+
172+
</mat-panel-title>
173+
174+
</mat-expansion-panel-header>
175+
<mat-list>
176+
<mat-list-item class="emphasized" *ngFor="let file of unknowLicense">
177+
<b>{{file}}</b>
178+
</mat-list-item>
179+
180+
181+
</mat-list>
182+
</mat-expansion-panel>
183+
184+
</div>
185+
186+
<div *ngIf="nullLicense.length!=0">
187+
<mat-expansion-panel>
188+
189+
<mat-expansion-panel-header>
190+
<mat-panel-title>
191+
<h5><u>Files which do not contain any licences</u></h5>
192+
193+
</mat-panel-title>
194+
195+
</mat-expansion-panel-header>
196+
<mat-list>
197+
<mat-list-item class="emphasized" *ngFor="let file of nullLicense">
198+
<b>{{file}}</b>
199+
</mat-list-item>
200+
201+
202+
</mat-list>
203+
</mat-expansion-panel>
204+
205+
</div>
206+
</mat-accordion>
121207
<br><br>
122208
<div *ngIf="loadingbar">
123209
<mat-progress-bar mode="indeterminate"
@@ -131,10 +217,12 @@
131217
<div>
132218
<button class="btn btn-primary" matStepperPrevious (click)="back()">Back</button>
133219
<button style="margin-left: 12px" class="btn btn-primary"
134-
(click)="onSubmitCheckCompatibility()" [disabled]="loadingbar">Next
220+
(click)="deleteFromBackend();onSubmitCheckCompatibility()" [disabled]="loadingbar">
221+
Next
135222
</button>
136223
</div>
137224
</form>
225+
138226
</mat-step>
139227
<mat-step>
140228
<ng-template matStepLabel>Select License</ng-template>

0 commit comments

Comments
 (0)