Mercurial > hg > orthanc
annotate OrthancServer/OrthancExplorer/file-upload.js @ 5648:a8e9113dc8f1
fix documentation of /tools/dicom-echo
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Jun 2024 19:15:42 +0200 |
parents | f7adfb22e20e |
children |
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 |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4122
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * 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
|
10 * 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
|
11 * 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
|
12 * 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
|
13 * |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
14 * 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
|
15 * 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
|
16 * 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
|
17 * General Public License for more details. |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * 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
|
20 * 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
|
21 **/ |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
22 |
4bb7522a63e0
do not enforce openssl exception in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
23 |
0 | 24 var pendingUploads = []; |
25 var currentUpload = 0; | |
26 var totalUpload = 0; | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
27 var alreadyInitialized = false; // trying to debug Orthanc issue #1 |
0 | 28 |
29 $(document).ready(function() { | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
30 if (alreadyInitialized) { |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
31 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
|
32 } else { |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
33 alreadyInitialized = true; |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
34 } |
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
35 |
0 | 36 // Initialize the jQuery File Upload widget: |
37 $('#fileupload').fileupload({ | |
38 //dataType: 'json', | |
39 //maxChunkSize: 500, | |
40 //sequentialUploads: true, | |
41 limitConcurrentUploads: 3, | |
42 add: function (e, data) { | |
43 pendingUploads.push(data); | |
44 } | |
45 }) | |
46 .bind('fileuploadstop', function(e, data) { | |
47 $('#upload-button').removeClass('ui-disabled'); | |
48 //$('#upload-abort').addClass('ui-disabled'); | |
49 $('#progress .bar').css('width', '100%'); | |
50 if ($('#progress .label').text() != 'Failure') | |
51 $('#progress .label').text('Done'); | |
52 }) | |
53 .bind('fileuploadfail', function(e, data) { | |
54 $('#progress .bar') | |
55 .css('width', '100%') | |
56 .css('background-color', 'red'); | |
57 $('#progress .label').text('Failure'); | |
58 }) | |
59 .bind('fileuploaddrop', function (e, data) { | |
3159
4cfed5c2eacd
added debug info for Orthanc issue #1
Alain Mazy <alain@mazy.be>
parents:
3104
diff
changeset
|
60 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
|
61 appendFilesToUploadList(data.files); |
0 | 62 }) |
63 .bind('fileuploadsend', function (e, data) { | |
64 // Update the progress bar. Note: for some weird reason, the | |
65 // "fileuploadprogressall" does not work under Firefox. | |
3111 | 66 var progress = parseInt(currentUpload / totalUploads * 100, 10); |
0 | 67 currentUpload += 1; |
68 $('#progress .label').text('Uploading: ' + progress + '%'); | |
69 $('#progress .bar') | |
70 .css('width', progress + '%') | |
71 .css('background-color', 'green'); | |
72 }); | |
73 }); | |
74 | |
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 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
|
76 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
|
77 $.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
|
78 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
|
79 }); |
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
|
80 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
|
81 } |
0 | 82 |
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
|
83 $('#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
|
84 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
|
85 }) |
0 | 86 |
3110
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 function ClearUploadProgress() |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
89 { |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
90 $('#progress .label').text(''); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
91 $('#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
|
92 } |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
93 |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
94 $('#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
|
95 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
|
96 $("#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
|
97 } |
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
|
98 |
3110
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
99 ClearUploadProgress(); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
100 }); |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
101 |
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
102 $('#upload').live('pageshow', function() { |
0 | 103 $('#fileupload').fileupload('enable'); |
104 }); | |
105 | |
106 $('#upload').live('pagehide', function() { | |
107 $('#fileupload').fileupload('disable'); | |
108 }); | |
109 | |
110 | |
111 $('#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
|
112 var pu = pendingUploads; |
0 | 113 pendingUploads = []; |
114 | |
115 $('.pending-file').remove(); | |
116 $('#upload-list').listview('refresh'); | |
3110
7047222cfa96
minor improvements to upload progress bar
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3109
diff
changeset
|
117 ClearUploadProgress(); |
0 | 118 |
119 currentUpload = 1; | |
120 totalUploads = pu.length + 1; | |
121 if (pu.length > 0) { | |
122 $('#upload-button').addClass('ui-disabled'); | |
123 //$('#upload-abort').removeClass('ui-disabled'); | |
124 } | |
125 | |
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
|
126 for (var i = 0; i < pu.length; i++) { |
0 | 127 pu[i].submit(); |
128 } | |
129 }); | |
130 | |
131 $('#upload-clear').live('click', function() { | |
132 pendingUploads = []; | |
133 $('.pending-file').remove(); | |
134 $('#upload-list').listview('refresh'); | |
135 }); | |
136 | |
137 /*$('#upload-abort').live('click', function() { | |
138 $('#fileupload').fileupload().abort(); | |
139 });*/ |