@acorex/connectivity 19.2.15 → 19.2.17-next.0

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.
@@ -1,5 +1,5 @@
1
1
  import { APPLICATION_SOURCE_NAME, MODULE_SOURCE_NAME, ENTITY_SOURCE_NAME, FEATURE_SOURCE_NAME, PERMISSION_SOURCE_NAME, PROPERTY_SOURCE_NAME, AXPModuleDesignerService } from '@acorex/modules/application-management';
2
- import { RootConfig, AXMFolderServiceImpl, AXMFolderService } from '@acorex/modules/document-management';
2
+ import { RootConfig, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMFolderService, AXMDocumentService } from '@acorex/modules/document-management';
3
3
  import { RootConfig as RootConfig$3, AXMNotificationEntityService } from '@acorex/modules/notification-management';
4
4
  import * as i1$1 from '@acorex/platform/auth';
5
5
  import { AXPSessionService, AXPPermissionProviderService, AXPAuthModule } from '@acorex/platform/auth';
@@ -659,86 +659,81 @@ const rootFolder = {
659
659
  const sampleFileTypes = [
660
660
  {
661
661
  ext: 'pdf',
662
- titles: [
663
- 'Risk Assessment Report',
664
- 'Safety Audit Checklist',
665
- 'Emergency Response Plan',
666
- 'Safety Training Manual'
667
- ]
662
+ titles: ['Risk Assessment Report', 'Safety Audit Checklist', 'Emergency Response Plan', 'Safety Training Manual'],
668
663
  },
669
664
  {
670
665
  ext: 'docx',
671
- titles: [
672
- 'Incident Investigation Form',
673
- 'Safety Meeting Minutes',
674
- 'Hazard Report Template',
675
- 'Safe Work Procedure'
676
- ]
666
+ titles: ['Incident Investigation Form', 'Safety Meeting Minutes', 'Hazard Report Template', 'Safe Work Procedure'],
677
667
  },
678
668
  {
679
669
  ext: 'xlsx',
680
- titles: [
681
- 'Incident Statistics',
682
- 'Safety Training Matrix',
683
- 'PPE Inventory List',
684
- 'Risk Register'
685
- ]
670
+ titles: ['Incident Statistics', 'Safety Training Matrix', 'PPE Inventory List', 'Risk Register'],
686
671
  },
687
672
  {
688
673
  ext: 'jpg',
689
- titles: [
690
- 'Hazard Photo',
691
- 'Safety Signage',
692
- 'Emergency Exit Plan',
693
- 'PPE Requirements Chart'
694
- ]
674
+ titles: ['Hazard Photo', 'Safety Signage', 'Emergency Exit Plan', 'PPE Requirements Chart'],
695
675
  },
696
676
  {
697
677
  ext: 'png',
698
- titles: [
699
- 'Safety Infographic',
700
- 'Evacuation Map',
701
- 'Incident Scene Photo',
702
- 'Safety Procedure Diagram'
703
- ]
678
+ titles: ['Safety Infographic', 'Evacuation Map', 'Incident Scene Photo', 'Safety Procedure Diagram'],
704
679
  },
705
680
  {
706
681
  ext: 'pptx',
707
- titles: [
708
- 'Safety Induction',
709
- 'WHS Training Module',
710
- 'Safety Committee Presentation',
711
- 'Toolbox Talk'
712
- ]
713
- }
682
+ titles: ['Safety Induction', 'WHS Training Module', 'Safety Committee Presentation', 'Toolbox Talk'],
683
+ },
714
684
  ];
715
685
  const sites = ['Main Factory', 'Warehouse Complex', 'Office Building', 'Construction Site'];
716
686
  const whsFolders = [
717
687
  {
718
688
  name: 'Policies and Procedures',
719
689
  subFolders: ['Safety Policies', 'Standard Operating Procedures', 'Emergency Procedures', 'Work Instructions'],
720
- commonFiles: ['WHS Policy Manual.pdf', 'Emergency Response Plan.pdf', 'Safety Management System.docx', 'Risk Management Framework.pdf']
690
+ commonFiles: [
691
+ 'WHS Policy Manual.pdf',
692
+ 'Emergency Response Plan.pdf',
693
+ 'Safety Management System.docx',
694
+ 'Risk Management Framework.pdf',
695
+ ],
721
696
  },
722
697
  {
723
698
  name: 'Risk Management',
724
699
  subFolders: ['Risk Assessments', 'Hazard Reports', 'Control Measures', 'Safety Audits'],
725
- commonFiles: ['Risk Assessment Matrix.xlsx', 'Hazard Register.xlsx', 'Control Measure Checklist.pdf', 'Audit Schedule.xlsx']
700
+ commonFiles: [
701
+ 'Risk Assessment Matrix.xlsx',
702
+ 'Hazard Register.xlsx',
703
+ 'Control Measure Checklist.pdf',
704
+ 'Audit Schedule.xlsx',
705
+ ],
726
706
  },
727
707
  {
728
708
  name: 'Incident Management',
729
709
  subFolders: ['Incident Reports', 'Investigations', 'Corrective Actions', 'Statistics'],
730
- commonFiles: ['Incident Report Form.docx', 'Investigation Guidelines.pdf', 'Corrective Action Register.xlsx', 'Monthly Statistics.xlsx']
710
+ commonFiles: [
711
+ 'Incident Report Form.docx',
712
+ 'Investigation Guidelines.pdf',
713
+ 'Corrective Action Register.xlsx',
714
+ 'Monthly Statistics.xlsx',
715
+ ],
731
716
  },
732
717
  {
733
718
  name: 'Training and Compliance',
734
719
  subFolders: ['Training Records', 'Certifications', 'Competency Assessments', 'Toolbox Talks'],
735
- commonFiles: ['Training Matrix.xlsx', 'Induction Package.pdf', 'Competency Framework.docx', 'Training Calendar.xlsx']
720
+ commonFiles: [
721
+ 'Training Matrix.xlsx',
722
+ 'Induction Package.pdf',
723
+ 'Competency Framework.docx',
724
+ 'Training Calendar.xlsx',
725
+ ],
736
726
  },
737
727
  {
738
728
  name: 'Safety Equipment',
739
729
  subFolders: ['PPE Records', 'Equipment Inspections', 'Maintenance Records', 'Safety Data Sheets'],
740
- commonFiles: ['PPE Register.xlsx', 'Equipment Maintenance Schedule.xlsx', 'Safety Equipment Inventory.xlsx', 'PPE Guidelines.pdf']
741
- }
730
+ commonFiles: [
731
+ 'PPE Register.xlsx',
732
+ 'Equipment Maintenance Schedule.xlsx',
733
+ 'Safety Equipment Inventory.xlsx',
734
+ 'PPE Guidelines.pdf',
735
+ ],
736
+ },
742
737
  ];
743
738
  sites.forEach((site) => {
744
739
  const siteFolderId = AXPDataGenerator$1.uuid();
@@ -873,17 +868,17 @@ allFolders.push(rootFolder);
873
868
  const FOLDER_MOCK_DATA = allFolders;
874
869
  const FILE_MOCK_DATA = allFiles;
875
870
 
876
- class AXCFolderDataSeeder {
871
+ class AXCFileDataSeeder {
877
872
  constructor() {
878
873
  this.storageService = inject(AXPDexieEntityStorageService);
879
874
  }
880
875
  async seed() {
881
- await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.folder.name}`, FOLDER_MOCK_DATA);
876
+ await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.document.name}`, FILE_MOCK_DATA);
882
877
  }
883
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
884
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder }); }
878
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
879
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder }); }
885
880
  }
886
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, decorators: [{
881
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder, decorators: [{
887
882
  type: Injectable
888
883
  }] });
889
884
 
@@ -956,8 +951,172 @@ class AXMFolderMockService extends AXMFolderServiceImpl {
956
951
  }
957
952
  return path.reverse();
958
953
  }
954
+ /**
955
+ * جستجوی فولدرها با نام مشخص شده با استفاده از روش بازگشتی
956
+ * @param searchTerm عبارت جستجو
957
+ * @param rootFolderId شناسه فولدر ریشه برای شروع جستجو
958
+ */
959
+ async searchFolders(searchTerm, rootFolderId) {
960
+ const result = [];
961
+ await this.searchFoldersRecursive(searchTerm, rootFolderId, result);
962
+ return result;
963
+ }
964
+ /**
965
+ * جستجوی بازگشتی فولدرها
966
+ * @param searchTerm عبارت جستجو
967
+ * @param folderId شناسه فولدر فعلی
968
+ * @param result آرایه نتایج
969
+ */
970
+ async searchFoldersRecursive(searchTerm, folderId, result) {
971
+ try {
972
+ // دریافت فولدر فعلی
973
+ const currentFolder = await this.getOne(folderId);
974
+ if (!currentFolder) {
975
+ return;
976
+ }
977
+ // بررسی زیرفولدرها
978
+ const subFolders = currentFolder.folders || [];
979
+ // افزودن فولدرهایی که با عبارت جستجو مطابقت دارند
980
+ for (const folder of subFolders) {
981
+ if (folder.name.toLowerCase().includes(searchTerm.toLowerCase())) {
982
+ result.push(folder);
983
+ }
984
+ // جستجوی بازگشتی در زیرفولدرها
985
+ if (folder.id) {
986
+ await this.searchFoldersRecursive(searchTerm, folder.id, result);
987
+ }
988
+ }
989
+ }
990
+ catch (error) {
991
+ console.error('Error searching folders:', error);
992
+ }
993
+ }
959
994
  }
960
995
 
996
+ class AXMFileMockService extends AXMDocumentServiceImpl {
997
+ constructor() {
998
+ super();
999
+ this.folderService = new AXMFolderMockService();
1000
+ }
1001
+ async updateParentFolder(file) {
1002
+ if (!file.parentId) {
1003
+ throw new Error('File must have a parent folder');
1004
+ }
1005
+ const parent = await this.folderService.getOne(file.parentId);
1006
+ if (parent && parent.id) {
1007
+ if (!parent.documents) {
1008
+ parent.documents = [];
1009
+ }
1010
+ const existingIndex = parent.documents.findIndex((f) => f.id === file.id);
1011
+ if (existingIndex === -1) {
1012
+ parent.documents.push(file);
1013
+ }
1014
+ else {
1015
+ parent.documents[existingIndex] = file;
1016
+ }
1017
+ await this.folderService.updateOne(parent.id, { documents: parent.documents });
1018
+ }
1019
+ }
1020
+ async removeFromParent(file) {
1021
+ if (!file.parentId) {
1022
+ throw new Error('File must have a parent folder');
1023
+ }
1024
+ const parent = await this.folderService.getOne(file.parentId);
1025
+ if (parent && parent.id && parent.documents) {
1026
+ parent.documents = parent.documents.filter((f) => f.id !== file.id);
1027
+ await this.folderService.updateOne(parent.id, { documents: parent.documents });
1028
+ }
1029
+ }
1030
+ async insertOne(request) {
1031
+ if (!request.parentId) {
1032
+ throw new Error('File must have a parent folder');
1033
+ }
1034
+ const newId = await super.insertOne(request);
1035
+ const fileData = {
1036
+ ...request,
1037
+ id: newId,
1038
+ };
1039
+ await this.updateParentFolder(fileData);
1040
+ return newId;
1041
+ }
1042
+ async updateOne(id, values) {
1043
+ const currentFile = await this.getOne(id);
1044
+ const updatedFile = await super.updateOne(id, values);
1045
+ if (currentFile && values.parentId !== undefined && currentFile.parentId !== values.parentId) {
1046
+ await this.removeFromParent(currentFile);
1047
+ }
1048
+ await this.updateParentFolder(updatedFile);
1049
+ return updatedFile;
1050
+ }
1051
+ async deleteOne(id) {
1052
+ const fileToDelete = await this.getOne(id);
1053
+ if (fileToDelete) {
1054
+ await this.removeFromParent(fileToDelete);
1055
+ await super.deleteOne(id);
1056
+ }
1057
+ }
1058
+ async getPath(documentId) {
1059
+ const file = await this.getOne(documentId);
1060
+ if (!file) {
1061
+ throw new Error('File not found');
1062
+ }
1063
+ return await this.folderService.getPath(file.parentId);
1064
+ }
1065
+ /**
1066
+ * جستجوی فایل‌ها با نام مشخص شده با استفاده از روش بازگشتی
1067
+ * @param searchTerm عبارت جستجو
1068
+ * @param rootFolderId شناسه فولدر ریشه برای شروع جستجو
1069
+ */
1070
+ async searchFiles(searchTerm, rootFolderId) {
1071
+ const result = [];
1072
+ await this.searchFilesRecursive(searchTerm, rootFolderId, result);
1073
+ return result;
1074
+ }
1075
+ /**
1076
+ * جستجوی بازگشتی فایل‌ها
1077
+ * @param searchTerm عبارت جستجو
1078
+ * @param folderId شناسه فولدر فعلی
1079
+ * @param result آرایه نتایج
1080
+ */
1081
+ async searchFilesRecursive(searchTerm, folderId, result) {
1082
+ try {
1083
+ const currentFolder = await this.folderService.getOne(folderId);
1084
+ if (!currentFolder) {
1085
+ return;
1086
+ }
1087
+ const files = currentFolder.documents || [];
1088
+ for (const file of files) {
1089
+ if (file.name.toLowerCase().includes(searchTerm.toLowerCase())) {
1090
+ result.push(file);
1091
+ }
1092
+ }
1093
+ const subFolders = currentFolder.folders || [];
1094
+ for (const folder of subFolders) {
1095
+ if (folder.id) {
1096
+ await this.searchFilesRecursive(searchTerm, folder.id, result);
1097
+ }
1098
+ }
1099
+ }
1100
+ catch (error) {
1101
+ console.error('Error searching files:', error);
1102
+ }
1103
+ }
1104
+ }
1105
+
1106
+ class AXCFolderDataSeeder {
1107
+ constructor() {
1108
+ this.storageService = inject(AXPDexieEntityStorageService);
1109
+ }
1110
+ async seed() {
1111
+ await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.folder.name}`, FOLDER_MOCK_DATA);
1112
+ }
1113
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1114
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder }); }
1115
+ }
1116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, decorators: [{
1117
+ type: Injectable
1118
+ }] });
1119
+
961
1120
  class EntitySearchProvider {
962
1121
  async search(text) {
963
1122
  const db = new Dexie('ACoreXPlatform');
@@ -3105,6 +3264,11 @@ class AXCMockModule {
3105
3264
  useClass: AXCDocumentTypeDataSeeder,
3106
3265
  multi: true,
3107
3266
  },
3267
+ {
3268
+ provide: AXP_DATA_SEEDER_TOKEN,
3269
+ useClass: AXCFileDataSeeder,
3270
+ multi: true,
3271
+ },
3108
3272
  {
3109
3273
  provide: AXPModuleDesignerService,
3110
3274
  useClass: AXCModuleDesignerService,
@@ -3121,6 +3285,10 @@ class AXCMockModule {
3121
3285
  provide: AXMFolderService,
3122
3286
  useClass: AXMFolderMockService,
3123
3287
  },
3288
+ {
3289
+ provide: AXMDocumentService,
3290
+ useClass: AXMFileMockService,
3291
+ },
3124
3292
  {
3125
3293
  provide: AXP_SEARCH_PROVIDER,
3126
3294
  useClass: EntitySearchProvider,
@@ -3218,6 +3386,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3218
3386
  useClass: AXCDocumentTypeDataSeeder,
3219
3387
  multi: true,
3220
3388
  },
3389
+ {
3390
+ provide: AXP_DATA_SEEDER_TOKEN,
3391
+ useClass: AXCFileDataSeeder,
3392
+ multi: true,
3393
+ },
3221
3394
  {
3222
3395
  provide: AXPModuleDesignerService,
3223
3396
  useClass: AXCModuleDesignerService,
@@ -3234,6 +3407,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
3234
3407
  provide: AXMFolderService,
3235
3408
  useClass: AXMFolderMockService,
3236
3409
  },
3410
+ {
3411
+ provide: AXMDocumentService,
3412
+ useClass: AXMFileMockService,
3413
+ },
3237
3414
  {
3238
3415
  provide: AXP_SEARCH_PROVIDER,
3239
3416
  useClass: EntitySearchProvider,