annotate OrthancServer/OrthancExplorer/file-upload.js @ 4740:c1d6ce00be3f openssl-3.x

integration mainline->openssl-3.x
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 06 Jul 2021 08:40:43 +0200
parents f0038043fb97
children 2e71a08eea15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4122
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
1 /**
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
4 * Department, University Hospital of Liege, Belgium
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4122
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4122
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
6 *
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
7 * This program is free software: you can redistribute it and/or
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 * modify it under the terms of the GNU General Public License as
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 * License, or (at your option) any later version.
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 *
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
12 * This program is distributed in the hope that it will be useful, but
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 * General Public License for more details.
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 *
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * You should have received a copy of the GNU General Public License
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 **/
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20
4bb7522a63e0 do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
21
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 var pendingUploads = [];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 var currentUpload = 0;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 var totalUpload = 0;
3159
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
25 var alreadyInitialized = false; // trying to debug Orthanc issue #1
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 $(document).ready(function() {
3159
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
28 if (alreadyInitialized) {
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
29 console.log("Orthanc issue #1: the fileupload has been initialized twice !");
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
30 } else {
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
31 alreadyInitialized = true;
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
32 }
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
33
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 // Initialize the jQuery File Upload widget:
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 $('#fileupload').fileupload({
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 //dataType: 'json',
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 //maxChunkSize: 500,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 //sequentialUploads: true,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 limitConcurrentUploads: 3,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 add: function (e, data) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 pendingUploads.push(data);
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 })
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 .bind('fileuploadstop', function(e, data) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 $('#upload-button').removeClass('ui-disabled');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 //$('#upload-abort').addClass('ui-disabled');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 $('#progress .bar').css('width', '100%');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 if ($('#progress .label').text() != 'Failure')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 $('#progress .label').text('Done');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 })
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 .bind('fileuploadfail', function(e, data) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 $('#progress .bar')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 .css('width', '100%')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 .css('background-color', 'red');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 $('#progress .label').text('Failure');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 })
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 .bind('fileuploaddrop', function (e, data) {
3159
4cfed5c2eacd added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents: 3104
diff changeset
58 console.log("dropped " + data.files.length + " files: ", data);
3102
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
59 appendFilesToUploadList(data.files);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 })
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 .bind('fileuploadsend', function (e, data) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 // Update the progress bar. Note: for some weird reason, the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 // "fileuploadprogressall" does not work under Firefox.
3111
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3110
diff changeset
64 var progress = parseInt(currentUpload / totalUploads * 100, 10);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 currentUpload += 1;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 $('#progress .label').text('Uploading: ' + progress + '%');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 $('#progress .bar')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 .css('width', progress + '%')
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 .css('background-color', 'green');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
3102
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
73 function appendFilesToUploadList(files) {
3103
81b58b549845 back to using 'var' instead of 'let' since let is not supported by many old browsers. All variables declaration have been moved to the top of the function to better show that their scope is the function
Alain Mazy <alain@mazy.be>
parents: 3102
diff changeset
74 var target = $('#upload-list');
3102
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
75 $.each(files, function (index, file) {
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
76 target.append('<li class="pending-file">' + file.name + '</li>');
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
77 });
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
78 target.listview('refresh');
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
79 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
3102
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
81 $('#fileupload').live('change', function (e) {
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
82 appendFilesToUploadList(e.target.files);
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
83 })
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
3110
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
85
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
86 function ClearUploadProgress()
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
87 {
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
88 $('#progress .label').text('');
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
89 $('#progress .bar').css('width', '0%').css('background-color', '#333');
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
90 }
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
91
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
92 $('#upload').live('pagebeforeshow', function() {
3102
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
93 if (navigator.userAgent.toLowerCase().indexOf('firefox') == -1) {
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
94 $("#issue-21-warning").css('display', 'none');
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
95 }
9b18c8d4d459 'fix' for Orthanc issue 21: added a select file button + a warning specific for Firefox users
Alain Mazy <alain@mazy.be>
parents: 3023
diff changeset
96
3110
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
97 ClearUploadProgress();
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
98 });
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
99
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
100 $('#upload').live('pageshow', function() {
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 $('#fileupload').fileupload('enable');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 $('#upload').live('pagehide', function() {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 $('#fileupload').fileupload('disable');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 $('#upload-button').live('click', function() {
3103
81b58b549845 back to using 'var' instead of 'let' since let is not supported by many old browsers. All variables declaration have been moved to the top of the function to better show that their scope is the function
Alain Mazy <alain@mazy.be>
parents: 3102
diff changeset
110 var pu = pendingUploads;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 pendingUploads = [];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 $('.pending-file').remove();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 $('#upload-list').listview('refresh');
3110
7047222cfa96 minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3109
diff changeset
115 ClearUploadProgress();
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 currentUpload = 1;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 totalUploads = pu.length + 1;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 if (pu.length > 0) {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 $('#upload-button').addClass('ui-disabled');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 //$('#upload-abort').removeClass('ui-disabled');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123
3103
81b58b549845 back to using 'var' instead of 'let' since let is not supported by many old browsers. All variables declaration have been moved to the top of the function to better show that their scope is the function
Alain Mazy <alain@mazy.be>
parents: 3102
diff changeset
124 for (var i = 0; i < pu.length; i++) {
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 pu[i].submit();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 $('#upload-clear').live('click', function() {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 pendingUploads = [];
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 $('.pending-file').remove();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 $('#upload-list').listview('refresh');
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 });
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 /*$('#upload-abort').live('click', function() {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 $('#fileupload').fileupload().abort();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 });*/