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