herum-shared 0.1.38 → 0.1.39

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.
Files changed (68) hide show
  1. package/assets/shared/audio-images/purple-pause.svg +4 -0
  2. package/assets/shared/audio-images/purple-play.svg +3 -0
  3. package/atoms/index.d.ts +55 -55
  4. package/constants/index.d.ts +181 -136
  5. package/dialogs/index.d.ts +4 -3
  6. package/environment/index.d.ts +2 -35
  7. package/fesm2022/herum-shared-animations.mjs +4 -0
  8. package/fesm2022/herum-shared-animations.mjs.map +1 -1
  9. package/fesm2022/herum-shared-atoms.mjs +110 -108
  10. package/fesm2022/herum-shared-atoms.mjs.map +1 -1
  11. package/fesm2022/herum-shared-constants.mjs +188 -159
  12. package/fesm2022/herum-shared-constants.mjs.map +1 -1
  13. package/fesm2022/herum-shared-decorators.mjs +4 -0
  14. package/fesm2022/herum-shared-decorators.mjs.map +1 -1
  15. package/fesm2022/herum-shared-dialogs.mjs +7 -4
  16. package/fesm2022/herum-shared-dialogs.mjs.map +1 -1
  17. package/fesm2022/herum-shared-directives.mjs +5 -1
  18. package/fesm2022/herum-shared-directives.mjs.map +1 -1
  19. package/fesm2022/herum-shared-environment.mjs +4 -0
  20. package/fesm2022/herum-shared-environment.mjs.map +1 -1
  21. package/fesm2022/herum-shared-errors.mjs +5 -1
  22. package/fesm2022/herum-shared-errors.mjs.map +1 -1
  23. package/fesm2022/herum-shared-fetched-message.mjs +39 -30
  24. package/fesm2022/herum-shared-fetched-message.mjs.map +1 -1
  25. package/fesm2022/herum-shared-molecules.mjs +57 -28
  26. package/fesm2022/herum-shared-molecules.mjs.map +1 -1
  27. package/fesm2022/herum-shared-mongo.mjs +414 -150
  28. package/fesm2022/herum-shared-mongo.mjs.map +1 -1
  29. package/fesm2022/herum-shared-objectsExample.mjs +5 -1
  30. package/fesm2022/herum-shared-objectsExample.mjs.map +1 -1
  31. package/fesm2022/herum-shared-pipes.mjs +64 -60
  32. package/fesm2022/herum-shared-pipes.mjs.map +1 -1
  33. package/fesm2022/herum-shared-services.mjs +144 -321
  34. package/fesm2022/herum-shared-services.mjs.map +1 -1
  35. package/fesm2022/herum-shared-static-services.mjs +4 -0
  36. package/fesm2022/herum-shared-static-services.mjs.map +1 -1
  37. package/fesm2022/herum-shared-table.mjs +61 -48
  38. package/fesm2022/herum-shared-table.mjs.map +1 -1
  39. package/fesm2022/herum-shared-testsObjects.mjs +89 -119
  40. package/fesm2022/herum-shared-testsObjects.mjs.map +1 -1
  41. package/fesm2022/herum-shared-tokens.mjs +4 -0
  42. package/fesm2022/herum-shared-tokens.mjs.map +1 -1
  43. package/fesm2022/herum-shared-utils.mjs +43 -39
  44. package/fesm2022/herum-shared-utils.mjs.map +1 -1
  45. package/fesm2022/herum-shared-validators.mjs +4 -0
  46. package/fesm2022/herum-shared-validators.mjs.map +1 -1
  47. package/fesm2022/herum-shared.mjs +9031 -890
  48. package/fesm2022/herum-shared.mjs.map +1 -1
  49. package/fetched-message/index.d.ts +11 -11
  50. package/index.d.ts +1654 -274
  51. package/molecules/index.d.ts +12 -9
  52. package/mongo/index.d.ts +125 -66
  53. package/objectsExample/index.d.ts +3 -1
  54. package/package.json +2 -5
  55. package/pipes/index.d.ts +25 -21
  56. package/services/index.d.ts +56 -67
  57. package/styles/_mixin.scss +2 -2
  58. package/styles/dialogs.scss +0 -5
  59. package/styles/variables/_colors.scss +5 -109
  60. package/styles/variables/_sizes.scss +2 -9
  61. package/table/index.d.ts +25 -18
  62. package/testsObjects/index.d.ts +3 -3
  63. package/tokens/index.d.ts +6 -4
  64. package/utils/index.d.ts +14 -10
  65. package/fesm2022/herum-shared-herum-types.mjs +0 -107
  66. package/fesm2022/herum-shared-herum-types.mjs.map +0 -1
  67. package/herum-types/index.d.ts +0 -200
  68. package/styles/variables/_colors.college.scss +0 -65
@@ -3,16 +3,16 @@ import { HttpHeaders } from '@angular/common/http';
3
3
  import * as i0 from '@angular/core';
4
4
  import { Inject, Injectable } from '@angular/core';
5
5
  import { BehaviorSubject, Subject, forkJoin } from 'rxjs';
6
- import { shareReplay, map, switchMap, tap } from 'rxjs/operators';
6
+ import { shareReplay, map, tap } from 'rxjs/operators';
7
7
  import { StorageService } from 'herum-shared/static-services';
8
8
  import { selfIsTeacherExample, closedListExample, permissionsTemplatesExample } from 'herum-shared/objectsExample';
9
9
  import { HERUM_SHARED_CONFIG_TOKEN } from 'herum-shared/environment';
10
- import { toHash, buildPath, setHeaders, remainJustWantedValueInDictionary, getVersionPathParameter } from 'herum-shared/utils';
10
+ import { toHash, buildPath, getVersionPathParameter } from 'herum-shared/utils';
11
11
  import * as i2 from '@angular/router';
12
- import { regexExpressions, generalKeys, uploadsManagerKeys, skipToastHeader, assignmentMetadata, attributes, defaultGrade, defaultAuthorizationObject, resourceIdPlaceholder, getPublishAuthorization, getMongoMethodsDisplayedNamesMap, resourcesFilesSuffixes, system } from 'herum-shared/constants';
13
- import * as i1$1 from 'herum-shared/herum-types';
14
- import { microResourceAuthorizationType } from 'herum-shared/herum-types';
12
+ import { regexExpressions, generalKeys, attributes, defaultGrade, defaultAuthorizationObject, resourceIdPlaceholder, getPublishAuthorization, resourcesFilesSuffixes, system, toastsTemplates, toastContext, toastStatuses, toastStates } from 'herum-shared/constants';
13
+ import { MicroResourceAuthorizationType } from 'herum-types/Resource';
15
14
  import { cloneDeep } from 'lodash';
15
+ import { QuizStatus } from 'herum-types/Enums';
16
16
  import { DOCUMENT } from '@angular/common';
17
17
  import { SYSTEM_TRACK_TEXT_CHANGES_SERVICE } from 'herum-shared/tokens';
18
18
 
@@ -34,8 +34,8 @@ class GraphQLService {
34
34
  variablesObjectForBody = this.generateVariablesObjectForBody(gqlQuery.variables);
35
35
  variablesStringForQuerySignature = this.generateVariablesStringForQuerySigniture(gqlQuery.variables, gqlQuery.queryName);
36
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 })
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, gqlQuery.useTotalCount).replace(regexExpressions.curlyBraces, '');
38
+ return this.httpClient.post(this.environmentConfig?.graphQLConfiguration.serverBasePath, { query: query, variables: variablesObjectForBody }, { headers: gqlQuery.headers })
39
39
  .pipe(shareReplay(1), map(res => {
40
40
  return res.data ? res.data[gqlQuery.resolverName] : null;
41
41
  }));
@@ -75,7 +75,7 @@ class GraphQLService {
75
75
  convertToResolverNameFormat(mongoCollectionName) {
76
76
  return mongoCollectionName.charAt(0).toLowerCase() + mongoCollectionName.slice(1);
77
77
  }
78
- generateQuery(resolverName, formatExample, condition, first, after, offsetPaging, variablesStringForQuerySigniture, order, conditionPaths, orderPaths, offsetPagingPaths, isListQuery, isOffsetPagination) {
78
+ generateQuery(resolverName, formatExample, condition, first, after, offsetPaging, variablesStringForQuerySigniture, order, conditionPaths, orderPaths, offsetPagingPaths, isListQuery, isOffsetPagination, useTotalCount) {
79
79
  const conditionString = this.generateConditionString(condition);
80
80
  const returnFormat = this.getKeysString(formatExample, conditionPaths, orderPaths, offsetPagingPaths);
81
81
  let orderString = order ? `order:${this.generateOrderString(order)},` : '';
@@ -92,7 +92,7 @@ class GraphQLService {
92
92
  pagingString += ',';
93
93
  const elementsName = isOffsetPagination ? 'items' : 'nodes';
94
94
  const query = `query ${variablesStringForQuerySigniture ? variablesStringForQuerySigniture : ''} {
95
- ${resolverName + resolverParameters} { ${isListQuery ? (isOffsetPagination ? offsetPagingDataFormat : defaultPagingDataFormat) + `,totalCount , ${elementsName} {` : ''} ${returnFormat} } ${isListQuery ? '}' : ''} }`;
95
+ ${resolverName + resolverParameters} { ${isListQuery ? (isOffsetPagination ? offsetPagingDataFormat : defaultPagingDataFormat) + `,${useTotalCount ? 'totalCount ,' : ''} ${elementsName} {` : ''} ${returnFormat} } ${isListQuery ? '}' : ''} }`;
96
96
  return query;
97
97
  }
98
98
  generateConditionString(condition, isRecursiveCall = false) {
@@ -371,7 +371,7 @@ class CommonGraphqlRequestsService {
371
371
  let filterQuery = this.gql.generateFilterStringDynamically(usersIds, generalKeys.id, 'String');
372
372
  let query = {
373
373
  resolverName: this.gql.convertToResolverNameFormat(this.environmentConfig?.mongoUpdates?.Collections?.Users),
374
- formatExample,
374
+ formatExample: formatExample,
375
375
  filters: {
376
376
  or: filterQuery.filters
377
377
  },
@@ -427,290 +427,41 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
427
427
  }]
428
428
  }] });
429
429
 
430
- const ATTACH = "Attach";
431
- class DbActionRequestsService {
430
+ const oneSecondInMilliseconds = 1000;
431
+ class GlobalErrorHandler {
432
432
  http;
433
- dbActionsInnerIdManagerService;
434
433
  environmentConfig;
435
- constructor(http, dbActionsInnerIdManagerService, environmentConfig) {
434
+ lastErrorKey = '';
435
+ lastErrorAt = 0;
436
+ constructor(http, environmentConfig) {
436
437
  this.http = http;
437
- this.dbActionsInnerIdManagerService = dbActionsInnerIdManagerService;
438
438
  this.environmentConfig = environmentConfig;
439
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' });
440
+ handleError(error) {
441
+ const currentKey = error?.message;
442
+ const now = Date.now();
443
+ if (currentKey == this.lastErrorKey && (now - this.lastErrorAt) < oneSecondInMilliseconds)
444
+ return;
445
+ this.lastErrorAt = now;
446
+ this.lastErrorKey = currentKey;
447
+ console.error(error);
448
+ this.http.post(this.environmentConfig?.environment?.userAction, {
449
+ system: this.environmentConfig?.environment?.systemIdentifier,
450
+ level: "Error",
451
+ application: "CLIENT ERROR",
452
+ message: error.message,
453
+ stack: error.stack,
454
+ }).subscribe();
455
+ }
456
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalErrorHandler, deps: [{ token: i1.HttpClient }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
457
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalErrorHandler });
651
458
  }
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: [{
459
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: GlobalErrorHandler, decorators: [{
460
+ type: Injectable
461
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
658
462
  type: Inject,
659
463
  args: [HERUM_SHARED_CONFIG_TOKEN]
660
464
  }] }] });
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
465
 
715
466
  class GlobalKeyboardListenerService {
716
467
  environmentConfig;
@@ -824,43 +575,43 @@ class MicroResourcesService {
824
575
  collectionItemType: '',
825
576
  openingTime,
826
577
  closingTime,
827
- authorizationType: microResourceAuthorizationType.update
578
+ authorizationType: MicroResourceAuthorizationType.update
828
579
  },
829
580
  {
830
581
  propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1]?.id, freeTextAnswerField),
831
582
  collectionItemType: '',
832
583
  openingTime,
833
584
  closingTime,
834
- authorizationType: microResourceAuthorizationType.update
585
+ authorizationType: MicroResourceAuthorizationType.update
835
586
  }];
836
587
  }
837
588
  getPublishGradeTimings(selectedResource, openingTime = new Date(2999, 1, 1), closingTime) {
838
589
  return [{
839
- authorizationType: microResourceAuthorizationType.view,
590
+ authorizationType: MicroResourceAuthorizationType.view,
840
591
  closingTime: closingTime,
841
592
  collectionItemType: "",
842
593
  openingTime: openingTime,
843
594
  propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, gradeField)
844
595
  }, {
845
- authorizationType: microResourceAuthorizationType.view,
596
+ authorizationType: MicroResourceAuthorizationType.view,
846
597
  closingTime: closingTime,
847
598
  collectionItemType: "",
848
599
  openingTime: openingTime,
849
600
  propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, gradeField)
850
601
  }, {
851
- authorizationType: microResourceAuthorizationType.view,
602
+ authorizationType: MicroResourceAuthorizationType.view,
852
603
  closingTime: closingTime,
853
604
  collectionItemType: "",
854
605
  openingTime: openingTime,
855
606
  propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, answerNotesField)
856
607
  }, {
857
- authorizationType: microResourceAuthorizationType.view,
608
+ authorizationType: MicroResourceAuthorizationType.view,
858
609
  closingTime: closingTime,
859
610
  collectionItemType: "",
860
611
  openingTime: openingTime,
861
612
  propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, answerNotesField)
862
613
  }, {
863
- authorizationType: microResourceAuthorizationType.view,
614
+ authorizationType: MicroResourceAuthorizationType.view,
864
615
  closingTime: closingTime,
865
616
  collectionItemType: "",
866
617
  openingTime: openingTime,
@@ -882,7 +633,7 @@ class MicroResourcesService {
882
633
  collectionItemType: microResource.collectionItemType,
883
634
  openingTime: microResource.openingTime,
884
635
  closingTime: microResource.closingTime,
885
- authorizationType: microResourceAuthorizationType.view
636
+ authorizationType: MicroResourceAuthorizationType.view
886
637
  });
887
638
  return this.updateUserMicroResourceAuthorization(user.student.id, lesson, resource, resource.microResourceAuthorizations);
888
639
  }
@@ -916,7 +667,7 @@ class MicroResourcesService {
916
667
  isQuestionPendingForCheck(resourceSubscription, questionData) {
917
668
  const microResourceAuthorizations = resourceSubscription.microResourceAuthorizations;
918
669
  const questionId = questionData.id;
919
- const questionClosingTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, freeTextAnswerField) && microResourceAuthorization.authorizationType === microResourceAuthorizationType.update)?.closingTime;
670
+ const questionClosingTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, freeTextAnswerField) && microResourceAuthorization.authorizationType === MicroResourceAuthorizationType.update)?.closingTime;
920
671
  const gradePublishOpeningTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, gradeField))?.openingTime;
921
672
  let isQuestionPendingForCheck = false;
922
673
  if (questionClosingTime && questionData.grade === defaultGrade) {
@@ -929,26 +680,26 @@ class MicroResourcesService {
929
680
  buildQuestionPropertyPath(id, field) {
930
681
  return `${UserQuestionsDataPath}[${id}].${field}`;
931
682
  }
683
+ isPublishGradeAuthenticated(innerAuthorizations, resource) {
684
+ const publishGradeInnerAuthorizations = this.getAuthorization(innerAuthorizations, defaultAuthorizationObject.resourceGrade(), MicroResourceAuthorizationType.view, resource);
685
+ return publishGradeInnerAuthorizations ? this.isAuthenticated(publishGradeInnerAuthorizations) : false;
686
+ }
932
687
  hasFillAuthorizationClosingTimePassed(innerAuthorizations, resource) {
933
688
  const fillAuthorizationPropertyPath = defaultAuthorizationObject.fill().propertyPath.replace(resourceIdPlaceholder, resource.id);
934
- const fillAuthorization = innerAuthorizations?.find(auth => auth.propertyPath == fillAuthorizationPropertyPath && auth.authorizationType == microResourceAuthorizationType.fill);
689
+ const fillAuthorization = innerAuthorizations?.find(auth => auth.propertyPath == fillAuthorizationPropertyPath && auth.authorizationType == MicroResourceAuthorizationType.fill);
935
690
  return this.isTimePass(fillAuthorization?.closingTime);
936
691
  }
937
- isPublishGradeAuthenticated(innerAuthorizations, resource) {
938
- const publishGradeInnerAuthorizations = this.getAuthorization(innerAuthorizations, defaultAuthorizationObject.resourceGrade(), microResourceAuthorizationType.view, resource);
939
- return publishGradeInnerAuthorizations ? this.isAuthenticated(publishGradeInnerAuthorizations) : false;
940
- }
941
692
  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);
693
+ const authorizationPropertyPath = defaultAuthorizationObject.propertyPath.replace(resourceIdPlaceholder, resource.id);
694
+ return innerAuthorizations.find((innerAuthorization) => innerAuthorization.propertyPath === authorizationPropertyPath && innerAuthorization.authorizationType === microResourceAuthorizationType);
944
695
  }
945
- createMultiResourceDefaultAuthorizations(students, pageId, resourcesIds, defaultAuthorizations, authorizations) {
696
+ createMultiResourceDefaultAuthorizations(students, pageId, resourcesIdsToDefaultAuthorizations, authorizations) {
946
697
  const updates = [];
947
698
  let microAuthorizations = [];
948
699
  if (authorizations)
949
700
  microAuthorizations = authorizations;
950
701
  else {
951
- resourcesIds.forEach(resourceId => {
702
+ Object.entries(resourcesIdsToDefaultAuthorizations).forEach(([resourceId, defaultAuthorizations]) => {
952
703
  let defaultAuthorizationsCopy = cloneDeep(defaultAuthorizations);
953
704
  defaultAuthorizationsCopy.forEach(authorization => authorization.propertyPath = authorization.propertyPath.replace(resourceIdPlaceholder, resourceId));
954
705
  microAuthorizations.push(...defaultAuthorizationsCopy);
@@ -1001,7 +752,7 @@ class MicroResourcesService {
1001
752
  const updates = [];
1002
753
  resourcesIdsToRemove.forEach(resourceIdToRemove => {
1003
754
  page.students.forEach(student => {
1004
- let resourceAuthorizationsToKeep = student.innerAuthorizations.filter(innerAuthorization => innerAuthorization.propertyPath.includes(resourceIdToRemove));
755
+ let resourceAuthorizationsToKeep = student.innerAuthorizations.filter(innerAuthorization => !innerAuthorization.propertyPath.includes(resourceIdToRemove));
1005
756
  updates.push({
1006
757
  userIds: [student.user?.id],
1007
758
  hadrachaPageId: page.id,
@@ -1011,6 +762,19 @@ class MicroResourcesService {
1011
762
  });
1012
763
  return forkJoin(updates.map(request => this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.resourcePaths?.resourceUpdateAuthorizations, request)));
1013
764
  }
765
+ getGradeDisplayText(gradeData) {
766
+ if (gradeData.gradeStatus === QuizStatus.checked) {
767
+ if (gradeData.isBinary) {
768
+ if (gradeData.isPassedGrade)
769
+ return 'עובר';
770
+ return 'נכשל';
771
+ }
772
+ return gradeData.grade.toFixed(0);
773
+ }
774
+ if (gradeData.gradeStatus === QuizStatus.submittedToCheck)
775
+ return 'בבדיקה';
776
+ return 'לא הוגש';
777
+ }
1014
778
  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 });
1015
779
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, providedIn: 'root' });
1016
780
  }
@@ -1026,19 +790,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
1026
790
 
1027
791
  class UtilsService {
1028
792
  environmentConfig;
1029
- constructor(environmentConfig) {
793
+ http;
794
+ constructor(environmentConfig, http) {
1030
795
  this.environmentConfig = environmentConfig;
796
+ this.http = http;
1031
797
  }
1032
- getDisplayedNameForMongoMethodByUserActivity(urlRequest) {
1033
- let mongoMethodDisplayedName;
1034
- const mongoMethodsDisplayedNamesMap = getMongoMethodsDisplayedNamesMap(this.environmentConfig?.mongoUpdates, this.environmentConfig?.authenticationPaths);
1035
- Object.entries(mongoMethodsDisplayedNamesMap).forEach(([mongoMethod, displayedName]) => {
1036
- const urlParts = urlRequest?.split('/');
1037
- const matchedMethod = urlParts?.find(urlPart => urlPart === mongoMethod);
1038
- if (matchedMethod)
1039
- mongoMethodDisplayedName = displayedName;
1040
- });
1041
- return mongoMethodDisplayedName;
798
+ ;
799
+ getModelInfo(model) {
800
+ return this.http.get(`${this.environmentConfig?.environment?.siteServerPath}/${model}/${this.environmentConfig?.mongoUpdates?.Methods?.ModelInfo}`);
1042
801
  }
1043
802
  getUrlFromFileData(fileData) {
1044
803
  if (!fileData?.key || !fileData?.bucket)
@@ -1049,14 +808,14 @@ class UtilsService {
1049
808
  fetchFiles(fileId, resourceType, bucket) {
1050
809
  if (!fileId)
1051
810
  return Promise.reject();
1052
- const bucketPath = bucket ? bucket : this.environmentConfig?.buckets[resourceType];
811
+ const bucketPath = bucket ? bucket : this.environmentConfig?.buckets?.[resourceType];
1053
812
  if (fileId && fileId[0] != '/' && bucketPath[bucketPath.length - 1] != '/')
1054
813
  fileId = "/" + fileId;
1055
814
  const path = this.environmentConfig?.environment?.s3ServerPath + bucketPath + fileId;
1056
815
  return fetch(path);
1057
816
  }
1058
817
  async initAudioFile(fileId, bucketName, signal) {
1059
- const audioBucketName = bucketName ? (bucketName + "/") : this.environmentConfig?.buckets.Audio;
818
+ const audioBucketName = bucketName ? (bucketName + "/") : this.environmentConfig?.buckets?.Audio;
1060
819
  return fetch(this.environmentConfig?.environment?.s3ServerPath + audioBucketName + fileId, { signal: signal })
1061
820
  .then(async (response) => {
1062
821
  const arrayBuffer = await response.arrayBuffer();
@@ -1080,7 +839,7 @@ class UtilsService {
1080
839
  }
1081
840
  });
1082
841
  }
1083
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, deps: [{ token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
842
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, deps: [{ token: HERUM_SHARED_CONFIG_TOKEN }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1084
843
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, providedIn: 'root' });
1085
844
  }
1086
845
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, decorators: [{
@@ -1091,7 +850,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
1091
850
  }], ctorParameters: () => [{ type: undefined, decorators: [{
1092
851
  type: Inject,
1093
852
  args: [HERUM_SHARED_CONFIG_TOKEN]
1094
- }] }] });
853
+ }] }, { type: i1.HttpClient }] });
1095
854
 
1096
855
  class ResourceDataBuilderService {
1097
856
  utilsService;
@@ -1185,6 +944,66 @@ function systemStylingFactory(systemName, systemStylingService) {
1185
944
  };
1186
945
  }
1187
946
 
947
+ class ToastsService {
948
+ toast$ = new BehaviorSubject(undefined);
949
+ toastId = 0;
950
+ toastsTemplates = toastsTemplates;
951
+ findErrorMessageByStatusCode(statusCode, mongoMethodDisplayedName) {
952
+ if (!toastContext.statusCodes[statusCode])
953
+ statusCode = 'genericError';
954
+ return toastContext.statusCodes[statusCode](mongoMethodDisplayedName);
955
+ }
956
+ showErrorToast(toastContextKey) {
957
+ if (!this.toastsTemplates[toastContextKey])
958
+ return;
959
+ let content = this.toastsTemplates[toastContextKey][toastStatuses.error];
960
+ let title = this.toastsTemplates[toastContextKey].title;
961
+ this.showToast(title, content, toastStatuses.error);
962
+ }
963
+ showSuccessToast(toastContextKey) {
964
+ if (!this.toastsTemplates[toastContextKey])
965
+ return;
966
+ let content = this.toastsTemplates[toastContextKey][toastStatuses.success];
967
+ let title = this.toastsTemplates[toastContextKey].title;
968
+ this.showToast(title, content, toastStatuses.success);
969
+ }
970
+ showInformationToast(toastContextKey) {
971
+ if (!this.toastsTemplates[toastContextKey])
972
+ return;
973
+ let content = this.toastsTemplates[toastContextKey][toastStatuses.information];
974
+ let title = this.toastsTemplates[toastContextKey].title;
975
+ this.showToast(title, content, toastStatuses.information);
976
+ }
977
+ showOnDemandToast(toastContextKey, status, toastStorageKey) {
978
+ if (!this.toastsTemplates[toastContextKey])
979
+ return;
980
+ if (this.hasToastAlreadyShownAndShouldShowOnce(toastStorageKey))
981
+ return;
982
+ let content = this.toastsTemplates[toastContextKey][status];
983
+ let title = this.toastsTemplates[toastContextKey].title;
984
+ this.showToast(title, content, status);
985
+ }
986
+ hasToastAlreadyShownAndShouldShowOnce(toastStorageKey) {
987
+ if (!toastStorageKey)
988
+ return false;
989
+ if (StorageService.getItem(toastStorageKey))
990
+ return true;
991
+ StorageService.setItem(toastStorageKey, toastStorageKey);
992
+ return false;
993
+ }
994
+ showToast(title, content, status) {
995
+ this.toast$.next({ title, content, status, id: ++this.toastId, state: toastStates.preEnter });
996
+ }
997
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ToastsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
998
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ToastsService, providedIn: 'root' });
999
+ }
1000
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ToastsService, decorators: [{
1001
+ type: Injectable,
1002
+ args: [{
1003
+ providedIn: 'root'
1004
+ }]
1005
+ }] });
1006
+
1188
1007
  class TrackTextChangesService {
1189
1008
  systemContextTrackTextChangesService;
1190
1009
  constructor(systemContextTrackTextChangesService) {
@@ -1201,14 +1020,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
1201
1020
  args: [{
1202
1021
  providedIn: 'root'
1203
1022
  }]
1204
- }], ctorParameters: () => [{ type: i1$1.ISystemTrackTextChangesService, decorators: [{
1023
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1205
1024
  type: Inject,
1206
1025
  args: [SYSTEM_TRACK_TEXT_CHANGES_SERVICE]
1207
1026
  }] }] });
1208
1027
 
1028
+ /**
1029
+ * @file Automatically generated by barrelsby.
1030
+ */
1031
+
1209
1032
  /**
1210
1033
  * Generated bundle index. Do not edit.
1211
1034
  */
1212
1035
 
1213
- export { AuthService, CommonGraphqlRequestsService, DbActionRequestsService, DbActionsInnerIdManagerService, GlobalKeyboardListenerService, GraphQLService, KeyPressService, LoaderManagerService, MicroResourcesService, NestedConditionSigniture, ResourceDataBuilderService, SystemStylingService, TrackTextChangesService, UtilsService, emptyValueFlagForCreationUniqListItem, freeTextAnswerField, innerUniqListItemKey, systemStylingFactory };
1036
+ export { AuthService, CommonGraphqlRequestsService, DbActionsInnerIdManagerService, GlobalErrorHandler, GlobalKeyboardListenerService, GraphQLService, KeyPressService, LoaderManagerService, MicroResourcesService, NestedConditionSigniture, ResourceDataBuilderService, SystemStylingService, ToastsService, TrackTextChangesService, UtilsService, emptyValueFlagForCreationUniqListItem, freeTextAnswerField, innerUniqListItemKey, systemStylingFactory };
1214
1037
  //# sourceMappingURL=herum-shared-services.mjs.map