@acorex/connectivity 19.2.16 → 19.2.17
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/fesm2022/acorex-connectivity-api.mjs +1 -1
- package/fesm2022/acorex-connectivity-mock.mjs +424 -274
- package/fesm2022/acorex-connectivity-mock.mjs.map +1 -1
- package/mock/lib/document-management/folder/folder.mock.data.d.ts +42 -2
- package/mock/lib/document-management/folder/folder.seeder.d.ts +1 -0
- package/mock/lib/document-management/folder/folder.service.d.ts +8 -7
- package/mock/lib/platform-management/file-storage/file-storage-service.d.ts +1 -1
- package/package.json +1 -1
- package/mock/lib/document-management/file/file.seeder.d.ts +0 -8
@@ -3,13 +3,15 @@ import { RootConfig, AXMFolderServiceImpl, AXMDocumentServiceImpl, AXMFolderServ
|
|
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';
|
6
|
-
import { AXPDataGenerator,
|
6
|
+
import { AXPDataGenerator, AXPFileStorageService, AXPFileStorageStatus, AXPRegionalService, AXP_SEARCH_PROVIDER } from '@acorex/platform/common';
|
7
7
|
import { AXPDexieEntityStorageService, AXPEntityDefinitionRegistryService, AXP_DATA_SEEDER_TOKEN, AXPEntityStorageService } from '@acorex/platform/layout/entity';
|
8
8
|
import * as i0 from '@angular/core';
|
9
|
-
import { inject, Injectable, NgModule } from '@angular/core';
|
9
|
+
import { inject, Injectable, NgModule, Injector } from '@angular/core';
|
10
10
|
import * as i1 from '@acorex/modules/conversation';
|
11
11
|
import { AXMConverstionModuleConst, AXMChatServiceImpl, AXMCommentServiceImpl, AXMChatModule, AXMChatService } from '@acorex/modules/conversation';
|
12
12
|
import { AXPDataGenerator as AXPDataGenerator$1 } from '@acorex/platform/core';
|
13
|
+
import { HttpClient } from '@angular/common/http';
|
14
|
+
import { firstValueFrom } from 'rxjs';
|
13
15
|
import Dexie from 'dexie';
|
14
16
|
import { AXP_WIDGET_DATASOURCE_PROVIDER } from '@acorex/platform/layout/builder';
|
15
17
|
import { RootConfig as RootConfig$1 } from '@acorex/modules/form-template-management';
|
@@ -18,7 +20,6 @@ import { RootConfig as RootConfig$2 } from '@acorex/modules/security-management'
|
|
18
20
|
import { AXMOrganizationNodeType, RootConfig as RootConfig$4 } from '@acorex/modules/organization-management';
|
19
21
|
import { RootConfig as RootConfig$5 } from '@acorex/modules/platform-management';
|
20
22
|
import { AXTranslationService } from '@acorex/core/translation';
|
21
|
-
import { firstValueFrom } from 'rxjs';
|
22
23
|
import { AXFileService } from '@acorex/core/file';
|
23
24
|
import { RootConfig as RootConfig$6 } from '@acorex/modules/scheduler-job-management';
|
24
25
|
import { RootConfig as RootConfig$7 } from '@acorex/modules/text-template-management';
|
@@ -637,251 +638,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
637
638
|
type: Injectable
|
638
639
|
}] });
|
639
640
|
|
640
|
-
const allFolders = [];
|
641
|
-
const allFiles = [];
|
642
|
-
const rootFolder = {
|
643
|
-
id: AXPDataGenerator$1.uuid(),
|
644
|
-
name: 'WHS Documentation',
|
645
|
-
color: '#FFFFFF',
|
646
|
-
description: 'Root folder for WHS/OHS Documentation',
|
647
|
-
parentId: undefined,
|
648
|
-
isSystem: true,
|
649
|
-
isHidden: false,
|
650
|
-
isDeleted: false,
|
651
|
-
createdAt: new Date(),
|
652
|
-
updatedAt: new Date(),
|
653
|
-
createdBy: 'system',
|
654
|
-
updatedBy: 'system',
|
655
|
-
folders: [],
|
656
|
-
documents: [],
|
657
|
-
};
|
658
|
-
// Updated sample file types with WHS/OHS specific examples
|
659
|
-
const sampleFileTypes = [
|
660
|
-
{
|
661
|
-
ext: 'pdf',
|
662
|
-
titles: ['Risk Assessment Report', 'Safety Audit Checklist', 'Emergency Response Plan', 'Safety Training Manual'],
|
663
|
-
},
|
664
|
-
{
|
665
|
-
ext: 'docx',
|
666
|
-
titles: ['Incident Investigation Form', 'Safety Meeting Minutes', 'Hazard Report Template', 'Safe Work Procedure'],
|
667
|
-
},
|
668
|
-
{
|
669
|
-
ext: 'xlsx',
|
670
|
-
titles: ['Incident Statistics', 'Safety Training Matrix', 'PPE Inventory List', 'Risk Register'],
|
671
|
-
},
|
672
|
-
{
|
673
|
-
ext: 'jpg',
|
674
|
-
titles: ['Hazard Photo', 'Safety Signage', 'Emergency Exit Plan', 'PPE Requirements Chart'],
|
675
|
-
},
|
676
|
-
{
|
677
|
-
ext: 'png',
|
678
|
-
titles: ['Safety Infographic', 'Evacuation Map', 'Incident Scene Photo', 'Safety Procedure Diagram'],
|
679
|
-
},
|
680
|
-
{
|
681
|
-
ext: 'pptx',
|
682
|
-
titles: ['Safety Induction', 'WHS Training Module', 'Safety Committee Presentation', 'Toolbox Talk'],
|
683
|
-
},
|
684
|
-
];
|
685
|
-
const sites = ['Main Factory', 'Warehouse Complex', 'Office Building', 'Construction Site'];
|
686
|
-
const whsFolders = [
|
687
|
-
{
|
688
|
-
name: 'Policies and Procedures',
|
689
|
-
subFolders: ['Safety Policies', 'Standard Operating Procedures', 'Emergency Procedures', 'Work Instructions'],
|
690
|
-
commonFiles: [
|
691
|
-
'WHS Policy Manual.pdf',
|
692
|
-
'Emergency Response Plan.pdf',
|
693
|
-
'Safety Management System.docx',
|
694
|
-
'Risk Management Framework.pdf',
|
695
|
-
],
|
696
|
-
},
|
697
|
-
{
|
698
|
-
name: 'Risk Management',
|
699
|
-
subFolders: ['Risk Assessments', 'Hazard Reports', 'Control Measures', 'Safety Audits'],
|
700
|
-
commonFiles: [
|
701
|
-
'Risk Assessment Matrix.xlsx',
|
702
|
-
'Hazard Register.xlsx',
|
703
|
-
'Control Measure Checklist.pdf',
|
704
|
-
'Audit Schedule.xlsx',
|
705
|
-
],
|
706
|
-
},
|
707
|
-
{
|
708
|
-
name: 'Incident Management',
|
709
|
-
subFolders: ['Incident Reports', 'Investigations', 'Corrective Actions', 'Statistics'],
|
710
|
-
commonFiles: [
|
711
|
-
'Incident Report Form.docx',
|
712
|
-
'Investigation Guidelines.pdf',
|
713
|
-
'Corrective Action Register.xlsx',
|
714
|
-
'Monthly Statistics.xlsx',
|
715
|
-
],
|
716
|
-
},
|
717
|
-
{
|
718
|
-
name: 'Training and Compliance',
|
719
|
-
subFolders: ['Training Records', 'Certifications', 'Competency Assessments', 'Toolbox Talks'],
|
720
|
-
commonFiles: [
|
721
|
-
'Training Matrix.xlsx',
|
722
|
-
'Induction Package.pdf',
|
723
|
-
'Competency Framework.docx',
|
724
|
-
'Training Calendar.xlsx',
|
725
|
-
],
|
726
|
-
},
|
727
|
-
{
|
728
|
-
name: 'Safety Equipment',
|
729
|
-
subFolders: ['PPE Records', 'Equipment Inspections', 'Maintenance Records', 'Safety Data Sheets'],
|
730
|
-
commonFiles: [
|
731
|
-
'PPE Register.xlsx',
|
732
|
-
'Equipment Maintenance Schedule.xlsx',
|
733
|
-
'Safety Equipment Inventory.xlsx',
|
734
|
-
'PPE Guidelines.pdf',
|
735
|
-
],
|
736
|
-
},
|
737
|
-
];
|
738
|
-
sites.forEach((site) => {
|
739
|
-
const siteFolderId = AXPDataGenerator$1.uuid();
|
740
|
-
const siteFolder = {
|
741
|
-
id: siteFolderId,
|
742
|
-
name: site,
|
743
|
-
color: '#FFFFFF',
|
744
|
-
description: `WHS Documentation for ${site}`,
|
745
|
-
parentId: rootFolder.id,
|
746
|
-
isSystem: false,
|
747
|
-
isHidden: false,
|
748
|
-
isDeleted: false,
|
749
|
-
createdAt: new Date(),
|
750
|
-
updatedAt: new Date(),
|
751
|
-
createdBy: 'system',
|
752
|
-
updatedBy: 'system',
|
753
|
-
tenantId: site,
|
754
|
-
userId: undefined,
|
755
|
-
folders: [],
|
756
|
-
documents: [],
|
757
|
-
};
|
758
|
-
const safetyRoles = ['Safety Officer', 'Site Supervisor', 'WHS Representative'];
|
759
|
-
safetyRoles.forEach((role) => {
|
760
|
-
const roleFolderId = AXPDataGenerator$1.uuid();
|
761
|
-
const roleFolder = {
|
762
|
-
id: roleFolderId,
|
763
|
-
name: role,
|
764
|
-
color: '#FFFFFF',
|
765
|
-
description: `${role} Documentation`,
|
766
|
-
parentId: siteFolder.id,
|
767
|
-
isSystem: false,
|
768
|
-
isHidden: false,
|
769
|
-
isDeleted: false,
|
770
|
-
createdAt: new Date(),
|
771
|
-
updatedAt: new Date(),
|
772
|
-
createdBy: 'system',
|
773
|
-
updatedBy: 'system',
|
774
|
-
tenantId: site,
|
775
|
-
userId: role.toLowerCase().replace(/\s+/g, '_'),
|
776
|
-
folders: [],
|
777
|
-
documents: [],
|
778
|
-
};
|
779
|
-
sampleFileTypes.forEach((fileType) => {
|
780
|
-
fileType.titles.forEach((title) => {
|
781
|
-
if (Math.random() > 0.5) {
|
782
|
-
const file = {
|
783
|
-
id: AXPDataGenerator$1.uuid(),
|
784
|
-
name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
|
785
|
-
title: title,
|
786
|
-
parentId: roleFolderId,
|
787
|
-
};
|
788
|
-
allFiles.push(file);
|
789
|
-
roleFolder.documents?.push(file);
|
790
|
-
}
|
791
|
-
});
|
792
|
-
});
|
793
|
-
siteFolder.folders?.push(roleFolder);
|
794
|
-
allFolders.push(roleFolder);
|
795
|
-
});
|
796
|
-
whsFolders.forEach((dept) => {
|
797
|
-
const deptFolderId = AXPDataGenerator$1.uuid();
|
798
|
-
const deptFolder = {
|
799
|
-
id: deptFolderId,
|
800
|
-
name: dept.name,
|
801
|
-
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
802
|
-
description: `${dept.name} documentation`,
|
803
|
-
parentId: siteFolder.id,
|
804
|
-
isSystem: false,
|
805
|
-
isHidden: false,
|
806
|
-
isDeleted: false,
|
807
|
-
createdAt: new Date(),
|
808
|
-
updatedAt: new Date(),
|
809
|
-
createdBy: 'system',
|
810
|
-
updatedBy: 'system',
|
811
|
-
tenantId: site,
|
812
|
-
folders: [],
|
813
|
-
documents: [],
|
814
|
-
};
|
815
|
-
dept.commonFiles.forEach((fileName) => {
|
816
|
-
const file = {
|
817
|
-
id: AXPDataGenerator$1.uuid(),
|
818
|
-
name: fileName,
|
819
|
-
title: fileName.split('.')[0],
|
820
|
-
parentId: deptFolderId,
|
821
|
-
};
|
822
|
-
allFiles.push(file);
|
823
|
-
deptFolder.documents?.push(file);
|
824
|
-
});
|
825
|
-
dept.subFolders.forEach((subFolderName) => {
|
826
|
-
const subFolderId = AXPDataGenerator$1.uuid();
|
827
|
-
const subFolder = {
|
828
|
-
id: subFolderId,
|
829
|
-
name: subFolderName,
|
830
|
-
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
831
|
-
description: `${subFolderName} documentation`,
|
832
|
-
parentId: deptFolderId,
|
833
|
-
isSystem: false,
|
834
|
-
isHidden: false,
|
835
|
-
isDeleted: false,
|
836
|
-
createdAt: new Date(),
|
837
|
-
updatedAt: new Date(),
|
838
|
-
createdBy: 'system',
|
839
|
-
updatedBy: 'system',
|
840
|
-
tenantId: site,
|
841
|
-
folders: [],
|
842
|
-
documents: [],
|
843
|
-
};
|
844
|
-
sampleFileTypes.forEach((fileType) => {
|
845
|
-
fileType.titles.forEach((title) => {
|
846
|
-
if (Math.random() > 0.7) {
|
847
|
-
const file = {
|
848
|
-
id: AXPDataGenerator$1.uuid(),
|
849
|
-
name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
|
850
|
-
title: title,
|
851
|
-
parentId: subFolderId,
|
852
|
-
};
|
853
|
-
allFiles.push(file);
|
854
|
-
subFolder.documents?.push(file);
|
855
|
-
}
|
856
|
-
});
|
857
|
-
});
|
858
|
-
deptFolder.folders?.push(subFolder);
|
859
|
-
allFolders.push(subFolder);
|
860
|
-
});
|
861
|
-
siteFolder.folders?.push(deptFolder);
|
862
|
-
allFolders.push(deptFolder);
|
863
|
-
});
|
864
|
-
rootFolder.folders?.push(siteFolder);
|
865
|
-
allFolders.push(siteFolder);
|
866
|
-
});
|
867
|
-
allFolders.push(rootFolder);
|
868
|
-
const FOLDER_MOCK_DATA = allFolders;
|
869
|
-
const FILE_MOCK_DATA = allFiles;
|
870
|
-
|
871
|
-
class AXCFileDataSeeder {
|
872
|
-
constructor() {
|
873
|
-
this.storageService = inject(AXPDexieEntityStorageService);
|
874
|
-
}
|
875
|
-
async seed() {
|
876
|
-
await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.document.name}`, FILE_MOCK_DATA);
|
877
|
-
}
|
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 }); }
|
880
|
-
}
|
881
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFileDataSeeder, decorators: [{
|
882
|
-
type: Injectable
|
883
|
-
}] });
|
884
|
-
|
885
641
|
class AXMFolderMockService extends AXMFolderServiceImpl {
|
886
642
|
async updateParentFolders(folder) {
|
887
643
|
if (folder.parentId) {
|
@@ -951,10 +707,20 @@ class AXMFolderMockService extends AXMFolderServiceImpl {
|
|
951
707
|
}
|
952
708
|
return path.reverse();
|
953
709
|
}
|
710
|
+
async getOne(id) {
|
711
|
+
const folder = await super.getOne(id);
|
712
|
+
if (folder) {
|
713
|
+
folder.nodeCount = (folder.folders?.length ?? 0) + (folder.documents?.length ?? 0);
|
714
|
+
folder.folders?.forEach((f) => {
|
715
|
+
f.nodeCount = (f.folders?.length ?? 0) + (f.documents?.length ?? 0);
|
716
|
+
});
|
717
|
+
}
|
718
|
+
return folder;
|
719
|
+
}
|
954
720
|
/**
|
955
|
-
*
|
956
|
-
* @param searchTerm
|
957
|
-
* @param rootFolderId
|
721
|
+
* Search folders with specified name using recursive method
|
722
|
+
* @param searchTerm search term
|
723
|
+
* @param rootFolderId ID of the root folder to start the search
|
958
724
|
*/
|
959
725
|
async searchFolders(searchTerm, rootFolderId) {
|
960
726
|
const result = [];
|
@@ -962,26 +728,26 @@ class AXMFolderMockService extends AXMFolderServiceImpl {
|
|
962
728
|
return result;
|
963
729
|
}
|
964
730
|
/**
|
965
|
-
*
|
966
|
-
* @param searchTerm
|
967
|
-
* @param folderId
|
968
|
-
* @param result
|
731
|
+
* Recursive folder search
|
732
|
+
* @param searchTerm search term
|
733
|
+
* @param folderId current folder ID
|
734
|
+
* @param result results array
|
969
735
|
*/
|
970
736
|
async searchFoldersRecursive(searchTerm, folderId, result) {
|
971
737
|
try {
|
972
|
-
//
|
738
|
+
// Get current folder
|
973
739
|
const currentFolder = await this.getOne(folderId);
|
974
740
|
if (!currentFolder) {
|
975
741
|
return;
|
976
742
|
}
|
977
|
-
//
|
743
|
+
// Check subfolders
|
978
744
|
const subFolders = currentFolder.folders || [];
|
979
|
-
//
|
745
|
+
// Add folders that match the search term
|
980
746
|
for (const folder of subFolders) {
|
981
747
|
if (folder.name.toLowerCase().includes(searchTerm.toLowerCase())) {
|
982
748
|
result.push(folder);
|
983
749
|
}
|
984
|
-
//
|
750
|
+
// Recursive search in subfolders
|
985
751
|
if (folder.id) {
|
986
752
|
await this.searchFoldersRecursive(searchTerm, folder.id, result);
|
987
753
|
}
|
@@ -1103,12 +869,407 @@ class AXMFileMockService extends AXMDocumentServiceImpl {
|
|
1103
869
|
}
|
1104
870
|
}
|
1105
871
|
|
872
|
+
/**
|
873
|
+
* Document Management Mock Data Service Class
|
874
|
+
* Manages simulated data for document management folders and files
|
875
|
+
*/
|
876
|
+
class DocumentManagementMockDataService {
|
877
|
+
/**
|
878
|
+
*
|
879
|
+
*/
|
880
|
+
constructor(injector) {
|
881
|
+
this.injector = injector;
|
882
|
+
// Protected data
|
883
|
+
this._folders = [];
|
884
|
+
this._files = [];
|
885
|
+
this._initialized = false;
|
886
|
+
// Inject required services
|
887
|
+
this.http = this.injector.get(HttpClient);
|
888
|
+
this.fileStorage = this.injector.get(AXPFileStorageService);
|
889
|
+
}
|
890
|
+
/**
|
891
|
+
* Access to simulated folders
|
892
|
+
*/
|
893
|
+
get folders() {
|
894
|
+
return this._folders;
|
895
|
+
}
|
896
|
+
/**
|
897
|
+
* Access to simulated files
|
898
|
+
*/
|
899
|
+
get files() {
|
900
|
+
return this._files;
|
901
|
+
}
|
902
|
+
/**
|
903
|
+
* Check initialization status
|
904
|
+
*/
|
905
|
+
get isInitialized() {
|
906
|
+
return this._initialized;
|
907
|
+
}
|
908
|
+
/**
|
909
|
+
* Initialize mock data without parameters
|
910
|
+
* Uses dependency injection for services
|
911
|
+
*/
|
912
|
+
async initialize() {
|
913
|
+
if (this._initialized) {
|
914
|
+
return;
|
915
|
+
}
|
916
|
+
const { folders, files } = await this.createMockData();
|
917
|
+
// Clear previous data
|
918
|
+
this._folders.length = 0;
|
919
|
+
this._files.length = 0;
|
920
|
+
// Add new data
|
921
|
+
this._folders.push(...folders);
|
922
|
+
this._files.push(...files);
|
923
|
+
this._initialized = true;
|
924
|
+
}
|
925
|
+
/**
|
926
|
+
* Fetch file as Blob
|
927
|
+
*/
|
928
|
+
async fetchFileAsBlob(fileName, type) {
|
929
|
+
try {
|
930
|
+
// Use window.location.origin to get the base URL of the application
|
931
|
+
const baseUrl = window.location.origin;
|
932
|
+
const subPath = type === 'image' ? 'image' : 'pdf';
|
933
|
+
const url = `${baseUrl}/assets/temp/${subPath}/${fileName}`;
|
934
|
+
const response = await firstValueFrom(this.http.get(url, { responseType: 'blob' }));
|
935
|
+
const blob = new Blob([response], { type: type === 'image' ? 'image/jpeg' : 'application/pdf' });
|
936
|
+
const file = new File([blob], fileName, { type: blob.type });
|
937
|
+
return file;
|
938
|
+
}
|
939
|
+
catch (error) {
|
940
|
+
console.error(`Error fetching file ${fileName}:`, error);
|
941
|
+
throw error;
|
942
|
+
}
|
943
|
+
}
|
944
|
+
/**
|
945
|
+
* Create mock data
|
946
|
+
*/
|
947
|
+
async createMockData() {
|
948
|
+
const allFolders = [];
|
949
|
+
const allFiles = [];
|
950
|
+
const rootFolder = {
|
951
|
+
id: AXPDataGenerator$1.uuid(),
|
952
|
+
name: 'WHS Documentation',
|
953
|
+
color: '#FFFFFF',
|
954
|
+
description: 'Root folder for WHS/OHS Documentation',
|
955
|
+
parentId: undefined,
|
956
|
+
isSystem: true,
|
957
|
+
isHidden: false,
|
958
|
+
isDeleted: false,
|
959
|
+
createdAt: new Date(),
|
960
|
+
updatedAt: new Date(),
|
961
|
+
createdBy: 'system',
|
962
|
+
updatedBy: 'system',
|
963
|
+
folders: [],
|
964
|
+
documents: [],
|
965
|
+
};
|
966
|
+
// Sites
|
967
|
+
const sites = ['Main Factory', 'Warehouse Complex', 'Office Building', 'Construction Site'];
|
968
|
+
// Sample file types with WHS/OHS specific examples
|
969
|
+
const sampleFileTypes = [
|
970
|
+
{
|
971
|
+
ext: 'pdf',
|
972
|
+
titles: [
|
973
|
+
'Risk Assessment Report',
|
974
|
+
'Safety Audit Checklist',
|
975
|
+
'Emergency Response Plan',
|
976
|
+
'Safety Training Manual',
|
977
|
+
],
|
978
|
+
},
|
979
|
+
{
|
980
|
+
ext: 'docx',
|
981
|
+
titles: [
|
982
|
+
'Incident Investigation Form',
|
983
|
+
'Safety Meeting Minutes',
|
984
|
+
'Hazard Report Template',
|
985
|
+
'Safe Work Procedure',
|
986
|
+
],
|
987
|
+
},
|
988
|
+
{
|
989
|
+
ext: 'xlsx',
|
990
|
+
titles: ['Incident Statistics', 'Safety Training Matrix', 'PPE Inventory List', 'Risk Register'],
|
991
|
+
},
|
992
|
+
{
|
993
|
+
ext: 'jpg',
|
994
|
+
titles: ['Hazard Photo', 'Safety Signage', 'Emergency Exit Plan', 'PPE Requirements Chart'],
|
995
|
+
},
|
996
|
+
{
|
997
|
+
ext: 'png',
|
998
|
+
titles: ['Safety Infographic', 'Evacuation Map', 'Incident Scene Photo', 'Safety Procedure Diagram'],
|
999
|
+
},
|
1000
|
+
{
|
1001
|
+
ext: 'pptx',
|
1002
|
+
titles: ['Safety Induction', 'WHS Training Module', 'Safety Committee Presentation', 'Toolbox Talk'],
|
1003
|
+
},
|
1004
|
+
];
|
1005
|
+
// WHS folders
|
1006
|
+
const whsFolders = [
|
1007
|
+
{
|
1008
|
+
name: 'Policies and Procedures',
|
1009
|
+
subFolders: ['Safety Policies', 'Standard Operating Procedures', 'Emergency Procedures', 'Work Instructions'],
|
1010
|
+
commonFiles: [
|
1011
|
+
'WHS Policy Manual.pdf',
|
1012
|
+
'Emergency Response Plan.pdf',
|
1013
|
+
'Safety Management System.docx',
|
1014
|
+
'Risk Management Framework.pdf',
|
1015
|
+
],
|
1016
|
+
},
|
1017
|
+
{
|
1018
|
+
name: 'Risk Management',
|
1019
|
+
subFolders: ['Risk Assessments', 'Hazard Reports', 'Control Measures', 'Safety Audits'],
|
1020
|
+
commonFiles: [
|
1021
|
+
'Risk Assessment Matrix.xlsx',
|
1022
|
+
'Hazard Register.xlsx',
|
1023
|
+
'Control Measure Checklist.pdf',
|
1024
|
+
'Audit Schedule.xlsx',
|
1025
|
+
],
|
1026
|
+
},
|
1027
|
+
{
|
1028
|
+
name: 'Incident Management',
|
1029
|
+
subFolders: ['Incident Reports', 'Investigations', 'Corrective Actions', 'Statistics'],
|
1030
|
+
commonFiles: [
|
1031
|
+
'Incident Report Form.docx',
|
1032
|
+
'Investigation Guidelines.pdf',
|
1033
|
+
'Corrective Action Register.xlsx',
|
1034
|
+
'Monthly Statistics.xlsx',
|
1035
|
+
],
|
1036
|
+
},
|
1037
|
+
{
|
1038
|
+
name: 'Training and Compliance',
|
1039
|
+
subFolders: ['Training Records', 'Certifications', 'Competency Assessments', 'Toolbox Talks'],
|
1040
|
+
commonFiles: [
|
1041
|
+
'Training Matrix.xlsx',
|
1042
|
+
'Induction Package.pdf',
|
1043
|
+
'Competency Framework.docx',
|
1044
|
+
'Training Calendar.xlsx',
|
1045
|
+
],
|
1046
|
+
},
|
1047
|
+
{
|
1048
|
+
name: 'Safety Equipment',
|
1049
|
+
subFolders: ['PPE Records', 'Equipment Inspections', 'Maintenance Records', 'Safety Data Sheets'],
|
1050
|
+
commonFiles: [
|
1051
|
+
'PPE Register.xlsx',
|
1052
|
+
'Equipment Maintenance Schedule.xlsx',
|
1053
|
+
'Safety Equipment Inventory.xlsx',
|
1054
|
+
'PPE Guidelines.pdf',
|
1055
|
+
],
|
1056
|
+
},
|
1057
|
+
];
|
1058
|
+
// Available real assets
|
1059
|
+
const REAL_IMAGES = ['1.jpg', '2.jpg', '3.jpg', '4.jpg'];
|
1060
|
+
const REAL_PDFS = ['1.pdf'];
|
1061
|
+
// Helper function to get random file name
|
1062
|
+
const getRandomImageName = () => {
|
1063
|
+
return REAL_IMAGES[Math.floor(Math.random() * REAL_IMAGES.length)];
|
1064
|
+
};
|
1065
|
+
const getRandomPdfName = () => {
|
1066
|
+
return REAL_PDFS[Math.floor(Math.random() * REAL_PDFS.length)];
|
1067
|
+
};
|
1068
|
+
for await (const site of sites) {
|
1069
|
+
const siteFolderId = AXPDataGenerator$1.uuid();
|
1070
|
+
const siteFolder = {
|
1071
|
+
id: siteFolderId,
|
1072
|
+
name: site,
|
1073
|
+
color: '#FFFFFF',
|
1074
|
+
description: `WHS Documentation for ${site}`,
|
1075
|
+
parentId: rootFolder.id,
|
1076
|
+
isSystem: false,
|
1077
|
+
isHidden: false,
|
1078
|
+
isDeleted: false,
|
1079
|
+
createdAt: new Date(),
|
1080
|
+
updatedAt: new Date(),
|
1081
|
+
createdBy: 'system',
|
1082
|
+
updatedBy: 'system',
|
1083
|
+
tenantId: site,
|
1084
|
+
userId: undefined,
|
1085
|
+
folders: [],
|
1086
|
+
documents: [],
|
1087
|
+
};
|
1088
|
+
try {
|
1089
|
+
// Add image document
|
1090
|
+
const imageName = getRandomImageName();
|
1091
|
+
const imageFile = await this.fetchFileAsBlob(imageName, 'image');
|
1092
|
+
const imageInfo = await this.fileStorage.save({
|
1093
|
+
category: 'site-images',
|
1094
|
+
file: imageFile,
|
1095
|
+
refId: siteFolderId,
|
1096
|
+
refType: 'site-folder',
|
1097
|
+
isPrimary: true,
|
1098
|
+
status: AXPFileStorageStatus.Committed,
|
1099
|
+
});
|
1100
|
+
const docImage = {
|
1101
|
+
id: AXPDataGenerator$1.uuid(),
|
1102
|
+
name: imageName,
|
1103
|
+
title: 'Site Overview',
|
1104
|
+
parentId: siteFolderId,
|
1105
|
+
fileId: imageInfo.fileId,
|
1106
|
+
meta: {
|
1107
|
+
type: 'image',
|
1108
|
+
size: imageFile.size,
|
1109
|
+
uploadedAt: imageInfo.uploadedAt,
|
1110
|
+
},
|
1111
|
+
};
|
1112
|
+
siteFolder.documents?.push(docImage);
|
1113
|
+
allFiles.push(docImage);
|
1114
|
+
// Add PDF document
|
1115
|
+
const pdfName = getRandomPdfName();
|
1116
|
+
const pdfFile = await this.fetchFileAsBlob(pdfName, 'pdf');
|
1117
|
+
const pdfInfo = await this.fileStorage.save({
|
1118
|
+
category: 'site-documents',
|
1119
|
+
file: pdfFile,
|
1120
|
+
refId: siteFolderId,
|
1121
|
+
refType: 'site-folder',
|
1122
|
+
isPrimary: false,
|
1123
|
+
status: AXPFileStorageStatus.Committed,
|
1124
|
+
});
|
1125
|
+
const doc = {
|
1126
|
+
id: AXPDataGenerator$1.uuid(),
|
1127
|
+
name: pdfName,
|
1128
|
+
title: 'Site Documentation',
|
1129
|
+
parentId: siteFolderId,
|
1130
|
+
fileId: pdfInfo.fileId,
|
1131
|
+
meta: {
|
1132
|
+
type: 'pdf',
|
1133
|
+
size: pdfFile.size,
|
1134
|
+
uploadedAt: pdfInfo.uploadedAt,
|
1135
|
+
},
|
1136
|
+
};
|
1137
|
+
siteFolder.documents?.push(doc);
|
1138
|
+
allFiles.push(doc);
|
1139
|
+
}
|
1140
|
+
catch (error) {
|
1141
|
+
console.error(`Error processing files for site ${site}:`, error);
|
1142
|
+
// Continue with next site even if current one fails
|
1143
|
+
continue;
|
1144
|
+
}
|
1145
|
+
const safetyRoles = ['Safety Officer', 'Site Supervisor', 'WHS Representative'];
|
1146
|
+
safetyRoles.forEach((role) => {
|
1147
|
+
const roleFolderId = AXPDataGenerator$1.uuid();
|
1148
|
+
const roleFolder = {
|
1149
|
+
id: roleFolderId,
|
1150
|
+
name: role,
|
1151
|
+
color: '#FFFFFF',
|
1152
|
+
description: `${role} Documentation`,
|
1153
|
+
parentId: siteFolder.id,
|
1154
|
+
isSystem: false,
|
1155
|
+
isHidden: false,
|
1156
|
+
isDeleted: false,
|
1157
|
+
createdAt: new Date(),
|
1158
|
+
updatedAt: new Date(),
|
1159
|
+
createdBy: 'system',
|
1160
|
+
updatedBy: 'system',
|
1161
|
+
tenantId: site,
|
1162
|
+
userId: role.toLowerCase().replace(/\s+/g, '_'),
|
1163
|
+
folders: [],
|
1164
|
+
documents: [],
|
1165
|
+
};
|
1166
|
+
// sampleFileTypes.forEach((fileType) => {
|
1167
|
+
// fileType.titles.forEach((title) => {
|
1168
|
+
// if (Math.random() > 0.5) {
|
1169
|
+
// const file: AXMDocumentManagementDocumentEntityModel = {
|
1170
|
+
// id: AXPDataGenerator.uuid(),
|
1171
|
+
// name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
|
1172
|
+
// title: title,
|
1173
|
+
// parentId: roleFolderId,
|
1174
|
+
// };
|
1175
|
+
// allFiles.push(file);
|
1176
|
+
// roleFolder.documents?.push(file);
|
1177
|
+
// }
|
1178
|
+
// });
|
1179
|
+
// });
|
1180
|
+
siteFolder.folders?.push(roleFolder);
|
1181
|
+
allFolders.push(roleFolder);
|
1182
|
+
});
|
1183
|
+
whsFolders.forEach((dept) => {
|
1184
|
+
const deptFolderId = AXPDataGenerator$1.uuid();
|
1185
|
+
const deptFolder = {
|
1186
|
+
id: deptFolderId,
|
1187
|
+
name: dept.name,
|
1188
|
+
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
1189
|
+
description: `${dept.name} documentation`,
|
1190
|
+
parentId: siteFolder.id,
|
1191
|
+
isSystem: false,
|
1192
|
+
isHidden: false,
|
1193
|
+
isDeleted: false,
|
1194
|
+
createdAt: new Date(),
|
1195
|
+
updatedAt: new Date(),
|
1196
|
+
createdBy: 'system',
|
1197
|
+
updatedBy: 'system',
|
1198
|
+
tenantId: site,
|
1199
|
+
folders: [],
|
1200
|
+
documents: [],
|
1201
|
+
};
|
1202
|
+
// dept.commonFiles.forEach((fileName) => {
|
1203
|
+
// const file: AXMDocumentManagementDocumentEntityModel = {
|
1204
|
+
// id: AXPDataGenerator.uuid(),
|
1205
|
+
// name: fileName,
|
1206
|
+
// title: fileName.split('.')[0],
|
1207
|
+
// parentId: deptFolderId,
|
1208
|
+
// };
|
1209
|
+
// allFiles.push(file);
|
1210
|
+
// deptFolder.documents?.push(file);
|
1211
|
+
// });
|
1212
|
+
dept.subFolders.forEach((subFolderName) => {
|
1213
|
+
const subFolderId = AXPDataGenerator$1.uuid();
|
1214
|
+
const subFolder = {
|
1215
|
+
id: subFolderId,
|
1216
|
+
name: subFolderName,
|
1217
|
+
color: '#' + Math.floor(Math.random() * 16777215).toString(16),
|
1218
|
+
description: `${subFolderName} documentation`,
|
1219
|
+
parentId: deptFolderId,
|
1220
|
+
isSystem: false,
|
1221
|
+
isHidden: false,
|
1222
|
+
isDeleted: false,
|
1223
|
+
createdAt: new Date(),
|
1224
|
+
updatedAt: new Date(),
|
1225
|
+
createdBy: 'system',
|
1226
|
+
updatedBy: 'system',
|
1227
|
+
tenantId: site,
|
1228
|
+
folders: [],
|
1229
|
+
documents: [],
|
1230
|
+
};
|
1231
|
+
// sampleFileTypes.forEach((fileType) => {
|
1232
|
+
// fileType.titles.forEach((title) => {
|
1233
|
+
// if (Math.random() > 0.7) {
|
1234
|
+
// const file: AXMDocumentManagementDocumentEntityModel = {
|
1235
|
+
// id: AXPDataGenerator.uuid(),
|
1236
|
+
// name: `${title.toLowerCase().replace(/\s+/g, '-')}.${fileType.ext}`,
|
1237
|
+
// title: title,
|
1238
|
+
// parentId: subFolderId,
|
1239
|
+
// };
|
1240
|
+
// allFiles.push(file);
|
1241
|
+
// subFolder.documents?.push(file);
|
1242
|
+
// }
|
1243
|
+
// });
|
1244
|
+
// });
|
1245
|
+
deptFolder.folders?.push(subFolder);
|
1246
|
+
allFolders.push(subFolder);
|
1247
|
+
});
|
1248
|
+
siteFolder.folders?.push(deptFolder);
|
1249
|
+
allFolders.push(deptFolder);
|
1250
|
+
});
|
1251
|
+
rootFolder.folders?.push(siteFolder);
|
1252
|
+
allFolders.push(siteFolder);
|
1253
|
+
}
|
1254
|
+
rootFolder.folders?.push(rootFolder);
|
1255
|
+
allFolders.push(rootFolder);
|
1256
|
+
return { folders: allFolders, files: allFiles };
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
|
1106
1260
|
class AXCFolderDataSeeder {
|
1107
1261
|
constructor() {
|
1108
1262
|
this.storageService = inject(AXPDexieEntityStorageService);
|
1263
|
+
this.injector = inject(Injector);
|
1109
1264
|
}
|
1110
1265
|
async seed() {
|
1111
|
-
await this.storageService.
|
1266
|
+
const folders = await this.storageService.getAll(`${RootConfig.module.name}.${RootConfig.entities.folder.name}`);
|
1267
|
+
if (folders.length === 0) {
|
1268
|
+
const doc = new DocumentManagementMockDataService(this.injector);
|
1269
|
+
await doc.initialize();
|
1270
|
+
await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.folder.name}`, doc.folders);
|
1271
|
+
await this.storageService.initial(`${RootConfig.module.name}.${RootConfig.entities.document.name}`, doc.files);
|
1272
|
+
}
|
1112
1273
|
}
|
1113
1274
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
1114
1275
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.3", ngImport: i0, type: AXCFolderDataSeeder }); }
|
@@ -2528,9 +2689,9 @@ class AXCFileStorageService {
|
|
2528
2689
|
size: request.file.size,
|
2529
2690
|
mimeType: request.file.type,
|
2530
2691
|
uploadedAt: new Date(),
|
2531
|
-
isPublic: request.metadata?.[
|
2692
|
+
isPublic: request.metadata?.['isPublic'] || true,
|
2532
2693
|
isPrimary: request.isPrimary || false,
|
2533
|
-
status: AXPFileStorageStatus.Temporary, // Use enum
|
2694
|
+
status: request.status ?? AXPFileStorageStatus.Temporary, // Use enum
|
2534
2695
|
};
|
2535
2696
|
// Save the binary content along with metadata in Dexie
|
2536
2697
|
await db.files.add({ ...fileInfo, binary: request.file });
|
@@ -2575,8 +2736,7 @@ class AXCFileStorageService {
|
|
2575
2736
|
(!request.isPublic || file.isPublic === request.isPublic) &&
|
2576
2737
|
(!request.mimeType || file.mimeType === request.mimeType) &&
|
2577
2738
|
(!request.uploadedAtRange ||
|
2578
|
-
(file.uploadedAt >= request.uploadedAtRange.from &&
|
2579
|
-
file.uploadedAt <= request.uploadedAtRange.to)) &&
|
2739
|
+
(file.uploadedAt >= request.uploadedAtRange.from && file.uploadedAt <= request.uploadedAtRange.to)) &&
|
2580
2740
|
file.status === AXPFileStorageStatus.Committed // Use enum
|
2581
2741
|
);
|
2582
2742
|
});
|
@@ -3264,11 +3424,6 @@ class AXCMockModule {
|
|
3264
3424
|
useClass: AXCDocumentTypeDataSeeder,
|
3265
3425
|
multi: true,
|
3266
3426
|
},
|
3267
|
-
{
|
3268
|
-
provide: AXP_DATA_SEEDER_TOKEN,
|
3269
|
-
useClass: AXCFileDataSeeder,
|
3270
|
-
multi: true,
|
3271
|
-
},
|
3272
3427
|
{
|
3273
3428
|
provide: AXPModuleDesignerService,
|
3274
3429
|
useClass: AXCModuleDesignerService,
|
@@ -3386,11 +3541,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.3", ngImpor
|
|
3386
3541
|
useClass: AXCDocumentTypeDataSeeder,
|
3387
3542
|
multi: true,
|
3388
3543
|
},
|
3389
|
-
{
|
3390
|
-
provide: AXP_DATA_SEEDER_TOKEN,
|
3391
|
-
useClass: AXCFileDataSeeder,
|
3392
|
-
multi: true,
|
3393
|
-
},
|
3394
3544
|
{
|
3395
3545
|
provide: AXPModuleDesignerService,
|
3396
3546
|
useClass: AXCModuleDesignerService,
|