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

Commit 9df913c

Browse files
author
JWittmeyer
committed
Adds request logic for huddle
1 parent 0ee4a1f commit 9df913c

File tree

5 files changed

+218
-101
lines changed

5 files changed

+218
-101
lines changed

src/app/base/services/project/project-apollo.service.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -930,6 +930,19 @@ export class ProjectApolloService {
930930
],
931931
});
932932
}
933+
requestHuddleData(projectId: string, huddleId: string, huddleType: string) {
934+
return this.apollo
935+
.query({
936+
query: queries.REQUEST_HUDDLE_DATA,
937+
variables: {
938+
projectId: projectId,
939+
huddleId: huddleId,
940+
huddleType: huddleType
941+
},
942+
fetchPolicy: 'no-cache',
943+
})
944+
.pipe(map((result) => result['data']['requestHuddleData']));
945+
}
933946

934947
getAccessLink(projectId: string, linkId: string) {
935948
return this.apollo

src/app/base/services/project/project-queries.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,5 +371,19 @@ export const queries = {
371371
link
372372
}
373373
}
374+
`,
375+
REQUEST_HUDDLE_DATA: gql`
376+
query ($projectId: ID!, $huddleId: ID!, $huddleType: String!) {
377+
requestHuddleData(projectId: $projectId, huddleId: $huddleId, huddleType: $huddleType) {
378+
huddleId
379+
recordIds
380+
huddleType
381+
startPos
382+
allowedTask
383+
canEdit
384+
}
385+
}
386+
374387
`
388+
375389
};

src/app/labeling/components/labeling-helper.ts renamed to src/app/labeling/components/helper/labeling-helper.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,51 @@ export type labelingLinkData = {
77
linkType: labelingLinkType;
88
};
99

10+
export type labelingHuddle = {
11+
recordIds: string[],
12+
partial: boolean
13+
linkData: labelingLinkData,
14+
allowedTask: string,
15+
canEdit: boolean
16+
};
17+
1018
export enum labelingLinkType {
1119
SESSION = "SESSION",
1220
DATA_SLICE = "DATA_SLICE",
1321
HEURISTIC = "HEURISTIC"
1422
}
23+
export enum userRoles {
24+
EXPERT = "EXPERT",
25+
ANNOTATOR = "ANNOTATOR",
26+
ENGINEER = "ENGINEER"
27+
}
28+
29+
export function assumeUserRole(userRole: string, linkType: labelingLinkType): string {
30+
if (userRole == "ANNOTATOR" || userRole == "EXPERT") return userRole;
31+
switch (linkType) {
32+
case labelingLinkType.DATA_SLICE:
33+
return userRoles.EXPERT;
34+
case labelingLinkType.HEURISTIC:
35+
return userRoles.ANNOTATOR;
36+
case labelingLinkType.SESSION:
37+
default:
38+
return userRoles.ENGINEER;
39+
}
40+
}
41+
export function guessLinkType(userRole: string): string {
42+
switch (userRole) {
43+
case userRoles.EXPERT:
44+
return labelingLinkType.DATA_SLICE;
45+
case userRoles.ANNOTATOR:
46+
return labelingLinkType.HEURISTIC;
47+
case userRoles.ENGINEER:
48+
default:
49+
return labelingLinkType.SESSION;
50+
}
51+
}
1552

1653
function linkTypeFromStr(str: string): labelingLinkType {
54+
if (!str) return labelingLinkType.SESSION;
1755
switch (str.toUpperCase()) {
1856
case "DATA_SLICE":
1957
return labelingLinkType.DATA_SLICE;

src/app/labeling/components/labeling.component.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<div *ngIf="user" class="h-full grid gap-0 bg-white" style="grid-template-rows: 65px minmax(auto,92%) 65px; "
22
[ngClass]="somethingLoading?'wait':null">
3+
<div *ngIf="roleAssumed" class="absolute left-0 right-0 flex items-center justify-center pointer-events-none"
4+
style="top:17px;z-index:100">
5+
<span class="inline-flex items-center px-2 py-0.5 rounded font-medium bg-red-100 text-red-800">
6+
You are viewing this page as {{user.role}}
7+
</span>
8+
</div>
39
<ng-container [ngTemplateOutlet]="navigationBar" [ngTemplateOutletContext]="{isBottom:false}">
410
</ng-container>
511
<ng-template #dummyDiv>
@@ -50,7 +56,7 @@
5056
[ngStyle]="{'display':isThisTheLabelImLookingFor(label.name,i,activeTask.taskType)?null:'none'}"
5157
[ngClass]="[getBackground(label.color), getText(label.color), getBorder(label.color), getHover(label.color)]">
5258
<div class="truncate" style="max-width: 260px;">{{label.name}}
53-
<kbd *ngIf="label.hotkey && (displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)"
59+
<kbd *ngIf="label.hotkey && (displayUserId == GOLD_USER_ID || displayUserId == user.id)"
5460
class="ml-1 uppercase inline-flex items-center border bg-white border-gray-200 rounded px-2 text-sm font-sans font-medium text-gray-400">{{label.hotkey}}</kbd>
5561
</div>
5662
</button>
@@ -235,7 +241,7 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
235241

236242
<div class="flex flex-grow items-center">
237243
<!--first N options as buttons-->
238-
<div *ngIf="(displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id) && this.labelingTasksMap.get(task.id)"
244+
<div *ngIf="(displayUserId == GOLD_USER_ID || displayUserId == user.id) && this.labelingTasksMap.get(task.id)"
239245
class="flex flex-row"
240246
[ngClass]="[this.labelingTasksMap.get(task.id).labels.length && showNLabelButton?'':'hidden']">
241247
<button
@@ -245,15 +251,15 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
245251
[ngClass]="[getBackground(label.color), getText(label.color), getBorder(label.color), getHover(label.color)]">
246252
<label
247253
class="leading-5 truncate max-w-xs cursor-pointer">{{label.name}}
248-
<kbd *ngIf="label.hotkey && (displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)"
254+
<kbd *ngIf="label.hotkey && (displayUserId == GOLD_USER_ID || displayUserId == user.id)"
249255
class="ml-1 uppercase inline-flex items-center border bg-white border-gray-200 rounded px-2 text-sm font-sans font-medium text-gray-400">{{label.hotkey}}</kbd>
250256
</label>
251257
</button>
252258
</div>
253259
<!--Button with all posibilities and search-->
254260

255261
<button data-tip="Choose from your labels"
256-
*ngIf="(displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)"
262+
*ngIf="(displayUserId == GOLD_USER_ID || displayUserId == user.id)"
257263
(mouseup)="openLabelBoxForTask($event,task.id)"
258264
class="tooltip tooltip-top flex flex-row flex-nowrap bg-white text-gray-700 text-sm font-medium mr-3 px-2 py-0.5 rounded-md border border-gray-300 hover:bg-gray-50 focus:outline-none">
259265
<span>other</span>
@@ -269,7 +275,7 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
269275
<div *ngIf="rla.sourceType != LabelSourceType.INFORMATION_SOURCE || (rla.sourceType == LabelSourceType.INFORMATION_SOURCE && showInformationSourcesFlag)"
270276
[attr.data-tip]="rla.dataTip"
271277
class="tooltip table"
272-
[ngClass]="(displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)?'mt-3':null">
278+
[ngClass]="(displayUserId == GOLD_USER_ID || displayUserId == user.id)?'mt-3':null">
273279
<ng-template
274280
[ngIf]="rla.sourceType != LabelSourceType.MANUAL"
275281
[ngIfElse]="displayNormalLabel">
@@ -334,7 +340,7 @@ <h1 class="text-lg text-gray-900 mb-2">Warning
334340
{{rla.labelingTaskLabel.name}}
335341
</div>
336342
<label
337-
*ngIf="(displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)"
343+
*ngIf="(displayUserId == GOLD_USER_ID || displayUserId == user.id)"
338344
class="pl-1 cursor-pointer"
339345
(click)="deleteRecordLabelAssociation($event,rla.id)">
340346
<svg xmlns="http://www.w3.org/2000/svg"
@@ -778,15 +784,15 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
778784
<div class="text-sm leading-5 text-gray-500 flex-shrink-0 mr-3 my-3">
779785
<div data-tip="If you reached the end, you can select new filters in the browser"
780786
class="tooltip tooltip-bottom relative">
781-
{{sessionData?.currentPos}} / {{sessionData?.recordIds.length}} records in <span
787+
{{huddleData?.linkData.requestedPos}} / {{huddleData?.recordIds.length}} records in <span
782788
class="cursor-help underline"
783789
style="text-decoration-style: dotted;text-underline-offset: 2px;text-decoration-color: #22c55e">current
784790
session</span>
785791
</div>
786792
</div>
787793
<div class="tooltip tooltip-left" data-tip="Arrow left">
788794
<button #previsousButton tabindex="0"
789-
[disabled]="!sessionData || sessionData.currentPos == 1 ?true:null"
795+
[disabled]="!huddleData || huddleData.linkData.requestedPos == 1 ?true:null"
790796
[ngClass]="previsousButton.disabled ? 'opacity-50 cursor-not-allowed' : 'opacity-100 cursor-pointer'"
791797
(click)="previousRecord()"
792798
class="bg-white text-gray-700 text-xs font-semibold mr-3 px-4 py-1.5 rounded-md border border-gray-300 whitespace-nowrap inline-flex items-center hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500">Back
@@ -803,7 +809,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
803809
</div>
804810
<div class="tooltip tooltip-left" data-tip="Arrow right">
805811
<button #nextButton tabindex="0"
806-
[disabled]="!sessionData || !sessionData.recordIds || sessionData.currentPos >= sessionData.recordIds.length ?true:null"
812+
[disabled]="!huddleData || !huddleData.recordIds || huddleData.linkData.requestedPos >= huddleData.recordIds.length ?true:null"
807813
[ngClass]="nextButton.disabled ? 'opacity-50 cursor-not-allowed' : 'opacity-100 cursor-pointer'"
808814
(click)="nextRecord()"
809815
class="bg-indigo-700 text-white text-xs font-semibold px-4 py-1.5 rounded-md cursor-pointer whitespace-nowrap inline-flex items-center hover:bg-indigo-800 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Next
@@ -862,7 +868,7 @@ <h2 class="text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl">
862868
class="rounded-lg text-white pl-2 normal-case self-start border rounded-l-none text-sm leading-5 font-bold pr-1"
863869
[ngClass]="[getBackground(exData.labelColor), getText(exData.labelColor), getBorder(exData.labelColor)]">
864870
{{exData.labelDisplay}}
865-
<label *ngIf="(displayUserId == GOLD_USER_ID || displayUserId == loggedInUser.id)"
871+
<label *ngIf="(displayUserId == GOLD_USER_ID || displayUserId == user.id)"
866872
class="p-1 pl-0 cursor-pointer"
867873
(click)="deleteRecordLabelAssociation($event,exData.markedEntry.id)">
868874
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 inline-block stroke-current relative"

0 commit comments

Comments
 (0)