herum-shared 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/animations/index.d.ts +5 -0
- package/assets/feed/exercise/exerciseAchivment.svg +11 -0
- package/assets/feed/icons/active/audio.svg +5 -0
- package/assets/feed/icons/active/collection.svg +15 -0
- package/assets/feed/icons/active/exercise.svg +13 -0
- package/assets/feed/icons/active/generic-file.svg +8 -0
- package/assets/feed/icons/active/image.svg +11 -0
- package/assets/feed/icons/active/link.svg +6 -0
- package/assets/feed/icons/active/pdf.svg +14 -0
- package/assets/feed/icons/active/presentation.svg +11 -0
- package/assets/feed/icons/active/quiz.svg +17 -0
- package/assets/feed/icons/active/story.svg +7 -0
- package/assets/feed/icons/active/video.svg +11 -0
- package/assets/feed/icons/comment.svg +12 -0
- package/assets/feed/icons/error/audio.svg +5 -0
- package/assets/feed/icons/error/collection.svg +15 -0
- package/assets/feed/icons/error/exercise.svg +13 -0
- package/assets/feed/icons/error/generic-file.svg +8 -0
- package/assets/feed/icons/error/image.svg +11 -0
- package/assets/feed/icons/error/pdf.svg +14 -0
- package/assets/feed/icons/error/presentation.svg +11 -0
- package/assets/feed/icons/error/quiz.svg +17 -0
- package/assets/feed/icons/error/story.svg +7 -0
- package/assets/feed/icons/error/video.svg +11 -0
- package/assets/feed/icons/eye.svg +13 -0
- package/assets/feed/icons/garbage-secondary.svg +14 -0
- package/assets/feed/icons/garbage.svg +14 -0
- package/assets/feed/icons/green-x.svg +165 -0
- package/assets/feed/icons/hamburger.svg +2 -0
- package/assets/feed/icons/inactive/audio.svg +5 -0
- package/assets/feed/icons/inactive/exercise.svg +17 -0
- package/assets/feed/icons/inactive/link.svg +6 -0
- package/assets/feed/icons/inactive/pdf.svg +19 -0
- package/assets/feed/icons/inactive/presentation.svg +13 -0
- package/assets/feed/icons/inactive/quiz.svg +25 -0
- package/assets/feed/icons/inactive/story.svg +7 -0
- package/assets/feed/icons/inactive/video.svg +13 -0
- package/assets/feed/icons/status/Group 856.svg +11 -0
- package/assets/feed/icons/status/almostDone.svg +11 -0
- package/assets/feed/icons/status/done.svg +11 -0
- package/assets/feed/icons/status/inProgress.svg +13 -0
- package/assets/feed/icons/white-chevron.svg +3 -0
- package/assets/feed/icons/wide-mode.png +0 -0
- package/assets/feed/icons/wide-mode.svg +7 -0
- package/assets/feed/icons/wide-mode2.svg +8 -0
- package/assets/files-icons/.image.svg +11 -0
- package/assets/files-icons/.mp4.png +0 -0
- package/assets/files-icons/.mp4.svg +12 -0
- package/assets/files-icons/.pdf.png +0 -0
- package/assets/files-icons/.pdf.svg +16 -0
- package/assets/files-icons/.pptx.png +0 -0
- package/assets/files-icons/.pptx.svg +12 -0
- package/assets/files-icons/.video.svg +12 -0
- package/assets/files-icons/default-file.png +0 -0
- package/assets/files-icons/generic-file.svg +8 -0
- package/assets/files-icons/story.png +0 -0
- package/assets/files-icons/story.svg +3 -0
- package/assets/files-icons/upload-file.svg +4 -0
- package/assets/general/calendar.svg +12 -0
- package/assets/general/chevron.svg +3 -0
- package/assets/general/clock.svg +4 -0
- package/assets/general/closed-chevron.png +0 -0
- package/assets/general/college-calendar.svg +12 -0
- package/assets/general/comment-icon.svg +12 -0
- package/assets/general/dialogX.png +0 -0
- package/assets/general/errorOwl.png +0 -0
- package/assets/general/green-x.svg +4 -0
- package/assets/general/grey-chevron.svg +3 -0
- package/assets/general/keyboardLink.svg +15 -0
- package/assets/general/logo.png +0 -0
- package/assets/general/noCollectionsMessage.svg +59 -0
- package/assets/general/open-chevron.png +0 -0
- package/assets/general/owl-logo.svg +98 -0
- package/assets/general/secondary-x.svg +3 -0
- package/assets/general/user.svg +15 -0
- package/assets/general/white-chevron.svg +3 -0
- package/assets/quiz/greenHeaderArrow.svg +12 -0
- package/assets/quiz/greyHeaderArrow.svg +12 -0
- package/assets/quiz/happyOwl.svg +126 -0
- package/assets/quiz/sadOwl.svg +94 -0
- package/assets/quiz/skip.svg +5 -0
- package/assets/shared/atoms/inputs/herum-inputs.component.scss +56 -0
- package/assets/shared/atoms/selects/herum-selects.component.scss +141 -0
- package/assets/shared/atoms/uploadingStatuses/error.svg +8 -0
- package/assets/shared/atoms/uploadingStatuses/information.svg +6 -0
- package/assets/shared/atoms/uploadingStatuses/success.svg +9 -0
- package/assets/shared/audio-images/gray-pause.svg +4 -0
- package/assets/shared/audio-images/gray-play.svg +3 -0
- package/assets/shared/audio-images/next15.svg +7 -0
- package/assets/shared/audio-images/pause.svg +4 -0
- package/assets/shared/audio-images/play.svg +3 -0
- package/assets/shared/audio-images/previous15.svg +7 -0
- package/assets/shared/background/cubes.png +0 -0
- package/assets/shared/background/cubes.svg +1900 -0
- package/assets/shared/icons/V.svg +3 -0
- package/assets/shared/icons/X.svg +3 -0
- package/assets/shared/icons/active-clipboard.svg +7 -0
- package/assets/shared/icons/active-drag.svg +44 -0
- package/assets/shared/icons/active-upload.svg +3 -0
- package/assets/shared/icons/add.svg +3 -0
- package/assets/shared/icons/attachUsers.png +0 -0
- package/assets/shared/icons/big-no-result-owl.png +0 -0
- package/assets/shared/icons/bigV.svg +3 -0
- package/assets/shared/icons/celeb-owl.png +0 -0
- package/assets/shared/icons/clock.svg +3 -0
- package/assets/shared/icons/drag.svg +44 -0
- package/assets/shared/icons/edit.svg +3 -0
- package/assets/shared/icons/editCollection.png +0 -0
- package/assets/shared/icons/femaleAvatar.svg +80 -0
- package/assets/shared/icons/inactive-clipboard.svg +7 -0
- package/assets/shared/icons/input/X.png +0 -0
- package/assets/shared/icons/input/X.svg +3 -0
- package/assets/shared/icons/input/drag.svg +6 -0
- package/assets/shared/icons/input/green-search.png +0 -0
- package/assets/shared/icons/input/grey-search.png +0 -0
- package/assets/shared/icons/input/search.svg +4 -0
- package/assets/shared/icons/maleAvatar.svg +55 -0
- package/assets/shared/icons/no-result-owl.png +0 -0
- package/assets/shared/icons/resources.svg +6 -0
- package/assets/shared/icons/secondary-x.svg +3 -0
- package/assets/shared/icons/settings.png +0 -0
- package/assets/shared/icons/stepper/white-v.svg +3 -0
- package/assets/shared/icons/table/edit.svg +3 -0
- package/assets/shared/icons/target.png +0 -0
- package/assets/shared/icons/upload.png +0 -0
- package/assets/shared/icons/upload.svg +7 -0
- package/assets/shared/icons/user.svg +8 -0
- package/assets/shared/icons/video/Play.PNG +0 -0
- package/assets/shared/icons/video/back10.PNG +0 -0
- package/assets/shared/icons/video/back10.svg +7 -0
- package/assets/shared/icons/video/download.PNG +0 -0
- package/assets/shared/icons/video/download.svg +4 -0
- package/assets/shared/icons/video/fullScreen.PNG +0 -0
- package/assets/shared/icons/video/fullScreen.svg +7 -0
- package/assets/shared/icons/video/minimize.png +0 -0
- package/assets/shared/icons/video/mute.png +0 -0
- package/assets/shared/icons/video/mute.svg +7 -0
- package/assets/shared/icons/video/next10.PNG +0 -0
- package/assets/shared/icons/video/next10.svg +7 -0
- package/assets/shared/icons/video/pause.PNG +0 -0
- package/assets/shared/icons/video/pause.svg +5 -0
- package/assets/shared/icons/video/pictureInPicture.png +0 -0
- package/assets/shared/icons/video/pictureInPicture.svg +5 -0
- package/assets/shared/icons/video/pictureInPictureOff.svg +7 -0
- package/assets/shared/icons/video/play.svg +4 -0
- package/assets/shared/icons/video/primary-play.png +0 -0
- package/assets/shared/icons/video/primaryPlay.svg +22 -0
- package/assets/shared/icons/video/sound.svg +8 -0
- package/assets/shared/icons/video/speaker.PNG +0 -0
- package/assets/shared/trackChanges/edit.svg +11 -0
- package/assets/shared/trackChanges/message-plus.svg +14 -0
- package/assets/shared/trackChanges/show-comments.svg +5 -0
- package/assets/shared/trackChanges/text-reference.svg +3 -0
- package/assets/shared/trackChanges/trash.svg +9 -0
- package/atoms/index.d.ts +836 -0
- package/constants/index.d.ts +795 -0
- package/decorators/index.d.ts +3 -0
- package/dialogs/index.d.ts +41 -0
- package/directives/index.d.ts +55 -0
- package/environment/index.d.ts +129 -0
- package/errors/index.d.ts +26 -0
- package/fesm2022/herum-shared-animations.mjs +41 -0
- package/fesm2022/herum-shared-animations.mjs.map +1 -0
- package/fesm2022/herum-shared-atoms.mjs +2919 -0
- package/fesm2022/herum-shared-atoms.mjs.map +1 -0
- package/fesm2022/herum-shared-constants.mjs +711 -0
- package/fesm2022/herum-shared-constants.mjs.map +1 -0
- package/fesm2022/herum-shared-decorators.mjs +12 -0
- package/fesm2022/herum-shared-decorators.mjs.map +1 -0
- package/fesm2022/herum-shared-dialogs.mjs +113 -0
- package/fesm2022/herum-shared-dialogs.mjs.map +1 -0
- package/fesm2022/herum-shared-directives.mjs +226 -0
- package/fesm2022/herum-shared-directives.mjs.map +1 -0
- package/fesm2022/herum-shared-environment.mjs +10 -0
- package/fesm2022/herum-shared-environment.mjs.map +1 -0
- package/fesm2022/herum-shared-errors.mjs +71 -0
- package/fesm2022/herum-shared-errors.mjs.map +1 -0
- package/fesm2022/herum-shared-fetched-message.mjs +118 -0
- package/fesm2022/herum-shared-fetched-message.mjs.map +1 -0
- package/fesm2022/herum-shared-herum-types.mjs +106 -0
- package/fesm2022/herum-shared-herum-types.mjs.map +1 -0
- package/fesm2022/herum-shared-molecules.mjs +1530 -0
- package/fesm2022/herum-shared-molecules.mjs.map +1 -0
- package/fesm2022/herum-shared-mongo-molecules.mjs +269 -0
- package/fesm2022/herum-shared-mongo-molecules.mjs.map +1 -0
- package/fesm2022/herum-shared-mongo-services.mjs +441 -0
- package/fesm2022/herum-shared-mongo-services.mjs.map +1 -0
- package/fesm2022/herum-shared-mongo.mjs +729 -0
- package/fesm2022/herum-shared-mongo.mjs.map +1 -0
- package/fesm2022/herum-shared-objectsExample.mjs +190 -0
- package/fesm2022/herum-shared-objectsExample.mjs.map +1 -0
- package/fesm2022/herum-shared-pipes.mjs +406 -0
- package/fesm2022/herum-shared-pipes.mjs.map +1 -0
- package/fesm2022/herum-shared-services.mjs +1107 -0
- package/fesm2022/herum-shared-services.mjs.map +1 -0
- package/fesm2022/herum-shared-static-services.mjs +140 -0
- package/fesm2022/herum-shared-static-services.mjs.map +1 -0
- package/fesm2022/herum-shared-table.mjs +837 -0
- package/fesm2022/herum-shared-table.mjs.map +1 -0
- package/fesm2022/herum-shared-testsObjects.mjs +5722 -0
- package/fesm2022/herum-shared-testsObjects.mjs.map +1 -0
- package/fesm2022/herum-shared-tokens.mjs +13 -0
- package/fesm2022/herum-shared-tokens.mjs.map +1 -0
- package/fesm2022/herum-shared-utils.mjs +380 -0
- package/fesm2022/herum-shared-utils.mjs.map +1 -0
- package/fesm2022/herum-shared-validators.mjs +76 -0
- package/fesm2022/herum-shared-validators.mjs.map +1 -0
- package/fesm2022/herum-shared.mjs +11709 -0
- package/fesm2022/herum-shared.mjs.map +1 -0
- package/fetched-message/index.d.ts +49 -0
- package/herum-types/index.d.ts +198 -0
- package/index.d.ts +2946 -0
- package/molecules/index.d.ts +458 -0
- package/mongo/index.d.ts +175 -0
- package/mongo/molecules/index.d.ts +76 -0
- package/mongo/services/index.d.ts +98 -0
- package/objectsExample/index.d.ts +11 -0
- package/package.json +128 -0
- package/pipes/index.d.ts +93 -0
- package/services/index.d.ts +266 -0
- package/static-services/index.d.ts +25 -0
- package/styles/_mixin.scss +86 -0
- package/styles/collection-wizard-layout.component.scss +70 -0
- package/styles/dialogs.scss +49 -0
- package/styles/forms.scss +18 -0
- package/styles/overView.scss +115 -0
- package/styles/variables/_colors.college.scss +65 -0
- package/styles/variables/_colors.scss +161 -0
- package/styles/variables/_sizes.scss +73 -0
- package/styles/wizard-steps-layout.scss +21 -0
- package/table/index.d.ts +233 -0
- package/testsObjects/index.d.ts +91 -0
- package/tokens/index.d.ts +8 -0
- package/utils/index.d.ts +92 -0
- package/validators/index.d.ts +20 -0
|
@@ -0,0 +1,1107 @@
|
|
|
1
|
+
import * as i1 from '@angular/common/http';
|
|
2
|
+
import { HttpHeaders } from '@angular/common/http';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Inject, Injectable } from '@angular/core';
|
|
5
|
+
import { BehaviorSubject, Subject, forkJoin } from 'rxjs';
|
|
6
|
+
import { shareReplay, map, switchMap, tap } from 'rxjs/operators';
|
|
7
|
+
import { StorageService } from 'herum-shared/static-services';
|
|
8
|
+
import { selfIsTeacherExample, closedListExample, permissionsTemplatesExample } from 'herum-shared/objectsExample';
|
|
9
|
+
import { HERUM_SHARED_CONFIG_TOKEN } from 'herum-shared/environment';
|
|
10
|
+
import { toHash, buildPath, setHeaders, remainJustWantedValueInDictionary, getUrlFromFileData, getVersionPathParameter } from 'herum-shared/utils';
|
|
11
|
+
import * as i2 from '@angular/router';
|
|
12
|
+
import { regexExpressions, generalKeys, uploadsManagerKeys, skipToastHeader, assignmentMetadata, attributes, defaultGrade, defaultAuthorizationObject, resourceIdPlaceholder, resourcesFilesSuffixes, system } from 'herum-shared/constants';
|
|
13
|
+
import * as i1$1 from 'herum-shared/herum-types';
|
|
14
|
+
import { MicroResourceAuthorizationType } from 'herum-shared/herum-types';
|
|
15
|
+
import { cloneDeep } from 'lodash';
|
|
16
|
+
import { DOCUMENT } from '@angular/common';
|
|
17
|
+
import { SYSTEM_TRACK_TEXT_CHANGES_SERVICE } from 'herum-shared/tokens';
|
|
18
|
+
|
|
19
|
+
const NestedConditionSigniture = "filters";
|
|
20
|
+
const defaultPagingDataFormat = "pageInfo { hasNextPage, hasPreviousPage, startCursor, endCursor }";
|
|
21
|
+
const offsetPagingDataFormat = "pageInfo { hasNextPage, hasPreviousPage }";
|
|
22
|
+
const DefaultQueryName = "DefaultQueryName";
|
|
23
|
+
class GraphQLService {
|
|
24
|
+
httpClient;
|
|
25
|
+
environmentConfig;
|
|
26
|
+
constructor(httpClient, environmentConfig) {
|
|
27
|
+
this.httpClient = httpClient;
|
|
28
|
+
this.environmentConfig = environmentConfig;
|
|
29
|
+
}
|
|
30
|
+
executeQuery(gqlQuery, isListQuery = true, isOffsetPagination = false) {
|
|
31
|
+
let variablesObjectForBody;
|
|
32
|
+
let variablesStringForQuerySignature;
|
|
33
|
+
if (gqlQuery.variables) {
|
|
34
|
+
variablesObjectForBody = this.generateVariablesObjectForBody(gqlQuery.variables);
|
|
35
|
+
variablesStringForQuerySignature = this.generateVariablesStringForQuerySigniture(gqlQuery.variables, gqlQuery.queryName);
|
|
36
|
+
}
|
|
37
|
+
const query = this.generateQuery(gqlQuery.resolverName, gqlQuery.formatExample, gqlQuery.filters, gqlQuery.paging?.first, gqlQuery.paging?.after, gqlQuery.offsetPaging, gqlQuery.variables?.length > 0 ? variablesStringForQuerySignature : '', gqlQuery.order, gqlQuery.conditionPaths, gqlQuery.orderPaths, gqlQuery.offsetPagingPaths, isListQuery, isOffsetPagination).replace(regexExpressions.curlyBraces, '');
|
|
38
|
+
return this.httpClient.post(this.environmentConfig?.graphQLConfiguration?.serverBasePath, { query: query, variables: variablesObjectForBody }, { headers: gqlQuery.headers })
|
|
39
|
+
.pipe(shareReplay(1), map(res => {
|
|
40
|
+
return res.data ? res.data[gqlQuery.resolverName] : null;
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
getFreeTextCondition(freeText, orConditionKeys) {
|
|
44
|
+
let filters = {
|
|
45
|
+
and: []
|
|
46
|
+
};
|
|
47
|
+
freeText.split(" ").forEach(substring => {
|
|
48
|
+
let orIteration = [];
|
|
49
|
+
orConditionKeys.forEach(orConditionKey => {
|
|
50
|
+
orIteration.push({
|
|
51
|
+
[orConditionKey]: { contains: substring }
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
filters.and.push({ or: orIteration });
|
|
55
|
+
});
|
|
56
|
+
return filters;
|
|
57
|
+
}
|
|
58
|
+
generateFilterStringDynamically(ids, key, type) {
|
|
59
|
+
let filters = [];
|
|
60
|
+
let variables = [];
|
|
61
|
+
ids.forEach((id, index) => {
|
|
62
|
+
let newFilter = {};
|
|
63
|
+
newFilter[key] = {
|
|
64
|
+
eq: '$' + key + index
|
|
65
|
+
};
|
|
66
|
+
filters.push(newFilter);
|
|
67
|
+
variables.push({
|
|
68
|
+
name: key + index,
|
|
69
|
+
value: id,
|
|
70
|
+
type
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return { filters, variables };
|
|
74
|
+
}
|
|
75
|
+
convertToResolverNameFormat(mongoCollectionName) {
|
|
76
|
+
return mongoCollectionName.charAt(0).toLowerCase() + mongoCollectionName.slice(1);
|
|
77
|
+
}
|
|
78
|
+
generateQuery(resolverName, formatExample, condition, first, after, offsetPaging, variablesStringForQuerySigniture, order, conditionPaths, orderPaths, offsetPagingPaths, isListQuery, isOffsetPagination) {
|
|
79
|
+
const conditionString = this.generateConditionString(condition);
|
|
80
|
+
const returnFormat = this.getKeysString(formatExample, conditionPaths, orderPaths, offsetPagingPaths);
|
|
81
|
+
let orderString = order ? `order:${this.generateOrderString(order)},` : '';
|
|
82
|
+
let pagingString = '';
|
|
83
|
+
if (isListQuery) {
|
|
84
|
+
pagingString = isOffsetPagination
|
|
85
|
+
? (offsetPaging?.skip > -1 || offsetPaging?.take > -1 ? this.generateOffsetPagingString(offsetPaging) : '')
|
|
86
|
+
: (first || after ? this.generatePagingString(first, after) : '');
|
|
87
|
+
}
|
|
88
|
+
if (after)
|
|
89
|
+
pagingString += ',';
|
|
90
|
+
const resolverParameters = (orderString + pagingString + conditionString) == '' ? '' : '(' + orderString + pagingString + conditionString + ')';
|
|
91
|
+
if (pagingString != '')
|
|
92
|
+
pagingString += ',';
|
|
93
|
+
const elementsName = isOffsetPagination ? 'items' : 'nodes';
|
|
94
|
+
const query = `query ${variablesStringForQuerySigniture ? variablesStringForQuerySigniture : ''} {
|
|
95
|
+
${resolverName + resolverParameters} { ${isListQuery ? (isOffsetPagination ? offsetPagingDataFormat : defaultPagingDataFormat) + `,totalCount , ${elementsName} {` : ''} ${returnFormat} } ${isListQuery ? '}' : ''} }`;
|
|
96
|
+
return query;
|
|
97
|
+
}
|
|
98
|
+
generateConditionString(condition, isRecursiveCall = false) {
|
|
99
|
+
let conditionString = "";
|
|
100
|
+
if (!condition || (!condition.and || condition.and?.length == 0) && (!condition.or || condition.or?.length == 0))
|
|
101
|
+
return conditionString;
|
|
102
|
+
if (condition) {
|
|
103
|
+
conditionString = isRecursiveCall ? "" : "where: {";
|
|
104
|
+
if (condition?.and) {
|
|
105
|
+
let andString = "";
|
|
106
|
+
condition.and.forEach(filter => {
|
|
107
|
+
(Object.keys(filter)[0] == 'or' || Object.keys(filter)[0] == 'and') ?
|
|
108
|
+
andString += `{${this.generateConditionString(filter, true)}},` :
|
|
109
|
+
andString += `{${this.getKeysString(filter, null, null, null, null, true)}},`;
|
|
110
|
+
});
|
|
111
|
+
andString = andString.slice(0, -1);
|
|
112
|
+
conditionString += `and: [${andString}]`;
|
|
113
|
+
conditionString += condition.or ? ',' : '';
|
|
114
|
+
}
|
|
115
|
+
if (condition?.or) {
|
|
116
|
+
let orString = "";
|
|
117
|
+
condition.or.forEach(filter => orString += `{${this.getKeysString(filter, null, null, null, null, true)}},`);
|
|
118
|
+
condition.or.forEach(filter => {
|
|
119
|
+
(Object.keys(filter)[0] == 'or' || Object.keys(filter)[0] == 'and') ?
|
|
120
|
+
orString += `{${this.generateConditionString(filter, true)}},` :
|
|
121
|
+
orString += `{${this.getKeysString(filter, null, null, null, null, true)}},`;
|
|
122
|
+
});
|
|
123
|
+
orString = orString.slice(0, -1);
|
|
124
|
+
conditionString += `or: [${orString} ]`;
|
|
125
|
+
}
|
|
126
|
+
conditionString += isRecursiveCall ? "" : "}";
|
|
127
|
+
}
|
|
128
|
+
return conditionString;
|
|
129
|
+
}
|
|
130
|
+
generatePagingString(first, after) {
|
|
131
|
+
let result = '';
|
|
132
|
+
result += first ? `first:${first},` : '';
|
|
133
|
+
result += after ? ` after:"${after}"` : '';
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
generateOffsetPagingString(offsetPaging) {
|
|
137
|
+
const { skip, take } = offsetPaging;
|
|
138
|
+
let result = '';
|
|
139
|
+
result += skip > -1 ? `skip:${skip},` : '';
|
|
140
|
+
result += take > -1 ? ` take:${take}, ` : '';
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
getKeysString(obj, conditionPaths, orderPaths, offsetPagingPaths, parentKey = null, isConditionString = false) {
|
|
144
|
+
let result = '';
|
|
145
|
+
for (const key in obj) {
|
|
146
|
+
result += `${key}`;
|
|
147
|
+
if (((conditionPaths && conditionPaths[key]) || (orderPaths && orderPaths[key])) && !isConditionString) {
|
|
148
|
+
result += '(';
|
|
149
|
+
if (conditionPaths && conditionPaths[key])
|
|
150
|
+
result += this.generateConditionString(conditionPaths[key]);
|
|
151
|
+
if (orderPaths && orderPaths[key])
|
|
152
|
+
result += this.getKeysString(orderPaths[key], null, null, null, null, true);
|
|
153
|
+
if (offsetPagingPaths && offsetPagingPaths[key])
|
|
154
|
+
result += (offsetPagingPaths[key].skip > -1 || offsetPagingPaths[key].take > -1) ? `,${this.generateOffsetPagingString(offsetPagingPaths[key])}` : '';
|
|
155
|
+
result += `)`;
|
|
156
|
+
}
|
|
157
|
+
if (offsetPagingPaths && offsetPagingPaths[key])
|
|
158
|
+
result += '{items';
|
|
159
|
+
if (obj[key]?.length > 0 && !isConditionString && obj[key] !== null && typeof obj[key] !== 'string') {
|
|
160
|
+
result += isConditionString ? `: { ${this.getKeysString(obj[key], conditionPaths, orderPaths, offsetPagingPaths, key, isConditionString)} }` :
|
|
161
|
+
` { ${this.getKeysString(obj[key][0], conditionPaths, orderPaths, key, isConditionString)} }`;
|
|
162
|
+
}
|
|
163
|
+
else if (typeof obj[key] === 'object' && obj[key] !== null && typeof obj[key] !== 'string')
|
|
164
|
+
result += isConditionString ? `: { ${this.getKeysString(obj[key], conditionPaths, orderPaths, offsetPagingPaths, key, isConditionString)} }` :
|
|
165
|
+
` { ${this.getKeysString(obj[key], conditionPaths, orderPaths, offsetPagingPaths, parentKey + '.' + key, isConditionString)} }`;
|
|
166
|
+
else if (typeof obj[key] === 'string' && obj[key] !== null && isConditionString)
|
|
167
|
+
result += (obj[key][0] == '$' || obj[key].includes('ASC') || obj[key].includes('DESC')) ? `: ${obj[key]}` : `: "${obj[key]}"`;
|
|
168
|
+
else if (typeof obj[key] === 'number' && obj[key] !== null && isConditionString)
|
|
169
|
+
result += `: ${JSON.stringify(obj[key])}`;
|
|
170
|
+
else if (typeof obj[key] === 'boolean' && obj[key] !== null && isConditionString)
|
|
171
|
+
result += `: ${obj[key]}`;
|
|
172
|
+
if (offsetPagingPaths && offsetPagingPaths[key])
|
|
173
|
+
result += '}';
|
|
174
|
+
result += ', ';
|
|
175
|
+
}
|
|
176
|
+
return result.slice(0, -2);
|
|
177
|
+
}
|
|
178
|
+
generateVariablesObjectForBody(variables) {
|
|
179
|
+
return variables.reduce((acc, obj) => {
|
|
180
|
+
acc[obj.name] = obj.value;
|
|
181
|
+
return acc;
|
|
182
|
+
}, {});
|
|
183
|
+
}
|
|
184
|
+
generateVariablesStringForQuerySigniture(variables, queryName) {
|
|
185
|
+
if (!queryName)
|
|
186
|
+
queryName = DefaultQueryName;
|
|
187
|
+
let result = (queryName ? queryName : DefaultQueryName) + '(';
|
|
188
|
+
variables.forEach(variable => {
|
|
189
|
+
result += "$" + variable.name + ":" + variable.type + ",";
|
|
190
|
+
});
|
|
191
|
+
result = result.slice(0, -1) + ")";
|
|
192
|
+
return result;
|
|
193
|
+
}
|
|
194
|
+
generateOrderString(order) {
|
|
195
|
+
let orderString = '{';
|
|
196
|
+
Object.keys(order).forEach((key, index, keys) => {
|
|
197
|
+
orderString += typeof order[key] === 'object' ?
|
|
198
|
+
`${key}:${this.generateOrderString(order[key])}` :
|
|
199
|
+
`${key}:${order[key]}`;
|
|
200
|
+
if (index < keys.length - 1)
|
|
201
|
+
orderString += ',';
|
|
202
|
+
});
|
|
203
|
+
return orderString + '}';
|
|
204
|
+
}
|
|
205
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GraphQLService, deps: [{ token: i1.HttpClient }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
206
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GraphQLService, providedIn: 'root' });
|
|
207
|
+
}
|
|
208
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GraphQLService, decorators: [{
|
|
209
|
+
type: Injectable,
|
|
210
|
+
args: [{
|
|
211
|
+
providedIn: 'root'
|
|
212
|
+
}]
|
|
213
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
|
|
214
|
+
type: Inject,
|
|
215
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
216
|
+
}] }] });
|
|
217
|
+
|
|
218
|
+
const AuthStorageKey = 'AUTH_SESSION_ID';
|
|
219
|
+
const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
|
|
220
|
+
class AuthService {
|
|
221
|
+
http;
|
|
222
|
+
router;
|
|
223
|
+
gql;
|
|
224
|
+
environmentConfig;
|
|
225
|
+
sessionId$ = new BehaviorSubject('');
|
|
226
|
+
isTeacher$ = new Subject();
|
|
227
|
+
constructor(http, router, gql, environmentConfig) {
|
|
228
|
+
this.http = http;
|
|
229
|
+
this.router = router;
|
|
230
|
+
this.gql = gql;
|
|
231
|
+
this.environmentConfig = environmentConfig;
|
|
232
|
+
let sessionId = StorageService.getItem(AuthStorageKey);
|
|
233
|
+
if (!sessionId)
|
|
234
|
+
return;
|
|
235
|
+
this.sessionId$.next(sessionId);
|
|
236
|
+
}
|
|
237
|
+
tryLogin(signInFormData) {
|
|
238
|
+
const personalId = signInFormData.personalId;
|
|
239
|
+
let loginFormat = {
|
|
240
|
+
identifier: personalId,
|
|
241
|
+
hash: toHash(this.generateStringForAuthenticationHash(personalId, signInFormData.militaryId))
|
|
242
|
+
};
|
|
243
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.authenticationPaths?.tryLogin, loginFormat)
|
|
244
|
+
.pipe(map((authenticationResponse) => this.handleNewSessionId(authenticationResponse)));
|
|
245
|
+
}
|
|
246
|
+
getUserIdentificationQuestions(personalId) {
|
|
247
|
+
return this.http.get(this.environmentConfig?.environment?.siteServerPath + `/Authentication/SecurityQuestions/${personalId}`);
|
|
248
|
+
}
|
|
249
|
+
signUp(signUpData) {
|
|
250
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.authenticationPaths?.signUp, signUpData)
|
|
251
|
+
.pipe(map((authenticationResponse) => this.handleNewSessionId(authenticationResponse)));
|
|
252
|
+
}
|
|
253
|
+
logout() {
|
|
254
|
+
this.clearSession();
|
|
255
|
+
this.router.navigate(['/login']);
|
|
256
|
+
}
|
|
257
|
+
clearSession() {
|
|
258
|
+
StorageService.deleteAll();
|
|
259
|
+
this.sessionId$.next('');
|
|
260
|
+
}
|
|
261
|
+
isValidSessionId(sessionId) {
|
|
262
|
+
let jSessionId = JSON.stringify(sessionId ?? '');
|
|
263
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.authenticationPaths?.isValidSessionId, jSessionId, { headers: headers });
|
|
264
|
+
}
|
|
265
|
+
isTeacher() {
|
|
266
|
+
let userQuery = {
|
|
267
|
+
resolverName: 'self',
|
|
268
|
+
formatExample: selfIsTeacherExample,
|
|
269
|
+
conditionPaths: { collegeStudyingLessons: { and: [{ lesson: { isDeleted: { eq: false } } }] } }
|
|
270
|
+
};
|
|
271
|
+
return this.gql.executeQuery(userQuery, false).pipe(map(user => {
|
|
272
|
+
const isTeacher = !(!user.collegeTeacherAssignments || user.collegeTeacherAssignments.length == 0) ||
|
|
273
|
+
!(!user.collegeTeachingLessons || user.collegeTeachingLessons.length == 0) ||
|
|
274
|
+
!(!user.collegeCheckingLessons || user.collegeCheckingLessons.length == 0) || user.isAdmin == true;
|
|
275
|
+
this.isTeacher$.next(isTeacher);
|
|
276
|
+
return isTeacher;
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
setIdentificationQuestions(password, questions) {
|
|
280
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + '/Authentication/UpdateLoginData', {
|
|
281
|
+
password,
|
|
282
|
+
securityQuestions: questions.map(question => ({ ...question, answer: toHash(question.answer) }))
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
resetPassword(securityQuestions, personalId, newPassword) {
|
|
286
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + '/Authentication/ResetPassword', {
|
|
287
|
+
personalId: personalId,
|
|
288
|
+
answers: securityQuestions.map(question => ({ questionId: question._id, answer: toHash(question.answer) })),
|
|
289
|
+
newPassword: newPassword
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
securityCheck(securityQuestions, personalId) {
|
|
293
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + '/Authentication/SecurityCheck', {
|
|
294
|
+
personalId: personalId,
|
|
295
|
+
answers: securityQuestions.map(question => ({ questionId: question._id, answer: toHash(question.answer) }))
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
handleNewSessionId(authenticationResponse) {
|
|
299
|
+
if (authenticationResponse.sessionId?.length > 0)
|
|
300
|
+
this.updateSessionId(authenticationResponse.sessionId);
|
|
301
|
+
return authenticationResponse;
|
|
302
|
+
}
|
|
303
|
+
updateSessionId(newValue) {
|
|
304
|
+
this.sessionId$.next(newValue);
|
|
305
|
+
StorageService.setItem(AuthStorageKey, newValue);
|
|
306
|
+
}
|
|
307
|
+
generateStringForAuthenticationHash(personalId, militaryId) {
|
|
308
|
+
return personalId + militaryId;
|
|
309
|
+
}
|
|
310
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: i2.Router }, { token: GraphQLService }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
311
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
312
|
+
}
|
|
313
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: AuthService, decorators: [{
|
|
314
|
+
type: Injectable,
|
|
315
|
+
args: [{
|
|
316
|
+
providedIn: 'root'
|
|
317
|
+
}]
|
|
318
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: i2.Router }, { type: GraphQLService }, { type: undefined, decorators: [{
|
|
319
|
+
type: Inject,
|
|
320
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
321
|
+
}] }] });
|
|
322
|
+
|
|
323
|
+
class CommonGraphqlRequestsService {
|
|
324
|
+
gql;
|
|
325
|
+
environmentConfig;
|
|
326
|
+
constructor(gql, environmentConfig) {
|
|
327
|
+
this.gql = gql;
|
|
328
|
+
this.environmentConfig = environmentConfig;
|
|
329
|
+
}
|
|
330
|
+
getGroupsByIds(ids, formatExample) {
|
|
331
|
+
let filterQuery = this.gql.generateFilterStringDynamically(ids, 'id', 'String');
|
|
332
|
+
let query = {
|
|
333
|
+
resolverName: this.gql.convertToResolverNameFormat(this.environmentConfig?.mongoUpdates?.Collections?.Groups),
|
|
334
|
+
formatExample: formatExample,
|
|
335
|
+
filters: {
|
|
336
|
+
or: filterQuery.filters
|
|
337
|
+
},
|
|
338
|
+
variables: filterQuery.variables
|
|
339
|
+
};
|
|
340
|
+
return this.gql.executeQuery(query).pipe(map(gqlGroups => gqlGroups?.nodes));
|
|
341
|
+
}
|
|
342
|
+
getClosedLists(names) {
|
|
343
|
+
let query = {
|
|
344
|
+
resolverName: this.gql.convertToResolverNameFormat(this.environmentConfig?.mongoUpdates?.Collections?.ClosedLists),
|
|
345
|
+
formatExample: closedListExample,
|
|
346
|
+
filters: { and: [{ isDeleted: { eq: false } }] },
|
|
347
|
+
variables: []
|
|
348
|
+
};
|
|
349
|
+
names?.forEach((name, i) => {
|
|
350
|
+
if (query.filters.or)
|
|
351
|
+
query.filters.or.push({
|
|
352
|
+
name: {
|
|
353
|
+
eq: '$name' + i
|
|
354
|
+
},
|
|
355
|
+
});
|
|
356
|
+
else
|
|
357
|
+
query.filters.or = [{
|
|
358
|
+
name: {
|
|
359
|
+
eq: '$name' + i
|
|
360
|
+
},
|
|
361
|
+
}];
|
|
362
|
+
query.variables.push({
|
|
363
|
+
name: 'name' + i,
|
|
364
|
+
value: name,
|
|
365
|
+
type: 'String'
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
return this.gql.executeQuery(query).pipe(map(gqlResult => gqlResult.nodes));
|
|
369
|
+
}
|
|
370
|
+
getUsersByIds(usersIds, formatExample) {
|
|
371
|
+
let filterQuery = this.gql.generateFilterStringDynamically(usersIds, generalKeys.id, 'String');
|
|
372
|
+
let query = {
|
|
373
|
+
resolverName: this.gql.convertToResolverNameFormat(this.environmentConfig?.mongoUpdates?.Collections?.Users),
|
|
374
|
+
formatExample,
|
|
375
|
+
filters: {
|
|
376
|
+
or: filterQuery.filters
|
|
377
|
+
},
|
|
378
|
+
variables: filterQuery.variables
|
|
379
|
+
};
|
|
380
|
+
return this.gql.executeQuery(query).pipe(map(gqlResponse => gqlResponse?.nodes));
|
|
381
|
+
}
|
|
382
|
+
getPermissionsTemplates() {
|
|
383
|
+
let query = {
|
|
384
|
+
resolverName: 'permissionsTemplates',
|
|
385
|
+
formatExample: permissionsTemplatesExample,
|
|
386
|
+
};
|
|
387
|
+
return this.gql.executeQuery(query).pipe(map(gqlResponse => gqlResponse.nodes));
|
|
388
|
+
}
|
|
389
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: CommonGraphqlRequestsService, deps: [{ token: GraphQLService }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
390
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: CommonGraphqlRequestsService, providedIn: 'root' });
|
|
391
|
+
}
|
|
392
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: CommonGraphqlRequestsService, decorators: [{
|
|
393
|
+
type: Injectable,
|
|
394
|
+
args: [{
|
|
395
|
+
providedIn: 'root'
|
|
396
|
+
}]
|
|
397
|
+
}], ctorParameters: () => [{ type: GraphQLService }, { type: undefined, decorators: [{
|
|
398
|
+
type: Inject,
|
|
399
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
400
|
+
}] }] });
|
|
401
|
+
|
|
402
|
+
const innerUniqListItemKey = '_id';
|
|
403
|
+
const emptyValueFlagForCreationUniqListItem = 'null';
|
|
404
|
+
class DbActionsInnerIdManagerService {
|
|
405
|
+
determineIfInnerIdIsNeeded(value) {
|
|
406
|
+
if (!Array.isArray(value))
|
|
407
|
+
return;
|
|
408
|
+
if (value[0][innerUniqListItemKey])
|
|
409
|
+
value[0].id = value[0][innerUniqListItemKey] == emptyValueFlagForCreationUniqListItem ? null : value[0][innerUniqListItemKey];
|
|
410
|
+
}
|
|
411
|
+
deleteInnerIdFieldIfExist(itemToAttach, itemValue) {
|
|
412
|
+
if (itemValue.hasOwnProperty(innerUniqListItemKey)) {
|
|
413
|
+
itemToAttach[Object.keys(itemToAttach)[0]][generalKeys.id] =
|
|
414
|
+
itemToAttach[Object.keys(itemToAttach)[0]][innerUniqListItemKey] == emptyValueFlagForCreationUniqListItem ?
|
|
415
|
+
null :
|
|
416
|
+
itemToAttach[Object.keys(itemToAttach)[0]][innerUniqListItemKey];
|
|
417
|
+
delete itemToAttach[Object.keys(itemToAttach)[0]][innerUniqListItemKey];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionsInnerIdManagerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
421
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionsInnerIdManagerService, providedIn: 'root' });
|
|
422
|
+
}
|
|
423
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionsInnerIdManagerService, decorators: [{
|
|
424
|
+
type: Injectable,
|
|
425
|
+
args: [{
|
|
426
|
+
providedIn: 'root'
|
|
427
|
+
}]
|
|
428
|
+
}] });
|
|
429
|
+
|
|
430
|
+
const ATTACH = "Attach";
|
|
431
|
+
class DbActionRequestsService {
|
|
432
|
+
http;
|
|
433
|
+
dbActionsInnerIdManagerService;
|
|
434
|
+
environmentConfig;
|
|
435
|
+
constructor(http, dbActionsInnerIdManagerService, environmentConfig) {
|
|
436
|
+
this.http = http;
|
|
437
|
+
this.dbActionsInnerIdManagerService = dbActionsInnerIdManagerService;
|
|
438
|
+
this.environmentConfig = environmentConfig;
|
|
439
|
+
}
|
|
440
|
+
getFileRequest(request, file) {
|
|
441
|
+
const formData = new FormData();
|
|
442
|
+
formData.append(generalKeys.newFileRequest, JSON.stringify(request));
|
|
443
|
+
formData.append(generalKeys.file, file);
|
|
444
|
+
return formData;
|
|
445
|
+
}
|
|
446
|
+
addOrUpdateAndAttachBulkWithFile(mongoCollectionName, fields, file, ids, uploadsManagerTitle, skipToast) {
|
|
447
|
+
let headers = this.setAddOrUpdateAndAttachBulkWithFileHeaders([uploadsManagerTitle, skipToast]);
|
|
448
|
+
return this.getMongoCollectionModelInfo(mongoCollectionName).pipe(switchMap((modelInfo) => {
|
|
449
|
+
if (fields.files)
|
|
450
|
+
delete fields.files;
|
|
451
|
+
const splittedFields = this.splitFieldByType(fields, modelInfo);
|
|
452
|
+
const request = {
|
|
453
|
+
DbBasicActionRequest: {
|
|
454
|
+
data: splittedFields.keysToUpdate,
|
|
455
|
+
ids
|
|
456
|
+
},
|
|
457
|
+
DbAttachmentActionRequests: this.getFormattedAttachments(ids, splittedFields.keysToAttach, splittedFields.keysToAttachInDifferentModel, modelInfo)
|
|
458
|
+
};
|
|
459
|
+
return this.http.put(buildPath([
|
|
460
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
461
|
+
mongoCollectionName,
|
|
462
|
+
this.environmentConfig?.mongoUpdates?.Methods?.AddOrUpdate,
|
|
463
|
+
this.environmentConfig?.mongoUpdates?.Submethods?.AndAttach,
|
|
464
|
+
this.environmentConfig?.mongoUpdates?.Options?.Bulk,
|
|
465
|
+
this.environmentConfig?.mongoUpdates?.Options?.SetFile
|
|
466
|
+
]), this.getFileRequest(request, file), { responseType: 'text', reportProgress: !!file, headers });
|
|
467
|
+
}));
|
|
468
|
+
}
|
|
469
|
+
setAddOrUpdateAndAttachBulkWithFileHeaders(headerToSet) {
|
|
470
|
+
let headers = null;
|
|
471
|
+
const [uploadsManagerTitle, skipToast] = headerToSet;
|
|
472
|
+
if (uploadsManagerTitle)
|
|
473
|
+
headers = setHeaders(new HttpHeaders(), [{ key: uploadsManagerKeys.uploadsManagerTitleHeader, value: uploadsManagerTitle }], true);
|
|
474
|
+
if (skipToast)
|
|
475
|
+
headers = skipToastHeader;
|
|
476
|
+
return headers;
|
|
477
|
+
}
|
|
478
|
+
AndAttachBulk(mongoCollectionName, fields, ids, method, attachmentsToUpdate) {
|
|
479
|
+
if (ids.every(id => !id))
|
|
480
|
+
ids = undefined;
|
|
481
|
+
return this.getMongoCollectionModelInfo(mongoCollectionName).pipe(switchMap((modelInfo) => {
|
|
482
|
+
const splittedFields = this.splitFieldByType(fields, modelInfo);
|
|
483
|
+
const request = {
|
|
484
|
+
DbBasicActionRequest: {
|
|
485
|
+
data: Object.assign(splittedFields.keysToUpdate, attachmentsToUpdate),
|
|
486
|
+
ids
|
|
487
|
+
},
|
|
488
|
+
DbAttachmentActionRequests: this.getFormattedAttachments(ids, splittedFields.keysToAttach, splittedFields.keysToAttachInDifferentModel, modelInfo)
|
|
489
|
+
};
|
|
490
|
+
if (method == 'create')
|
|
491
|
+
delete request.DbBasicActionRequest.ids;
|
|
492
|
+
return this.http.request(method == 'create' ? 'post' : 'put', buildPath([
|
|
493
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
494
|
+
mongoCollectionName,
|
|
495
|
+
method == 'addOrUpdate' ? this.environmentConfig?.mongoUpdates?.Methods?.AddOrUpdate : this.environmentConfig?.mongoUpdates?.Methods?.Create,
|
|
496
|
+
this.environmentConfig?.mongoUpdates?.Submethods?.AndAttach,
|
|
497
|
+
this.environmentConfig?.mongoUpdates?.Options?.Bulk
|
|
498
|
+
]), { body: request });
|
|
499
|
+
}));
|
|
500
|
+
}
|
|
501
|
+
basicBulk(mongoCollectionName, fields, ids, requestType, skipToast) {
|
|
502
|
+
return this.getMongoCollectionModelInfo(mongoCollectionName).pipe(switchMap((modelInfo) => {
|
|
503
|
+
const updatedFields = remainJustWantedValueInDictionary(generalKeys.id, fields);
|
|
504
|
+
const splitedFields = this.splitFieldByType(fields, modelInfo);
|
|
505
|
+
const requests = Object.entries(updatedFields).map(([field, value]) => {
|
|
506
|
+
const fieldModelInfo = splitedFields.keysToAttachInDifferentModel[field];
|
|
507
|
+
return fieldModelInfo?.sourceField ?
|
|
508
|
+
this.buildMirrorSourceCollectionRequestsData(value, fieldModelInfo.sourceField, fieldModelInfo.innerPreviewModelName, ids[0], requestType, fieldModelInfo.attachedToType)
|
|
509
|
+
: this.buildSourceCollectionRequestsData(ids, { [field]: value }, requestType, mongoCollectionName);
|
|
510
|
+
});
|
|
511
|
+
let headers = null;
|
|
512
|
+
if (skipToast)
|
|
513
|
+
headers = skipToastHeader;
|
|
514
|
+
return this.http.post(buildPath([
|
|
515
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
516
|
+
mongoCollectionName,
|
|
517
|
+
this.environmentConfig?.mongoUpdates?.Methods?.Basic,
|
|
518
|
+
this.environmentConfig?.mongoUpdates?.Options?.Bulk,
|
|
519
|
+
]), { requests }, { headers });
|
|
520
|
+
}));
|
|
521
|
+
}
|
|
522
|
+
buildSourceCollectionRequestsData(mongoSourceCollectionIds, data, requestType, mongoSourceCollectionName) {
|
|
523
|
+
return {
|
|
524
|
+
ids: mongoSourceCollectionIds,
|
|
525
|
+
data,
|
|
526
|
+
requestType,
|
|
527
|
+
actOnType: mongoSourceCollectionName
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
buildMirrorSourceCollectionRequestsData(fieldValue, sourceField, innerPreviewModelName, mongoSourceCollectionId, requestType, attachedToType) {
|
|
531
|
+
return {
|
|
532
|
+
ids: this.arrayOfIdObjectsToIdsArray(fieldValue),
|
|
533
|
+
data: this.buildBasicBulkObjectData(sourceField, innerPreviewModelName, mongoSourceCollectionId),
|
|
534
|
+
requestType,
|
|
535
|
+
actOnType: attachedToType
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
arrayOfIdObjectsToIdsArray(array) {
|
|
539
|
+
return array.map(object => object.id);
|
|
540
|
+
}
|
|
541
|
+
buildBasicBulkObjectData(sourceField, innerPreviewModelName, mongoSourceCollectionId) {
|
|
542
|
+
const value = innerPreviewModelName ? { [innerPreviewModelName]: { id: mongoSourceCollectionId } } : { id: mongoSourceCollectionId };
|
|
543
|
+
return { [sourceField]: [value] };
|
|
544
|
+
}
|
|
545
|
+
deleteMongoDocument(mongoCollectionName, ids) {
|
|
546
|
+
return this.http.post(buildPath([
|
|
547
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
548
|
+
mongoCollectionName,
|
|
549
|
+
this.environmentConfig?.mongoUpdates?.Methods?.Delete,
|
|
550
|
+
]), ids);
|
|
551
|
+
}
|
|
552
|
+
deletePreviewItemsFromList(mongoCollectionName, fields, ids) {
|
|
553
|
+
const request = {
|
|
554
|
+
ids,
|
|
555
|
+
data: fields
|
|
556
|
+
};
|
|
557
|
+
return this.http.put(buildPath([
|
|
558
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
559
|
+
mongoCollectionName,
|
|
560
|
+
this.environmentConfig?.mongoUpdates?.Methods?.ListItemDeletion
|
|
561
|
+
]), request);
|
|
562
|
+
}
|
|
563
|
+
getFormattedAttachments(ids, objectsToAttach, keysToAttachInDifferentModel, modelInfo) {
|
|
564
|
+
let result = [];
|
|
565
|
+
Object.keys(objectsToAttach).forEach(keyToAttach => {
|
|
566
|
+
let attachments = {};
|
|
567
|
+
if (Array.isArray(objectsToAttach[keyToAttach]))
|
|
568
|
+
objectsToAttach[keyToAttach].forEach((itemToAttach) => {
|
|
569
|
+
const itemKey = Object.keys(itemToAttach)[0];
|
|
570
|
+
const itemValue = itemToAttach[itemKey];
|
|
571
|
+
this.dbActionsInnerIdManagerService.deleteInnerIdFieldIfExist(itemToAttach, itemValue);
|
|
572
|
+
if (itemValue.hasOwnProperty(generalKeys.id) && itemValue[generalKeys.id] !== null)
|
|
573
|
+
delete itemToAttach[Object.keys(itemToAttach)[0]][generalKeys.id];
|
|
574
|
+
Object.assign(attachments, itemToAttach);
|
|
575
|
+
});
|
|
576
|
+
else
|
|
577
|
+
attachments[objectsToAttach[keyToAttach]] = {};
|
|
578
|
+
objectsToAttach[keyToAttach].forEach((objectToAttach, index) => {
|
|
579
|
+
if (objectsToAttach[keyToAttach] && Object.keys(objectsToAttach[keyToAttach][index]) && attachments[Object.keys(objectsToAttach[keyToAttach][index])[0]])
|
|
580
|
+
Object.keys(attachments[Object.keys(objectsToAttach[keyToAttach][index])[0]]).forEach(keyOfObjectToAttachData => {
|
|
581
|
+
if (modelInfo[keyToAttach].innerPreviewModelName == keyOfObjectToAttachData || !modelInfo[keyToAttach].innerProperties.hasOwnProperty(keyOfObjectToAttachData))
|
|
582
|
+
delete attachments[Object.keys(objectsToAttach[keyToAttach][index])[0]][keyOfObjectToAttachData];
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
result.push({
|
|
586
|
+
field: keyToAttach.charAt(0).toUpperCase() + keyToAttach.slice(1),
|
|
587
|
+
attachments,
|
|
588
|
+
ids
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
Object.keys(keysToAttachInDifferentModel).forEach(field => {
|
|
592
|
+
const extensionValue = Object.values(DbActionsInconsistencyMap[field].extension)[0];
|
|
593
|
+
const updatedExtensionInfo = { [ids[0]]: extensionValue };
|
|
594
|
+
let request = {
|
|
595
|
+
field: keysToAttachInDifferentModel[field].sourceField,
|
|
596
|
+
attachments: updatedExtensionInfo,
|
|
597
|
+
ids: keysToAttachInDifferentModel[field].values.map(value => value.id),
|
|
598
|
+
attachedToType: keysToAttachInDifferentModel[field].attachedToType
|
|
599
|
+
};
|
|
600
|
+
result.push(request);
|
|
601
|
+
});
|
|
602
|
+
return result;
|
|
603
|
+
}
|
|
604
|
+
splitFieldByType(fields, modelInfo) {
|
|
605
|
+
return Object.entries(fields).reduce((acc, [key, value]) => {
|
|
606
|
+
if (modelInfo[key] && (modelInfo[key].attachedToType == null || modelInfo[key].sourceField == null || modelInfo[key].sourceField == undefined)) {
|
|
607
|
+
const group = modelInfo[key].propertyUpdateType === ATTACH ? 'keysToAttach' : 'keysToUpdate';
|
|
608
|
+
if (value !== null && value !== undefined && (!Array.isArray(value) || value.length > 0)) {
|
|
609
|
+
acc[group] = {
|
|
610
|
+
...acc[group], [key]: modelInfo[key].propertyUpdateType === ATTACH ?
|
|
611
|
+
value?.map(value => {
|
|
612
|
+
return { [value.id + '']: value };
|
|
613
|
+
}) :
|
|
614
|
+
value
|
|
615
|
+
};
|
|
616
|
+
this.dbActionsInnerIdManagerService.determineIfInnerIdIsNeeded(value);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
if (modelInfo[DbActionsInconsistencyMap[key]?.backendNaming])
|
|
621
|
+
acc.keysToAttachInDifferentModel = {
|
|
622
|
+
...acc.keysToAttachInDifferentModel, [key]: {
|
|
623
|
+
attachedToType: modelInfo[DbActionsInconsistencyMap[key].backendNaming]?.attachedToType,
|
|
624
|
+
sourceField: modelInfo[DbActionsInconsistencyMap[key].backendNaming]?.sourceField,
|
|
625
|
+
innerPreviewModelName: modelInfo[DbActionsInconsistencyMap[key].backendNaming]?.innerPreviewModelName,
|
|
626
|
+
values: fields[key]
|
|
627
|
+
}
|
|
628
|
+
};
|
|
629
|
+
else
|
|
630
|
+
acc.keysToAttachInDifferentModel = {
|
|
631
|
+
...acc.keysToAttachInDifferentModel, [key]: {
|
|
632
|
+
attachedToType: modelInfo[key]?.attachedToType,
|
|
633
|
+
sourceField: modelInfo[key]?.sourceField,
|
|
634
|
+
innerPreviewModelName: modelInfo[key]?.innerPreviewModelName,
|
|
635
|
+
values: fields[key]
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
return acc;
|
|
640
|
+
}, { keysToAttach: {}, keysToUpdate: {}, keysToAttachInDifferentModel: {} });
|
|
641
|
+
}
|
|
642
|
+
getMongoCollectionModelInfo(mongoCollectionName) {
|
|
643
|
+
return this.http.get(buildPath([
|
|
644
|
+
this.environmentConfig?.environment?.siteServerPath,
|
|
645
|
+
mongoCollectionName,
|
|
646
|
+
this.environmentConfig?.mongoUpdates?.Methods?.ModelInfo
|
|
647
|
+
]));
|
|
648
|
+
}
|
|
649
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionRequestsService, deps: [{ token: i1.HttpClient }, { token: DbActionsInnerIdManagerService }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
650
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionRequestsService, providedIn: 'root' });
|
|
651
|
+
}
|
|
652
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: DbActionRequestsService, decorators: [{
|
|
653
|
+
type: Injectable,
|
|
654
|
+
args: [{
|
|
655
|
+
providedIn: 'root'
|
|
656
|
+
}]
|
|
657
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: DbActionsInnerIdManagerService }, { type: undefined, decorators: [{
|
|
658
|
+
type: Inject,
|
|
659
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
660
|
+
}] }] });
|
|
661
|
+
const DbActionsInconsistencyMap = {
|
|
662
|
+
groups: {
|
|
663
|
+
backendNaming: "members",
|
|
664
|
+
extension: {
|
|
665
|
+
"NEW_VALUE": {}
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
groupsPermissions: {
|
|
669
|
+
backendNaming: "permittedGroups",
|
|
670
|
+
extension: {
|
|
671
|
+
"NEW_VALUE": {
|
|
672
|
+
"permission": {
|
|
673
|
+
"update": true
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
groupsViewPermissions: {
|
|
679
|
+
backendNaming: "permittedGroups",
|
|
680
|
+
extension: {
|
|
681
|
+
"NEW_VALUE": {
|
|
682
|
+
"permission": {
|
|
683
|
+
"update": false
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
},
|
|
688
|
+
assignments: {
|
|
689
|
+
backendNaming: "assignments",
|
|
690
|
+
extension: {
|
|
691
|
+
"NEW_VALUE": {
|
|
692
|
+
"id": null,
|
|
693
|
+
assignmentMetadata
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
"collegeTeacherAssignments": {
|
|
698
|
+
backendNaming: "collegeTeacherAssignments",
|
|
699
|
+
extension: {
|
|
700
|
+
"NEW_VALUE": {
|
|
701
|
+
"id": null
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
},
|
|
705
|
+
"collegeStudentAssignments": {
|
|
706
|
+
backendNaming: "collegeStudentAssignments",
|
|
707
|
+
extension: {
|
|
708
|
+
"NEW_VALUE": {
|
|
709
|
+
"id": null
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
class GlobalKeyboardListenerService {
|
|
716
|
+
environmentConfig;
|
|
717
|
+
globalKeyboardEvents$ = new Subject();
|
|
718
|
+
connection;
|
|
719
|
+
constructor(environmentConfig) {
|
|
720
|
+
this.environmentConfig = environmentConfig;
|
|
721
|
+
this.initGlobalSocket();
|
|
722
|
+
}
|
|
723
|
+
initGlobalSocket() {
|
|
724
|
+
if (this.connection)
|
|
725
|
+
return;
|
|
726
|
+
this.connection = new WebSocket(this.environmentConfig?.environment?.keyboardEventsLocalSocketPath);
|
|
727
|
+
this.connection.onmessage = (webSocketMessage) => {
|
|
728
|
+
const event = JSON.parse(webSocketMessage.data);
|
|
729
|
+
if (event.state == 'UP')
|
|
730
|
+
this.globalKeyboardEvents$.next(event);
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
get globalKeysToChromeKeysNames() {
|
|
734
|
+
return {
|
|
735
|
+
'NUMPAD 0': 'Insert',
|
|
736
|
+
'NUMPAD 1': 'End',
|
|
737
|
+
'NUMPAD 2': 'ArrowDown',
|
|
738
|
+
'NUMPAD 3': 'PageDown',
|
|
739
|
+
'NUMPAD 4': 'ArrowLeft',
|
|
740
|
+
'NUMPAD 5': 'Clear',
|
|
741
|
+
'NUMPAD 6': 'ArrowRight',
|
|
742
|
+
'NUMPAD 7': 'Home',
|
|
743
|
+
'NUMPAD 8': '',
|
|
744
|
+
'NUMPAD 9': 'PageUp',
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalKeyboardListenerService, deps: [{ token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
748
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalKeyboardListenerService, providedIn: 'root' });
|
|
749
|
+
}
|
|
750
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalKeyboardListenerService, decorators: [{
|
|
751
|
+
type: Injectable,
|
|
752
|
+
args: [{
|
|
753
|
+
providedIn: 'root'
|
|
754
|
+
}]
|
|
755
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
756
|
+
type: Inject,
|
|
757
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
758
|
+
}] }] });
|
|
759
|
+
|
|
760
|
+
class KeyPressService {
|
|
761
|
+
shouldPreventMacroKeyPress(event, macroKeysPress) {
|
|
762
|
+
const eventTarget = event.target;
|
|
763
|
+
const targetMacroKeys = eventTarget.getAttribute(attributes.preventMacroKeysPressEvent)?.split(",").map(Number);
|
|
764
|
+
const targetHasPreventMacroKeyPress = targetMacroKeys?.some(targetMacroKey => macroKeysPress.includes(targetMacroKey));
|
|
765
|
+
return targetHasPreventMacroKeyPress || eventTarget.hasAttribute(attributes.contenteditable);
|
|
766
|
+
}
|
|
767
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: KeyPressService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
768
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: KeyPressService, providedIn: 'root' });
|
|
769
|
+
}
|
|
770
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: KeyPressService, decorators: [{
|
|
771
|
+
type: Injectable,
|
|
772
|
+
args: [{
|
|
773
|
+
providedIn: 'root'
|
|
774
|
+
}]
|
|
775
|
+
}] });
|
|
776
|
+
|
|
777
|
+
class LoaderManagerService {
|
|
778
|
+
loadersIds = [];
|
|
779
|
+
loadingDescription = '';
|
|
780
|
+
addLoader(loaderId, description) {
|
|
781
|
+
this.loadersIds.push(loaderId);
|
|
782
|
+
this.loadingDescription = description;
|
|
783
|
+
}
|
|
784
|
+
changeDescription(description) {
|
|
785
|
+
this.loadingDescription = description;
|
|
786
|
+
}
|
|
787
|
+
clear() {
|
|
788
|
+
this.loadersIds = [];
|
|
789
|
+
this.loadingDescription = '';
|
|
790
|
+
}
|
|
791
|
+
removeLoaderId(loaderIdToRemove) {
|
|
792
|
+
let indexToRemove = this.loadersIds.findIndex(loaderId => loaderId == loaderIdToRemove);
|
|
793
|
+
if (indexToRemove != -1)
|
|
794
|
+
this.loadersIds.splice(indexToRemove, 1);
|
|
795
|
+
}
|
|
796
|
+
get isFullScreenLoading() {
|
|
797
|
+
return this.loadersIds.length > 0;
|
|
798
|
+
}
|
|
799
|
+
;
|
|
800
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: LoaderManagerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
801
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: LoaderManagerService, providedIn: 'root' });
|
|
802
|
+
}
|
|
803
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: LoaderManagerService, decorators: [{
|
|
804
|
+
type: Injectable,
|
|
805
|
+
args: [{
|
|
806
|
+
providedIn: 'root'
|
|
807
|
+
}]
|
|
808
|
+
}] });
|
|
809
|
+
|
|
810
|
+
const freeTextAnswerField = 'FreeTextAnswer';
|
|
811
|
+
const gradeField = 'Grade';
|
|
812
|
+
const answerNotesField = 'AnswerNotes[]';
|
|
813
|
+
const UserQuestionsDataPath = 'QuizData.UserQuestionsData';
|
|
814
|
+
class MicroResourcesService {
|
|
815
|
+
http;
|
|
816
|
+
environmentConfig;
|
|
817
|
+
constructor(http, environmentConfig) {
|
|
818
|
+
this.http = http;
|
|
819
|
+
this.environmentConfig = environmentConfig;
|
|
820
|
+
}
|
|
821
|
+
getAssignmentUpdateTimings(selectedResource, openingTime, closingTime) {
|
|
822
|
+
return [{
|
|
823
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0]?.id, freeTextAnswerField),
|
|
824
|
+
collectionItemType: '',
|
|
825
|
+
openingTime,
|
|
826
|
+
closingTime,
|
|
827
|
+
authorizationType: MicroResourceAuthorizationType.update
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1]?.id, freeTextAnswerField),
|
|
831
|
+
collectionItemType: '',
|
|
832
|
+
openingTime,
|
|
833
|
+
closingTime,
|
|
834
|
+
authorizationType: MicroResourceAuthorizationType.update
|
|
835
|
+
}];
|
|
836
|
+
}
|
|
837
|
+
getPublishGradeTimings(selectedResource, openingTime = new Date(2999, 1, 1), closingTime) {
|
|
838
|
+
return [{
|
|
839
|
+
authorizationType: MicroResourceAuthorizationType.view,
|
|
840
|
+
closingTime: closingTime,
|
|
841
|
+
collectionItemType: "",
|
|
842
|
+
openingTime: openingTime,
|
|
843
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, gradeField)
|
|
844
|
+
}, {
|
|
845
|
+
authorizationType: MicroResourceAuthorizationType.view,
|
|
846
|
+
closingTime: closingTime,
|
|
847
|
+
collectionItemType: "",
|
|
848
|
+
openingTime: openingTime,
|
|
849
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, gradeField)
|
|
850
|
+
}, {
|
|
851
|
+
authorizationType: MicroResourceAuthorizationType.view,
|
|
852
|
+
closingTime: closingTime,
|
|
853
|
+
collectionItemType: "",
|
|
854
|
+
openingTime: openingTime,
|
|
855
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, answerNotesField)
|
|
856
|
+
}, {
|
|
857
|
+
authorizationType: MicroResourceAuthorizationType.view,
|
|
858
|
+
closingTime: closingTime,
|
|
859
|
+
collectionItemType: "",
|
|
860
|
+
openingTime: openingTime,
|
|
861
|
+
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, answerNotesField)
|
|
862
|
+
}, {
|
|
863
|
+
authorizationType: MicroResourceAuthorizationType.view,
|
|
864
|
+
closingTime: closingTime,
|
|
865
|
+
collectionItemType: "",
|
|
866
|
+
openingTime: openingTime,
|
|
867
|
+
propertyPath: `Grade`
|
|
868
|
+
}];
|
|
869
|
+
}
|
|
870
|
+
updateUserMicroResourceAuthorizationLocally(currentLesson, studentId, microResourceAuthorizations, selectedResource) {
|
|
871
|
+
currentLesson.students.find(student => student.student.id == studentId)
|
|
872
|
+
.resourceSubscriptions.find(resourceSubscription => resourceSubscription.resourcePreview.id == selectedResource.id)
|
|
873
|
+
.microResourceAuthorizations = microResourceAuthorizations;
|
|
874
|
+
}
|
|
875
|
+
updateUserMicroResourceVisibility(microResource, resource, lesson, user) {
|
|
876
|
+
let propertyPath;
|
|
877
|
+
propertyPath = this.resolvePropertyPath(microResource.propertyPath, resource.quiz.questions);
|
|
878
|
+
resource.microResourceAuthorizations = resource.microResourceAuthorizations.filter(microResourceAuthorization => microResourceAuthorization.propertyPath != "" &&
|
|
879
|
+
microResourceAuthorization.propertyPath != propertyPath);
|
|
880
|
+
resource.microResourceAuthorizations.push({
|
|
881
|
+
propertyPath: propertyPath,
|
|
882
|
+
collectionItemType: microResource.collectionItemType,
|
|
883
|
+
openingTime: microResource.openingTime,
|
|
884
|
+
closingTime: microResource.closingTime,
|
|
885
|
+
authorizationType: MicroResourceAuthorizationType.view
|
|
886
|
+
});
|
|
887
|
+
return this.updateUserMicroResourceAuthorization(user.student.id, lesson, resource, resource.microResourceAuthorizations);
|
|
888
|
+
}
|
|
889
|
+
updateUserMicroResourceAuthorization(studentId, lesson, resource, authorizations) {
|
|
890
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + '/Activity/UpdateAuthorizations', {
|
|
891
|
+
userIds: [studentId],
|
|
892
|
+
lessonId: lesson.id,
|
|
893
|
+
resourceId: resource.id,
|
|
894
|
+
authorizations
|
|
895
|
+
}).pipe(tap(() => {
|
|
896
|
+
this.updateUserMicroResourceAuthorizationLocally(lesson, studentId, authorizations, resource);
|
|
897
|
+
}));
|
|
898
|
+
}
|
|
899
|
+
resolvePropertyPath(path, questions) {
|
|
900
|
+
return typeof path === 'function' ? path(questions) : path;
|
|
901
|
+
}
|
|
902
|
+
isTimePass(date) {
|
|
903
|
+
if (!date)
|
|
904
|
+
return false;
|
|
905
|
+
return new Date(date).getTime() < new Date().getTime();
|
|
906
|
+
}
|
|
907
|
+
isAuthenticated(microResource) {
|
|
908
|
+
return this.isTimePass(microResource.openingTime) && !this.isTimePass(microResource.closingTime);
|
|
909
|
+
}
|
|
910
|
+
isQuestionAssignment(resourceSubscription, questionType) {
|
|
911
|
+
const question = resourceSubscription?.quizData?.userQuestionsData.find(userQuestionData => userQuestionData.questionType === questionType);
|
|
912
|
+
if (!question)
|
|
913
|
+
return false;
|
|
914
|
+
return !!resourceSubscription.microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(question.id, freeTextAnswerField));
|
|
915
|
+
}
|
|
916
|
+
isQuestionPendingForCheck(resourceSubscription, questionData) {
|
|
917
|
+
const microResourceAuthorizations = resourceSubscription.microResourceAuthorizations;
|
|
918
|
+
const questionId = questionData.id;
|
|
919
|
+
const questionClosingTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, freeTextAnswerField) && microResourceAuthorization.authorizationType === MicroResourceAuthorizationType.update)?.closingTime;
|
|
920
|
+
const gradePublishOpeningTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, gradeField))?.openingTime;
|
|
921
|
+
let isQuestionPendingForCheck = false;
|
|
922
|
+
if (questionClosingTime && questionData.grade === defaultGrade) {
|
|
923
|
+
isQuestionPendingForCheck = gradePublishOpeningTime ?
|
|
924
|
+
new Date(questionClosingTime).getTime() < new Date().getTime() && new Date().getTime() < new Date(gradePublishOpeningTime).getTime() :
|
|
925
|
+
new Date(questionClosingTime).getTime() < new Date().getTime();
|
|
926
|
+
}
|
|
927
|
+
return isQuestionPendingForCheck;
|
|
928
|
+
}
|
|
929
|
+
buildQuestionPropertyPath(id, field) {
|
|
930
|
+
return `${UserQuestionsDataPath}[${id}].${field}`;
|
|
931
|
+
}
|
|
932
|
+
hasFillAuthorizationClosingTimePassed(innerAuthorizations, resource) {
|
|
933
|
+
const fillAuthorizationPropertyPath = defaultAuthorizationObject.fill().propertyPath.replace(resourceIdPlaceholder, resource.id);
|
|
934
|
+
const fillAuthorization = innerAuthorizations?.find(auth => auth.propertyPath == fillAuthorizationPropertyPath && auth.authorizationType == MicroResourceAuthorizationType.fill);
|
|
935
|
+
return this.isTimePass(fillAuthorization?.closingTime);
|
|
936
|
+
}
|
|
937
|
+
isPublishGradeAuthenticated(innerAuthorizations, resource) {
|
|
938
|
+
const publishGradeInnerAuthorizations = this.getAuthorization(innerAuthorizations, defaultAuthorizationObject.resourceGrade(), MicroResourceAuthorizationType.view, resource);
|
|
939
|
+
return publishGradeInnerAuthorizations ? this.isAuthenticated(publishGradeInnerAuthorizations) : false;
|
|
940
|
+
}
|
|
941
|
+
getAuthorization(innerAuthorizations, defaultAuthorizationObject, MicroResourceAuthorizationType, resource) {
|
|
942
|
+
const fillAuthorizationPropertyPath = defaultAuthorizationObject.propertyPath.replace(resourceIdPlaceholder, resource.id);
|
|
943
|
+
return innerAuthorizations.find((innerAuthorization) => innerAuthorization.propertyPath === fillAuthorizationPropertyPath && innerAuthorization.authorizationType === MicroResourceAuthorizationType);
|
|
944
|
+
}
|
|
945
|
+
createMultiResourceDefaultAuthorizations(students, pageId, resourcesIds, defaultAuthorizations, authorizations) {
|
|
946
|
+
const updates = [];
|
|
947
|
+
let microAuthorizations = [];
|
|
948
|
+
if (authorizations)
|
|
949
|
+
microAuthorizations = authorizations;
|
|
950
|
+
else {
|
|
951
|
+
resourcesIds.forEach(resourceId => {
|
|
952
|
+
let defaultAuthorizationsCopy = cloneDeep(defaultAuthorizations);
|
|
953
|
+
defaultAuthorizationsCopy.forEach(authorization => authorization.propertyPath = authorization.propertyPath.replace(resourceIdPlaceholder, resourceId));
|
|
954
|
+
microAuthorizations.push(...defaultAuthorizationsCopy);
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
const parsedAuthorizations = microAuthorizations.map((authorization) => ({
|
|
958
|
+
propertyPath: authorization.propertyPath,
|
|
959
|
+
closingTime: authorization.closingTime,
|
|
960
|
+
openingTime: authorization.openingTime,
|
|
961
|
+
authorizationType: authorization.authorizationType,
|
|
962
|
+
lastUpDateTime: new Date(),
|
|
963
|
+
collectionItemType: authorization.collectionItemType
|
|
964
|
+
}));
|
|
965
|
+
students.forEach(student => {
|
|
966
|
+
updates.push({
|
|
967
|
+
userIds: [student.user?.id],
|
|
968
|
+
hadrachaPageId: pageId,
|
|
969
|
+
authorizations: [...(student.innerAuthorizations || []), ...parsedAuthorizations]
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
return forkJoin(updates.map(request => {
|
|
973
|
+
return this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.resourcePaths?.resourceUpdateAuthorizations, request);
|
|
974
|
+
}));
|
|
975
|
+
}
|
|
976
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, deps: [{ token: i1.HttpClient }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
977
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, providedIn: 'root' });
|
|
978
|
+
}
|
|
979
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, decorators: [{
|
|
980
|
+
type: Injectable,
|
|
981
|
+
args: [{
|
|
982
|
+
providedIn: 'root'
|
|
983
|
+
}]
|
|
984
|
+
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
|
|
985
|
+
type: Inject,
|
|
986
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
987
|
+
}] }] });
|
|
988
|
+
|
|
989
|
+
class ResourceDataBuilderService {
|
|
990
|
+
environmentConfig;
|
|
991
|
+
constructor(environmentConfig) {
|
|
992
|
+
this.environmentConfig = environmentConfig;
|
|
993
|
+
}
|
|
994
|
+
buildFilePath(resource) {
|
|
995
|
+
return getUrlFromFileData(resource.resourceFile, this.environmentConfig?.environment?.s3ServerPath) + this.getVersionPathParameter(resource);
|
|
996
|
+
}
|
|
997
|
+
buildDirectoryPath(resource) {
|
|
998
|
+
return getUrlFromFileData(resource.resourceFile, this.environmentConfig?.environment?.s3ServerPath) + resourcesFilesSuffixes[resource.resourceType] + this.getVersionPathParameter(resource);
|
|
999
|
+
}
|
|
1000
|
+
getVersionPathParameter(resource) {
|
|
1001
|
+
return getVersionPathParameter(new Date(resource.lastUpdateTime));
|
|
1002
|
+
}
|
|
1003
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
1004
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, providedIn: 'root' });
|
|
1005
|
+
}
|
|
1006
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, decorators: [{
|
|
1007
|
+
type: Injectable,
|
|
1008
|
+
args: [{
|
|
1009
|
+
providedIn: 'root'
|
|
1010
|
+
}]
|
|
1011
|
+
}], ctorParameters: () => [{ type: undefined }] });
|
|
1012
|
+
|
|
1013
|
+
class SystemStylingService {
|
|
1014
|
+
document;
|
|
1015
|
+
rendererFactory;
|
|
1016
|
+
renderer = null;
|
|
1017
|
+
constructor(document, rendererFactory) {
|
|
1018
|
+
this.document = document;
|
|
1019
|
+
this.rendererFactory = rendererFactory;
|
|
1020
|
+
this.renderer = this.rendererFactory.createRenderer(null, null);
|
|
1021
|
+
}
|
|
1022
|
+
setHerumStyling() {
|
|
1023
|
+
this.renderer.removeClass(document.body, "college-colors");
|
|
1024
|
+
this.renderer.removeClass(document.body, "hadracha-colors");
|
|
1025
|
+
this.renderer.addClass(document.body, "herum-colors");
|
|
1026
|
+
this.setFavicon("/assets/college/pagesIcons/EchoIcon.svg");
|
|
1027
|
+
}
|
|
1028
|
+
setCollegeStyling() {
|
|
1029
|
+
this.setCssVariable("--main-header-height", "0vh");
|
|
1030
|
+
this.renderer.removeClass(document.body, "hadracha-colors");
|
|
1031
|
+
this.renderer.removeClass(document.body, "herum-colors");
|
|
1032
|
+
this.renderer.addClass(document.body, "college-colors");
|
|
1033
|
+
this.setFavicon("/assets/college/pagesIcons/EchoIcon.svg");
|
|
1034
|
+
}
|
|
1035
|
+
setHadrachaStyling() {
|
|
1036
|
+
this.renderer.removeClass(document.body, "college-colors");
|
|
1037
|
+
this.renderer.removeClass(document.body, "herum-colors");
|
|
1038
|
+
this.renderer.addClass(document.body, "hadracha-colors");
|
|
1039
|
+
this.setFavicon("/assets/hadracha/general/hadracha-favicon.svg");
|
|
1040
|
+
}
|
|
1041
|
+
setCssVariable(name, value) {
|
|
1042
|
+
document.documentElement.style.setProperty(name, value);
|
|
1043
|
+
}
|
|
1044
|
+
setFavicon(path) {
|
|
1045
|
+
const link = this.document.querySelector("link[rel*='icon']");
|
|
1046
|
+
link.type = 'image/x-icon';
|
|
1047
|
+
link.rel = 'icon';
|
|
1048
|
+
link.href = path;
|
|
1049
|
+
this.document.head.appendChild(link);
|
|
1050
|
+
}
|
|
1051
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: SystemStylingService, deps: [{ token: DOCUMENT }, { token: i0.RendererFactory2 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1052
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: SystemStylingService, providedIn: 'root' });
|
|
1053
|
+
}
|
|
1054
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: SystemStylingService, decorators: [{
|
|
1055
|
+
type: Injectable,
|
|
1056
|
+
args: [{
|
|
1057
|
+
providedIn: 'root'
|
|
1058
|
+
}]
|
|
1059
|
+
}], ctorParameters: () => [{ type: Document, decorators: [{
|
|
1060
|
+
type: Inject,
|
|
1061
|
+
args: [DOCUMENT]
|
|
1062
|
+
}] }, { type: i0.RendererFactory2 }] });
|
|
1063
|
+
function systemStylingFactory(systemName, systemStylingService) {
|
|
1064
|
+
return () => {
|
|
1065
|
+
switch (systemName) {
|
|
1066
|
+
case system.college:
|
|
1067
|
+
systemStylingService.setCollegeStyling();
|
|
1068
|
+
break;
|
|
1069
|
+
case system.herum:
|
|
1070
|
+
systemStylingService.setHerumStyling();
|
|
1071
|
+
break;
|
|
1072
|
+
case system.hadracha:
|
|
1073
|
+
systemStylingService.setHadrachaStyling();
|
|
1074
|
+
break;
|
|
1075
|
+
default:
|
|
1076
|
+
throw new Error(`Unsupported system:${systemName}`);
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
class TrackTextChangesService {
|
|
1082
|
+
systemContextTrackTextChangesService;
|
|
1083
|
+
constructor(systemContextTrackTextChangesService) {
|
|
1084
|
+
this.systemContextTrackTextChangesService = systemContextTrackTextChangesService;
|
|
1085
|
+
}
|
|
1086
|
+
getStyle() {
|
|
1087
|
+
return this.systemContextTrackTextChangesService.getStyle();
|
|
1088
|
+
}
|
|
1089
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: TrackTextChangesService, deps: [{ token: SYSTEM_TRACK_TEXT_CHANGES_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1090
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: TrackTextChangesService, providedIn: 'root' });
|
|
1091
|
+
}
|
|
1092
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: TrackTextChangesService, decorators: [{
|
|
1093
|
+
type: Injectable,
|
|
1094
|
+
args: [{
|
|
1095
|
+
providedIn: 'root'
|
|
1096
|
+
}]
|
|
1097
|
+
}], ctorParameters: () => [{ type: i1$1.ISystemTrackTextChangesService, decorators: [{
|
|
1098
|
+
type: Inject,
|
|
1099
|
+
args: [SYSTEM_TRACK_TEXT_CHANGES_SERVICE]
|
|
1100
|
+
}] }] });
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Generated bundle index. Do not edit.
|
|
1104
|
+
*/
|
|
1105
|
+
|
|
1106
|
+
export { AuthService, CommonGraphqlRequestsService, DbActionRequestsService, DbActionsInnerIdManagerService, GlobalKeyboardListenerService, GraphQLService, KeyPressService, LoaderManagerService, MicroResourcesService, NestedConditionSigniture, ResourceDataBuilderService, SystemStylingService, TrackTextChangesService, emptyValueFlagForCreationUniqListItem, freeTextAnswerField, innerUniqListItemKey, systemStylingFactory };
|
|
1107
|
+
//# sourceMappingURL=herum-shared-services.mjs.map
|