Skip to content
This repository was archived by the owner on Mar 8, 2024. It is now read-only.

Commit c6add0e

Browse files
Remove GDPR flag on bricks integrator (#146)
* Remove GDPR flag on bricks integrator * Added gdpr flags as contants * Removed additional check * Updated filter params on bricks integrator * Code improvements * Comment added * PR comments * PR comments
1 parent b77ec94 commit c6add0e

File tree

4 files changed

+56
-39
lines changed

4 files changed

+56
-39
lines changed

src/app/base/components/bricks-integrator/bricks-integrator.component.html

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,6 @@
199199
(click)="selectSearchResult(result.id)"
200200
class="group flex flex-row items-center cursor-pointer select-none rounded-xl p-3 hover:bg-gray-100 relative"
201201
id="option-1" role="option" tabindex="-1">
202-
<div *ngIf="result.id >0 && config.extendedIntegrator" class="absolute right-2 top-2">
203-
<div class="tooltip tooltip-left"
204-
[attr.data-tip]="result.attributes.gdprCompliant?'GDPR Compliant':'Not GDPR Compliant'">
205-
<button
206-
[ngClass]="result.attributes.gdprCompliant?'bg-green-100 border border-green-400 text-green-700':'bg-red-100 border border-red-400 text-red-700'"
207-
class="rounded-lg text-xs px-2.5 py-0.5 cursor-default border">GDPR</button>
208-
</div>
209-
</div>
210202
<svg *ngIf="result.attributes.moduleType == 'generator'" xmlns="http://www.w3.org/2000/svg"
211203
class="h-6 w-6 flex-none text-gray-900 text-opacity-40" width="24" height="24"
212204
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none"
@@ -267,7 +259,8 @@
267259
<div class="col-start-1 col-span-full">
268260
<div class="flex flex-row justify-between cursor-pointer items-center"
269261
(click)="config.extendedIntegratorOverviewAddInfoOpen=!config.extendedIntegratorOverviewAddInfoOpen">
270-
<label class="text-base font-bold text-gray-900 cursor-pointer">Details</label>
262+
<label
263+
class="text-base font-bold text-gray-900 cursor-pointer underline">Details</label>
271264
<div [ngClass]="config.extendedIntegratorOverviewAddInfoOpen?'rotate-transform':null">
272265
<svg xmlns="http://www.w3.org/2000/svg"
273266
class="icon icon-tabler icon-tabler-chevrons-down" width="24" height="24"
@@ -298,8 +291,9 @@
298291
<div class="col-start-1 col-span-full">
299292
<div class="flex flex-row justify-between cursor-pointer items-center"
300293
(click)="config.overviewCodeOpen=!config.overviewCodeOpen">
301-
<label class="text-base font-bold text-gray-900 cursor-pointer">Source Code<span
302-
class="text-sm font-normal">(guided integration through tab
294+
<label class="text-base font-bold text-gray-900 cursor-pointer"><span
295+
class="underline">Source Code</span>
296+
<span class="text-sm font-normal">&nbsp;(guided integration through tab
303297
integration)</span></label>
304298
<div [ngClass]="config.overviewCodeOpen?'rotate-transform':null">
305299
<svg xmlns="http://www.w3.org/2000/svg"
@@ -315,9 +309,9 @@
315309
<div [ngClass]="config.overviewCodeOpen?'':'hidden'"
316310
class="flex flex-col mt-1 items-center">
317311

318-
<div class="overflow-y-auto"
319-
style="max-height:15rem;max-width: 35rem; overflow-x:hidden">
320-
<pre class="editor-pre">{{codeParser.baseCode}}</pre>
312+
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem;">
313+
<pre class="editor-pre"
314+
[ngStyle]="{'overflow-x':config.overviewCodeOpen? 'auto': 'hidden'}">{{codeParser.baseCode}}</pre>
321315
</div>
322316
<div class="mt-2 tooltip"
323317
[attr.data-tip]="config.copied?'Copied':'Click to copy raw code'">
@@ -349,8 +343,9 @@
349343
<div class="col-start-1 col-span-full">
350344
<div class="flex flex-row justify-between cursor-pointer items-center"
351345
(click)="config.overviewCodeOpen=!config.overviewCodeOpen">
352-
<label class="text-base font-bold text-gray-900 cursor-pointer">Source Code<span
353-
class="text-sm font-normal">(guided integration through tab
346+
<label class="text-base font-bold text-gray-900 cursor-pointer"><span
347+
class="underline">Source Code</span>
348+
<span class="text-sm font-normal">&nbsp;(guided integration through tab
354349
integration)</span></label>
355350
<div [ngClass]="config.overviewCodeOpen?'rotate-transform':null">
356351
<svg xmlns="http://www.w3.org/2000/svg"
@@ -366,9 +361,9 @@
366361
<div [ngClass]="config.overviewCodeOpen?'':'hidden'"
367362
class="flex flex-col mt-1 items-center">
368363

369-
<div class="overflow-y-auto"
370-
style="max-height:15rem;max-width: 35rem; overflow-x:hidden">
371-
<pre class="editor-pre">{{codeParser.baseCode}}</pre>
364+
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem;">
365+
<pre class="editor-pre"
366+
[ngStyle]="{'overflow-x':config.overviewCodeOpen? 'auto': 'hidden'}">{{codeParser.baseCode}}</pre>
372367
</div>
373368
<div class="mt-2 tooltip"
374369
[attr.data-tip]="config.copied?'Copied':'Click to copy raw code'">
@@ -658,8 +653,9 @@
658653
</div>
659654
</div>
660655
<div [ngClass]="config.integratorCodeOpen?'':'hidden'" class="flex flex-col mt-1 items-center">
661-
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem; overflow-x:hidden">
662-
<pre class="editor-pre">{{config.preparedCode}}</pre>
656+
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem;">
657+
<pre class="editor-pre"
658+
[ngStyle]="{'overflow-x':config.overviewCodeOpen? 'auto': 'hidden'}">{{config.preparedCode}}</pre>
663659
</div>
664660
</div>
665661
</div>
@@ -681,8 +677,9 @@
681677
</div>
682678

683679
<div [ngClass]="config.integratorParseOpen?'':'hidden'" class="flex flex-col mt-1 items-center">
684-
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem; overflow-x:hidden">
685-
<pre class="editor-pre">{{config.preparedJson}}</pre>
680+
<div class="overflow-y-auto" style="max-height:15rem;max-width: 35rem;">
681+
<pre class="editor-pre"
682+
[ngStyle]="{'overflow-x':config.overviewCodeOpen? 'auto': 'hidden'}">{{config.preparedJson}}</pre>
686683
</div>
687684
<div class="flex flex-row flex-wrap gap-2">
688685
<div class="flex flex-row flex-nowrap cursor-pointer"

src/app/base/components/bricks-integrator/bricks-integrator.component.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { ProjectApolloService } from '../../services/project/project-apollo.serv
1010
import { BricksCodeParser } from './helper/code-parser';
1111
import { BricksDataRequestor } from './helper/data-requestor';
1212
import { BricksAPIData, BricksIntegratorConfig, BricksSearchData, BricksVariable, BricksVariableType, getEmptyBricksIntegratorConfig, IntegratorPage } from './helper/type-helper';
13-
import { extendDummyElements, getDummyNodeByIdForApi } from './helper/dummy-nodes';
13+
import { GROUPS_TO_REMOVE, extendDummyElements, getDummyNodeByIdForApi } from './helper/dummy-nodes';
1414
import { caesarCipher } from 'src/app/util/cipher';
1515
import { PASS_ME } from 'src/app/util/cipher';
16-
import { copyToClipboard, isStringTrue, jsonCopy } from 'submodules/javascript-functions/general';
16+
import { copyToClipboard, removeArrayFromArray, isStringTrue, jsonCopy } from 'submodules/javascript-functions/general';
1717
import { capitalizeFirst } from 'submodules/javascript-functions/case-types-parser';
1818

1919
@Component({
@@ -133,16 +133,25 @@ export class BricksIntegratorComponent implements OnInit, OnDestroy {
133133
private buildSearchUrl(): string {
134134
let filter = "?pagination[pageSize]=99999";
135135
filter += this.extendUrl(this.moduleTypeFilter, "moduleType");
136-
filter += this.extendUrl(this.executionTypeFilter, "executionType")
136+
filter += this.extendUrl(this.executionTypeFilter, "executionType");
137137
return this.HttpBaseLink + filter;
138138
}
139139

140140
private extendUrl(value: string, attribute: string): string {
141-
if (!value) return "";
142141
let filter = "";
142+
if (!value) return filter += "&filters[executionType][$ne]=activeLearner";
143143
const splitVal: string[] = value.split(',');
144144
for (let i = 0; i < splitVal.length; i++) {
145145
filter += "&filters[" + attribute + "][$eq]=" + splitVal[i].trim();
146+
filter += this.filterActiveLearnersFromGenerators(splitVal, i, filter);
147+
}
148+
return filter;
149+
}
150+
151+
private filterActiveLearnersFromGenerators(splitVal: string[], index: number, filter: string) {
152+
// Remove active learners from generators (on ac page we have generators and classifiers but we want to exclude active learners there)
153+
if (splitVal[index].trim() == 'generator' && this.executionTypeFilter != "activeLearner") {
154+
filter += "&filters[executionType][$ne]=activeLearner";
146155
}
147156
return filter;
148157
}
@@ -170,12 +179,15 @@ export class BricksIntegratorComponent implements OnInit, OnDestroy {
170179
this.config.search.currentRequest = null;
171180
let finalData;
172181
if (this.config.extendedIntegrator) {
173-
finalData = data.data.map(e => {
174-
const c = jsonCopy(e);
175-
if (e.attributes.partOfGroup) c.attributes.partOfGroup = JSON.parse(c.attributes.partOfGroup);
176-
if (e.attributes.availableFor) c.attributes.availableFor = JSON.parse(c.attributes.availableFor);
177-
if (e.attributes.integratorInputs) c.attributes.integratorInputs = JSON.parse(c.attributes.integratorInputs);
178-
return c;
182+
finalData = data.data.map(integratorData => {
183+
const integratorDataCopy = jsonCopy(integratorData);
184+
if (integratorData.attributes.partOfGroup) {
185+
integratorDataCopy.attributes.partOfGroup = JSON.parse(integratorDataCopy.attributes.partOfGroup);
186+
integratorDataCopy.attributes.partOfGroup = removeArrayFromArray(integratorDataCopy.attributes.partOfGroup, GROUPS_TO_REMOVE);
187+
}
188+
if (integratorData.attributes.availableFor) integratorDataCopy.attributes.availableFor = JSON.parse(integratorDataCopy.attributes.availableFor);
189+
if (integratorData.attributes.integratorInputs) integratorDataCopy.attributes.integratorInputs = JSON.parse(integratorDataCopy.attributes.integratorInputs);
190+
return integratorDataCopy;
179191
});
180192
} else finalData = data.data;
181193
if (this.executionTypeFilter) {
@@ -262,8 +274,6 @@ export class BricksIntegratorComponent implements OnInit, OnDestroy {
262274

263275
private getGroupName(groupKey: string): string {
264276
switch (groupKey) {
265-
case "gdpr_compliant": return "GDPR Compliant";
266-
case "not_gdpr_compliant": return "Not GDPR Compliant";
267277
case "no_api_key": return "No API Key";
268278
default: return capitalizeFirst(groupKey);
269279
}
@@ -361,8 +371,10 @@ export class BricksIntegratorComponent implements OnInit, OnDestroy {
361371
next: (c: any) => {
362372
if (!c.data.attributes.integratorInputs) this.config.api.data = c;
363373
else {
374+
// Additional parsing for integrator inputs used in the overview section in the bricks integrator
364375
this.config.api.data = c;
365376
this.config.api.data.data.attributes.partOfGroup = JSON.parse(c.data.attributes.partOfGroup);
377+
this.config.api.data.data.attributes.partOfGroup = removeArrayFromArray(this.config.api.data.data.attributes.partOfGroup, GROUPS_TO_REMOVE);
366378
this.config.api.data.data.attributes.partOfGroupText = this.config.api.data.data.attributes.partOfGroup.map(x => this.getGroupName(x)).join(", ");
367379
this.config.api.data.data.attributes.availableFor = JSON.parse(c.data.attributes.availableFor);
368380
this.config.api.data.data.attributes.integratorInputs = JSON.parse(c.data.attributes.integratorInputs);

src/app/base/components/bricks-integrator/helper/dummy-nodes.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function getDummyNodeByIdForApi(id: DummyNodes): any {
3939
baseNode.data.attributes.description = "Lets you test the new structure with dummy data from vader sentiment (only available for kern admins)";
4040
baseNode.data.attributes.availableFor = ["refinery"];
4141
baseNode.data.attributes.sourceCode = DUMMY_CODE_VADER;
42-
baseNode.data.attributes.partOfGroup = ["sentiment", "gdpr_compliant"];
42+
baseNode.data.attributes.partOfGroup = ["sentiment"];
4343
baseNode.data.attributes.integratorInputs = {
4444
"name": "vader_sentiment",
4545
"refineryDataType": "text",
@@ -110,7 +110,7 @@ function getDummyNodeByIdForSelection(id: DummyNodes, extendedIntegrator: boolea
110110
baseNode.attributes.description = "Lets you test the new structure with dummy data from vader sentiment (only available for kern admins)";
111111
// baseNode.attributes.sourceCode = DUMMY_CODE_VADER;
112112
baseNode.attributes.availableFor = ["refinery"];
113-
baseNode.attributes.partOfGroup = ["sentiment", "gdpr_compliant"];
113+
baseNode.attributes.partOfGroup = ["sentiment"];
114114

115115
return baseNode;
116116

@@ -215,4 +215,8 @@ def vader_sentiment(record):
215215
elif vs["compound"] <= -0.05:
216216
return "negative"
217217
elif MODE == "scores":
218-
return vs`;
218+
return vs`;
219+
220+
221+
// TODO: Remove this when grdp is removed from bricks
222+
export const GROUPS_TO_REMOVE = ['gdpr_compliant', 'not_gdpr_compliant'];

submodules/javascript-functions/general.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,8 @@ export function countOccurrences(str: string, search: string): number {
173173
else break;
174174
}
175175
return c;
176-
}
176+
}
177+
178+
export function removeArrayFromArray(mainArray: any[], arrayToRemove: any[]) {
179+
return mainArray.filter((element) => !arrayToRemove.includes(element));
180+
}

0 commit comments

Comments
 (0)