Mercurial > hg > orthanc
annotate OrthancServer/OrthancExplorer/file-upload.js @ 4124:28944db5318b framework-lgpl
adding missing license headers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 20:19:00 +0200 |
parents | 4bb7522a63e0 |
children | d9473bd5ed43 |
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 |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
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 * In addition, as a special exception, the copyright holders of this |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
13 * program give permission to link the code of its release with the |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * that use the same license as the "OpenSSL" library), and distribute |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
16 * the linked executables. You must obey the GNU General Public License |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * in all respects for all of the code used other than "OpenSSL". If you |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * modify file(s) with this exception, you may extend this exception to |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * your version of the file(s), but you are not obligated to do so. If |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
20 * you do not wish to do so, delete this exception statement from your |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
21 * version. If you delete this exception statement from all source files |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
22 * in the program, then also delete it here. |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
23 * |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
24 * 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
|
25 * 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
|
26 * 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
|
27 * General Public License for more details. |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
28 * |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
29 * 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
|
30 * 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
|
31 **/ |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
32 |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
33 |
0 | 34 var pendingUploads = []; |
35 var currentUpload = 0; | |
36 var totalUpload = 0; | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
37 var alreadyInitialized = false; // trying to debug Orthanc issue #1 |
0 | 38 |
39 $(document).ready(function() { | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
40 if (alreadyInitialized) { |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
41 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
|
42 } else { |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
43 alreadyInitialized = true; |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
44 } |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
45 |
0 | 46 // Initialize the jQuery File Upload widget: |
47 $('#fileupload').fileupload({ | |
48 //dataType: 'json', | |
49 //maxChunkSize: 500, | |
50 //sequentialUploads: true, | |
51 limitConcurrentUploads: 3, | |
52 add: function (e, data) { | |
53 pendingUploads.push(data); | |
54 } | |
55 }) | |
56 .bind('fileuploadstop', function(e, data) { | |
57 $('#upload-button').removeClass('ui-disabled'); | |
58 //$('#upload-abort').addClass('ui-disabled'); | |
59 $('#progress .bar').css('width', '100%'); | |
60 if ($('#progress .label').text() != 'Failure') | |
61 $('#progress .label').text('Done'); | |
62 }) | |
63 .bind('fileuploadfail', function(e, data) { | |
64 $('#progress .bar') | |
65 .css('width', '100%') | |
66 .css('background-color', 'red'); | |
67 $('#progress .label').text('Failure'); | |
68 }) | |
69 .bind('fileuploaddrop', function (e, data) { | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
70 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
|
71 appendFilesToUploadList(data.files); |
0 | 72 }) |
73 .bind('fileuploadsend', function (e, data) { | |
74 // Update the progress bar. Note: for some weird reason, the | |
75 // "fileuploadprogressall" does not work under Firefox. | |
3111 | 76 var progress = parseInt(currentUpload / totalUploads * 100, 10); |
0 | 77 currentUpload += 1; |
78 $('#progress .label').text('Uploading: ' + progress + '%'); | |
79 $('#progress .bar') | |
80 .css('width', progress + '%') | |
81 .css('background-color', 'green'); | |
82 }); | |
83 }); | |
84 | |
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
|
85 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
|
86 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
|
87 $.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
|
88 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
|
89 }); |
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
|
90 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
|
91 } |
0 | 92 |
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 $('#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
|
94 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
|
95 }) |
0 | 96 |
3110
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
97 |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
98 function ClearUploadProgress() |
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 $('#progress .label').text(''); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
101 $('#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
|
102 } |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
103 |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
104 $('#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
|
105 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
|
106 $("#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
|
107 } |
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
|
108 |
3110
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
109 ClearUploadProgress(); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
110 }); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
111 |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
112 $('#upload').live('pageshow', function() { |
0 | 113 $('#fileupload').fileupload('enable'); |
114 }); | |
115 | |
116 $('#upload').live('pagehide', function() { | |
117 $('#fileupload').fileupload('disable'); | |
118 }); | |
119 | |
120 | |
121 $('#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
|
122 var pu = pendingUploads; |
0 | 123 pendingUploads = []; |
124 | |
125 $('.pending-file').remove(); | |
126 $('#upload-list').listview('refresh'); | |
3110
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
127 ClearUploadProgress(); |
0 | 128 |
129 currentUpload = 1; | |
130 totalUploads = pu.length + 1; | |
131 if (pu.length > 0) { | |
132 $('#upload-button').addClass('ui-disabled'); | |
133 //$('#upload-abort').removeClass('ui-disabled'); | |
134 } | |
135 | |
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
|
136 for (var i = 0; i < pu.length; i++) { |
0 | 137 pu[i].submit(); |
138 } | |
139 }); | |
140 | |
141 $('#upload-clear').live('click', function() { | |
142 pendingUploads = []; | |
143 $('.pending-file').remove(); | |
144 $('#upload-list').listview('refresh'); | |
145 }); | |
146 | |
147 /*$('#upload-abort').live('click', function() { | |
148 $('#fileupload').fileupload().abort(); | |
149 });*/ |