djgentelella 0.4.10__py3-none-any.whl → 0.5.0__py3-none-any.whl
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.
- djgentelella/__init__.py +1 -1
- djgentelella/admin.py +7 -1
- djgentelella/firmador_digital/forms.py +46 -16
- djgentelella/firmador_digital/models.py +12 -15
- djgentelella/firmador_digital/views.py +1 -1
- djgentelella/locale/es/LC_MESSAGES/django.mo +0 -0
- djgentelella/locale/es/LC_MESSAGES/django.po +18 -0
- djgentelella/locale/es/LC_MESSAGES/djangojs.mo +0 -0
- djgentelella/migrations/0014_trash.py +31 -0
- djgentelella/migrations/0015_trash_deleted_by.py +21 -0
- djgentelella/migrations/0016_trash_created_at.py +20 -0
- djgentelella/models.py +96 -0
- djgentelella/models_manager.py +40 -0
- djgentelella/static/djgentelella.flags.vendors.min.css +1 -1
- djgentelella/static/gentelella/css/custom.css +19 -2
- djgentelella/static/gentelella/css/modern.css +15 -0
- djgentelella/static/gentelella/css/modern_black_white.css +15 -0
- djgentelella/static/gentelella/css/pdfviewer.css +43 -1
- djgentelella/static/gentelella/images/default.png +0 -0
- djgentelella/static/gentelella/js/base/digital_signature.js +87 -26
- djgentelella/static/gentelella/js/base.js +87 -26
- djgentelella/static/gentelella/js/digital_signature_update.js +29 -0
- djgentelella/static/vendors/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css.map +75 -7
- djgentelella/static/vendors/flags/1x1/ac.svg +75 -7
- djgentelella/static/vendors/flags/1x1/cp.svg +75 -7
- djgentelella/static/vendors/flags/1x1/dg.svg +75 -7
- djgentelella/static/vendors/flags/1x1/ea.svg +75 -7
- djgentelella/static/vendors/flags/1x1/es-ct.svg +75 -7
- djgentelella/static/vendors/flags/1x1/es-ga.svg +75 -7
- djgentelella/static/vendors/flags/1x1/ic.svg +75 -7
- djgentelella/static/vendors/flags/1x1/ta.svg +75 -7
- djgentelella/static/vendors/flags/1x1/xx.svg +75 -7
- djgentelella/static/vendors/flags/4x3/ac.svg +75 -7
- djgentelella/static/vendors/flags/4x3/cp.svg +75 -7
- djgentelella/static/vendors/flags/4x3/dg.svg +75 -7
- djgentelella/static/vendors/flags/4x3/ea.svg +75 -7
- djgentelella/static/vendors/flags/4x3/es-ct.svg +75 -7
- djgentelella/static/vendors/flags/4x3/es-ga.svg +75 -7
- djgentelella/static/vendors/flags/4x3/ic.svg +75 -7
- djgentelella/static/vendors/flags/4x3/ta.svg +75 -7
- djgentelella/static/vendors/flags/4x3/xx.svg +75 -7
- djgentelella/templates/gentelella/app/sidebar.html +7 -4
- djgentelella/templates/gentelella/digital_signature/update_signature_settings.html +24 -36
- djgentelella/templates/gentelella/widgets/digital_signature.html +41 -7
- djgentelella/trash/api.py +58 -0
- djgentelella/trash/filterset.py +20 -0
- djgentelella/trash/serializer.py +45 -0
- djgentelella/urls.py +4 -0
- djgentelella/widgets/core.py +6 -5
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/METADATA +2 -2
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/RECORD +55 -46
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/AUTHORS +0 -0
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/LICENSE.txt +0 -0
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/WHEEL +0 -0
- {djgentelella-0.4.10.dist-info → djgentelella-0.5.0.dist-info}/top_level.txt +0 -0
|
@@ -150,7 +150,7 @@ html , body{
|
|
|
150
150
|
}
|
|
151
151
|
.left_col {
|
|
152
152
|
background: #2A3F54;
|
|
153
|
-
height:
|
|
153
|
+
max-height: 1600px;
|
|
154
154
|
}
|
|
155
155
|
.select2-container {
|
|
156
156
|
width: 100% !important;
|
|
@@ -931,7 +931,9 @@ a:focus {
|
|
|
931
931
|
line-height: 30px
|
|
932
932
|
}
|
|
933
933
|
.main_menu_side {
|
|
934
|
-
padding: 0
|
|
934
|
+
padding: 0;
|
|
935
|
+
max-height: 100vh;
|
|
936
|
+
overflow-y: auto;
|
|
935
937
|
}
|
|
936
938
|
.bs-docs-sidebar .nav>li>a {
|
|
937
939
|
display: block;
|
|
@@ -4685,3 +4687,18 @@ input-group > .custom-file {
|
|
|
4685
4687
|
overflow:auto;
|
|
4686
4688
|
-webkit-overflow-scrolling: touch
|
|
4687
4689
|
}
|
|
4690
|
+
|
|
4691
|
+
/* ── WebKit/Blink: Chrome, Edge, Brave, Safari, Firefox not need */
|
|
4692
|
+
*::-webkit-scrollbar {
|
|
4693
|
+
width: 4px;
|
|
4694
|
+
height: 4px;
|
|
4695
|
+
}
|
|
4696
|
+
|
|
4697
|
+
*::-webkit-scrollbar-thumb {
|
|
4698
|
+
background: #767684;
|
|
4699
|
+
border-radius: 5px;
|
|
4700
|
+
}
|
|
4701
|
+
|
|
4702
|
+
*::-webkit-scrollbar-track {
|
|
4703
|
+
background: transparent;
|
|
4704
|
+
}
|
|
@@ -5371,3 +5371,18 @@ div.form-group {
|
|
|
5371
5371
|
border: 1px solid #1ABB9C;; /* Bordes */
|
|
5372
5372
|
border-radius: 5px; /* Esquinas redondeadas */
|
|
5373
5373
|
}
|
|
5374
|
+
|
|
5375
|
+
/* ── WebKit/Blink: Chrome, Edge, Brave, Safari, Firefox not need */
|
|
5376
|
+
*::-webkit-scrollbar {
|
|
5377
|
+
width: 4px;
|
|
5378
|
+
height: 4px;
|
|
5379
|
+
}
|
|
5380
|
+
|
|
5381
|
+
*::-webkit-scrollbar-thumb {
|
|
5382
|
+
background: #767684;
|
|
5383
|
+
border-radius: 5px;
|
|
5384
|
+
}
|
|
5385
|
+
|
|
5386
|
+
*::-webkit-scrollbar-track {
|
|
5387
|
+
background: transparent;
|
|
5388
|
+
}
|
|
@@ -5372,3 +5372,18 @@ div.form-group {
|
|
|
5372
5372
|
border: 1px solid #1ABB9C;; /* Bordes */
|
|
5373
5373
|
border-radius: 5px; /* Esquinas redondeadas */
|
|
5374
5374
|
}
|
|
5375
|
+
|
|
5376
|
+
/* ── WebKit/Blink: Chrome, Edge, Brave, Safari, Firefox not need */
|
|
5377
|
+
*::-webkit-scrollbar {
|
|
5378
|
+
width: 4px;
|
|
5379
|
+
height: 4px;
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
*::-webkit-scrollbar-thumb {
|
|
5383
|
+
background: #767684;
|
|
5384
|
+
border-radius: 5px;
|
|
5385
|
+
}
|
|
5386
|
+
|
|
5387
|
+
*::-webkit-scrollbar-track {
|
|
5388
|
+
background: transparent;
|
|
5389
|
+
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
max-width: 100%;
|
|
17
17
|
max-height: 300px;
|
|
18
18
|
box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
|
|
19
|
-
overflow
|
|
19
|
+
overflow: auto;
|
|
20
20
|
/*max-width: 770px;*/
|
|
21
21
|
/*max-height: 950px;*/
|
|
22
22
|
}
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
.widget-digital-signature .pdfviewer {
|
|
25
25
|
/*width: 100%;*/
|
|
26
26
|
/*height: auto;*/
|
|
27
|
+
margin: 0 auto;
|
|
27
28
|
display: block;
|
|
29
|
+
width: auto;
|
|
30
|
+
height: auto;
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
.widget-digital-signature .signature {
|
|
@@ -145,3 +148,42 @@
|
|
|
145
148
|
transform: scale(0.95);
|
|
146
149
|
}
|
|
147
150
|
}
|
|
151
|
+
|
|
152
|
+
.widget-digital-signature .expanded-viewer {
|
|
153
|
+
position: fixed;
|
|
154
|
+
top: 0;
|
|
155
|
+
left: 0;
|
|
156
|
+
width: 100vw !important;
|
|
157
|
+
height: 100vh !important;
|
|
158
|
+
background: #f7f7f7;
|
|
159
|
+
z-index: 1050;
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-direction: column;
|
|
162
|
+
justify-content: start;
|
|
163
|
+
align-items: stretch;
|
|
164
|
+
padding: 1rem;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.widget-digital-signature .expanded-canvas-container {
|
|
168
|
+
width: 100% !important;
|
|
169
|
+
max-width: 1200px;
|
|
170
|
+
height: 85vh !important;
|
|
171
|
+
margin: 0 auto;
|
|
172
|
+
max-height: 1000px;
|
|
173
|
+
display: block;
|
|
174
|
+
overflow: auto
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.widget-digital-signature .hide {
|
|
178
|
+
display: none !important;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.widget-digital-signature .expanded-viewer #container_select_card {
|
|
182
|
+
position: sticky;
|
|
183
|
+
top: 0;
|
|
184
|
+
z-index: 100;
|
|
185
|
+
background: #fff;
|
|
186
|
+
box-shadow: 0 2px 8px rgba(0,0,0,0.06);
|
|
187
|
+
margin-bottom: 1rem;
|
|
188
|
+
border-radius: 8px;
|
|
189
|
+
}
|
|
Binary file
|
|
@@ -100,8 +100,13 @@ class PdfSignatureComponent {
|
|
|
100
100
|
this.btn_next = container.querySelector('.next');
|
|
101
101
|
this.page_num = container.querySelector('.page_num');
|
|
102
102
|
this.page_number = container.querySelector('.page_number');
|
|
103
|
+
this.btn_expand = container.querySelector('.btn_expand');
|
|
103
104
|
this.page_count = container.querySelector('.page_count');
|
|
104
105
|
this.sub_canvas_container = container.querySelector('.sub_canvas_container');
|
|
106
|
+
this.pdfSignatureContainer = container.querySelector('.pdf-signature-container');
|
|
107
|
+
this.digitalSignatureCard = container.querySelector('.digital-signature-card');
|
|
108
|
+
this.btns_expand = container.querySelector('.container_select_card_expanded');
|
|
109
|
+
this.expandHelpMessage = container.querySelector('.expand-help-message');
|
|
105
110
|
|
|
106
111
|
// Verify that all required elements are present
|
|
107
112
|
if (!this.signature || !this.canvas || !this.btn_prev || !this.btn_next || !this.page_num || !this.page_number || !this.page_count || !this.sub_canvas_container) {
|
|
@@ -119,6 +124,7 @@ class PdfSignatureComponent {
|
|
|
119
124
|
this.signY = 198;
|
|
120
125
|
this.signWidth = 133;
|
|
121
126
|
this.signHeight = 133;
|
|
127
|
+
this.expanded = false;
|
|
122
128
|
|
|
123
129
|
// Initializes the processes
|
|
124
130
|
this.initEvents();
|
|
@@ -133,6 +139,7 @@ class PdfSignatureComponent {
|
|
|
133
139
|
this.btn_next.addEventListener('click', () => this.onNextPage());
|
|
134
140
|
this.page_number.addEventListener('change', (e) => this.renderPage(e.target.value));
|
|
135
141
|
this.page_number.addEventListener('keyup', (e) => this.renderPage(e.target.value));
|
|
142
|
+
this.btn_expand.addEventListener('click', () => this.expand());
|
|
136
143
|
}
|
|
137
144
|
|
|
138
145
|
initPDFViewer() {
|
|
@@ -185,6 +192,44 @@ class PdfSignatureComponent {
|
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
|
|
195
|
+
expand() {
|
|
196
|
+
this.expanded = !this.expanded;
|
|
197
|
+
if (this.expanded) {
|
|
198
|
+
this.pdfSignatureContainer.classList.add('expanded-viewer');
|
|
199
|
+
this.sub_canvas_container.classList.add('expanded-canvas-container');
|
|
200
|
+
this.digitalSignatureCard.classList.add('hide');
|
|
201
|
+
this.expandHelpMessage.classList.add('hide');
|
|
202
|
+
this.btns_expand.classList.remove('hide');
|
|
203
|
+
|
|
204
|
+
requestAnimationFrame(() => {
|
|
205
|
+
this.adjustScaleToContainer().then(() => {
|
|
206
|
+
this.renderPage(this.pageNum);
|
|
207
|
+
this.sub_canvas_container.scrollTop = (this.canvas.height / 2) - (this.sub_canvas_container.clientHeight / 2);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
} else {
|
|
211
|
+
this.pdfSignatureContainer.classList.remove('expanded-viewer');
|
|
212
|
+
this.sub_canvas_container.classList.remove('expanded-canvas-container');
|
|
213
|
+
this.digitalSignatureCard.classList.remove('hide');
|
|
214
|
+
this.expandHelpMessage.classList.remove('hide');
|
|
215
|
+
this.btns_expand.classList.add('hide');
|
|
216
|
+
this.scale = 1.2;
|
|
217
|
+
this.renderPage(this.pageNum);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
adjustScaleToContainer() {
|
|
224
|
+
return this.pdfDoc.getPage(this.pageNum).then((page) => {
|
|
225
|
+
const containerWidth = Math.min(this.sub_canvas_container.offsetWidth, 1200);
|
|
226
|
+
const viewport = page.getViewport({scale: 1});
|
|
227
|
+
let nextScale = (containerWidth * 0.95) / viewport.width;
|
|
228
|
+
this.scale = Math.min(nextScale, 2.0);
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
|
|
188
233
|
renderPage(num) {
|
|
189
234
|
this.pageRendering = true;
|
|
190
235
|
this.pdfDoc.getPage(num).then((page) => {
|
|
@@ -357,7 +402,7 @@ class PdfSignatureComponent {
|
|
|
357
402
|
return tempSignature;
|
|
358
403
|
}
|
|
359
404
|
|
|
360
|
-
|
|
405
|
+
// If required, you can define a method for loading an image
|
|
361
406
|
loadSignatureImage(signatureImage, imageContainer) {
|
|
362
407
|
return new Promise((resolve, reject) => {
|
|
363
408
|
if (!signatureImage) {
|
|
@@ -408,9 +453,9 @@ class SignatureManager {
|
|
|
408
453
|
this.container = container;
|
|
409
454
|
this.modal = new bootstrap.Modal(container.querySelector("#loading_sign"));
|
|
410
455
|
this.firmador = new DocumentClient(container, container.getAttribute("data-widget-id"), this, url_ws, custom_event, this.doc_instance);
|
|
411
|
-
this.signerBtn = container.
|
|
456
|
+
this.signerBtn = container.querySelectorAll(".btn_signer");
|
|
412
457
|
this.errorsContainer = container.querySelector(".errors_signer");
|
|
413
|
-
this.refreshBtn = container.
|
|
458
|
+
this.refreshBtn = container.querySelectorAll(".btn_signer_refresh");
|
|
414
459
|
this.socketError = false;
|
|
415
460
|
this.pdfvisor = pdfvisor;
|
|
416
461
|
|
|
@@ -418,11 +463,15 @@ class SignatureManager {
|
|
|
418
463
|
}
|
|
419
464
|
|
|
420
465
|
initEvents() {
|
|
421
|
-
if (this.signerBtn) {
|
|
422
|
-
this.signerBtn.
|
|
466
|
+
if (this.signerBtn && this.signerBtn.length) {
|
|
467
|
+
this.signerBtn.forEach(btn => {
|
|
468
|
+
btn.addEventListener('click', () => this.sign());
|
|
469
|
+
});
|
|
423
470
|
}
|
|
424
|
-
if (this.refreshBtn) {
|
|
425
|
-
this.refreshBtn.
|
|
471
|
+
if (this.refreshBtn && this.refreshBtn.length) {
|
|
472
|
+
this.refreshBtn.forEach(btn => {
|
|
473
|
+
btn.addEventListener('click', () => this.refresh());
|
|
474
|
+
});
|
|
426
475
|
}
|
|
427
476
|
}
|
|
428
477
|
|
|
@@ -821,37 +870,49 @@ function DocumentClient(container, widgetId, signatureManager, url_ws, custom_ev
|
|
|
821
870
|
this.signatureManager.clearErrors();
|
|
822
871
|
},
|
|
823
872
|
"success_certificates": function (data) {
|
|
824
|
-
|
|
825
873
|
if (data.length > 0) {
|
|
826
|
-
container.
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
874
|
+
container.querySelectorAll("#container_select_card, #container_select_card_expanded_hide").forEach(el => {
|
|
875
|
+
el.classList.remove("d-none");
|
|
876
|
+
el.classList.remove("hide");
|
|
877
|
+
});
|
|
878
|
+
container.querySelectorAll("#container_select_card_tem").forEach(el => {
|
|
879
|
+
el.classList.add("d-none");
|
|
880
|
+
el.classList.add("hide");
|
|
881
|
+
});
|
|
830
882
|
|
|
831
|
-
|
|
883
|
+
let select_cards = container.querySelectorAll(".select_card");
|
|
884
|
+
if (!select_cards.length) {
|
|
832
885
|
console.error(`Select not found for widget ${widgetId}`);
|
|
833
886
|
return;
|
|
834
887
|
}
|
|
835
|
-
select_card.innerHTML = "";
|
|
836
888
|
this.certificates = {};
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
889
|
+
select_cards.forEach(select_card => {
|
|
890
|
+
select_card.innerHTML = "";
|
|
891
|
+
data.forEach((element) => {
|
|
892
|
+
this.certificates[element.tokenSerialNumber] = element;
|
|
893
|
+
let start_token = element.tokenSerialNumber.substring(0, 4);
|
|
894
|
+
let newOption = new Option(
|
|
895
|
+
`${start_token} ${element.commonName}`,
|
|
896
|
+
element.tokenSerialNumber,
|
|
897
|
+
false, false
|
|
898
|
+
);
|
|
899
|
+
select_card.appendChild(newOption);
|
|
900
|
+
});
|
|
847
901
|
});
|
|
848
902
|
} else {
|
|
849
|
-
container.
|
|
850
|
-
|
|
903
|
+
container.querySelectorAll("#container_select_card, #container_select_card_expanded_hide").forEach(el => {
|
|
904
|
+
el.classList.add("d-none");
|
|
905
|
+
el.classList.add("hide");
|
|
906
|
+
});
|
|
907
|
+
container.querySelectorAll("#container_select_card_tem").forEach(el => {
|
|
908
|
+
el.classList.remove("d-none");
|
|
909
|
+
el.classList.remove("hide");
|
|
910
|
+
});
|
|
851
911
|
this.signatureManager.addError(2);
|
|
852
912
|
}
|
|
853
913
|
},
|
|
854
914
|
|
|
915
|
+
|
|
855
916
|
"do_sign_remote": function () {
|
|
856
917
|
let select = container.querySelector(".select_card");
|
|
857
918
|
let selected_card = select ? select.value : null;
|
|
@@ -2375,8 +2375,13 @@ class PdfSignatureComponent {
|
|
|
2375
2375
|
this.btn_next = container.querySelector('.next');
|
|
2376
2376
|
this.page_num = container.querySelector('.page_num');
|
|
2377
2377
|
this.page_number = container.querySelector('.page_number');
|
|
2378
|
+
this.btn_expand = container.querySelector('.btn_expand');
|
|
2378
2379
|
this.page_count = container.querySelector('.page_count');
|
|
2379
2380
|
this.sub_canvas_container = container.querySelector('.sub_canvas_container');
|
|
2381
|
+
this.pdfSignatureContainer = container.querySelector('.pdf-signature-container');
|
|
2382
|
+
this.digitalSignatureCard = container.querySelector('.digital-signature-card');
|
|
2383
|
+
this.btns_expand = container.querySelector('.container_select_card_expanded');
|
|
2384
|
+
this.expandHelpMessage = container.querySelector('.expand-help-message');
|
|
2380
2385
|
|
|
2381
2386
|
// Verify that all required elements are present
|
|
2382
2387
|
if (!this.signature || !this.canvas || !this.btn_prev || !this.btn_next || !this.page_num || !this.page_number || !this.page_count || !this.sub_canvas_container) {
|
|
@@ -2394,6 +2399,7 @@ class PdfSignatureComponent {
|
|
|
2394
2399
|
this.signY = 198;
|
|
2395
2400
|
this.signWidth = 133;
|
|
2396
2401
|
this.signHeight = 133;
|
|
2402
|
+
this.expanded = false;
|
|
2397
2403
|
|
|
2398
2404
|
// Initializes the processes
|
|
2399
2405
|
this.initEvents();
|
|
@@ -2408,6 +2414,7 @@ class PdfSignatureComponent {
|
|
|
2408
2414
|
this.btn_next.addEventListener('click', () => this.onNextPage());
|
|
2409
2415
|
this.page_number.addEventListener('change', (e) => this.renderPage(e.target.value));
|
|
2410
2416
|
this.page_number.addEventListener('keyup', (e) => this.renderPage(e.target.value));
|
|
2417
|
+
this.btn_expand.addEventListener('click', () => this.expand());
|
|
2411
2418
|
}
|
|
2412
2419
|
|
|
2413
2420
|
initPDFViewer() {
|
|
@@ -2460,6 +2467,44 @@ class PdfSignatureComponent {
|
|
|
2460
2467
|
}
|
|
2461
2468
|
}
|
|
2462
2469
|
|
|
2470
|
+
expand() {
|
|
2471
|
+
this.expanded = !this.expanded;
|
|
2472
|
+
if (this.expanded) {
|
|
2473
|
+
this.pdfSignatureContainer.classList.add('expanded-viewer');
|
|
2474
|
+
this.sub_canvas_container.classList.add('expanded-canvas-container');
|
|
2475
|
+
this.digitalSignatureCard.classList.add('hide');
|
|
2476
|
+
this.expandHelpMessage.classList.add('hide');
|
|
2477
|
+
this.btns_expand.classList.remove('hide');
|
|
2478
|
+
|
|
2479
|
+
requestAnimationFrame(() => {
|
|
2480
|
+
this.adjustScaleToContainer().then(() => {
|
|
2481
|
+
this.renderPage(this.pageNum);
|
|
2482
|
+
this.sub_canvas_container.scrollTop = (this.canvas.height / 2) - (this.sub_canvas_container.clientHeight / 2);
|
|
2483
|
+
});
|
|
2484
|
+
});
|
|
2485
|
+
} else {
|
|
2486
|
+
this.pdfSignatureContainer.classList.remove('expanded-viewer');
|
|
2487
|
+
this.sub_canvas_container.classList.remove('expanded-canvas-container');
|
|
2488
|
+
this.digitalSignatureCard.classList.remove('hide');
|
|
2489
|
+
this.expandHelpMessage.classList.remove('hide');
|
|
2490
|
+
this.btns_expand.classList.add('hide');
|
|
2491
|
+
this.scale = 1.2;
|
|
2492
|
+
this.renderPage(this.pageNum);
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
|
|
2496
|
+
}
|
|
2497
|
+
|
|
2498
|
+
adjustScaleToContainer() {
|
|
2499
|
+
return this.pdfDoc.getPage(this.pageNum).then((page) => {
|
|
2500
|
+
const containerWidth = Math.min(this.sub_canvas_container.offsetWidth, 1200);
|
|
2501
|
+
const viewport = page.getViewport({scale: 1});
|
|
2502
|
+
let nextScale = (containerWidth * 0.95) / viewport.width;
|
|
2503
|
+
this.scale = Math.min(nextScale, 2.0);
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
|
|
2507
|
+
|
|
2463
2508
|
renderPage(num) {
|
|
2464
2509
|
this.pageRendering = true;
|
|
2465
2510
|
this.pdfDoc.getPage(num).then((page) => {
|
|
@@ -2632,7 +2677,7 @@ class PdfSignatureComponent {
|
|
|
2632
2677
|
return tempSignature;
|
|
2633
2678
|
}
|
|
2634
2679
|
|
|
2635
|
-
|
|
2680
|
+
// If required, you can define a method for loading an image
|
|
2636
2681
|
loadSignatureImage(signatureImage, imageContainer) {
|
|
2637
2682
|
return new Promise((resolve, reject) => {
|
|
2638
2683
|
if (!signatureImage) {
|
|
@@ -2683,9 +2728,9 @@ class SignatureManager {
|
|
|
2683
2728
|
this.container = container;
|
|
2684
2729
|
this.modal = new bootstrap.Modal(container.querySelector("#loading_sign"));
|
|
2685
2730
|
this.firmador = new DocumentClient(container, container.getAttribute("data-widget-id"), this, url_ws, custom_event, this.doc_instance);
|
|
2686
|
-
this.signerBtn = container.
|
|
2731
|
+
this.signerBtn = container.querySelectorAll(".btn_signer");
|
|
2687
2732
|
this.errorsContainer = container.querySelector(".errors_signer");
|
|
2688
|
-
this.refreshBtn = container.
|
|
2733
|
+
this.refreshBtn = container.querySelectorAll(".btn_signer_refresh");
|
|
2689
2734
|
this.socketError = false;
|
|
2690
2735
|
this.pdfvisor = pdfvisor;
|
|
2691
2736
|
|
|
@@ -2693,11 +2738,15 @@ class SignatureManager {
|
|
|
2693
2738
|
}
|
|
2694
2739
|
|
|
2695
2740
|
initEvents() {
|
|
2696
|
-
if (this.signerBtn) {
|
|
2697
|
-
this.signerBtn.
|
|
2741
|
+
if (this.signerBtn && this.signerBtn.length) {
|
|
2742
|
+
this.signerBtn.forEach(btn => {
|
|
2743
|
+
btn.addEventListener('click', () => this.sign());
|
|
2744
|
+
});
|
|
2698
2745
|
}
|
|
2699
|
-
if (this.refreshBtn) {
|
|
2700
|
-
this.refreshBtn.
|
|
2746
|
+
if (this.refreshBtn && this.refreshBtn.length) {
|
|
2747
|
+
this.refreshBtn.forEach(btn => {
|
|
2748
|
+
btn.addEventListener('click', () => this.refresh());
|
|
2749
|
+
});
|
|
2701
2750
|
}
|
|
2702
2751
|
}
|
|
2703
2752
|
|
|
@@ -3096,37 +3145,49 @@ function DocumentClient(container, widgetId, signatureManager, url_ws, custom_ev
|
|
|
3096
3145
|
this.signatureManager.clearErrors();
|
|
3097
3146
|
},
|
|
3098
3147
|
"success_certificates": function (data) {
|
|
3099
|
-
|
|
3100
3148
|
if (data.length > 0) {
|
|
3101
|
-
container.
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3149
|
+
container.querySelectorAll("#container_select_card, #container_select_card_expanded_hide").forEach(el => {
|
|
3150
|
+
el.classList.remove("d-none");
|
|
3151
|
+
el.classList.remove("hide");
|
|
3152
|
+
});
|
|
3153
|
+
container.querySelectorAll("#container_select_card_tem").forEach(el => {
|
|
3154
|
+
el.classList.add("d-none");
|
|
3155
|
+
el.classList.add("hide");
|
|
3156
|
+
});
|
|
3105
3157
|
|
|
3106
|
-
|
|
3158
|
+
let select_cards = container.querySelectorAll(".select_card");
|
|
3159
|
+
if (!select_cards.length) {
|
|
3107
3160
|
console.error(`Select not found for widget ${widgetId}`);
|
|
3108
3161
|
return;
|
|
3109
3162
|
}
|
|
3110
|
-
select_card.innerHTML = "";
|
|
3111
3163
|
this.certificates = {};
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3164
|
+
select_cards.forEach(select_card => {
|
|
3165
|
+
select_card.innerHTML = "";
|
|
3166
|
+
data.forEach((element) => {
|
|
3167
|
+
this.certificates[element.tokenSerialNumber] = element;
|
|
3168
|
+
let start_token = element.tokenSerialNumber.substring(0, 4);
|
|
3169
|
+
let newOption = new Option(
|
|
3170
|
+
`${start_token} ${element.commonName}`,
|
|
3171
|
+
element.tokenSerialNumber,
|
|
3172
|
+
false, false
|
|
3173
|
+
);
|
|
3174
|
+
select_card.appendChild(newOption);
|
|
3175
|
+
});
|
|
3122
3176
|
});
|
|
3123
3177
|
} else {
|
|
3124
|
-
container.
|
|
3125
|
-
|
|
3178
|
+
container.querySelectorAll("#container_select_card, #container_select_card_expanded_hide").forEach(el => {
|
|
3179
|
+
el.classList.add("d-none");
|
|
3180
|
+
el.classList.add("hide");
|
|
3181
|
+
});
|
|
3182
|
+
container.querySelectorAll("#container_select_card_tem").forEach(el => {
|
|
3183
|
+
el.classList.remove("d-none");
|
|
3184
|
+
el.classList.remove("hide");
|
|
3185
|
+
});
|
|
3126
3186
|
this.signatureManager.addError(2);
|
|
3127
3187
|
}
|
|
3128
3188
|
},
|
|
3129
3189
|
|
|
3190
|
+
|
|
3130
3191
|
"do_sign_remote": function () {
|
|
3131
3192
|
let select = container.querySelector(".select_card");
|
|
3132
3193
|
let selected_card = select ? select.value : null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
+
function updatePreview(inputId, previewId) {
|
|
3
|
+
const input = document.getElementById(inputId);
|
|
4
|
+
const img = document.getElementById(previewId);
|
|
5
|
+
if (input && img) {
|
|
6
|
+
input.addEventListener("change", function () {
|
|
7
|
+
const file = input.files[0];
|
|
8
|
+
if (file && file.type.startsWith("image/")) {
|
|
9
|
+
const reader = new FileReader();
|
|
10
|
+
reader.onload = e => img.src = e.target.result;
|
|
11
|
+
reader.readAsDataURL(file);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
updatePreview("id_image", "image-preview");
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// auto remove messages
|
|
21
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
22
|
+
setTimeout(function () {
|
|
23
|
+
document.querySelectorAll(".alert-success").forEach(function (message) {
|
|
24
|
+
message.style.transition = "opacity 0.5s";
|
|
25
|
+
message.style.opacity = "0";
|
|
26
|
+
setTimeout(() => message.remove(), 500);
|
|
27
|
+
});
|
|
28
|
+
}, 1500);
|
|
29
|
+
});
|