@genesislcap/pbc-documents-ui 15.19.0 → 15.19.1-FUI-2610.1
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/package.json +26 -27
- package/dist/dts/services/document.service.test.d.ts +0 -2
- package/dist/dts/services/document.service.test.d.ts.map +0 -1
- package/dist/esm/services/document.service.test.js +0 -50
- package/dist/esm/services/document.service.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/components/document-upload/document-upload.styles.ts +0 -183
- package/src/components/document-upload/document-upload.template.ts +0 -122
- package/src/components/document-upload/document-upload.ts +0 -190
- package/src/components/document-upload/document-upload.types.ts +0 -6
- package/src/components/rapid-components.ts +0 -70
- package/src/components/template-asset-link/template-asset-link.styles.ts +0 -42
- package/src/components/template-asset-link/template-asset-link.template.ts +0 -41
- package/src/components/template-asset-link/template-asset-link.ts +0 -109
- package/src/components/utils/action-cell-renderer.ts +0 -58
- package/src/components/utils/column-config.ts +0 -188
- package/src/components/utils/icons.ts +0 -149
- package/src/components/zero-components.ts +0 -57
- package/src/config/config.ts +0 -49
- package/src/config/configure.ts +0 -67
- package/src/config/index.ts +0 -2
- package/src/config/templates.ts +0 -58
- package/src/globals.d.ts +0 -7
- package/src/index.federated.ts +0 -1
- package/src/index.ts +0 -3
- package/src/main/index.ts +0 -4
- package/src/main/main.styles.ts +0 -187
- package/src/main/main.template.ts +0 -93
- package/src/main/main.ts +0 -560
- package/src/sandbox.ts +0 -42
- package/src/services/document.service.test.ts +0 -87
- package/src/services/document.service.ts +0 -150
- package/src/tags/index.ts +0 -1
- package/src/tags/tags.ts +0 -79
- package/src/types/index.ts +0 -2
- package/src/types/main.types.ts +0 -100
- package/src/types/utils.types.ts +0 -7
- package/src/typings.d.ts +0 -1
- package/src/utils/formatting.ts +0 -55
- package/src/utils/index.ts +0 -4
- package/src/utils/logger.ts +0 -3
- package/src/utils/misc.ts +0 -11
- package/src/utils/notifications.ts +0 -9
- package/src/utils/styles.ts +0 -28
- package/tsconfig.json +0 -29
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/pbc-documents-ui",
|
|
3
3
|
"description": "Genesis Document Management UI",
|
|
4
|
-
"version": "15.19.
|
|
4
|
+
"version": "15.19.1-FUI-2610.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -76,42 +76,41 @@
|
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@genesislcap/design-system-configurator": "15.19.
|
|
80
|
-
"@genesislcap/eslint-config": "15.19.
|
|
81
|
-
"@genesislcap/foundation-testing": "15.19.
|
|
82
|
-
"@genesislcap/genx": "15.19.
|
|
83
|
-
"@genesislcap/prettier-config": "15.19.
|
|
84
|
-
"@genesislcap/stylelint-config": "15.19.
|
|
79
|
+
"@genesislcap/design-system-configurator": "15.19.1-FUI-2610.1",
|
|
80
|
+
"@genesislcap/eslint-config": "15.19.1-FUI-2610.1",
|
|
81
|
+
"@genesislcap/foundation-testing": "15.19.1-FUI-2610.1",
|
|
82
|
+
"@genesislcap/genx": "15.19.1-FUI-2610.1",
|
|
83
|
+
"@genesislcap/prettier-config": "15.19.1-FUI-2610.1",
|
|
84
|
+
"@genesislcap/stylelint-config": "15.19.1-FUI-2610.1",
|
|
85
85
|
"@types/node": "^22.10.2",
|
|
86
86
|
"rimraf": "^3.0.2",
|
|
87
87
|
"tslib": "^2.3.1",
|
|
88
88
|
"typescript": "^4.9.5"
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
|
-
"@genesislcap/foundation-comms": "15.19.
|
|
92
|
-
"@genesislcap/foundation-entity-management": "15.19.
|
|
93
|
-
"@genesislcap/foundation-events": "15.19.
|
|
94
|
-
"@genesislcap/foundation-forms": "15.19.
|
|
95
|
-
"@genesislcap/foundation-header": "15.19.
|
|
96
|
-
"@genesislcap/foundation-layout": "15.19.
|
|
97
|
-
"@genesislcap/foundation-logger": "15.19.
|
|
98
|
-
"@genesislcap/foundation-notifications": "15.19.
|
|
99
|
-
"@genesislcap/foundation-store": "15.19.
|
|
100
|
-
"@genesislcap/foundation-ui": "15.19.
|
|
101
|
-
"@genesislcap/foundation-user": "15.19.
|
|
102
|
-
"@genesislcap/foundation-utils": "15.19.
|
|
103
|
-
"@genesislcap/foundation-zero": "15.19.
|
|
104
|
-
"@genesislcap/foundation-zero-grid-tabulator": "15.19.
|
|
105
|
-
"@genesislcap/grid-tabulator": "15.19.
|
|
106
|
-
"@genesislcap/rapid-design-system": "15.19.
|
|
107
|
-
"@genesislcap/rapid-grid-tabulator": "15.19.
|
|
108
|
-
"@genesislcap/web-core": "15.19.
|
|
91
|
+
"@genesislcap/foundation-comms": "15.19.1-FUI-2610.1",
|
|
92
|
+
"@genesislcap/foundation-entity-management": "15.19.1-FUI-2610.1",
|
|
93
|
+
"@genesislcap/foundation-events": "15.19.1-FUI-2610.1",
|
|
94
|
+
"@genesislcap/foundation-forms": "15.19.1-FUI-2610.1",
|
|
95
|
+
"@genesislcap/foundation-header": "15.19.1-FUI-2610.1",
|
|
96
|
+
"@genesislcap/foundation-layout": "15.19.1-FUI-2610.1",
|
|
97
|
+
"@genesislcap/foundation-logger": "15.19.1-FUI-2610.1",
|
|
98
|
+
"@genesislcap/foundation-notifications": "15.19.1-FUI-2610.1",
|
|
99
|
+
"@genesislcap/foundation-store": "15.19.1-FUI-2610.1",
|
|
100
|
+
"@genesislcap/foundation-ui": "15.19.1-FUI-2610.1",
|
|
101
|
+
"@genesislcap/foundation-user": "15.19.1-FUI-2610.1",
|
|
102
|
+
"@genesislcap/foundation-utils": "15.19.1-FUI-2610.1",
|
|
103
|
+
"@genesislcap/foundation-zero": "15.19.1-FUI-2610.1",
|
|
104
|
+
"@genesislcap/foundation-zero-grid-tabulator": "15.19.1-FUI-2610.1",
|
|
105
|
+
"@genesislcap/grid-tabulator": "15.19.1-FUI-2610.1",
|
|
106
|
+
"@genesislcap/rapid-design-system": "15.19.1-FUI-2610.1",
|
|
107
|
+
"@genesislcap/rapid-grid-tabulator": "15.19.1-FUI-2610.1",
|
|
108
|
+
"@genesislcap/web-core": "15.19.1-FUI-2610.1",
|
|
109
109
|
"rxjs": "^7.5.4",
|
|
110
110
|
"tslib": "^2.3.1"
|
|
111
111
|
},
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"customElements": "dist/custom-elements.json"
|
|
116
|
-
"gitHead": "83695de98c2288c2e89992215cb391652f6c5eec"
|
|
115
|
+
"customElements": "dist/custom-elements.json"
|
|
117
116
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document.service.test.d.ts","sourceRoot":"","sources":["../../../src/services/document.service.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
2
|
-
import { DocumentServiceImpl } from './document.service';
|
|
3
|
-
function withStubbedGlobals(run, sessionStore = {}) {
|
|
4
|
-
const original = {
|
|
5
|
-
fetch: globalThis.fetch,
|
|
6
|
-
sessionStorage: globalThis.sessionStorage,
|
|
7
|
-
};
|
|
8
|
-
let captured;
|
|
9
|
-
globalThis.fetch = ((url, init) => {
|
|
10
|
-
captured = { url, init };
|
|
11
|
-
return new Promise(() => { });
|
|
12
|
-
});
|
|
13
|
-
globalThis.sessionStorage = {
|
|
14
|
-
getItem: (key) => (key in sessionStore ? sessionStore[key] : null),
|
|
15
|
-
};
|
|
16
|
-
try {
|
|
17
|
-
run(() => captured);
|
|
18
|
-
}
|
|
19
|
-
finally {
|
|
20
|
-
globalThis.fetch = original.fetch;
|
|
21
|
-
globalThis.sessionStorage = original.sessionStorage;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function makeService(authToken) {
|
|
25
|
-
const auth = {
|
|
26
|
-
loggedUserResult: authToken === null ? null : { authToken },
|
|
27
|
-
};
|
|
28
|
-
const connect = {};
|
|
29
|
-
return new DocumentServiceImpl(connect, auth);
|
|
30
|
-
}
|
|
31
|
-
const Suite = createLogicSuite('DocumentServiceImpl.downloadDocument');
|
|
32
|
-
Suite('sends the auth token from Auth.loggedUserResult, not raw sessionStorage', () => {
|
|
33
|
-
withStubbedGlobals((capture) => {
|
|
34
|
-
const service = makeService('valid-token-123');
|
|
35
|
-
service.downloadDocument('FILE_ID');
|
|
36
|
-
const { url, init } = capture();
|
|
37
|
-
assert.is(url, 'gwf/file-server/download?fileStorageId=FILE_ID');
|
|
38
|
-
assert.is(init.headers.get('SESSION_AUTH_TOKEN'), 'valid-token-123', 'should use the token from Auth, regardless of the sessionStorage key prefix');
|
|
39
|
-
}, { '@custxClientApp/authToken': 'valid-token-123' });
|
|
40
|
-
});
|
|
41
|
-
Suite('omits the auth header when there is no logged-in user', () => {
|
|
42
|
-
withStubbedGlobals((capture) => {
|
|
43
|
-
const service = makeService(null);
|
|
44
|
-
service.downloadDocument('FILE_ID');
|
|
45
|
-
const { init } = capture();
|
|
46
|
-
assert.not.ok(init.headers.get('SESSION_AUTH_TOKEN'), 'no user means no SESSION_AUTH_TOKEN header (never the string "null")');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
Suite.run();
|
|
50
|
-
//# sourceMappingURL=document.service.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document.service.test.js","sourceRoot":"","sources":["../../../src/services/document.service.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAWzD,SAAS,kBAAkB,CACzB,GAA6C,EAC7C,eAAuC,EAAE;IAEzC,MAAM,QAAQ,GAAG;QACf,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,cAAc,EAAG,UAAkB,CAAC,cAAc;KACnD,CAAC;IAEF,IAAI,QAAyB,CAAC;IAG9B,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,GAAW,EAAE,IAAiB,EAAE,EAAE;QACrD,QAAQ,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,OAAO,CAAW,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACzC,CAAC,CAAiB,CAAC;IAIlB,UAAkB,CAAC,cAAc,GAAG;QACnC,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;KAC3E,CAAC;IAEF,IAAI,CAAC;QACH,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC;IACtB,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;QACjC,UAAkB,CAAC,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;IAC/D,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,SAAwB;IAC3C,MAAM,IAAI,GAAG;QACX,gBAAgB,EAAE,SAAS,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE;KACzC,CAAC;IACrB,MAAM,OAAO,GAAG,EAAwB,CAAC;IACzC,OAAO,IAAI,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,KAAK,GAAG,gBAAgB,CAAC,sCAAsC,CAAC,CAAC;AAEvE,KAAK,CAAC,yEAAyE,EAAE,GAAG,EAAE;IACpF,kBAAkB,CAChB,CAAC,OAAO,EAAE,EAAE;QACV,MAAM,OAAO,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;QAC/C,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEpC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,gDAAgD,CAAC,CAAC;QACjE,MAAM,CAAC,EAAE,CACN,IAAI,CAAC,OAAmB,CAAC,GAAG,CAAC,oBAAoB,CAAC,EACnD,iBAAiB,EACjB,6EAA6E,CAC9E,CAAC;IACJ,CAAC,EAED,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,CACnD,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,uDAAuD,EAAE,GAAG,EAAE;IAClE,kBAAkB,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAEpC,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC;QAC3B,MAAM,CAAC,GAAG,CAAC,EAAE,CACV,IAAI,CAAC,OAAmB,CAAC,GAAG,CAAC,oBAAoB,CAAC,EACnD,sEAAsE,CACvE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"root":["../src/globals.d.ts","../src/index.federated.ts","../src/index.ts","../src/sandbox.ts","../src/typings.d.ts","../src/components/rapid-components.ts","../src/components/zero-components.ts","../src/components/document-upload/document-upload.styles.ts","../src/components/document-upload/document-upload.template.ts","../src/components/document-upload/document-upload.ts","../src/components/document-upload/document-upload.types.ts","../src/components/template-asset-link/template-asset-link.styles.ts","../src/components/template-asset-link/template-asset-link.template.ts","../src/components/template-asset-link/template-asset-link.ts","../src/components/utils/action-cell-renderer.ts","../src/components/utils/column-config.ts","../src/components/utils/icons.ts","../src/config/config.ts","../src/config/configure.ts","../src/config/index.ts","../src/config/templates.ts","../src/main/index.ts","../src/main/main.styles.ts","../src/main/main.template.ts","../src/main/main.ts","../src/services/document.service.test.ts","../src/services/document.service.ts","../src/tags/index.ts","../src/tags/tags.ts","../src/types/index.ts","../src/types/main.types.ts","../src/types/utils.types.ts","../src/utils/formatting.ts","../src/utils/index.ts","../src/utils/logger.ts","../src/utils/misc.ts","../src/utils/notifications.ts","../src/utils/styles.ts"],"version":"5.9.2"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { css } from '@genesislcap/web-core';
|
|
2
|
-
|
|
3
|
-
export const DocumentUploadStyles = css`
|
|
4
|
-
:host {
|
|
5
|
-
height: 100%;
|
|
6
|
-
width: 100%;
|
|
7
|
-
padding: calc(var(--design-unit) * 3px);
|
|
8
|
-
background-color: var(--neutral-layer-4);
|
|
9
|
-
box-sizing: border-box;
|
|
10
|
-
display: grid;
|
|
11
|
-
grid-template-rows: auto 1fr;
|
|
12
|
-
grid-gap: calc(var(--design-unit) * 3px);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
div.path {
|
|
16
|
-
display: grid;
|
|
17
|
-
grid-template-columns: auto 1fr;
|
|
18
|
-
grid-gap: calc(var(--design-unit) * 3px);
|
|
19
|
-
align-items: center;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
div.template {
|
|
23
|
-
align-items: center;
|
|
24
|
-
display: flex;
|
|
25
|
-
gap: calc(var(--design-unit) * 3px);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
div.config {
|
|
29
|
-
display: grid;
|
|
30
|
-
grid-template-columns: 1fr auto;
|
|
31
|
-
grid-gap: calc(var(--design-unit) * 3px);
|
|
32
|
-
align-items: center;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.container {
|
|
36
|
-
display: flex;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
align-items: center;
|
|
39
|
-
height: 100%;
|
|
40
|
-
border-radius: calc(var(--control-corner-radius) * 1px);
|
|
41
|
-
border: calc(var(--stroke-width) * 1px) dashed var(--accent-fill-rest);
|
|
42
|
-
background-color: var(--neutral-layer-3);
|
|
43
|
-
box-sizing: border-box;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.clickable {
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.dialog {
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
align-items: center;
|
|
54
|
-
gap: calc(var(--design-unit) * 3px);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.document-name {
|
|
58
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
59
|
-
color: var(--neutral-stroke-hover);
|
|
60
|
-
text-align: center;
|
|
61
|
-
line-height: var(--type-ramp-base-line-height);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.document-size {
|
|
65
|
-
color: var(--neutral-foreground-hint);
|
|
66
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
67
|
-
text-align: center;
|
|
68
|
-
line-height: normal;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.drag-prompt {
|
|
72
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
73
|
-
color: var(--neutral-foreground-rest);
|
|
74
|
-
text-align: center;
|
|
75
|
-
line-height: normal;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.drag-prompt > span {
|
|
79
|
-
color: var(--accent-fill-rest);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.progress {
|
|
83
|
-
width: 261px;
|
|
84
|
-
height: calc(var(--design-unit) * 1px);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.error-progress::part(determinate) {
|
|
88
|
-
background-color: var(--error-color);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
label.type-prompt {
|
|
92
|
-
font-size: var(--type-ramp-plus-1-font-size);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.type-prompt {
|
|
96
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
97
|
-
color: var(--neutral-foreground-hint);
|
|
98
|
-
text-align: center;
|
|
99
|
-
line-height: normal;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.upload-icon,
|
|
103
|
-
.error-icon {
|
|
104
|
-
fill: var(--neutral-foreground-rest);
|
|
105
|
-
animation: animation-upload-icon 3s infinite;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.upload-successfull::part(determinate) {
|
|
109
|
-
background-color: var(--success-color);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.uploading-prompt {
|
|
113
|
-
width: 134px;
|
|
114
|
-
margin-left: 75px;
|
|
115
|
-
font-size: var(--type-ramp-minus-1-font-size);
|
|
116
|
-
color: var(--neutral-foreground-rest);
|
|
117
|
-
line-height: normal;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.uploading-prompt::after {
|
|
121
|
-
overflow: hidden;
|
|
122
|
-
display: inline-block;
|
|
123
|
-
vertical-align: bottom;
|
|
124
|
-
animation: ellipsis steps(4, end) 2s infinite;
|
|
125
|
-
content: '...';
|
|
126
|
-
width: 0;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
.success-icon {
|
|
130
|
-
position: relative;
|
|
131
|
-
height: calc(var(--base-height-multiplier) * 5px);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.success-icon > svg {
|
|
135
|
-
position: absolute;
|
|
136
|
-
top: 50%;
|
|
137
|
-
left: 50%;
|
|
138
|
-
transform: translate(-50%, -50%);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@keyframes ellipsis {
|
|
142
|
-
to {
|
|
143
|
-
width: 14px;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@keyframes ellipsis {
|
|
148
|
-
to {
|
|
149
|
-
width: 14px;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.error-icon {
|
|
154
|
-
fill: var(--error-color);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
@keyframes animation-upload-icon {
|
|
158
|
-
0% {
|
|
159
|
-
opacity: 100%;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
50% {
|
|
163
|
-
opacity: 30%;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
100% {
|
|
167
|
-
opacity: 100%;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
@keyframes animation-upload-icon {
|
|
171
|
-
0% {
|
|
172
|
-
opacity: 100%;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
50% {
|
|
176
|
-
opacity: 30%;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
100% {
|
|
180
|
-
opacity: 100%;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
`;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { html, ref, repeat, sync, when } from '@genesislcap/web-core';
|
|
2
|
-
import { iconTag, optionTag, progressTag, selectInputTag, textInputTag } from '../../tags';
|
|
3
|
-
import { FileMetaType } from '../../types';
|
|
4
|
-
import { formatBytes } from '../../utils/formatting';
|
|
5
|
-
import { checkmark, checkmarkBackground, checkmarkCircle, uploadIconLarge } from '../utils/icons';
|
|
6
|
-
import type { DocumentUpload } from './document-upload';
|
|
7
|
-
import { UploadState } from './document-upload.types';
|
|
8
|
-
|
|
9
|
-
const filePathPicker = html<DocumentUpload>`
|
|
10
|
-
<div class="path">
|
|
11
|
-
<label class="type-prompt">Upload path:</label>
|
|
12
|
-
<${textInputTag} value=${sync((x) => x.filePath)} ?disabled=${(x) => x.currentState !== UploadState.START || x.fileStorageId}></${textInputTag}>
|
|
13
|
-
</div>
|
|
14
|
-
`;
|
|
15
|
-
|
|
16
|
-
const templateTooltip = `
|
|
17
|
-
<h3>File type</h3>
|
|
18
|
-
<p>Choose the meta file type of the file you're going to upload, it can be ${Object.keys(
|
|
19
|
-
FileMetaType,
|
|
20
|
-
)
|
|
21
|
-
.map((f) => `<code>${f}</code>`)
|
|
22
|
-
.join(', ')}.</p>
|
|
23
|
-
<p>A user document is a standard file.</p>
|
|
24
|
-
<p>When a document is marked as a template, it can be selected in the reporting component as a template file from which to generate a document.</p>
|
|
25
|
-
<p>Valid templating format extensions are:</p>
|
|
26
|
-
<ul>
|
|
27
|
-
<li>Excel: <code>.xls</code> or <code>.xlsx</code></li>
|
|
28
|
-
<li>PDF: <code>.html</code> or <code>.xhtml</code></li>
|
|
29
|
-
</ul>
|
|
30
|
-
<p>A document configured as a template asset can then be linked to that asset. This, for example, allows you to generate reports using templates that use assets, such as images.</p>
|
|
31
|
-
<p>If you have uploaded an asset click on the linking button on the template and then choose the asset(s) to link to on the pop-up dialog.</p>
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const templateCheckbox = html<DocumentUpload>`
|
|
35
|
-
<div class="template">
|
|
36
|
-
<${iconTag} tooltip="${templateTooltip}"></${iconTag}>
|
|
37
|
-
<label class="type-prompt">File type</label>
|
|
38
|
-
<${selectInputTag}
|
|
39
|
-
value=${sync((x) => x.fileMetaType)}
|
|
40
|
-
?disabled=${(x) => x.currentState !== UploadState.START || x.fileStorageId}
|
|
41
|
-
>
|
|
42
|
-
${repeat(
|
|
43
|
-
() => Object.keys(FileMetaType),
|
|
44
|
-
html<FileMetaType, DocumentUpload>`
|
|
45
|
-
<${optionTag} ?selected=${(x, c) => x === c.parent.fileMetaType}>${(x) => x}</${optionTag}>`,
|
|
46
|
-
{ recycle: false },
|
|
47
|
-
)}
|
|
48
|
-
</${selectInputTag}>
|
|
49
|
-
</div>
|
|
50
|
-
`;
|
|
51
|
-
|
|
52
|
-
export const DocumentUploadTemplate = html<DocumentUpload>`
|
|
53
|
-
<template>
|
|
54
|
-
<div class="config">${filePathPicker} ${templateCheckbox}</div>
|
|
55
|
-
<div class="container" ${ref('dropArea')}>
|
|
56
|
-
${when(
|
|
57
|
-
(x) => x.currentState === UploadState.START,
|
|
58
|
-
html<DocumentUpload>`
|
|
59
|
-
<div class="dialog">
|
|
60
|
-
<span class="upload-icon">${uploadIconLarge}</span>
|
|
61
|
-
<a class="drag-prompt clickable" @click=${(x) => x.fileClick()}>
|
|
62
|
-
Drag and drop or
|
|
63
|
-
<span>select</span>
|
|
64
|
-
a file to upload.
|
|
65
|
-
</a>
|
|
66
|
-
<a class="type-prompt">
|
|
67
|
-
Allows all file types including: PDF, CSV, JPG, PNG, HTML etc.
|
|
68
|
-
</a>
|
|
69
|
-
</div>
|
|
70
|
-
`,
|
|
71
|
-
)}
|
|
72
|
-
${when(
|
|
73
|
-
(x) => x.currentState === UploadState.UPLOADING,
|
|
74
|
-
html<DocumentUpload>`
|
|
75
|
-
<div class="dialog">
|
|
76
|
-
<span class="upload-icon">${uploadIconLarge}</span>
|
|
77
|
-
<a
|
|
78
|
-
class="${(x) =>
|
|
79
|
-
x.currentState === UploadState.UPLOADING ? 'uploading-prompt' : 'drag-prompt'}"
|
|
80
|
-
>
|
|
81
|
-
${(x) => (x.currentState === UploadState.UPLOADING ? 'Uploading' : 'File Uploaded')}
|
|
82
|
-
</a>
|
|
83
|
-
<a class="document-name">${(x) => x.fileName}</a>
|
|
84
|
-
<a class="document-size">${(x) => formatBytes(x.fileSize, 2)}</a>
|
|
85
|
-
<${progressTag}
|
|
86
|
-
class="progress ${(x) => (x.fileUploadProgress >= 100 ? 'upload-successfull' : '')}"
|
|
87
|
-
min="0"
|
|
88
|
-
max="100"
|
|
89
|
-
value=${(x) => x.fileUploadProgress}
|
|
90
|
-
></${progressTag}>
|
|
91
|
-
</div>
|
|
92
|
-
`,
|
|
93
|
-
)}
|
|
94
|
-
${when(
|
|
95
|
-
(x) => x.currentState === UploadState.UPLOADED,
|
|
96
|
-
html<DocumentUpload>`
|
|
97
|
-
<div class="dialog">
|
|
98
|
-
<span class="success-icon">${checkmarkBackground} ${checkmarkCircle} ${checkmark}</span>
|
|
99
|
-
<a class="drag-prompt">Document successfully uploaded</a>
|
|
100
|
-
</div>
|
|
101
|
-
`,
|
|
102
|
-
)}
|
|
103
|
-
${when(
|
|
104
|
-
(x) => x.currentState === UploadState.ERROR,
|
|
105
|
-
html<DocumentUpload>`
|
|
106
|
-
<div class="dialog">
|
|
107
|
-
<span class="error-icon">${uploadIconLarge}</span>
|
|
108
|
-
<a class="drag-prompt">Error uploading file. Please try again.</a>
|
|
109
|
-
<a class="document-name">${(x) => x.fileName}</a>
|
|
110
|
-
<a class="document-size">${(x) => formatBytes(x.fileSize, 2)}</a>
|
|
111
|
-
<${progressTag}
|
|
112
|
-
class="progress error-progress"
|
|
113
|
-
min="0"
|
|
114
|
-
max="100"
|
|
115
|
-
value="100"
|
|
116
|
-
></${progressTag}>
|
|
117
|
-
</div>
|
|
118
|
-
`,
|
|
119
|
-
)}
|
|
120
|
-
</div>
|
|
121
|
-
</template>
|
|
122
|
-
`;
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from '@genesislcap/foundation-events';
|
|
2
|
-
import { attr, customElement, DOM, GenesisElement, observable } from '@genesislcap/web-core';
|
|
3
|
-
import { IDocumentService } from '../../services/document.service';
|
|
4
|
-
import {
|
|
5
|
-
DocManagerEventDetailMap,
|
|
6
|
-
DocManagerEvents,
|
|
7
|
-
FileMetaType,
|
|
8
|
-
FileUploadMode,
|
|
9
|
-
} from '../../types/main.types';
|
|
10
|
-
import { logger, showNotificationToast } from '../../utils';
|
|
11
|
-
import { DocumentUploadStyles } from './document-upload.styles';
|
|
12
|
-
import { DocumentUploadTemplate } from './document-upload.template';
|
|
13
|
-
import { UploadState } from './document-upload.types';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Document upload / replace drop zone.
|
|
17
|
-
* @public
|
|
18
|
-
*
|
|
19
|
-
* @fires handle-upload-started
|
|
20
|
-
* @fires handle-replace-started
|
|
21
|
-
* @fires handle-file-process-error
|
|
22
|
-
* @fires handle-file-uploaded
|
|
23
|
-
* @fires handle-file-replaced
|
|
24
|
-
*/
|
|
25
|
-
@customElement({
|
|
26
|
-
name: 'document-upload',
|
|
27
|
-
template: DocumentUploadTemplate,
|
|
28
|
-
styles: DocumentUploadStyles,
|
|
29
|
-
})
|
|
30
|
-
export class DocumentUpload extends EventEmitter<DocManagerEventDetailMap>(GenesisElement) {
|
|
31
|
-
@IDocumentService docService: IDocumentService;
|
|
32
|
-
|
|
33
|
-
@observable currentState: UploadState = UploadState.START;
|
|
34
|
-
@observable fileName: string;
|
|
35
|
-
@observable fileSize: number;
|
|
36
|
-
@observable fileUploadProgress: number = 0;
|
|
37
|
-
@observable fileUploadMode: FileUploadMode;
|
|
38
|
-
|
|
39
|
-
@attr({ attribute: 'file-path' }) filePath = '/';
|
|
40
|
-
@attr({ attribute: 'file-meta-type' }) fileMetaType = FileMetaType.USER_DOCUMENT;
|
|
41
|
-
@attr({ attribute: 'file-storage-id' }) fileStorageId = null;
|
|
42
|
-
|
|
43
|
-
public dropArea: HTMLDivElement;
|
|
44
|
-
public fileSelect: HTMLInputElement;
|
|
45
|
-
public endpoint: string = '';
|
|
46
|
-
|
|
47
|
-
private readonly errorViewTime: number = 7000;
|
|
48
|
-
private readonly uploadingUploadedViewTime: number = 2000;
|
|
49
|
-
|
|
50
|
-
private file: any;
|
|
51
|
-
|
|
52
|
-
connectedCallback() {
|
|
53
|
-
super.connectedCallback();
|
|
54
|
-
DOM.queueUpdate(() => {
|
|
55
|
-
this.createFileUploadInput();
|
|
56
|
-
|
|
57
|
-
['dragenter', 'dragover', 'dragleave', 'drop'].forEach((eventName) => {
|
|
58
|
-
this.dropArea.addEventListener(eventName, this.preventDefaults, false);
|
|
59
|
-
});
|
|
60
|
-
this.dropArea.addEventListener('drop', this.handleDrop.bind(this), false);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public fileClick() {
|
|
65
|
-
this.fileSelect.click();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private handleDrop(e) {
|
|
69
|
-
if (this.currentState === UploadState.START) {
|
|
70
|
-
const dt = e.dataTransfer;
|
|
71
|
-
const files = dt.files;
|
|
72
|
-
|
|
73
|
-
const firstElement = 0;
|
|
74
|
-
|
|
75
|
-
if (files[firstElement]) {
|
|
76
|
-
const file = files[firstElement];
|
|
77
|
-
this.updateSelectedFile(file);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private createFileUploadInput() {
|
|
83
|
-
this.fileSelect = document.createElement('input') as HTMLInputElement;
|
|
84
|
-
this.fileSelect.type = 'file';
|
|
85
|
-
this.fileSelect.onchange = (event) => {
|
|
86
|
-
logger.debug('file upload click');
|
|
87
|
-
this.fileSelected(event);
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
private fileSelected(event) {
|
|
92
|
-
// Only take the first file
|
|
93
|
-
const file = event.target.files[0];
|
|
94
|
-
this.updateSelectedFile(file);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private updateSelectedFile(file: any) {
|
|
98
|
-
if (this.fileUploadMode === FileUploadMode.DISABLED) {
|
|
99
|
-
throw new Error('File upload is disabled and cannot be operated');
|
|
100
|
-
}
|
|
101
|
-
if (file.size === 0) {
|
|
102
|
-
showNotificationToast({
|
|
103
|
-
title: 'Invalid File',
|
|
104
|
-
body: `Cannot upload empty file "${file.name}."\nUploaded files must be non-empty.`,
|
|
105
|
-
toast: { type: 'critical' as any },
|
|
106
|
-
});
|
|
107
|
-
this.cleanData();
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
this.file = file;
|
|
111
|
-
this.fileName = this.file.name;
|
|
112
|
-
this.fileSize = this.file.size;
|
|
113
|
-
this.fileSelect.value = '';
|
|
114
|
-
this.fileUploadProgress = 0;
|
|
115
|
-
if (this.fileUploadMode === FileUploadMode.REPLACE) {
|
|
116
|
-
this.replaceFile();
|
|
117
|
-
} else if (this.fileUploadMode === FileUploadMode.UPLOAD) {
|
|
118
|
-
this.uploadedFile();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private uploadedFile() {
|
|
123
|
-
this.currentState = UploadState.UPLOADING;
|
|
124
|
-
this.$emit(DocManagerEvents.HandleUploadStarted);
|
|
125
|
-
this.docService
|
|
126
|
-
.uploadDocument({ file: this.file, path: this.filePath, fileMetaType: this.fileMetaType })
|
|
127
|
-
.then((x) => {
|
|
128
|
-
if (x.ok) {
|
|
129
|
-
this.fileUploadProgress = 100;
|
|
130
|
-
this.handleFinishUpload();
|
|
131
|
-
} else {
|
|
132
|
-
this.handleError(); // Add logging later
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
private replaceFile() {
|
|
137
|
-
this.currentState = UploadState.UPLOADING;
|
|
138
|
-
this.$emit(DocManagerEvents.HandleReplaceStarted);
|
|
139
|
-
this.docService
|
|
140
|
-
.replaceDocument({
|
|
141
|
-
file: this.file,
|
|
142
|
-
fileStorageId: this.fileStorageId,
|
|
143
|
-
})
|
|
144
|
-
.then((x) => {
|
|
145
|
-
if (x.ok) {
|
|
146
|
-
this.fileUploadProgress = 100;
|
|
147
|
-
this.handleFinishUpload();
|
|
148
|
-
} else {
|
|
149
|
-
this.handleError(); // Add logging later
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
public cleanData() {
|
|
155
|
-
this.file = undefined;
|
|
156
|
-
this.fileName = undefined;
|
|
157
|
-
this.fileSize = undefined;
|
|
158
|
-
this.fileSelect.value = '';
|
|
159
|
-
this.fileUploadProgress = 0;
|
|
160
|
-
this.currentState = UploadState.START;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
private preventDefaults(e) {
|
|
164
|
-
e.preventDefault();
|
|
165
|
-
e.stopPropagation();
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
private handleError() {
|
|
169
|
-
this.$emit(DocManagerEvents.HandleFileProcessError);
|
|
170
|
-
this.currentState = UploadState.ERROR;
|
|
171
|
-
setTimeout(() => {
|
|
172
|
-
this.currentState = UploadState.START;
|
|
173
|
-
}, this.errorViewTime);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
private handleFinishUpload() {
|
|
177
|
-
setTimeout(() => {
|
|
178
|
-
const isReplace = this.fileUploadMode === FileUploadMode.REPLACE;
|
|
179
|
-
this.$emit(
|
|
180
|
-
isReplace ? DocManagerEvents.HandleFileReplaced : DocManagerEvents.HandleFileUploaded,
|
|
181
|
-
);
|
|
182
|
-
showNotificationToast({
|
|
183
|
-
title: isReplace ? 'Replace Document' : 'Upload Document',
|
|
184
|
-
body: `Document was ${isReplace ? 'replaced' : 'uploaded'} successfully`,
|
|
185
|
-
toast: { type: 'success' as any },
|
|
186
|
-
});
|
|
187
|
-
this.cleanData();
|
|
188
|
-
}, this.uploadingUploadedViewTime);
|
|
189
|
-
}
|
|
190
|
-
}
|