@genesislcap/pbc-documents-ui 0.0.1 → 0.0.2

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 (29) hide show
  1. package/package.json +3 -3
  2. package/src/components/components.ts +0 -49
  3. package/src/components/foundation-document-manager/component/document-grid/column-config.ts +0 -108
  4. package/src/components/foundation-document-manager/component/document-grid/document-grid.styles.ts +0 -10
  5. package/src/components/foundation-document-manager/component/document-grid/document-grid.template.ts +0 -14
  6. package/src/components/foundation-document-manager/component/document-grid/document-grid.ts +0 -39
  7. package/src/components/foundation-document-manager/component/document-tile/document-tile.styles.ts +0 -137
  8. package/src/components/foundation-document-manager/component/document-tile/document-tile.template.ts +0 -71
  9. package/src/components/foundation-document-manager/component/document-tile/document-tile.ts +0 -119
  10. package/src/components/foundation-document-manager/component/document-upload/document-upload.styles.ts +0 -157
  11. package/src/components/foundation-document-manager/component/document-upload/document-upload.template.ts +0 -82
  12. package/src/components/foundation-document-manager/component/document-upload/document-upload.ts +0 -146
  13. package/src/components/foundation-document-manager/document-manager.styles.ts +0 -245
  14. package/src/components/foundation-document-manager/document-manager.template.ts +0 -111
  15. package/src/components/foundation-document-manager/document-manager.ts +0 -128
  16. package/src/components/foundation-document-manager/index.ts +0 -1
  17. package/src/components/foundation-document-manager/utils/action-cell-renderer.ts +0 -55
  18. package/src/components/foundation-document-manager/utils/file-type-cell-renderer.ts +0 -33
  19. package/src/components/foundation-document-manager/utils/icons.ts +0 -251
  20. package/src/components/index.ts +0 -1
  21. package/src/index.federated.ts +0 -1
  22. package/src/index.ts +0 -3
  23. package/src/services/document.service.ts +0 -83
  24. package/src/utils/dataserver.ts +0 -42
  25. package/src/utils/endpoint.ts +0 -19
  26. package/src/utils/formatting.ts +0 -59
  27. package/src/utils/index.ts +0 -1
  28. package/src/utils/logger.ts +0 -2
  29. package/src/utils/types.ts +0 -11
@@ -1,83 +0,0 @@
1
- import { DI } from '@microsoft/fast-foundation';
2
- import { Auth, Connect, Message, SocketObservable } from '@genesislcap/foundation-comms';
3
- import { getEndpointUrl } from '../utils/endpoint';
4
- import { logger } from '../utils';
5
-
6
- export interface IDocumentService {
7
- streamDocuments(): SocketObservable<Message<any>>;
8
- uploadDocument(file: File): Promise<any>;
9
- downloadDocument(documentId: string);
10
- }
11
-
12
- class DocumentServiceImpl implements IDocumentService {
13
- constructor(
14
- @Connect private connect: Connect,
15
- @Auth private auth: Auth,
16
- ) {}
17
-
18
- public streamDocuments(): SocketObservable<Message<any>> {
19
- return this.connect.stream(
20
- 'ALL_FILE_STORAGES',
21
- (streamMessage: Message) => {
22
- () => {};
23
- },
24
- (x) => {},
25
- );
26
- }
27
-
28
- async uploadDocument(file: File): Promise<any> {
29
- if (!file) {
30
- logger.error('No file provided.');
31
- return;
32
- }
33
-
34
- const headers = new Headers();
35
- headers.append('SESSION_AUTH_TOKEN', this.auth.loggedUserResult.authToken);
36
- const formData = new FormData();
37
- formData.append(file.name, file);
38
-
39
- const endpoint = getEndpointUrl('file-server/upload/');
40
- const response = await fetch(endpoint, {
41
- method: 'POST',
42
- body: formData,
43
- headers: headers,
44
- });
45
-
46
- return response.json();
47
- }
48
-
49
- downloadDocument(documentId: string) {
50
- const headers = new Headers();
51
- headers.append('SESSION_AUTH_TOKEN', sessionStorage.getItem('authToken'));
52
-
53
- const endpoint = getEndpointUrl(`file-server/download?fileStorageId=${documentId}`);
54
-
55
- let filename = '';
56
- fetch(endpoint, {
57
- method: 'GET',
58
- headers: headers,
59
- })
60
- .then((response) => {
61
- const contentDispositionHeader = response.headers.get('Content-disposition');
62
- filename = contentDispositionHeader.split(';')[1].split('filename')[1].split('=')[1].trim();
63
- return response.blob();
64
- })
65
- .then((blob) => URL.createObjectURL(blob))
66
- .then((url) => {
67
- const a = document.createElement('a');
68
- a.style.display = 'none';
69
- a.href = url;
70
- a.download = filename;
71
- document.body.appendChild(a);
72
- a.click();
73
- window.URL.revokeObjectURL(url);
74
- })
75
- .catch((err) => {
76
- logger.error(err);
77
- });
78
- }
79
- }
80
-
81
- export const IDocumentService = DI.createInterface<IDocumentService>((x) =>
82
- x.singleton(DocumentServiceImpl),
83
- );
@@ -1,42 +0,0 @@
1
- export function updateArray(
2
- newData: Array<any>,
3
- oldData: Array<any>,
4
- newDataAtEnd: boolean = false,
5
- ): Array<any> {
6
- if (newData && oldData && oldData.length > 0) {
7
- newData.forEach((row) => {
8
- const eventData = row;
9
-
10
- if (eventData && eventData.DETAILS) {
11
- const ref = eventData.DETAILS.ROW_REF;
12
- const type = eventData.DETAILS.OPERATION;
13
-
14
- if (type === 'INSERT') {
15
- if (!oldData.find((x) => x.DETAILS?.ROW_REF === ref)) {
16
- if (newDataAtEnd) {
17
- oldData.push(eventData);
18
- } else {
19
- oldData.unshift(eventData);
20
- }
21
- }
22
- }
23
-
24
- if (type === 'DELETE') {
25
- const index = oldData.findIndex((x) => row.DETAILS?.ROW_REF === x.DETAILS?.ROW_REF);
26
- if (index != undefined) {
27
- oldData.splice(index, 1);
28
- }
29
- }
30
-
31
- if (type === 'MODIFY') {
32
- oldData = oldData.map((item: any) =>
33
- item.DETAILS?.ROW_REF === ref ? { ...item, ...eventData } : item,
34
- );
35
- }
36
- }
37
- });
38
- } else if (newData && (!oldData || oldData.length === 0)) {
39
- oldData = [...new Set(newData)] as any[];
40
- }
41
- return oldData;
42
- }
@@ -1,19 +0,0 @@
1
- export const getEndpointUrl = (endpoint: string): string => {
2
- let urlRoot = sessionStorage.getItem('hostUrl');
3
-
4
- if (urlRoot.startsWith('https')) {
5
- urlRoot = urlRoot.substring(5);
6
- } else if (urlRoot.startsWith('ws:')) {
7
- urlRoot = urlRoot.substring(3);
8
- } else if (urlRoot.startsWith('wss:')) {
9
- urlRoot = urlRoot.substring(4);
10
- } else {
11
- urlRoot = urlRoot.substring(4);
12
- }
13
-
14
- if (urlRoot.includes('localhost')) {
15
- return 'http:' + urlRoot + endpoint;
16
- } else {
17
- return 'https:' + urlRoot + endpoint;
18
- }
19
- };
@@ -1,59 +0,0 @@
1
- /**
2
- * Number formatter, can be used directly on ag-grid columns as valueFormatter.
3
- *
4
- * @param minDP min decimal points
5
- * @param maxDP max decimal points
6
- */
7
- export function formatNumber(minDP = 2, maxDP = minDP) {
8
- return (params) => {
9
- if (!(params && typeof params.value === 'number')) return '';
10
- const lang = (navigator && navigator.language) || 'en-GB';
11
- return Intl.NumberFormat(lang, {
12
- minimumFractionDigits: minDP,
13
- maximumFractionDigits: maxDP,
14
- }).format(params.value);
15
- };
16
- }
17
-
18
- export const formatDateLong = (param: number): string => {
19
- if (!(param && typeof param === 'number' && param > 0)) return '';
20
- const date = new Date(param);
21
-
22
- const formattedDate = new Intl.DateTimeFormat(Intl.DateTimeFormat().resolvedOptions().locale, {
23
- year: 'numeric',
24
- month: 'short',
25
- day: '2-digit',
26
- }).format(date);
27
- return formattedDate;
28
- };
29
-
30
- export const getFileType = (fileName: string): string => {
31
- const typeIndex = fileName.lastIndexOf('.');
32
- return fileName.substring(typeIndex + 1).toUpperCase();
33
- };
34
-
35
- export const getFileColor = (fileType: string): string => {
36
- switch (fileType) {
37
- case 'CSV':
38
- return '#63a103';
39
- case 'JPG':
40
- case 'PNG':
41
- return '#8a98f5';
42
- case 'PDF':
43
- return '#f9644d';
44
- default:
45
- return '#ffffff';
46
- }
47
- };
48
-
49
- export const formatBytes = (bytes, decimals = 2): string => {
50
- if (!+bytes) return '0 Bytes';
51
-
52
- const k = 1000;
53
- const dm = decimals < 0 ? 0 : decimals;
54
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
55
-
56
- const i = Math.floor(Math.log(bytes) / Math.log(k));
57
-
58
- return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
59
- };
@@ -1 +0,0 @@
1
- export * from './logger';
@@ -1,2 +0,0 @@
1
- import { createLogger } from '@genesislcap/foundation-logger';
2
- export const logger = createLogger('genesis-file-server');
@@ -1,11 +0,0 @@
1
- export interface IFileStorage {
2
- FILE_STORAGE_ID: string;
3
- STORAGE_MANAGER: string;
4
- FILE_NAME: string;
5
- FILE_SIZE: number;
6
- MODIFIED_AT: number;
7
- MODIFIED_BY: string;
8
- CREATED_BY: string;
9
- CREATED_AT: number;
10
- LOCATION_DETAILS: string;
11
- }